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
|
/* $OpenBSD: sunxi.c,v 1.6 2015/05/20 00:14:56 jsg 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 <machine/bus.h>
#include <arm/armv7/armv7var.h>
#include <armv7/armv7/armv7var.h>
#include <armv7/sunxi/sunxireg.h>
int sunxi_match(struct device *, void *, void *);
void sxia1x_init();
void sxia20_init();
struct cfattach sunxi_ca = {
sizeof(struct armv7_softc), sunxi_match, armv7_attach
};
struct cfdriver sunxi_cd = {
NULL, "sunxi", DV_DULL
};
struct board_dev sun4i_devs[] = {
{ "sxipio", 0 },
{ "sxiccmu", 0 },
{ "a1xintc", 0 },
{ "sxitimer", 0 },
{ "sxitimer", 1 },
{ "sxitimer", 2 },
{ "sxidog", 0 },
{ "sxirtc", 0 },
{ "sxiuart", 0 },
{ "sxiuart", 1 },
{ "sxiuart", 2 },
{ "sxiuart", 3 },
{ "sxiuart", 4 },
{ "sxiuart", 5 },
{ "sxiuart", 6 },
{ "sxiuart", 7 },
{ "sxie", 0 },
{ "ahci", 0 },
{ "ehci", 0 },
{ "ehci", 1 },
#if 0
{ "ohci", 0 },
{ "ohci", 1 },
#endif
{ NULL, 0 }
};
struct board_dev sun7i_devs[] = {
{ "sxipio", 0 },
{ "sxiccmu", 0 },
{ "sxitimer", 0 },
{ "sxitimer", 1 },
{ "sxitimer", 2 },
{ "sxidog", 0 },
{ "sxirtc", 0 },
{ "sxiuart", 0 },
{ "sxiuart", 1 },
{ "sxiuart", 2 },
{ "sxiuart", 3 },
{ "sxiuart", 4 },
{ "sxiuart", 5 },
{ "sxiuart", 6 },
{ "sxiuart", 7 },
{ "sxie", 0 },
{ "ahci", 0 },
{ "ehci", 0 },
{ "ehci", 1 },
#if 0
{ "ohci", 0 },
{ "ohci", 1 },
#endif
{ NULL, 0 }
};
struct armv7_board sunxi_boards[] = {
{
BOARD_ID_SUN4I_A10,
"Allwinner A1x",
sun4i_devs,
sxia1x_init,
},
{
BOARD_ID_SUN7I_A20,
"Allwinner A20",
sun7i_devs,
sxia20_init,
},
{ 0, NULL, NULL, NULL },
};
struct board_dev *
sunxi_board_devs(void)
{
int i;
for (i = 0; sunxi_boards[i].name != NULL; i++) {
if (sunxi_boards[i].board_id == board_id)
return (sunxi_boards[i].devs);
}
return (NULL);
}
void
sunxi_board_init(void)
{
bus_space_handle_t ioh;
int i, match = 0;
for (i = 0; sunxi_boards[i].name != NULL; i++) {
if (sunxi_boards[i].board_id == board_id) {
sunxi_boards[i].init();
match = 1;
break;
}
}
if (match) {
if (bus_space_map(&armv7_bs_tag, SYSCTRL_ADDR, SYSCTRL_SIZE, 0,
&ioh))
panic("sunxi_attach: bus_space_map failed!");
/* map the part of SRAM dedicated to EMAC to EMAC */
bus_space_write_4(&armv7_bs_tag, ioh, 4,
bus_space_read_4(&armv7_bs_tag, ioh, 4) | (5 << 2));
}
}
const char *
sunxi_board_name(void)
{
int i;
for (i = 0; sunxi_boards[i].name != NULL; i++) {
if (sunxi_boards[i].board_id == board_id) {
return (sunxi_boards[i].name);
break;
}
}
return (NULL);
}
int
sunxi_match(struct device *parent, void *cfdata, void *aux)
{
return (sunxi_board_devs() != NULL);
}
|