Module Name: src Committed By: jmcneill Date: Mon May 29 23:21:12 UTC 2017
Modified Files: src/sys/arch/arm/fdt: files.fdt src/sys/arch/arm/nvidia: tegra_platform.c src/sys/arch/evbarm/conf: TEGRA src/sys/arch/evbarm/tegra: tegra_machdep.c Added Files: src/sys/arch/arm/fdt: arm_fdt.c arm_fdtvar.h Removed Files: src/sys/arch/arm/fdt: armv7_fdt.c armv7_fdtvar.h Log Message: Rename armv7fdt to armfdt now that bus space + dma tags are filled in by platform code. To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/fdt/arm_fdt.c \ src/sys/arch/arm/fdt/arm_fdtvar.h cvs rdiff -u -r1.3 -r0 src/sys/arch/arm/fdt/armv7_fdt.c cvs rdiff -u -r1.2 -r0 src/sys/arch/arm/fdt/armv7_fdtvar.h cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/fdt/files.fdt cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/nvidia/tegra_platform.c cvs rdiff -u -r1.20 -r1.21 src/sys/arch/evbarm/conf/TEGRA cvs rdiff -u -r1.47 -r1.48 src/sys/arch/evbarm/tegra/tegra_machdep.c 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/arm/fdt/files.fdt diff -u src/sys/arch/arm/fdt/files.fdt:1.2 src/sys/arch/arm/fdt/files.fdt:1.3 --- src/sys/arch/arm/fdt/files.fdt:1.2 Sun May 28 00:40:20 2017 +++ src/sys/arch/arm/fdt/files.fdt Mon May 29 23:21:12 2017 @@ -1,8 +1,8 @@ -# $NetBSD: files.fdt,v 1.2 2017/05/28 00:40:20 jmcneill Exp $ +# $NetBSD: files.fdt,v 1.3 2017/05/29 23:21:12 jmcneill Exp $ -device armv7fdt { }: bus_space_generic, fdtbus -attach armv7fdt at root with armv7_fdt -file arch/arm/fdt/armv7_fdt.c armv7_fdt +device armfdt { }: bus_space_generic, fdtbus +attach armfdt at root with arm_fdt +file arch/arm/fdt/arm_fdt.c arm_fdt attach cpu at cpus with cpu_fdt file arch/arm/fdt/cpu_fdt.c cpu_fdt Index: src/sys/arch/arm/nvidia/tegra_platform.c diff -u src/sys/arch/arm/nvidia/tegra_platform.c:1.2 src/sys/arch/arm/nvidia/tegra_platform.c:1.3 --- src/sys/arch/arm/nvidia/tegra_platform.c:1.2 Mon May 29 23:13:03 2017 +++ src/sys/arch/arm/nvidia/tegra_platform.c Mon May 29 23:21:12 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: tegra_platform.c,v 1.2 2017/05/29 23:13:03 jmcneill Exp $ */ +/* $NetBSD: tegra_platform.c,v 1.3 2017/05/29 23:21:12 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared D. McNeill <jmcne...@invisible.ca> @@ -33,7 +33,7 @@ #include "ukbd.h" #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: tegra_platform.c,v 1.2 2017/05/29 23:13:03 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tegra_platform.c,v 1.3 2017/05/29 23:21:12 jmcneill Exp $"); #include <sys/param.h> #include <sys/bus.h> @@ -51,7 +51,7 @@ __KERNEL_RCSID(0, "$NetBSD: tegra_platfo #include <arm/nvidia/tegra_reg.h> #include <arm/nvidia/tegra_var.h> -#include <arm/fdt/armv7_fdtvar.h> +#include <arm/fdt/arm_fdtvar.h> #if NUKBD > 0 #include <dev/usb/ukbdvar.h> @@ -179,7 +179,7 @@ tegra_platform_reset(void) tegra_pmc_reset(); } -static const struct armv7_platform tegra_platform = { +static const struct arm_platform tegra_platform = { .devmap = tegra_platform_devmap, .bootstrap = tegra_platform_bootstrap, .init_attach_args = tegra_platform_init_attach_args, @@ -188,5 +188,5 @@ static const struct armv7_platform tegra .reset = tegra_platform_reset, }; -ARMV7_PLATFORM(tegra124, "nvidia,tegra124", &tegra_platform); -ARMV7_PLATFORM(tegra210, "nvidia,tegra210", &tegra_platform); +ARM_PLATFORM(tegra124, "nvidia,tegra124", &tegra_platform); +ARM_PLATFORM(tegra210, "nvidia,tegra210", &tegra_platform); Index: src/sys/arch/evbarm/conf/TEGRA diff -u src/sys/arch/evbarm/conf/TEGRA:1.20 src/sys/arch/evbarm/conf/TEGRA:1.21 --- src/sys/arch/evbarm/conf/TEGRA:1.20 Sun May 28 00:40:21 2017 +++ src/sys/arch/evbarm/conf/TEGRA Mon May 29 23:21:12 2017 @@ -1,5 +1,5 @@ # -# $NetBSD: TEGRA,v 1.20 2017/05/28 00:40:21 jmcneill Exp $ +# $NetBSD: TEGRA,v 1.21 2017/05/29 23:21:12 jmcneill Exp $ # # NVIDIA Tegra K1 (T124) # @@ -28,7 +28,7 @@ makeoptions COPY_SYMTAB=1 config netbsd root on ? type ? # Device tree support -armv7fdt0 at root +armfdt0 at root fdt* at fdtbus? # CPUs Index: src/sys/arch/evbarm/tegra/tegra_machdep.c diff -u src/sys/arch/evbarm/tegra/tegra_machdep.c:1.47 src/sys/arch/evbarm/tegra/tegra_machdep.c:1.48 --- src/sys/arch/evbarm/tegra/tegra_machdep.c:1.47 Mon May 29 23:13:03 2017 +++ src/sys/arch/evbarm/tegra/tegra_machdep.c Mon May 29 23:21:12 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: tegra_machdep.c,v 1.47 2017/05/29 23:13:03 jmcneill Exp $ */ +/* $NetBSD: tegra_machdep.c,v 1.48 2017/05/29 23:21:12 jmcneill Exp $ */ /*- * Copyright (c) 2015 Jared D. McNeill <jmcne...@invisible.ca> @@ -27,7 +27,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: tegra_machdep.c,v 1.47 2017/05/29 23:13:03 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tegra_machdep.c,v 1.48 2017/05/29 23:21:12 jmcneill Exp $"); #include "opt_tegra.h" #include "opt_machdep.h" @@ -68,7 +68,7 @@ __KERNEL_RCSID(0, "$NetBSD: tegra_machde #include <evbarm/include/autoconf.h> #include <evbarm/tegra/platform.h> -#include <arm/fdt/armv7_fdtvar.h> +#include <arm/fdt/arm_fdtvar.h> #ifndef TEGRA_MAX_BOOT_STRING #define TEGRA_MAX_BOOT_STRING 1024 @@ -103,7 +103,7 @@ static struct boot_physmem bp_lowgig = { static void tegra_putchar(char c) { - const struct armv7_platform *plat = armv7_fdt_platform(); + const struct arm_platform *plat = arm_fdt_platform(); if (plat && plat->early_purchar) plat->early_putchar(c); } @@ -155,7 +155,7 @@ tegra_printn(u_int n, int base) u_int initarm(void *arg) { - const struct armv7_platform *plat; + const struct arm_platform *plat; uint64_t memory_addr, memory_size; psize_t ram_size = 0; @@ -173,7 +173,7 @@ initarm(void *arg) } /* Lookup platform specific backend */ - plat = armv7_fdt_platform(); + plat = arm_fdt_platform(); if (plat == NULL) panic("Kernel does not support this device"); @@ -295,7 +295,7 @@ void consinit(void) { static bool initialized = false; - const struct armv7_platform *plat = armv7_fdt_platform(); + const struct arm_platform *plat = arm_fdt_platform(); const struct fdt_console *cons = fdtbus_get_console(); struct fdt_attach_args faa; @@ -313,7 +313,7 @@ consinit(void) void tegra_device_register(device_t self, void *aux) { - const struct armv7_platform *plat = armv7_fdt_platform(); + const struct arm_platform *plat = arm_fdt_platform(); if (plat && plat->device_register) plat->device_register(self, aux); @@ -322,7 +322,7 @@ tegra_device_register(device_t self, voi static void tegra_reset(void) { - const struct armv7_platform *plat = armv7_fdt_platform(); + const struct arm_platform *plat = arm_fdt_platform(); fdtbus_power_reset(); Added files: Index: src/sys/arch/arm/fdt/arm_fdt.c diff -u /dev/null src/sys/arch/arm/fdt/arm_fdt.c:1.1 --- /dev/null Mon May 29 23:21:12 2017 +++ src/sys/arch/arm/fdt/arm_fdt.c Mon May 29 23:21:12 2017 @@ -0,0 +1,100 @@ +/* $NetBSD: arm_fdt.c,v 1.1 2017/05/29 23:21:12 jmcneill Exp $ */ + +/*- + * Copyright (c) 2017 Jared D. McNeill <jmcne...@invisible.ca> + * 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 ``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 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 <sys/cdefs.h> +__KERNEL_RCSID(0, "$NetBSD: arm_fdt.c,v 1.1 2017/05/29 23:21:12 jmcneill Exp $"); + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/device.h> + +#include <machine/cpu.h> +#include <sys/bus.h> + +#include <dev/fdt/fdtvar.h> +#include <dev/ofw/openfirm.h> + +#include <arm/fdt/arm_fdtvar.h> + +static int arm_fdt_match(device_t, cfdata_t, void *); +static void arm_fdt_attach(device_t, device_t, void *); + +CFATTACH_DECL_NEW(arm_fdt, 0, + arm_fdt_match, arm_fdt_attach, NULL, NULL); + +static struct arm_platlist arm_platform_list = + TAILQ_HEAD_INITIALIZER(arm_platform_list); + +int +arm_fdt_match(device_t parent, cfdata_t cf, void *aux) +{ + return 1; +} + +void +arm_fdt_attach(device_t parent, device_t self, void *aux) +{ + const struct arm_platform *plat = arm_fdt_platform(); + struct fdt_attach_args faa; + + aprint_naive("\n"); + aprint_normal("\n"); + + plat->init_attach_args(&faa); + faa.faa_name = ""; + faa.faa_phandle = OF_peer(0); + + config_found(self, &faa, NULL); +} + +const struct arm_platform * +arm_fdt_platform(void) +{ + static const struct arm_platform_info *booted_platform = NULL; + + if (booted_platform == NULL) { + __link_set_decl(arm_platforms, struct arm_platform_info); + struct arm_platform_info * const *info; + const struct arm_platform_info *best_info = NULL; + const int phandle = OF_peer(0); + int match, best_match = 0; + + __link_set_foreach(info, arm_platforms) { + const char * const compat[] = { (*info)->compat, NULL }; + match = of_match_compatible(phandle, compat); + if (match > best_match) { + best_match = match; + best_info = *info; + } + } + + booted_platform = best_info; + } + + return booted_platform == NULL ? NULL : booted_platform->ops; +} Index: src/sys/arch/arm/fdt/arm_fdtvar.h diff -u /dev/null src/sys/arch/arm/fdt/arm_fdtvar.h:1.1 --- /dev/null Mon May 29 23:21:12 2017 +++ src/sys/arch/arm/fdt/arm_fdtvar.h Mon May 29 23:21:12 2017 @@ -0,0 +1,66 @@ +/* $NetBSD: arm_fdtvar.h,v 1.1 2017/05/29 23:21:12 jmcneill Exp $ */ + +/*- + * Copyright (c) 2017 Jared D. McNeill <jmcne...@invisible.ca> + * 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 ``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 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_ARM_FDTVAR_H +#define _ARM_ARM_FDTVAR_H + +/* + * Platform-specific data + */ + +struct fdt_attach_args; + +struct arm_platform { + const struct pmap_devmap * (*devmap)(void); + void (*bootstrap)(void); + void (*init_attach_args)(struct fdt_attach_args *); + void (*early_putchar)(char); + void (*device_register)(device_t, void *); + void (*reset)(void); +}; + +struct arm_platform_info { + const char * compat; + const struct arm_platform * ops; +}; + +#define _ARM_PLATFORM_REGISTER(name) \ + __link_set_add_rodata(arm_platforms, __CONCAT(name,_platinfo)); + +#define ARM_PLATFORM(_name, _compat, _ops) \ +static const struct arm_platform_info __CONCAT(_name,_platinfo) = { \ + .compat = (_compat), \ + .ops = (_ops) \ +}; \ +_ARM_PLATFORM_REGISTER(_name) + +TAILQ_HEAD(arm_platlist, arm_platform_info); + +const struct arm_platform * arm_fdt_platform(void); + +#endif /* !_ARM_ARM_FDTVAR_H */