Remove messy machdep code for Alpine V1 and use proper drivers instead
Let drivers for Alpine CCU, NB and Serdes take care of internal SoC configuration. Obtained from: Semihalf Submitted by: Michal Stanek <mst@semihalf.com> Sponsored by: Annapurna Labs Reviewed by: imp,wma Differential Revision: https://reviews.freebsd.org/D7566
This commit is contained in:
parent
0da791731a
commit
f8aa374846
@ -51,21 +51,10 @@ __FBSDID("$FreeBSD$");
|
||||
#include "opt_ddb.h"
|
||||
#include "opt_platform.h"
|
||||
|
||||
struct mtx al_dbg_lock;
|
||||
|
||||
#define DEVMAP_MAX_VA_ADDRESS 0xF0000000
|
||||
bus_addr_t al_devmap_pa;
|
||||
bus_addr_t al_devmap_size;
|
||||
|
||||
#define AL_NB_SERVICE_OFFSET 0x70000
|
||||
#define AL_NB_CCU_OFFSET 0x90000
|
||||
#define AL_CCU_SNOOP_CONTROL_IOFAB_0_OFFSET 0x4000
|
||||
#define AL_CCU_SNOOP_CONTROL_IOFAB_1_OFFSET 0x5000
|
||||
#define AL_CCU_SPECULATION_CONTROL_OFFSET 0x4
|
||||
|
||||
#define AL_NB_ACF_MISC_OFFSET 0xD0
|
||||
#define AL_NB_ACF_MISC_READ_BYPASS (1 << 30)
|
||||
|
||||
int alpine_get_devmap_base(bus_addr_t *pa, bus_addr_t *size);
|
||||
|
||||
vm_offset_t
|
||||
@ -90,35 +79,7 @@ platform_gpio_init(void)
|
||||
void
|
||||
platform_late_init(void)
|
||||
{
|
||||
bus_addr_t reg_baddr;
|
||||
uint32_t val;
|
||||
|
||||
if (!mtx_initialized(&al_dbg_lock))
|
||||
mtx_init(&al_dbg_lock, "ALDBG", "ALDBG", MTX_SPIN);
|
||||
|
||||
/* configure system fabric */
|
||||
if (bus_space_map(fdtbus_bs_tag, al_devmap_pa, al_devmap_size, 0,
|
||||
®_baddr))
|
||||
panic("Couldn't map Register Space area");
|
||||
|
||||
/* do not allow reads to bypass writes to different addresses */
|
||||
val = bus_space_read_4(fdtbus_bs_tag, reg_baddr,
|
||||
AL_NB_SERVICE_OFFSET + AL_NB_ACF_MISC_OFFSET);
|
||||
val &= ~AL_NB_ACF_MISC_READ_BYPASS;
|
||||
bus_space_write_4(fdtbus_bs_tag, reg_baddr,
|
||||
AL_NB_SERVICE_OFFSET + AL_NB_ACF_MISC_OFFSET, val);
|
||||
|
||||
/* enable cache snoop */
|
||||
bus_space_write_4(fdtbus_bs_tag, reg_baddr,
|
||||
AL_NB_CCU_OFFSET + AL_CCU_SNOOP_CONTROL_IOFAB_0_OFFSET, 1);
|
||||
bus_space_write_4(fdtbus_bs_tag, reg_baddr,
|
||||
AL_NB_CCU_OFFSET + AL_CCU_SNOOP_CONTROL_IOFAB_1_OFFSET, 1);
|
||||
|
||||
/* disable speculative fetches from masters */
|
||||
bus_space_write_4(fdtbus_bs_tag, reg_baddr,
|
||||
AL_NB_CCU_OFFSET + AL_CCU_SPECULATION_CONTROL_OFFSET, 7);
|
||||
|
||||
bus_space_unmap(fdtbus_bs_tag, reg_baddr, al_devmap_size);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -68,22 +68,14 @@ __FBSDID("$FreeBSD$");
|
||||
#define AL_NB_INIT_CONTROL (0x8)
|
||||
#define AL_NB_CONFIG_STATUS_PWR_CTRL(cpu) (0x2020 + (cpu)*0x100)
|
||||
|
||||
#define SERDES_NUM_GROUPS 4
|
||||
#define SERDES_GROUP_SIZE 0x400
|
||||
|
||||
extern bus_addr_t al_devmap_pa;
|
||||
extern bus_addr_t al_devmap_size;
|
||||
|
||||
extern void mpentry(void);
|
||||
|
||||
int alpine_serdes_resource_get(uint32_t group, bus_space_tag_t *tag,
|
||||
bus_addr_t *baddr);
|
||||
static int platform_mp_get_core_cnt(void);
|
||||
static int alpine_get_cpu_resume_base(u_long *pbase, u_long *psize);
|
||||
static int alpine_get_nb_base(u_long *pbase, u_long *psize);
|
||||
static int alpine_get_serdes_base(u_long *pbase, u_long *psize);
|
||||
int alpine_serdes_resource_get(uint32_t group, bus_space_tag_t *tag,
|
||||
bus_addr_t *baddr);
|
||||
static boolean_t alpine_validate_cpu(u_int, phandle_t, u_int, pcell_t *);
|
||||
|
||||
static boolean_t
|
||||
@ -254,60 +246,3 @@ platform_mp_start_ap(void)
|
||||
bus_space_unmap(fdtbus_bs_tag, nb_baddr, nb_size);
|
||||
bus_space_unmap(fdtbus_bs_tag, cpu_resume_baddr, cpu_resume_size);
|
||||
}
|
||||
|
||||
static int
|
||||
alpine_get_serdes_base(u_long *pbase, u_long *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 =
|
||||
ofw_bus_find_compatible(node, "annapurna-labs,al-serdes")) == 0)
|
||||
return (EFAULT);
|
||||
|
||||
if (fdt_regsize(node, &base, &size))
|
||||
return (EFAULT);
|
||||
|
||||
*pbase = base;
|
||||
*psize = size;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
alpine_serdes_resource_get(uint32_t group, bus_space_tag_t *tag, bus_addr_t *baddr)
|
||||
{
|
||||
u_long serdes_base, serdes_size;
|
||||
int ret;
|
||||
static bus_addr_t baddr_mapped[SERDES_NUM_GROUPS];
|
||||
|
||||
if (group >= SERDES_NUM_GROUPS)
|
||||
return (EINVAL);
|
||||
|
||||
if (baddr_mapped[group]) {
|
||||
*tag = fdtbus_bs_tag;
|
||||
*baddr = baddr_mapped[group];
|
||||
return (0);
|
||||
}
|
||||
|
||||
ret = alpine_get_serdes_base(&serdes_base, &serdes_size);
|
||||
if (ret)
|
||||
return (ret);
|
||||
|
||||
ret = bus_space_map(fdtbus_bs_tag,
|
||||
al_devmap_pa + serdes_base + group * SERDES_GROUP_SIZE,
|
||||
(SERDES_NUM_GROUPS - group) * SERDES_GROUP_SIZE, 0, baddr);
|
||||
if (ret)
|
||||
return (ret);
|
||||
|
||||
baddr_mapped[group] = *baddr;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
@ -32,6 +32,10 @@ options SMP # Enable multiple cores
|
||||
device gic
|
||||
options INTRNG
|
||||
|
||||
# Annapurna Alpine drivers
|
||||
device al_ccu # Alpine Cache Coherency Unit
|
||||
device al_nb_service # Alpine North Bridge Service
|
||||
|
||||
# Pseudo devices
|
||||
device loop
|
||||
device random
|
||||
|
Loading…
x
Reference in New Issue
Block a user