Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
awilliam
GitHub Repository: awilliam/linux-vfio
Path: blob/master/arch/arm/mach-dove/common.c
10817 views
1
/*
2
* arch/arm/mach-dove/common.c
3
*
4
* Core functions for Marvell Dove 88AP510 System On Chip
5
*
6
* This file is licensed under the terms of the GNU General Public
7
* License version 2. This program is licensed "as is" without any
8
* warranty of any kind, whether express or implied.
9
*/
10
11
#include <linux/kernel.h>
12
#include <linux/delay.h>
13
#include <linux/init.h>
14
#include <linux/platform_device.h>
15
#include <linux/pci.h>
16
#include <linux/serial_8250.h>
17
#include <linux/clk.h>
18
#include <linux/mbus.h>
19
#include <linux/ata_platform.h>
20
#include <linux/serial_8250.h>
21
#include <linux/gpio.h>
22
#include <asm/page.h>
23
#include <asm/setup.h>
24
#include <asm/timex.h>
25
#include <asm/hardware/cache-tauros2.h>
26
#include <asm/mach/map.h>
27
#include <asm/mach/time.h>
28
#include <asm/mach/pci.h>
29
#include <mach/dove.h>
30
#include <mach/bridge-regs.h>
31
#include <asm/mach/arch.h>
32
#include <linux/irq.h>
33
#include <plat/time.h>
34
#include <plat/common.h>
35
#include "common.h"
36
37
static int get_tclk(void);
38
39
/*****************************************************************************
40
* I/O Address Mapping
41
****************************************************************************/
42
static struct map_desc dove_io_desc[] __initdata = {
43
{
44
.virtual = DOVE_SB_REGS_VIRT_BASE,
45
.pfn = __phys_to_pfn(DOVE_SB_REGS_PHYS_BASE),
46
.length = DOVE_SB_REGS_SIZE,
47
.type = MT_DEVICE,
48
}, {
49
.virtual = DOVE_NB_REGS_VIRT_BASE,
50
.pfn = __phys_to_pfn(DOVE_NB_REGS_PHYS_BASE),
51
.length = DOVE_NB_REGS_SIZE,
52
.type = MT_DEVICE,
53
}, {
54
.virtual = DOVE_PCIE0_IO_VIRT_BASE,
55
.pfn = __phys_to_pfn(DOVE_PCIE0_IO_PHYS_BASE),
56
.length = DOVE_PCIE0_IO_SIZE,
57
.type = MT_DEVICE,
58
}, {
59
.virtual = DOVE_PCIE1_IO_VIRT_BASE,
60
.pfn = __phys_to_pfn(DOVE_PCIE1_IO_PHYS_BASE),
61
.length = DOVE_PCIE1_IO_SIZE,
62
.type = MT_DEVICE,
63
},
64
};
65
66
void __init dove_map_io(void)
67
{
68
iotable_init(dove_io_desc, ARRAY_SIZE(dove_io_desc));
69
}
70
71
/*****************************************************************************
72
* EHCI0
73
****************************************************************************/
74
void __init dove_ehci0_init(void)
75
{
76
orion_ehci_init(&dove_mbus_dram_info,
77
DOVE_USB0_PHYS_BASE, IRQ_DOVE_USB0);
78
}
79
80
/*****************************************************************************
81
* EHCI1
82
****************************************************************************/
83
void __init dove_ehci1_init(void)
84
{
85
orion_ehci_1_init(&dove_mbus_dram_info,
86
DOVE_USB1_PHYS_BASE, IRQ_DOVE_USB1);
87
}
88
89
/*****************************************************************************
90
* GE00
91
****************************************************************************/
92
void __init dove_ge00_init(struct mv643xx_eth_platform_data *eth_data)
93
{
94
orion_ge00_init(eth_data, &dove_mbus_dram_info,
95
DOVE_GE00_PHYS_BASE, IRQ_DOVE_GE00_SUM,
96
0, get_tclk());
97
}
98
99
/*****************************************************************************
100
* SoC RTC
101
****************************************************************************/
102
void __init dove_rtc_init(void)
103
{
104
orion_rtc_init(DOVE_RTC_PHYS_BASE, IRQ_DOVE_RTC);
105
}
106
107
/*****************************************************************************
108
* SATA
109
****************************************************************************/
110
void __init dove_sata_init(struct mv_sata_platform_data *sata_data)
111
{
112
orion_sata_init(sata_data, &dove_mbus_dram_info,
113
DOVE_SATA_PHYS_BASE, IRQ_DOVE_SATA);
114
115
}
116
117
/*****************************************************************************
118
* UART0
119
****************************************************************************/
120
void __init dove_uart0_init(void)
121
{
122
orion_uart0_init(DOVE_UART0_VIRT_BASE, DOVE_UART0_PHYS_BASE,
123
IRQ_DOVE_UART_0, get_tclk());
124
}
125
126
/*****************************************************************************
127
* UART1
128
****************************************************************************/
129
void __init dove_uart1_init(void)
130
{
131
orion_uart1_init(DOVE_UART1_VIRT_BASE, DOVE_UART1_PHYS_BASE,
132
IRQ_DOVE_UART_1, get_tclk());
133
}
134
135
/*****************************************************************************
136
* UART2
137
****************************************************************************/
138
void __init dove_uart2_init(void)
139
{
140
orion_uart2_init(DOVE_UART2_VIRT_BASE, DOVE_UART2_PHYS_BASE,
141
IRQ_DOVE_UART_2, get_tclk());
142
}
143
144
/*****************************************************************************
145
* UART3
146
****************************************************************************/
147
void __init dove_uart3_init(void)
148
{
149
orion_uart3_init(DOVE_UART3_VIRT_BASE, DOVE_UART3_PHYS_BASE,
150
IRQ_DOVE_UART_3, get_tclk());
151
}
152
153
/*****************************************************************************
154
* SPI
155
****************************************************************************/
156
void __init dove_spi0_init(void)
157
{
158
orion_spi_init(DOVE_SPI0_PHYS_BASE, get_tclk());
159
}
160
161
void __init dove_spi1_init(void)
162
{
163
orion_spi_init(DOVE_SPI1_PHYS_BASE, get_tclk());
164
}
165
166
/*****************************************************************************
167
* I2C
168
****************************************************************************/
169
void __init dove_i2c_init(void)
170
{
171
orion_i2c_init(DOVE_I2C_PHYS_BASE, IRQ_DOVE_I2C, 10);
172
}
173
174
/*****************************************************************************
175
* Time handling
176
****************************************************************************/
177
void __init dove_init_early(void)
178
{
179
orion_time_set_base(TIMER_VIRT_BASE);
180
}
181
182
static int get_tclk(void)
183
{
184
/* use DOVE_RESET_SAMPLE_HI/LO to detect tclk */
185
return 166666667;
186
}
187
188
static void dove_timer_init(void)
189
{
190
orion_time_init(BRIDGE_VIRT_BASE, BRIDGE_INT_TIMER1_CLR,
191
IRQ_DOVE_BRIDGE, get_tclk());
192
}
193
194
struct sys_timer dove_timer = {
195
.init = dove_timer_init,
196
};
197
198
/*****************************************************************************
199
* XOR 0
200
****************************************************************************/
201
void __init dove_xor0_init(void)
202
{
203
orion_xor0_init(&dove_mbus_dram_info,
204
DOVE_XOR0_PHYS_BASE, DOVE_XOR0_HIGH_PHYS_BASE,
205
IRQ_DOVE_XOR_00, IRQ_DOVE_XOR_01);
206
}
207
208
/*****************************************************************************
209
* XOR 1
210
****************************************************************************/
211
void __init dove_xor1_init(void)
212
{
213
orion_xor1_init(DOVE_XOR1_PHYS_BASE, DOVE_XOR1_HIGH_PHYS_BASE,
214
IRQ_DOVE_XOR_10, IRQ_DOVE_XOR_11);
215
}
216
217
/*****************************************************************************
218
* SDIO
219
****************************************************************************/
220
static u64 sdio_dmamask = DMA_BIT_MASK(32);
221
222
static struct resource dove_sdio0_resources[] = {
223
{
224
.start = DOVE_SDIO0_PHYS_BASE,
225
.end = DOVE_SDIO0_PHYS_BASE + 0xff,
226
.flags = IORESOURCE_MEM,
227
}, {
228
.start = IRQ_DOVE_SDIO0,
229
.end = IRQ_DOVE_SDIO0,
230
.flags = IORESOURCE_IRQ,
231
},
232
};
233
234
static struct platform_device dove_sdio0 = {
235
.name = "sdhci-dove",
236
.id = 0,
237
.dev = {
238
.dma_mask = &sdio_dmamask,
239
.coherent_dma_mask = DMA_BIT_MASK(32),
240
},
241
.resource = dove_sdio0_resources,
242
.num_resources = ARRAY_SIZE(dove_sdio0_resources),
243
};
244
245
void __init dove_sdio0_init(void)
246
{
247
platform_device_register(&dove_sdio0);
248
}
249
250
static struct resource dove_sdio1_resources[] = {
251
{
252
.start = DOVE_SDIO1_PHYS_BASE,
253
.end = DOVE_SDIO1_PHYS_BASE + 0xff,
254
.flags = IORESOURCE_MEM,
255
}, {
256
.start = IRQ_DOVE_SDIO1,
257
.end = IRQ_DOVE_SDIO1,
258
.flags = IORESOURCE_IRQ,
259
},
260
};
261
262
static struct platform_device dove_sdio1 = {
263
.name = "sdhci-dove",
264
.id = 1,
265
.dev = {
266
.dma_mask = &sdio_dmamask,
267
.coherent_dma_mask = DMA_BIT_MASK(32),
268
},
269
.resource = dove_sdio1_resources,
270
.num_resources = ARRAY_SIZE(dove_sdio1_resources),
271
};
272
273
void __init dove_sdio1_init(void)
274
{
275
platform_device_register(&dove_sdio1);
276
}
277
278
void __init dove_init(void)
279
{
280
int tclk;
281
282
tclk = get_tclk();
283
284
printk(KERN_INFO "Dove 88AP510 SoC, ");
285
printk(KERN_INFO "TCLK = %dMHz\n", (tclk + 499999) / 1000000);
286
287
#ifdef CONFIG_CACHE_TAUROS2
288
tauros2_init();
289
#endif
290
dove_setup_cpu_mbus();
291
292
/* internal devices that every board has */
293
dove_rtc_init();
294
dove_xor0_init();
295
dove_xor1_init();
296
}
297
298