1 /* $NetBSD: omap_ocp.c,v 1.3 2008/11/21 17:13:07 matt Exp $ */
4 * Autoconfiguration support for the Texas Instruments OMAP OCP bus.
5 * Based on arm/xscale/pxa2x0.c which in turn was derived
6 * from arm/sa11x0/sa11x0.c
8 * Copyright (c) 2002, 2005 Genetec Corporation. All rights reserved.
9 * Written by Hiroyuki Bessho for Genetec Corporation.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. All advertising materials mentioning features or use of this software
20 * must display the following acknowledgement:
21 * This product includes software developed for the NetBSD Project by
22 * Genetec Corporation.
23 * 4. The name of Genetec Corporation may not be used to endorse or
24 * promote products derived from this software without specific prior
27 * THIS SOFTWARE IS PROVIDED BY GENETEC CORPORATION ``AS IS'' AND
28 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
29 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GENETEC CORPORATION
31 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 * POSSIBILITY OF SUCH DAMAGE.
39 * Copyright (c) 1997, 1998, 2001, The NetBSD Foundation, Inc.
40 * All rights reserved.
42 * This code is derived from software contributed to The NetBSD Foundation
43 * by IWAMOTO Toshihiro, Ichiro FUKUHARA and Paul Kranenburg.
45 * Redistribution and use in source and binary forms, with or without
46 * modification, are permitted provided that the following conditions
48 * 1. Redistributions of source code must retain the above copyright
49 * notice, this list of conditions and the following disclaimer.
50 * 2. Redistributions in binary form must reproduce the above copyright
51 * notice, this list of conditions and the following disclaimer in the
52 * documentation and/or other materials provided with the distribution.
54 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
55 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
56 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
57 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
58 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
59 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
60 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
61 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
62 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
63 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
64 * POSSIBILITY OF SUCH DAMAGE.
67 * Shin Takemura and PocketBSD Project. All rights reserved.
69 * Redistribution and use in source and binary forms, with or without
70 * modification, are permitted provided that the following conditions
72 * 1. Redistributions of source code must retain the above copyright
73 * notice, this list of conditions and the following disclaimer.
74 * 2. Redistributions in binary form must reproduce the above copyright
75 * notice, this list of conditions and the following disclaimer in the
76 * documentation and/or other materials provided with the distribution.
77 * 3. All advertising materials mentioning features or use of this software
78 * must display the following acknowledgement:
79 * This product includes software developed by the PocketBSD project
80 * and its contributors.
81 * 4. Neither the name of the project nor the names of its contributors
82 * may be used to endorse or promote products derived from this software
83 * without specific prior written permission.
85 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
86 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
87 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
88 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
89 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
90 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
91 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
92 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
93 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
94 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
98 #include <sys/cdefs.h>
99 __KERNEL_RCSID(0, "$NetBSD: omap_ocp.c,v 1.3 2008/11/21 17:13:07 matt Exp $");
101 #include "locators.h"
103 #include <sys/param.h>
104 #include <sys/systm.h>
105 #include <sys/device.h>
106 #include <sys/kernel.h>
107 #include <sys/reboot.h>
109 #include <machine/cpu.h>
110 #include <machine/bus.h>
112 #include <arm/cpufunc.h>
113 #include <arm/mainbus/mainbus.h>
114 #include <arm/omap/omap_reg.h>
115 #include <arm/omap/omap_ocp.h>
119 bus_dma_tag_t sc_dmac
;
123 static int ocp_match(device_t
, cfdata_t
, void *);
124 static void ocp_attach(device_t
, device_t
, void *);
125 static int ocp_search(device_t
, cfdata_t
, const int *, void *);
126 static int ocp_print(void *, const char *);
128 /* attach structures */
129 CFATTACH_DECL_NEW(ocp
, sizeof(struct ocp_softc
),
130 ocp_match
, ocp_attach
, NULL
, NULL
);
132 static int ocp_attached
;
135 ocp_match(device_t parent
, cfdata_t match
, void *aux
)
143 ocp_attach(device_t parent
, device_t self
, void *aux
)
145 struct ocp_softc
*sc
= device_private(self
);
150 #error DMA not implemented
151 sc
->sc_dmac
= &omap_bus_dma_tag
;
156 aprint_normal(": OCP Bus\n");
160 * Attach all our devices
162 config_search_ia(ocp_search
, self
, "ocp", NULL
);
166 ocp_search(device_t parent
, cfdata_t cf
, const int *ldesc
, void *aux
)
168 struct ocp_softc
*sc
= device_private(parent
);
169 struct ocp_attach_args aa
;
171 switch (cf
->cf_loc
[OCPCF_MULT
]) {
173 aa
.ocp_iot
= &omap_bs_tag
;
176 aa
.ocp_iot
= &omap_a2x_bs_tag
;
179 aa
.ocp_iot
= &omap_a4x_bs_tag
;
182 panic("Unsupported OCP multiplier.");
185 aa
.ocp_dmac
= sc
->sc_dmac
;
186 aa
.ocp_addr
= cf
->cf_loc
[OCPCF_ADDR
];
187 aa
.ocp_size
= cf
->cf_loc
[OCPCF_SIZE
];
188 aa
.ocp_intr
= cf
->cf_loc
[OCPCF_INTR
];
190 if (config_match(parent
, cf
, &aa
))
191 config_attach(parent
, cf
, &aa
, ocp_print
);
197 ocp_print(void *aux
, const char *name
)
199 struct ocp_attach_args
*sa
= (struct ocp_attach_args
*)aux
;
201 if (sa
->ocp_addr
!= OCPCF_ADDR_DEFAULT
) {
202 aprint_normal(" addr 0x%08lx", sa
->ocp_addr
);
203 if (sa
->ocp_size
> OCPCF_SIZE_DEFAULT
)
204 aprint_normal("-0x%08lx", sa
->ocp_addr
+ sa
->ocp_size
-1);
206 if (sa
->ocp_intr
!= OCPCF_INTR_DEFAULT
)
207 aprint_normal(" intr %d", sa
->ocp_intr
);