xref: /freebsd/sys/arm/ti/omap4/omap4_mp.c (revision fdafd315ad0d0f28a11b9fb4476a9ab059c62b92)
1e53470feSOleksandr Tymoshenko /*-
2*4d846d26SWarner Losh  * SPDX-License-Identifier: BSD-2-Clause
3af3dc4a7SPedro F. Giffuni  *
4e53470feSOleksandr Tymoshenko  * Copyright (c) 2012 Olivier Houchard.  All rights reserved.
5e53470feSOleksandr Tymoshenko  *
6e53470feSOleksandr Tymoshenko  * Redistribution and use in source and binary forms, with or without
7e53470feSOleksandr Tymoshenko  * modification, are permitted provided that the following conditions
8e53470feSOleksandr Tymoshenko  * are met:
9e53470feSOleksandr Tymoshenko  * 1. Redistributions of source code must retain the above copyright
10e53470feSOleksandr Tymoshenko  *    notice, this list of conditions and the following disclaimer.
11e53470feSOleksandr Tymoshenko  * 2. Redistributions in binary form must reproduce the above copyright
12e53470feSOleksandr Tymoshenko  *    notice, this list of conditions and the following disclaimer in the
13e53470feSOleksandr Tymoshenko  *    documentation and/or other materials provided with the distribution.
14e53470feSOleksandr Tymoshenko  *
15e53470feSOleksandr Tymoshenko  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16e53470feSOleksandr Tymoshenko  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17e53470feSOleksandr Tymoshenko  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18e53470feSOleksandr Tymoshenko  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19e53470feSOleksandr Tymoshenko  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20e53470feSOleksandr Tymoshenko  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21e53470feSOleksandr Tymoshenko  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22e53470feSOleksandr Tymoshenko  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23e53470feSOleksandr Tymoshenko  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24e53470feSOleksandr Tymoshenko  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25e53470feSOleksandr Tymoshenko  */
26e53470feSOleksandr Tymoshenko 
27e53470feSOleksandr Tymoshenko #include <sys/param.h>
28e53470feSOleksandr Tymoshenko #include <sys/systm.h>
29e53470feSOleksandr Tymoshenko #include <sys/bus.h>
30e53470feSOleksandr Tymoshenko #include <sys/lock.h>
31e53470feSOleksandr Tymoshenko #include <sys/mutex.h>
32e53470feSOleksandr Tymoshenko #include <sys/smp.h>
33e53470feSOleksandr Tymoshenko 
34087af50aSAndrew Turner #include <vm/vm.h>
35087af50aSAndrew Turner #include <vm/pmap.h>
36087af50aSAndrew Turner 
37a89156f5SMichal Meloun #include <machine/cpu.h>
38e53470feSOleksandr Tymoshenko #include <machine/smp.h>
39e53470feSOleksandr Tymoshenko #include <machine/fdt.h>
40e53470feSOleksandr Tymoshenko #include <machine/intr.h>
4144f0c15cSOlivier Houchard #include <machine/platformvar.h>
42e53470feSOleksandr Tymoshenko 
43e53470feSOleksandr Tymoshenko #include <arm/ti/ti_smc.h>
443185adf0SAndrew Turner #include <arm/ti/omap4/omap4_machdep.h>
45e53470feSOleksandr Tymoshenko #include <arm/ti/omap4/omap4_smc.h>
46e53470feSOleksandr Tymoshenko 
47e53470feSOleksandr Tymoshenko void
omap4_mp_setmaxid(platform_t plat)4844f0c15cSOlivier Houchard omap4_mp_setmaxid(platform_t plat)
49e53470feSOleksandr Tymoshenko {
50e53470feSOleksandr Tymoshenko 
5144f0c15cSOlivier Houchard 	if (mp_ncpus != 0)
5244f0c15cSOlivier Houchard 		return;
53e53470feSOleksandr Tymoshenko 	mp_maxid = 1;
5427f38a8dSTijl Coosemans 	mp_ncpus = 2;
55e53470feSOleksandr Tymoshenko }
56e53470feSOleksandr Tymoshenko 
57e53470feSOleksandr Tymoshenko void
omap4_mp_start_ap(platform_t plat)5844f0c15cSOlivier Houchard omap4_mp_start_ap(platform_t plat)
59e53470feSOleksandr Tymoshenko {
60e53470feSOleksandr Tymoshenko 	bus_addr_t scu_addr;
61e53470feSOleksandr Tymoshenko 
62e53470feSOleksandr Tymoshenko 	if (bus_space_map(fdtbus_bs_tag, 0x48240000, 0x1000, 0, &scu_addr) != 0)
63e53470feSOleksandr Tymoshenko 		panic("Couldn't map the SCU\n");
64e53470feSOleksandr Tymoshenko 	/* Enable the SCU */
65e53470feSOleksandr Tymoshenko 	*(volatile unsigned int *)scu_addr |= 1;
66e53470feSOleksandr Tymoshenko 	//*(volatile unsigned int *)(scu_addr + 0x30) |= 1;
67a89156f5SMichal Meloun 	dcache_wbinv_poc_all();
68a89156f5SMichal Meloun 
69e53470feSOleksandr Tymoshenko 	ti_smc0(0x200, 0xfffffdff, MODIFY_AUX_CORE_0);
706626207eSOlivier Houchard 	ti_smc0(pmap_kextract((vm_offset_t)mpentry), 0, WRITE_AUX_CORE_1);
717cc70732SMichal Meloun 	dsb();
727cc70732SMichal Meloun 	sev();
73e53470feSOleksandr Tymoshenko 	bus_space_unmap(fdtbus_bs_tag, scu_addr, 0x1000);
74e53470feSOleksandr Tymoshenko }
75