OpenCores
URL https://opencores.org/ocsvn/c0or1k/c0or1k/trunk

Subversion Repositories c0or1k

[/] [c0or1k/] [trunk/] [src/] [platform/] [realview/] [platform.c] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 drasko
/*
2
 * Realview generic initialisation and setup
3
 *
4
 * Copyright (C) 2009 B Labs Ltd.
5
 */
6
#include <l4/platform/realview/uart.h>
7
#include <l4/platform/realview/irq.h>
8
#include INC_PLAT(offsets.h)
9
#include INC_GLUE(mapping.h)
10
#include INC_GLUE(smp.h)
11
#include <l4/generic/irq.h>
12
#include <l4/generic/space.h>
13
#include <l4/generic/platform.h>
14
#include <l4/generic/smp.h>
15
#include INC_PLAT(platform.h)
16
#include INC_ARCH(io.h)
17
 
18
/* We will use UART0 for kernel as well as user tasks, so map it to kernel and user space */
19
void init_platform_console(void)
20
{
21
        add_boot_mapping(PLATFORM_UART0_BASE, PLATFORM_CONSOLE_VBASE, PAGE_SIZE,
22
                         MAP_IO_DEFAULT);
23
 
24
        /*
25
         * Map same UART IO area to userspace so that primitive uart-based
26
         * userspace printf can work. Note, this raw mapping is to be
27
         * removed in the future, when file-based io is implemented.
28
         */
29
        add_boot_mapping(PLATFORM_UART0_BASE, USERSPACE_CONSOLE_VBASE, PAGE_SIZE,
30
                         MAP_USR_IO);
31
 
32
        uart_init(PLATFORM_CONSOLE_VBASE);
33
}
34
 
35
void platform_timer_start(void)
36
{
37
        /* Enable irq line for TIMER0 */
38
        irq_enable(IRQ_TIMER0);
39
 
40
        /* Set cpu to all cpus for timer0 */
41
        // irq_set_cpu(IRQ_TIMER0, cpu_all_mask());
42
 
43
        /* Enable timer */
44
        timer_start(PLATFORM_TIMER0_VBASE);
45
}
46
 
47
void init_platform_timer(void)
48
{
49
        add_boot_mapping(PLATFORM_TIMER0_BASE, PLATFORM_TIMER0_VBASE, PAGE_SIZE,
50
                         MAP_IO_DEFAULT);
51
 
52
        /* 1 Mhz means can tick up to 1,000,000 times a second */
53
        timer_init(PLATFORM_TIMER0_VBASE, 1000000 / CONFIG_SCHED_TICKS);
54
}
55
 
56
/* If these bits are off, 32Khz OSC source is used */
57
#define TIMER3_SCTRL_1MHZ       (1 << 21)
58
#define TIMER2_SCTRL_1MHZ       (1 << 19)
59
#define TIMER1_SCTRL_1MHZ       (1 << 17)
60
#define TIMER0_SCTRL_1MHZ       (1 << 15)
61
 
62
/* Set all timers to use 1Mhz OSC clock */
63
void init_timer_osc(void)
64
{
65
        volatile u32 reg;
66
 
67
        add_boot_mapping(PLATFORM_SYSCTRL_BASE, PLATFORM_SYSCTRL_VBASE,
68
                         PAGE_SIZE, MAP_IO_DEFAULT);
69
 
70
        reg = read(SP810_SCCTRL);
71
 
72
        reg |= TIMER0_SCTRL_1MHZ | TIMER1_SCTRL_1MHZ
73
               | TIMER2_SCTRL_1MHZ | TIMER3_SCTRL_1MHZ;
74
 
75
        write(reg, SP810_SCCTRL);
76
 
77
}
78
 
79
void platform_init(void)
80
{
81
        init_timer_osc();
82
        init_platform_console();
83
        init_platform_timer();
84
        init_platform_irq_controller();
85
        init_platform_devices();
86
 
87
#if defined (CONFIG_SMP)
88
        init_smp();
89
        scu_init();
90
#endif
91
}
92
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.