mirror of
https://git.FreeBSD.org/src.git
synced 2024-11-24 07:40:52 +00:00
Add PLATFORM and PLATFORM_SMP support to the ALPINE kernel configuration.
This will help move it to be part of GENERIC.
This commit is contained in:
parent
b77a75e4a6
commit
c20963ad19
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=320643
@ -43,97 +43,10 @@ __FBSDID("$FreeBSD$");
|
||||
#include <machine/fdt.h>
|
||||
#include <machine/intr.h>
|
||||
|
||||
#define WDTLOAD 0x000
|
||||
#define LOAD_MIN 0x00000001
|
||||
#define LOAD_MAX 0xFFFFFFFF
|
||||
#define WDTVALUE 0x004
|
||||
#define WDTCONTROL 0x008
|
||||
/* control register masks */
|
||||
#define INT_ENABLE (1 << 0)
|
||||
#define RESET_ENABLE (1 << 1)
|
||||
#define WDTLOCK 0xC00
|
||||
#define UNLOCK 0x1ACCE551
|
||||
#define LOCK 0x00000001
|
||||
|
||||
extern bus_addr_t al_devmap_pa;
|
||||
|
||||
static int alpine_get_wdt_base(uint32_t *pbase, uint32_t *psize);
|
||||
#ifndef INTRNG
|
||||
static int alpine_pic_decode_fdt(uint32_t iparent, uint32_t *intr,
|
||||
int *interrupt, int *trig, int *pol);
|
||||
|
||||
int alpine_get_devmap_base(bus_addr_t *pa, bus_addr_t *size);
|
||||
|
||||
int alpine_get_devmap_base(bus_addr_t *pa, bus_addr_t *size)
|
||||
{
|
||||
phandle_t node;
|
||||
|
||||
if ((node = OF_finddevice("/")) == 0)
|
||||
return (ENXIO);
|
||||
|
||||
if ((node = fdt_find_compatible(node, "simple-bus", 1)) == 0)
|
||||
return (ENXIO);
|
||||
|
||||
return fdt_get_range(node, 0, pa, size);
|
||||
}
|
||||
|
||||
static int
|
||||
alpine_get_wdt_base(uint32_t *pbase, uint32_t *psize)
|
||||
{
|
||||
phandle_t node;
|
||||
u_long base = 0;
|
||||
u_long size = 0;
|
||||
|
||||
if (pbase == NULL || psize == NULL)
|
||||
return (EINVAL);
|
||||
|
||||
if ((node = OF_finddevice("/")) == -1)
|
||||
return (EFAULT);
|
||||
|
||||
if ((node = fdt_find_compatible(node, "simple-bus", 1)) == 0)
|
||||
return (EFAULT);
|
||||
|
||||
if ((node =
|
||||
fdt_find_compatible(node, "arm,sp805", 1)) == 0)
|
||||
return (EFAULT);
|
||||
|
||||
if (fdt_regsize(node, &base, &size))
|
||||
return (EFAULT);
|
||||
|
||||
*pbase = base;
|
||||
*psize = size;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
cpu_reset(void)
|
||||
{
|
||||
uint32_t wdbase, wdsize;
|
||||
bus_addr_t wdbaddr;
|
||||
int ret;
|
||||
|
||||
ret = alpine_get_wdt_base(&wdbase, &wdsize);
|
||||
if (ret) {
|
||||
printf("Unable to get WDT base, do power down manually...");
|
||||
goto infinite;
|
||||
}
|
||||
|
||||
ret = bus_space_map(fdtbus_bs_tag, al_devmap_pa + wdbase,
|
||||
wdsize, 0, &wdbaddr);
|
||||
if (ret) {
|
||||
printf("Unable to map WDT base, do power down manually...");
|
||||
goto infinite;
|
||||
}
|
||||
|
||||
bus_space_write_4(fdtbus_bs_tag, wdbaddr, WDTLOCK, UNLOCK);
|
||||
bus_space_write_4(fdtbus_bs_tag, wdbaddr, WDTLOAD, LOAD_MIN);
|
||||
bus_space_write_4(fdtbus_bs_tag, wdbaddr, WDTCONTROL, INT_ENABLE | RESET_ENABLE);
|
||||
|
||||
infinite:
|
||||
while (1) {}
|
||||
}
|
||||
|
||||
#ifndef INTRNG
|
||||
static int
|
||||
alpine_pic_decode_fdt(uint32_t iparent, uint32_t *intr, int *interrupt,
|
||||
int *trig, int *pol)
|
||||
|
@ -26,66 +26,137 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "opt_ddb.h"
|
||||
#include "opt_platform.h"
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/bus.h>
|
||||
#include <sys/lock.h>
|
||||
#include <sys/mutex.h>
|
||||
#include <sys/devmap.h>
|
||||
|
||||
#include <vm/vm.h>
|
||||
#include <vm/pmap.h>
|
||||
|
||||
#include <machine/bus.h>
|
||||
#include <machine/frame.h> /* For trapframe_t, used in <machine/machdep.h> */
|
||||
#include <machine/machdep.h>
|
||||
#include <machine/platform.h>
|
||||
#include <machine/fdt.h>
|
||||
#include <machine/platformvar.h>
|
||||
|
||||
#include "opt_ddb.h"
|
||||
#include "opt_platform.h"
|
||||
#include <dev/fdt/fdt_common.h>
|
||||
#include <dev/ofw/openfirm.h>
|
||||
|
||||
#include <arm/annapurna/alpine/alpine_mp.h>
|
||||
|
||||
#include "platform_if.h"
|
||||
|
||||
#define WDTLOAD 0x000
|
||||
#define LOAD_MIN 0x00000001
|
||||
#define LOAD_MAX 0xFFFFFFFF
|
||||
#define WDTVALUE 0x004
|
||||
#define WDTCONTROL 0x008
|
||||
/* control register masks */
|
||||
#define INT_ENABLE (1 << 0)
|
||||
#define RESET_ENABLE (1 << 1)
|
||||
#define WDTLOCK 0xC00
|
||||
#define UNLOCK 0x1ACCE551
|
||||
#define LOCK 0x00000001
|
||||
|
||||
#define DEVMAP_MAX_VA_ADDRESS 0xF0000000
|
||||
bus_addr_t al_devmap_pa;
|
||||
bus_addr_t al_devmap_size;
|
||||
|
||||
int alpine_get_devmap_base(bus_addr_t *pa, bus_addr_t *size);
|
||||
|
||||
vm_offset_t
|
||||
platform_lastaddr(void)
|
||||
static int
|
||||
alpine_get_devmap_base(bus_addr_t *pa, bus_addr_t *size)
|
||||
{
|
||||
phandle_t node;
|
||||
|
||||
return (DEVMAP_MAX_VA_ADDRESS);
|
||||
if ((node = OF_finddevice("/")) == 0)
|
||||
return (ENXIO);
|
||||
|
||||
if ((node = fdt_find_compatible(node, "simple-bus", 1)) == 0)
|
||||
return (ENXIO);
|
||||
|
||||
return fdt_get_range(node, 0, pa, size);
|
||||
}
|
||||
|
||||
void
|
||||
platform_probe_and_attach(void)
|
||||
static int
|
||||
alpine_get_wdt_base(uint32_t *pbase, uint32_t *psize)
|
||||
{
|
||||
phandle_t node;
|
||||
u_long base = 0;
|
||||
u_long size = 0;
|
||||
|
||||
}
|
||||
if (pbase == NULL || psize == NULL)
|
||||
return (EINVAL);
|
||||
|
||||
void
|
||||
platform_gpio_init(void)
|
||||
{
|
||||
if ((node = OF_finddevice("/")) == -1)
|
||||
return (EFAULT);
|
||||
|
||||
}
|
||||
if ((node = fdt_find_compatible(node, "simple-bus", 1)) == 0)
|
||||
return (EFAULT);
|
||||
|
||||
void
|
||||
platform_late_init(void)
|
||||
{
|
||||
if ((node =
|
||||
fdt_find_compatible(node, "arm,sp805", 1)) == 0)
|
||||
return (EFAULT);
|
||||
|
||||
if (fdt_regsize(node, &base, &size))
|
||||
return (EFAULT);
|
||||
|
||||
*pbase = base;
|
||||
*psize = size;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Construct devmap table with DT-derived config data.
|
||||
*/
|
||||
int
|
||||
platform_devmap_init(void)
|
||||
static int
|
||||
alpine_devmap_init(platform_t plat)
|
||||
{
|
||||
alpine_get_devmap_base(&al_devmap_pa, &al_devmap_size);
|
||||
devmap_add_entry(al_devmap_pa, al_devmap_size);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static void
|
||||
alpine_cpu_reset(platform_t plat)
|
||||
{
|
||||
uint32_t wdbase, wdsize;
|
||||
bus_addr_t wdbaddr;
|
||||
int ret;
|
||||
|
||||
ret = alpine_get_wdt_base(&wdbase, &wdsize);
|
||||
if (ret) {
|
||||
printf("Unable to get WDT base, do power down manually...");
|
||||
goto infinite;
|
||||
}
|
||||
|
||||
ret = bus_space_map(fdtbus_bs_tag, al_devmap_pa + wdbase,
|
||||
wdsize, 0, &wdbaddr);
|
||||
if (ret) {
|
||||
printf("Unable to map WDT base, do power down manually...");
|
||||
goto infinite;
|
||||
}
|
||||
|
||||
bus_space_write_4(fdtbus_bs_tag, wdbaddr, WDTLOCK, UNLOCK);
|
||||
bus_space_write_4(fdtbus_bs_tag, wdbaddr, WDTLOAD, LOAD_MIN);
|
||||
bus_space_write_4(fdtbus_bs_tag, wdbaddr, WDTCONTROL,
|
||||
INT_ENABLE | RESET_ENABLE);
|
||||
|
||||
infinite:
|
||||
while (1) {}
|
||||
}
|
||||
|
||||
static platform_method_t alpine_methods[] = {
|
||||
PLATFORMMETHOD(platform_devmap_init, alpine_devmap_init),
|
||||
PLATFORMMETHOD(platform_cpu_reset, alpine_cpu_reset),
|
||||
|
||||
#ifdef SMP
|
||||
PLATFORMMETHOD(platform_mp_start_ap, alpine_mp_start_ap),
|
||||
PLATFORMMETHOD(platform_mp_setmaxid, alpine_mp_setmaxid),
|
||||
#endif
|
||||
PLATFORMMETHOD_END,
|
||||
};
|
||||
FDT_PLATFORM_DEF(alpine, "alpine", 0, "annapurna,alpine", 200);
|
||||
|
@ -43,12 +43,15 @@ __FBSDID("$FreeBSD$");
|
||||
#include <machine/fdt.h>
|
||||
#include <machine/intr.h>
|
||||
#include <machine/cpu-v6.h>
|
||||
#include <machine/platformvar.h>
|
||||
|
||||
#include <dev/fdt/fdt_common.h>
|
||||
#include <dev/ofw/openfirm.h>
|
||||
#include <dev/ofw/ofw_cpu.h>
|
||||
#include <dev/ofw/ofw_bus_subr.h>
|
||||
|
||||
#include <arm/annapurna/alpine/alpine_mp.h>
|
||||
|
||||
#define AL_CPU_RESUME_WATERMARK_REG 0x00
|
||||
#define AL_CPU_RESUME_FLAGS_REG 0x04
|
||||
#define AL_CPU_RESUME_PCPU_RADDR_REG(cpu) (0x08 + 0x04 + 8*(cpu))
|
||||
@ -112,7 +115,7 @@ platform_mp_get_core_cnt(void)
|
||||
}
|
||||
|
||||
void
|
||||
platform_mp_setmaxid(void)
|
||||
alpine_mp_setmaxid(platform_t plat)
|
||||
{
|
||||
|
||||
mp_ncpus = platform_mp_get_core_cnt();
|
||||
@ -172,7 +175,7 @@ alpine_get_nb_base(u_long *pbase, u_long *psize)
|
||||
}
|
||||
|
||||
void
|
||||
platform_mp_start_ap(void)
|
||||
alpine_mp_start_ap(platform_t plat)
|
||||
{
|
||||
uint32_t physaddr;
|
||||
vm_offset_t vaddr;
|
||||
|
35
sys/arm/annapurna/alpine/alpine_mp.h
Normal file
35
sys/arm/annapurna/alpine/alpine_mp.h
Normal file
@ -0,0 +1,35 @@
|
||||
/*-
|
||||
* Copyright (c) 2017 Andrew Turner
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifndef _ANNAPURNA_ALPINE_MP_H_
|
||||
#define _ANNAPURNA_ALPINE_MP_H_
|
||||
|
||||
void alpine_mp_start_ap(platform_t plat);
|
||||
void alpine_mp_setmaxid(platform_t plat);
|
||||
|
||||
#endif /* _ANNAPURNA_ALPINE_MP_H_ */
|
@ -27,6 +27,8 @@ makeoptions WERROR="-Werror"
|
||||
|
||||
options SCHED_4BSD # 4BSD scheduler
|
||||
options SMP # Enable multiple cores
|
||||
options PLATFORM
|
||||
options PLATFORM_SMP
|
||||
|
||||
# Interrupt controller
|
||||
device gic
|
||||
|
Loading…
Reference in New Issue
Block a user