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