1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
|
/* $OpenBSD: omap.c,v 1.2 2011/11/11 10:46:35 matthieu Exp $ */
/*
* Copyright (c) 2005,2008 Dale Rahn <drahn@openbsd.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/device.h>
#include <sys/malloc.h>
#include <sys/reboot.h>
#define _ARM32_BUS_DMA_PRIVATE
#include <machine/bus.h>
#include <arch/arm/armv7/armv7var.h>
#include <beagle/dev/omapvar.h>
struct arm32_bus_dma_tag omap_bus_dma_tag = {
0,
0,
NULL,
_bus_dmamap_create,
_bus_dmamap_destroy,
_bus_dmamap_load,
_bus_dmamap_load_mbuf,
_bus_dmamap_load_uio,
_bus_dmamap_load_raw,
_bus_dmamap_unload,
_bus_dmamap_sync,
_bus_dmamem_alloc,
_bus_dmamem_free,
_bus_dmamem_map,
_bus_dmamem_unmap,
_bus_dmamem_mmap,
};
struct board_dev {
char *name;
int unit;
};
struct board_dev beagleboard_devs[] = {
{ "prcm", 0 },
{ "intc", 0 },
{ "gptimer", 0 },
{ "gptimer", 1 },
{ "omgpio", 0 },
{ "omgpio", 1 },
{ "omgpio", 2 },
{ "omgpio", 3 },
{ "omgpio", 4 },
{ "omgpio", 5 },
{ "ommmc", 0 }, /* HSMMC1 */
{ "com", 2 }, /* UART3 */
{ NULL, 0 }
};
struct board_dev overo_devs[] = {
{ "prcm", 0 },
{ "intc", 0 },
{ "gptimer", 0 },
{ "gptimer", 1 },
{ "omgpio", 0 },
{ "omgpio", 1 },
{ "omgpio", 2 },
{ "omgpio", 3 },
{ "omgpio", 4 },
{ "omgpio", 5 },
{ "ommmc", 0 }, /* HSMMC1 */
{ "com", 2 }, /* UART3 */
{ NULL, 0 }
};
struct board_dev pandaboard_devs[] = {
{ "ampintc", 0 },
{ "amptimer", 0 },
{ "omgpio", 0 },
{ "omgpio", 1 },
{ "omgpio", 2 },
{ "omgpio", 3 },
{ "omgpio", 4 },
{ "omgpio", 5 },
{ "ommmc", 0 }, /* HSMMC1 */
{ "com", 2 }, /* UART3 */
{ NULL, 0 }
};
struct board_dev *board_devs;
struct omap_dev *omap_devs = NULL;
struct omap_softc {
struct device sc_dv;
};
int omap_match(struct device *, void *, void *);
void omap_attach(struct device *, struct device *, void *);
int omap_submatch(struct device *, void *, void *);
struct cfattach omap_ca = {
sizeof(struct omap_softc), omap_match, omap_attach
};
struct cfdriver omap_cd = {
NULL, "omap", DV_DULL
};
int
omap_match(struct device *parent, void *cfdata, void *aux)
{
return (1);
}
void
omap_attach(struct device *parent, struct device *self, void *aux)
{
struct board_dev *bd;
switch (board_id) {
case BOARD_ID_OMAP3_BEAGLE:
printf(": BeagleBoard\n");
omap3_init();
board_devs = beagleboard_devs;
break;
case BOARD_ID_OMAP3_OVERO:
printf(": Gumstix Overo\n");
omap3_init();
board_devs = overo_devs;
break;
case BOARD_ID_OMAP4_PANDA:
printf(": PandaBoard\n");
omap4_init();
board_devs = pandaboard_devs;
break;
default:
printf("\n");
panic("%s: board type 0x%x unknown", __func__, board_id);
}
/* Directly configure on-board devices (dev* in config file). */
for (bd = board_devs; bd->name != NULL; bd++) {
struct omap_dev *od = omap_find_dev(bd->name, bd->unit);
struct omap_attach_args oa;
if (od == NULL)
printf("%s: device %s unit %d not found\n",
self->dv_xname, bd->name, bd->unit);
memset(&oa, 0, sizeof(oa));
oa.oa_dev = od;
oa.oa_iot = &armv7_bs_tag;
oa.oa_dmat = &omap_bus_dma_tag;
if (config_found_sm(self, &oa, NULL, omap_submatch) == NULL)
printf("%s: device %s unit %d not configured\n",
self->dv_xname, bd->name, bd->unit);
}
}
/*
* We do direct configuration of devices on this SoC "bus", so we
* never call the child device's match function at all (it can be
* NULL in the struct cfattach).
*/
int
omap_submatch(struct device *parent, void *child, void *aux)
{
struct cfdata *cf = child;
struct omap_attach_args *oa = aux;
if (strcmp(cf->cf_driver->cd_name, oa->oa_dev->name) == 0)
return (1);
/* "These are not the droids you are looking for." */
return (0);
}
void
omap_set_devs(struct omap_dev *devs)
{
omap_devs = devs;
}
struct omap_dev *
omap_find_dev(const char *name, int unit)
{
struct omap_dev *od;
if (omap_devs == NULL)
panic("%s: omap_devs == NULL", __func__);
for (od = omap_devs; od->name != NULL; od++) {
if (od->unit == unit && strcmp(od->name, name) == 0)
return (od);
}
return (NULL);
}
|