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