omap4_mp.c revision 295319
1168515Sgshapiro/*-
264562Sgshapiro * Copyright (c) 2012 Olivier Houchard.  All rights reserved.
338032Speter *
490792Sgshapiro * Redistribution and use in source and binary forms, with or without
5168515Sgshapiro * modification, are permitted provided that the following conditions
664562Sgshapiro * are met:
764562Sgshapiro * 1. Redistributions of source code must retain the above copyright
864562Sgshapiro *    notice, this list of conditions and the following disclaimer.
964562Sgshapiro * 2. Redistributions in binary form must reproduce the above copyright
1038032Speter *    notice, this list of conditions and the following disclaimer in the
1164562Sgshapiro *    documentation and/or other materials provided with the distribution.
1264562Sgshapiro *
1364562Sgshapiro * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
1490792Sgshapiro * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
1594334Sgshapiro * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
1664562Sgshapiro * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
1738032Speter * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
1864562Sgshapiro * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
1964562Sgshapiro * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2064562Sgshapiro * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2138032Speter * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
2264562Sgshapiro * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 */
24
25#include <sys/cdefs.h>
26__FBSDID("$FreeBSD: head/sys/arm/ti/omap4/omap4_mp.c 295319 2016-02-05 14:57:41Z mmel $");
27#include <sys/param.h>
28#include <sys/systm.h>
29#include <sys/bus.h>
30#include <sys/lock.h>
31#include <sys/mutex.h>
32#include <sys/smp.h>
33
34#include <vm/vm.h>
35#include <vm/pmap.h>
36
37#include <machine/cpu.h>
38#include <machine/smp.h>
39#include <machine/fdt.h>
40#include <machine/intr.h>
41
42#include <arm/ti/ti_smc.h>
43#include <arm/ti/omap4/omap4_smc.h>
44
45void
46platform_mp_init_secondary(void)
47{
48	intr_pic_init_secondary();
49}
50
51void
52platform_mp_setmaxid(void)
53{
54
55	mp_maxid = 1;
56	mp_ncpus = 2;
57}
58
59int
60platform_mp_probe(void)
61{
62
63	return (1);
64}
65
66void
67platform_mp_start_ap(void)
68{
69	bus_addr_t scu_addr;
70
71	if (bus_space_map(fdtbus_bs_tag, 0x48240000, 0x1000, 0, &scu_addr) != 0)
72		panic("Couldn't map the SCU\n");
73	/* Enable the SCU */
74	*(volatile unsigned int *)scu_addr |= 1;
75	//*(volatile unsigned int *)(scu_addr + 0x30) |= 1;
76	dcache_wbinv_poc_all();
77
78	ti_smc0(0x200, 0xfffffdff, MODIFY_AUX_CORE_0);
79	ti_smc0(pmap_kextract((vm_offset_t)mpentry), 0, WRITE_AUX_CORE_1);
80	armv7_sev();
81	bus_space_unmap(fdtbus_bs_tag, scu_addr, 0x1000);
82}
83
84void
85platform_ipi_send(cpuset_t cpus, u_int ipi)
86{
87	pic_ipi_send(cpus, ipi);
88}
89