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