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

Subversion Repositories c0or1k

[/] [c0or1k/] [trunk/] [src/] [platform/] [beagle/] [platform.c] - Blame information for rev 6

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 drasko
/*
2
 * Beagle Board platform-specific initialisation and setup
3
 *
4
 * Copyright (C) 2007 Bahadir Balban
5
 */
6
#include <l4/generic/platform.h>
7
#include <l4/generic/space.h>
8
#include <l4/generic/irq.h>
9
#include <l4/generic/bootmem.h>
10
#include INC_ARCH(linker.h)
11
#include INC_SUBARCH(mm.h)
12
#include INC_GLUE(mapping.h)
13
#include INC_SUBARCH(mmu_ops.h)
14
#include INC_GLUE(memory.h)
15
#include INC_PLAT(platform.h)
16
#include INC_PLAT(uart.h)
17
#include INC_PLAT(timer.h)
18
#include INC_PLAT(irq.h)
19
#include INC_ARCH(asm.h)
20
#include INC_PLAT(cm.h)
21
 
22
/*
23
 * The devices that are used by the kernel are mapped
24
 * independent of these capabilities, but these provide a
25
 * concise description of what is used by the kernel.
26
 */
27
int platform_setup_device_caps(struct kernel_resources *kres)
28
{
29
        struct capability *timer[1];
30
 
31
        /* Setup timer1 capability as free */
32
        timer[0] =  alloc_bootmem(sizeof(*timer[0]), 0);
33
        timer[0]->start = __pfn(PLATFORM_TIMER1_BASE);
34
        timer[0]->end = timer[0]->start + 1;
35
        timer[0]->size = timer[0]->end - timer[0]->start;
36
        cap_set_devtype(timer[0], CAP_DEVTYPE_TIMER);
37
        cap_set_devnum(timer[0], 1);
38
        link_init(&timer[0]->list);
39
        cap_list_insert(timer[0], &kres->devmem_free);
40
 
41
        return 0;
42
}
43
 
44
/*
45
 * Use UART2 for kernel as well as user tasks,
46
 * so map it to kernel and user space, this only
47
 * is provided by beagle board
48
 */
49
void init_platform_console(void)
50
{
51
        add_boot_mapping(PLATFORM_UART2_BASE, PLATFORM_CONSOLE_VBASE,
52
                         PAGE_SIZE, MAP_IO_DEFAULT);
53
 
54
        add_boot_mapping(PLATFORM_PERCM_BASE, PLATFORM_PERCM_VBASE,
55
                         PAGE_SIZE, MAP_IO_DEFAULT);
56
 
57
        /*
58
         * Map same UART IO area to userspace so that primitive uart-based
59
         * userspace printf can work. Note, this raw mapping is to be
60
         * removed in the future, when file-based io is implemented.
61
         */
62
        add_boot_mapping(PLATFORM_UART2_BASE, USERSPACE_CONSOLE_VBASE,
63
                         PAGE_SIZE, MAP_USR_IO);
64
 
65
        /* use 32KHz clock signal */
66
        omap_cm_clk_select(PLATFORM_PERCM_VBASE, 11,
67
                           OMAP_TIMER_CLKSRC_SYS_CLK);
68
 
69
        /* Enable Interface and Functional clock */
70
        omap_cm_enable_iclk(PLATFORM_PERCM_VBASE, 11);
71
        omap_cm_enable_fclk(PLATFORM_PERCM_VBASE, 11);
72
 
73
        uart_init(PLATFORM_CONSOLE_VBASE);
74
}
75
 
76
void platform_timer_start(void)
77
{
78
        /* Enable irq line for TIMER0 */
79
        irq_enable(IRQ_TIMER0);
80
 
81
        /* Enable timer */
82
        timer_start(PLATFORM_TIMER0_VBASE);
83
}
84
 
85
/*
86
 * We are using GPTIMER1 only, so we map GPTIMER1 base,
87
 * incase any other timer is needed we need to map it
88
 * to userspace or kernel space as needed
89
 */
90
void init_platform_timer(void)
91
{
92
        add_boot_mapping(PLATFORM_TIMER0_BASE, PLATFORM_TIMER0_VBASE,
93
                         PAGE_SIZE, MAP_IO_DEFAULT);
94
 
95
        add_boot_mapping(PLATFORM_WKUP_CM_BASE, PLATFORM_WKUP_CM_VBASE,
96
                         PAGE_SIZE, MAP_IO_DEFAULT);
97
 
98
#if 0
99
        /* use 32KHz clock signal */
100
        omap_cm_clk_select(PLATFORM_WKUP_CM_VBASE, 0,
101
                           OMAP_TIMER_CLKSRC_32KHZ_CLK);
102
#else
103
        /*
104
        * Assumption: Beagle board RevC manual says,
105
        * it has 26MHz oscillator present, so we are
106
        * assuming this oscillator is our system clock
107
        */
108
        omap_cm_clk_select(PLATFORM_WKUP_CM_VBASE, 0,
109
                           OMAP_TIMER_CLKSRC_SYS_CLK);
110
#endif
111
 
112
        /* Enable Interface and Functional clock */
113
        omap_cm_enable_iclk(PLATFORM_WKUP_CM_VBASE, 0);
114
        omap_cm_enable_fclk(PLATFORM_WKUP_CM_VBASE, 0);
115
 
116
        timer_init(PLATFORM_TIMER0_VBASE);
117
}
118
 
119
void init_platform_irq_controller()
120
{
121
        add_boot_mapping(PLATFORM_INTC_BASE, PLATFORM_INTC_VBASE,
122
                         PAGE_SIZE, MAP_IO_DEFAULT);
123
 
124
        irq_controllers_init();
125
}
126
 
127
void init_platform_devices()
128
{
129
        /* Add userspace devices here as you develop their irq handlers */
130
        add_boot_mapping(PLATFORM_TIMER1_BASE, PLATFORM_TIMER1_VBASE,
131
                         PAGE_SIZE, MAP_IO_DEFAULT);
132
 
133
}
134
 
135
void platform_init(void)
136
{
137
        init_platform_console();
138
        init_platform_timer();
139
        init_platform_irq_controller();
140
        init_platform_devices();
141
}
142
 

powered by: WebSVN 2.1.0

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