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

Subversion Repositories c0or1k

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 drasko
/*
2
 * Copyright 2010 B Labs.Ltd.
3
 *
4
 * Author: Prem Mallappa  <prem.mallappa@b-labs.co.uk>
5
 *
6
 * Description: SMP related platform definitions
7
 */
8
#include <l4/generic/platform.h>
9
#include INC_ARCH(io.h)
10
#include INC_SUBARCH(proc.h)
11
#include INC_PLAT(platform.h)
12
#include INC_PLAT(offsets.h)
13
#include INC_PLAT(sysctrl.h)
14
#include INC_GLUE(smp.h)
15
#include INC_GLUE(ipi.h)
16
#include INC_GLUE(mapping.h)
17
#include INC_SUBARCH(cpu.h)
18
#include <l4/drivers/irq/gic/gic.h>
19
#include <l4/lib/string.h>
20
#include <l4/generic/space.h>
21
 
22
extern struct irq_desc irq_desc_array[IRQS_MAX];
23
 
24
/* Print some SCU information */
25
void scu_print_state(void)
26
{
27
        volatile u32 scu_cfg = read(SCU_VBASE + SCU_CFG_REG);
28
        int ncpu = (scu_cfg & SCU_CFG_NCPU_MASK) + 1;
29
        printk("%s: SMP: %d CPU cluster, CPU", __KERNELNAME__, ncpu);
30
        for (int i = 0; i < ncpu; i++) {
31
                if ((1 << i) & (scu_cfg >> SCU_CFG_SMP_NCPU_SHIFT))
32
                        printk("%d/", i);
33
        }
34
        printk(" are participating in SMP\n");
35
 
36
}
37
 
38
void scu_init(void)
39
{
40
        volatile u32 scu_ctrl = read(SCU_VBASE + SCU_CTRL_REG);
41
 
42
        /* Enable the SCU */
43
        if (!(scu_ctrl & SCU_CTRL_EN))
44
                scu_ctrl |= SCU_CTRL_EN;
45
 
46
        write(scu_ctrl, SCU_VBASE + SCU_CTRL_REG);
47
}
48
 
49
void platform_smp_init(int ncpus)
50
{
51
        /* Add GIC SoftIRQ (aka IPI) */
52
        for (int i = 0; i < 16; i++) {
53
                strncpy(irq_desc_array[i].name, "SoftInt", 8);
54
                irq_desc_array[i].chip  = &irq_chip_array[0];
55
                irq_desc_array[i].handler = &ipi_handler;
56
        }
57
 
58
        add_boot_mapping(PLATFORM_SYSTEM_REGISTERS, PLATFORM_SYSREGS_VBASE,
59
                         PAGE_SIZE, MAP_IO_DEFAULT);
60
 
61
}
62
 
63
int platform_smp_start(int cpu, void (*smp_start_func)(int))
64
{
65
        /*
66
         * Wake up just one core by writing the starting address to FLAGS
67
         * register in SYSCTRL
68
         */
69
        write(0xffffffff, SYS_FLAGS_CLR + PLATFORM_SYSREGS_VBASE);
70
        write((unsigned int)smp_start_func, SYS_FLAGS_SET + PLATFORM_SYSREGS_VBASE);
71
        dsb();  /* Make sure the write occurs */
72
 
73
        /* Wake up other core who is waiting on a WFI. */
74
        gic_send_ipi(CPUID_TO_MASK(cpu), 0);
75
 
76
        return 0;
77
}
78
 
79
void secondary_init_platform(void)
80
{
81
        gic_cpu_init(0, GIC0_CPU_VBASE);
82
}

powered by: WebSVN 2.1.0

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