Module Name: src Committed By: skrll Date: Wed Oct 3 09:24:36 UTC 2018
Modified Files: src/sys/arch/evbarm/conf: files.generic64 Added Files: src/sys/arch/arm/cavium: files.thunderx thunderx_platform.c thunderx_platform.h Log Message: Embryonic Cavium ThunderX support To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/cavium/files.thunderx \ src/sys/arch/arm/cavium/thunderx_platform.c \ src/sys/arch/arm/cavium/thunderx_platform.h cvs rdiff -u -r1.5 -r1.6 src/sys/arch/evbarm/conf/files.generic64 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/evbarm/conf/files.generic64 diff -u src/sys/arch/evbarm/conf/files.generic64:1.5 src/sys/arch/evbarm/conf/files.generic64:1.6 --- src/sys/arch/evbarm/conf/files.generic64:1.5 Sat Sep 8 00:51:57 2018 +++ src/sys/arch/evbarm/conf/files.generic64 Wed Oct 3 09:24:36 2018 @@ -1,4 +1,4 @@ -# $NetBSD: files.generic64,v 1.5 2018/09/08 00:51:57 jmcneill Exp $ +# $NetBSD: files.generic64,v 1.6 2018/10/03 09:24:36 skrll Exp $ # defparam opt_arm_debug.h EARLYCONS @@ -12,6 +12,7 @@ include "arch/evbarm/conf/files.fdt" # include "arch/arm/amd/files.seattle" include "arch/arm/broadcom/files.bcm2835" +include "arch/arm/cavium/files.thunderx" include "arch/arm/nvidia/files.tegra" include "arch/arm/rockchip/files.rockchip" include "arch/arm/sunxi/files.sunxi" Added files: Index: src/sys/arch/arm/cavium/files.thunderx diff -u /dev/null src/sys/arch/arm/cavium/files.thunderx:1.1 --- /dev/null Wed Oct 3 09:24:36 2018 +++ src/sys/arch/arm/cavium/files.thunderx Wed Oct 3 09:24:36 2018 @@ -0,0 +1,9 @@ +# $NetBSD: files.thunderx,v 1.1 2018/10/03 09:24:36 skrll Exp $ +# +# Configuration info for Cavium ThunderX based systems. +# +# + +file arch/arm/cavium/thunderx_platform.c soc_thunderx + +defflag opt_soc.h SOC_THUNDERX Index: src/sys/arch/arm/cavium/thunderx_platform.c diff -u /dev/null src/sys/arch/arm/cavium/thunderx_platform.c:1.1 --- /dev/null Wed Oct 3 09:24:36 2018 +++ src/sys/arch/arm/cavium/thunderx_platform.c Wed Oct 3 09:24:36 2018 @@ -0,0 +1,131 @@ +/* $NetBSD: thunderx_platform.c,v 1.1 2018/10/03 09:24:36 skrll Exp $ */ + +/*- + * Copyright (c) 2018 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Nick Hudson + * + * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. + */ + +#include "opt_console.h" +#include "opt_soc.h" +#include "opt_multiprocessor.h" + +#include <sys/cdefs.h> +__KERNEL_RCSID(0, "$NetBSD: thunderx_platform.c,v 1.1 2018/10/03 09:24:36 skrll Exp $"); + +#include <sys/param.h> +#include <sys/bus.h> +#include <sys/cpu.h> +#include <sys/device.h> + +#include <dev/fdt/fdtvar.h> +#include <arm/fdt/arm_fdtvar.h> + +#include <uvm/uvm_extern.h> + +#include <machine/bootconfig.h> +#include <arm/cpufunc.h> +#include <arm/locore.h> + +#include <evbarm/dev/plcomreg.h> +#include <evbarm/dev/plcomvar.h> + +#include <dev/ic/ns16550reg.h> +#include <dev/ic/comreg.h> + +#include <arm/cortex/gtmr_var.h> + +#include <arm/arm/psci.h> +#include <arm/fdt/psci_fdtvar.h> + +#include <arm/cavium/thunderx_platform.h> + +void thunderx_platform_early_putchar(char); + +static const struct pmap_devmap * +thunderx_platform_devmap(void) +{ + static const struct pmap_devmap devmap[] = { + DEVMAP_ENTRY(THUNDERX_CORE_VBASE, THUNDERX_CORE_PBASE, THUNDERX_CORE_SIZE), + DEVMAP_ENTRY_END + }; + + return devmap; +} + +static void +thunderx_platform_init_attach_args(struct fdt_attach_args *faa) +{ + extern struct arm32_bus_dma_tag arm_generic_dma_tag; + extern struct bus_space arm_generic_bs_tag; + extern struct bus_space arm_generic_a4x_bs_tag; + + faa->faa_bst = &arm_generic_bs_tag; + faa->faa_a4x_bst = &arm_generic_a4x_bs_tag; + faa->faa_dmat = &arm_generic_dma_tag; +} + +void +thunderx_platform_early_putchar(char c) +{ +#ifdef CONSADDR + volatile uint32_t *uartaddr = (volatile uint32_t *)CONSADDR; + + while ((le32toh(uartaddr[PL01XCOM_FR / 4]) & PL01X_FR_TXFF) != 0) + continue; + + uartaddr[PL01XCOM_DR / 4] = htole32(c); + arm_dsb(); + + while ((le32toh(uartaddr[PL01XCOM_FR / 4]) & PL01X_FR_TXFE) == 0) + continue; +#endif +} + +static void +thunderx_platform_device_register(device_t self, void *aux) +{ +} + +static u_int +thunderx_platform_uart_freq(void) +{ + + return 133315200; +} + +static const struct arm_platform thunderx_platform = { + .ap_devmap = thunderx_platform_devmap, + .ap_bootstrap = arm_fdt_cpu_bootstrap, + .ap_init_attach_args = thunderx_platform_init_attach_args, + .ap_early_putchar = thunderx_platform_early_putchar, + .ap_device_register = thunderx_platform_device_register, + .ap_reset = psci_fdt_reset, + .ap_delay = gtmr_delay, + .ap_uart_freq = thunderx_platform_uart_freq, +}; + +ARM_PLATFORM(thunderx, "cavium,thunder-88xx", &thunderx_platform); Index: src/sys/arch/arm/cavium/thunderx_platform.h diff -u /dev/null src/sys/arch/arm/cavium/thunderx_platform.h:1.1 --- /dev/null Wed Oct 3 09:24:36 2018 +++ src/sys/arch/arm/cavium/thunderx_platform.h Wed Oct 3 09:24:36 2018 @@ -0,0 +1,41 @@ +/* $NetBSD: thunderx_platform.h,v 1.1 2018/10/03 09:24:36 skrll Exp $ */ + +/*- + * Copyright (c) 2018 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Nick Hudson + * + * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. + */ + +#ifndef _ARM_THUNDERX_PLATFORM_H +#define _ARM_THUNDERX_PLATFORM_H + +#include <arch/evbarm/fdt/platform.h> + +#define THUNDERX_CORE_VBASE KERNEL_IO_VBASE +#define THUNDERX_CORE_PBASE 0x87e024000000UL +#define THUNDERX_CORE_SIZE 0x01000000UL + +#endif /* _ARM_THUNDERX_PLATFORM_H */