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

Subversion Repositories c0or1k

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 drasko
/*
2
 * EB platform-specific initialisation and setup
3
 *
4
 * Copyright (C) 2009-2010 B Labs Ltd.
5
 * Author: Prem Mallappa <prem.mallappa@b-labs.co.uk>
6
 *
7
 */
8
#include <l4/generic/platform.h>
9
#include <l4/generic/bootmem.h>
10
#include INC_PLAT(offsets.h)
11
#include INC_ARCH(io.h)
12
#include <l4/generic/space.h>
13
#include <l4/generic/irq.h>
14
#include <l4/generic/cap-types.h>
15
#include INC_PLAT(platform.h)
16
#include INC_PLAT(irq.h)
17
#include INC_GLUE(mapping.h)
18
#include INC_GLUE(smp.h)
19
 
20
/*
21
 * FIXME: This is not a platform specific
22
 * call, we will move this out later
23
 */
24
void device_cap_init(struct kernel_resources *kres, int devtype,
25
                     int devnum, unsigned long base)
26
{
27
        struct capability *cap;
28
 
29
        cap =  alloc_bootmem(sizeof(*cap), 0);
30
        cap_set_devtype(cap, devtype);
31
        cap_set_devnum(cap, devnum);
32
        cap->start = __pfn(base);
33
        cap->end = cap->start + 1;
34
        cap->size = cap->end - cap->start;
35
        link_init(&cap->list);
36
        cap_list_insert(cap, &kres->devmem_free);
37
}
38
 
39
/*
40
 * The devices that are used by the kernel are mapped
41
 * independent of these capabilities, but these provide a
42
 * concise description of what is used by the kernel.
43
 */
44
int platform_setup_device_caps(struct kernel_resources *kres)
45
{
46
        device_cap_init(kres, CAP_DEVTYPE_UART, 1, PLATFORM_UART1_BASE);
47
        device_cap_init(kres, CAP_DEVTYPE_UART, 2, PLATFORM_UART2_BASE);
48
        device_cap_init(kres, CAP_DEVTYPE_UART, 3, PLATFORM_UART3_BASE);
49
        device_cap_init(kres, CAP_DEVTYPE_TIMER, 1, PLATFORM_TIMER1_BASE);
50
        device_cap_init(kres, CAP_DEVTYPE_KEYBOARD, 0, PLATFORM_KEYBOARD0_BASE);
51
        device_cap_init(kres, CAP_DEVTYPE_MOUSE, 0, PLATFORM_MOUSE0_BASE);
52
 
53
        return 0;
54
}
55
 
56
void init_platform_irq_controller()
57
{
58
 
59
        unsigned int sysctrl = PLATFORM_SYSCTRL_VBASE;
60
        write(SYSCTRL_UNLOCK, sysctrl + SYS_LOCK);
61
        write(PLD_CTRL1_INTMOD_WITHOUT_DCC, sysctrl + SYS_PLDCTL1);
62
        write(SYSCTRL_LOCK, sysctrl + SYS_LOCK);        /* Lock again */
63
 
64
#if defined (CONFIG_CPU_ARM11MPCORE) || defined (CONFIG_CPU_CORTEXA9)
65
        /* TODO: we need to map 64KB ?*/
66
        add_boot_mapping(MPCORE_PRIVATE_BASE, MPCORE_PRIVATE_VBASE,
67
                         PAGE_SIZE * 2, MAP_IO_DEFAULT);
68
 
69
        gic_dist_init(0, GIC0_DIST_VBASE);
70
        gic_cpu_init(0, GIC0_CPU_VBASE);
71
 
72
#else
73
        add_boot_mapping(PLATFORM_GIC1_BASE, PLATFORM_GIC1_VBASE, PAGE_SIZE*2,
74
                         MAP_IO_DEFAULT);
75
 
76
        gic_dist_init(1, GIC1_DIST_VBASE);
77
#endif
78
 
79
#if !defined (CONFIG_CPU_ARM11MPCORE) && !defined (CONFIG_CPU_CORTEXA9)
80
        gic_cpu_init(1, PLATFORM_GIC1_VBASE);
81
#endif
82
        irq_controllers_init();
83
}
84
 
85
void init_platform_devices()
86
{
87
        /* TIMER23 */
88
        add_boot_mapping(PLATFORM_TIMER1_BASE, PLATFORM_TIMER1_VBASE,
89
                         PAGE_SIZE, MAP_IO_DEFAULT);
90
 
91
        /* KEYBOARD - KMI0 */
92
        add_boot_mapping(PLATFORM_KEYBOARD0_BASE, PLATFORM_KEYBOARD0_VBASE,
93
                         PAGE_SIZE, MAP_IO_DEFAULT);
94
 
95
        /* MOUSE - KMI1 */
96
        add_boot_mapping(PLATFORM_MOUSE0_BASE, PLATFORM_MOUSE0_VBASE,
97
                         PAGE_SIZE, MAP_IO_DEFAULT);
98
 
99
}

powered by: WebSVN 2.1.0

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