CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Fri Jul 23 21:33:35 UTC 2021 Modified Files: src/sys/arch/arm/fdt: acpi_fdt.c Log Message: smbios: Support SMBIOS 2.x tables. To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/sys/arch/arm/fdt/acpi_fdt.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/acpi_fdt.c diff -u src/sys/arch/arm/fdt/acpi_fdt.c:1.20 src/sys/arch/arm/fdt/acpi_fdt.c:1.21 --- src/sys/arch/arm/fdt/acpi_fdt.c:1.20 Thu Jul 22 00:47:55 2021 +++ src/sys/arch/arm/fdt/acpi_fdt.c Fri Jul 23 21:33:35 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_fdt.c,v 1.20 2021/07/22 00:47:55 jmcneill Exp $ */ +/* $NetBSD: acpi_fdt.c,v 1.21 2021/07/23 21:33:35 jmcneill Exp $ */ /*- * Copyright (c) 2015-2017 Jared McNeill @@ -30,7 +30,7 @@ #include "opt_efi.h" #include -__KERNEL_RCSID(0, "$NetBSD: acpi_fdt.c,v 1.20 2021/07/22 00:47:55 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_fdt.c,v 1.21 2021/07/23 21:33:35 jmcneill Exp $"); #include #include @@ -140,11 +140,36 @@ acpi_fdt_poweroff(device_t dev) psci_system_off(); } +static int +acpi_fdt_smbios_version(void) +{ + uint8_t *hdr; + int smbver; + + if (smbios_table == 0) { + return 0; + } + + hdr = AcpiOsMapMemory(smbios_table, 24); + if (hdr == NULL) { + return 0; + } + if (smbios3_check_header(hdr)) { + smbver = 3; + } else if (smbios2_check_header(hdr)) { + smbver = 2; + } else { + smbver = 0; + } + AcpiOsUnmapMemory(hdr, 24); + return smbver; +} + static void acpi_fdt_smbios_init(device_t dev) { - struct smb3hdr *sh; uint8_t *ptr; + int smbver; const int chosen = OF_finddevice("/chosen"); if (chosen >= 0) { @@ -154,29 +179,48 @@ acpi_fdt_smbios_init(device_t dev) return; } - sh = AcpiOsMapMemory(smbios_table, sizeof(*sh)); - if (sh == NULL) { - return; - } - if (!smbios3_check_header((uint8_t *)sh)) { - AcpiOsUnmapMemory(sh, sizeof(*sh)); - return; - } + smbver = acpi_fdt_smbios_version(); + if (smbver == 3) { + struct smb3hdr *sh = AcpiOsMapMemory(smbios_table, sizeof(*sh)); + if (sh == NULL) { + return; + } + + ptr = AcpiOsMapMemory(sh->addr, sh->size); + if (ptr != NULL) { + smbios_entry.addr = ptr; + smbios_entry.len = sh->size; + smbios_entry.rev = sh->eprev; + smbios_entry.mjr = sh->majrev; + smbios_entry.min = sh->minrev; + smbios_entry.doc = sh->docrev; + smbios_entry.count = UINT16_MAX; + } - ptr = AcpiOsMapMemory(sh->addr, sh->size); - if (ptr != NULL) { - smbios_entry.addr = ptr; - smbios_entry.len = sh->size; - smbios_entry.rev = sh->eprev; - smbios_entry.mjr = sh->majrev; - smbios_entry.min = sh->minrev; - smbios_entry.doc = sh->docrev; - smbios_entry.count = UINT16_MAX; - - device_printf(dev, "SMBIOS rev. %d.%d.%d @ 0x%lx\n", + aprint_normal_dev(dev, "SMBIOS rev. %d.%d.%d @ 0x%lx\n", sh->majrev, sh->minrev, sh->docrev, (u_long)sh->addr); + AcpiOsUnmapMemory(sh, sizeof(*sh)); + } else if (smbver == 2) { + struct smbhdr *sh = AcpiOsMapMemory(smbios_table, sizeof(*sh)); + if (sh == NULL) { + return; + } + + ptr = AcpiOsMapMemory(sh->addr, sh->size); + if (ptr != NULL) { + smbios_entry.addr = ptr; + smbios_entry.len = sh->size; + smbios_entry.rev = 0; + smbios_entry.mjr = sh->majrev; + smbios_entry.min = sh->minrev; + smbios_entry.doc = 0; + smbios_entry.count = sh->count; + } + + aprint_normal_dev(dev, "SMBIOS rev. %d.%d @ 0x%lx (%d entries)\n", + sh->majrev, sh->minrev, (u_long)sh->addr, sh->count); + AcpiOsUnmapMemory(sh, sizeof(*sh)); } - AcpiOsUnmapMemory(sh, sizeof(*sh)); } static void
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Thu Jul 22 00:47:56 UTC 2021 Modified Files: src/sys/arch/arm/fdt: acpi_fdt.c files.fdt Log Message: Expose SMBIOS tables using sysctl machdep.dmi.*, same as x86. To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/sys/arch/arm/fdt/acpi_fdt.c cvs rdiff -u -r1.33 -r1.34 src/sys/arch/arm/fdt/files.fdt 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/acpi_fdt.c diff -u src/sys/arch/arm/fdt/acpi_fdt.c:1.19 src/sys/arch/arm/fdt/acpi_fdt.c:1.20 --- src/sys/arch/arm/fdt/acpi_fdt.c:1.19 Sat Apr 24 23:36:26 2021 +++ src/sys/arch/arm/fdt/acpi_fdt.c Thu Jul 22 00:47:55 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_fdt.c,v 1.19 2021/04/24 23:36:26 thorpej Exp $ */ +/* $NetBSD: acpi_fdt.c,v 1.20 2021/07/22 00:47:55 jmcneill Exp $ */ /*- * Copyright (c) 2015-2017 Jared McNeill @@ -30,7 +30,7 @@ #include "opt_efi.h" #include -__KERNEL_RCSID(0, "$NetBSD: acpi_fdt.c,v 1.19 2021/04/24 23:36:26 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_fdt.c,v 1.20 2021/07/22 00:47:55 jmcneill Exp $"); #include #include @@ -47,6 +47,7 @@ __KERNEL_RCSID(0, "$NetBSD: acpi_fdt.c,v #include #include +#include #include @@ -61,6 +62,7 @@ static void acpi_fdt_attach(device_t, de static void acpi_fdt_poweroff(device_t); +static void acpi_fdt_smbios_init(device_t); static void acpi_fdt_sysctl_init(void); extern struct arm32_bus_dma_tag acpi_coherent_dma_tag; @@ -89,18 +91,24 @@ acpi_fdt_match(device_t parent, cfdata_t static void acpi_fdt_attach(device_t parent, device_t self, void *aux) { + extern void platform_init(void); /* XXX */ struct fdt_attach_args * const faa = aux; struct acpibus_attach_args aa; aprint_naive("\n"); aprint_normal("\n"); + acpi_fdt_smbios_init(self); + platform_init(); + fdtbus_register_power_controller(self, faa->faa_phandle, _fdt_power_funcs); if (!acpi_probe()) panic("ACPI subsystem failed to initialize"); + platform_init(); + memset(, 0, sizeof(aa)); #if NPCI > 0 aa.aa_pciflags = @@ -133,26 +141,64 @@ acpi_fdt_poweroff(device_t dev) } static void +acpi_fdt_smbios_init(device_t dev) +{ + struct smb3hdr *sh; + uint8_t *ptr; + + const int chosen = OF_finddevice("/chosen"); + if (chosen >= 0) { + of_getprop_uint64(chosen, "netbsd,smbios-table", _table); + } + if (smbios_table == 0) { + return; + } + + sh = AcpiOsMapMemory(smbios_table, sizeof(*sh)); + if (sh == NULL) { + return; + } + if (!smbios3_check_header((uint8_t *)sh)) { + AcpiOsUnmapMemory(sh, sizeof(*sh)); + return; + } + + ptr = AcpiOsMapMemory(sh->addr, sh->size); + if (ptr != NULL) { + smbios_entry.addr = ptr; + smbios_entry.len = sh->size; + smbios_entry.rev = sh->eprev; + smbios_entry.mjr = sh->majrev; + smbios_entry.min = sh->minrev; + smbios_entry.doc = sh->docrev; + smbios_entry.count = UINT16_MAX; + + device_printf(dev, "SMBIOS rev. %d.%d.%d @ 0x%lx\n", + sh->majrev, sh->minrev, sh->docrev, (u_long)sh->addr); + } + AcpiOsUnmapMemory(sh, sizeof(*sh)); +} + +static void acpi_fdt_sysctl_init(void) { const struct sysctlnode *rnode; int error; - const int chosen = OF_finddevice("/chosen"); - if (chosen >= 0) - of_getprop_uint64(chosen, "netbsd,smbios-table", _table); + if (smbios_table == 0) { + return; + } error = sysctl_createv(NULL, 0, NULL, , CTLFLAG_PERMANENT, CTLTYPE_NODE, "machdep", NULL, NULL, 0, NULL, 0, CTL_MACHDEP, CTL_EOL); - if (error) + if (error) { return; - - if (smbios_table != 0) { - (void)sysctl_createv(NULL, 0, , NULL, - CTLFLAG_PERMANENT | CTLFLAG_READONLY | CTLFLAG_HEX, CTLTYPE_QUAD, - "smbios", SYSCTL_DESCR("SMBIOS table pointer"), - NULL, 0, _table, sizeof(smbios_table), - CTL_CREATE, CTL_EOL); } + + (void)sysctl_createv(NULL, 0, , NULL, + CTLFLAG_PERMANENT | CTLFLAG_READONLY | CTLFLAG_HEX, CTLTYPE_QUAD, + "smbios", SYSCTL_DESCR("SMBIOS table pointer"), + NULL, 0, _table, sizeof(smbios_table), + CTL_CREATE, CTL_EOL); } Index: src/sys/arch/arm/fdt/files.fdt diff -u src/sys/arch/arm/fdt/files.fdt:1.33 src/sys/arch/arm/fdt/files.fdt:1.34 --- src/sys/arch/arm/fdt/files.fdt:1.33 Mon Apr 26 14:44:16 2021 +++ src/sys/arch/arm/fdt/files.fdt Thu Jul 22 00:47:55 2021 @@ -1,4 +1,4 @@ -# $NetBSD: files.fdt,v 1.33 2021/04/26 14:44:16 thorpej Exp $ +# $NetBSD: files.fdt,v 1.34 2021/07/22 00:47:55 jmcneill Exp $ include "dev/pckbport/files.pckbport" @@ -75,6 +75,7 @@ file arch/arm/fdt/pmu_fdt.c pmu_fdt attach genfb at fdt with plfb_fdt: fdt_display_timing file arch/arm/fdt/plfb_fdt.c plfb_fdt -device acpifdt: acpibus +device acpifdt: acpibus, smbios attach acpifdt at fdt with acpi_fdt file arch/arm/fdt/acpi_fdt.c acpi_fdt +file dev/smbios_platform.c acpi_fdt
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: thorpej Date: Mon Apr 26 14:44:16 UTC 2021 Modified Files: src/sys/arch/arm/fdt: files.fdt Log Message: armfdt does not need its own interface attribute; all of its children attach to the "fdt" interface attribute. To generate a diff of this commit: cvs rdiff -u -r1.32 -r1.33 src/sys/arch/arm/fdt/files.fdt 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.32 src/sys/arch/arm/fdt/files.fdt:1.33 --- src/sys/arch/arm/fdt/files.fdt:1.32 Sat Oct 10 15:25:31 2020 +++ src/sys/arch/arm/fdt/files.fdt Mon Apr 26 14:44:16 2021 @@ -1,8 +1,8 @@ -# $NetBSD: files.fdt,v 1.32 2020/10/10 15:25:31 jmcneill Exp $ +# $NetBSD: files.fdt,v 1.33 2021/04/26 14:44:16 thorpej Exp $ include "dev/pckbport/files.pckbport" -device armfdt { }: bus_space_generic, fdt +device armfdt: bus_space_generic, fdt attach armfdt at root with arm_fdt file arch/arm/fdt/arm_fdt.c arm_fdt file arch/arm/fdt/arm_platform.c arm_fdt & gtmr_fdt & psci_fdt
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Tue Feb 23 11:31:52 UTC 2021 Modified Files: src/sys/arch/arm/fdt: arm_fdt.c Log Message: Install a default irq handler that panics when no interrupt controller driver is installed. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/sys/arch/arm/fdt/arm_fdt.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/arm_fdt.c diff -u src/sys/arch/arm/fdt/arm_fdt.c:1.14 src/sys/arch/arm/fdt/arm_fdt.c:1.15 --- src/sys/arch/arm/fdt/arm_fdt.c:1.14 Wed Jan 27 03:10:19 2021 +++ src/sys/arch/arm/fdt/arm_fdt.c Tue Feb 23 11:31:52 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: arm_fdt.c,v 1.14 2021/01/27 03:10:19 thorpej Exp $ */ +/* $NetBSD: arm_fdt.c,v 1.15 2021/02/23 11:31:52 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared D. McNeill @@ -31,7 +31,7 @@ #include "opt_modular.h" #include -__KERNEL_RCSID(0, "$NetBSD: arm_fdt.c,v 1.14 2021/01/27 03:10:19 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: arm_fdt.c,v 1.15 2021/02/23 11:31:52 jmcneill Exp $"); #include #include @@ -56,6 +56,8 @@ __KERNEL_RCSID(0, "$NetBSD: arm_fdt.c,v static int arm_fdt_match(device_t, cfdata_t, void *); static void arm_fdt_attach(device_t, device_t, void *); +static void arm_fdt_irq_default_handler(void *); + #ifdef EFI_RUNTIME static void arm_fdt_efi_init(device_t); static int arm_fdt_efi_rtc_gettime(todr_chip_handle_t, struct clock_ymdhms *); @@ -76,7 +78,7 @@ struct arm_fdt_cpu_hatch_cb { static TAILQ_HEAD(, arm_fdt_cpu_hatch_cb) arm_fdt_cpu_hatch_cbs = TAILQ_HEAD_INITIALIZER(arm_fdt_cpu_hatch_cbs); -static void (*_arm_fdt_irq_handler)(void *) = NULL; +static void (*_arm_fdt_irq_handler)(void *) = arm_fdt_irq_default_handler; static void (*_arm_fdt_timer_init)(void) = NULL; int @@ -169,10 +171,16 @@ arm_fdt_cpu_hatch(struct cpu_info *ci) c->cb(c->priv, ci); } +static void +arm_fdt_irq_default_handler(void *frame) +{ + panic("missing interrupt controller driver"); +} + void arm_fdt_irq_set_handler(void (*irq_handler)(void *)) { - KASSERT(_arm_fdt_irq_handler == NULL); + KASSERT(_arm_fdt_irq_handler == arm_fdt_irq_default_handler); _arm_fdt_irq_handler = irq_handler; }
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: thorpej Date: Wed Jan 27 01:54:06 UTC 2021 Modified Files: src/sys/arch/arm/fdt: gicv3_fdt.c pcihost_fdt.c Log Message: Use DEVICE_COMPAT_EOL. To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/sys/arch/arm/fdt/gicv3_fdt.c cvs rdiff -u -r1.21 -r1.22 src/sys/arch/arm/fdt/pcihost_fdt.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/gicv3_fdt.c diff -u src/sys/arch/arm/fdt/gicv3_fdt.c:1.13 src/sys/arch/arm/fdt/gicv3_fdt.c:1.14 --- src/sys/arch/arm/fdt/gicv3_fdt.c:1.13 Mon Jan 25 14:20:38 2021 +++ src/sys/arch/arm/fdt/gicv3_fdt.c Wed Jan 27 01:54:06 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: gicv3_fdt.c,v 1.13 2021/01/25 14:20:38 thorpej Exp $ */ +/* $NetBSD: gicv3_fdt.c,v 1.14 2021/01/27 01:54:06 thorpej Exp $ */ /*- * Copyright (c) 2015-2018 Jared McNeill @@ -31,7 +31,7 @@ #define _INTR_PRIVATE #include -__KERNEL_RCSID(0, "$NetBSD: gicv3_fdt.c,v 1.13 2021/01/25 14:20:38 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: gicv3_fdt.c,v 1.14 2021/01/27 01:54:06 thorpej Exp $"); #include #include @@ -109,7 +109,7 @@ struct gicv3_fdt_softc { static const struct device_compatible_entry gicv3_fdt_quirks[] = { { .compat = "rockchip,rk3399", .value = GICV3_QUIRK_RK3399 }, - { } + DEVICE_COMPAT_EOL }; CFATTACH_DECL_NEW(gicv3_fdt, sizeof(struct gicv3_fdt_softc), @@ -117,7 +117,7 @@ CFATTACH_DECL_NEW(gicv3_fdt, sizeof(stru static const struct device_compatible_entry compat_data[] = { { .compat = "arm,gic-v3" }, - { } + DEVICE_COMPAT_EOL }; static int @@ -181,7 +181,7 @@ gicv3_fdt_attach(device_t parent, device /* Interrupt Translation Services */ static const struct device_compatible_entry its_compat[] = { { .compat = "arm,gic-v3-its" }, - { } + DEVICE_COMPAT_EOL }; for (int child = OF_child(phandle); child; Index: src/sys/arch/arm/fdt/pcihost_fdt.c diff -u src/sys/arch/arm/fdt/pcihost_fdt.c:1.21 src/sys/arch/arm/fdt/pcihost_fdt.c:1.22 --- src/sys/arch/arm/fdt/pcihost_fdt.c:1.21 Mon Jan 25 14:20:38 2021 +++ src/sys/arch/arm/fdt/pcihost_fdt.c Wed Jan 27 01:54:06 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: pcihost_fdt.c,v 1.21 2021/01/25 14:20:38 thorpej Exp $ */ +/* $NetBSD: pcihost_fdt.c,v 1.22 2021/01/27 01:54:06 thorpej Exp $ */ /*- * Copyright (c) 2018 Jared D. McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pcihost_fdt.c,v 1.21 2021/01/25 14:20:38 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pcihost_fdt.c,v 1.22 2021/01/27 01:54:06 thorpej Exp $"); #include @@ -98,7 +98,7 @@ CFATTACH_DECL_NEW(pcihost_fdt, sizeof(st static const struct device_compatible_entry compat_data[] = { { .compat = "pci-host-cam-generic", .value = PCIHOST_CAM }, { .compat = "pci-host-ecam-generic", .value = PCIHOST_ECAM }, - { } + DEVICE_COMPAT_EOL }; static int
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: thorpej Date: Tue Jan 19 00:40:17 UTC 2021 Modified Files: src/sys/arch/arm/fdt: gicv3_fdt.c Log Message: Use device_compatible_entry / of_search_compatible() for the GICv3 quirk table. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/fdt/gicv3_fdt.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/gicv3_fdt.c diff -u src/sys/arch/arm/fdt/gicv3_fdt.c:1.11 src/sys/arch/arm/fdt/gicv3_fdt.c:1.12 --- src/sys/arch/arm/fdt/gicv3_fdt.c:1.11 Fri Jan 15 00:38:22 2021 +++ src/sys/arch/arm/fdt/gicv3_fdt.c Tue Jan 19 00:40:17 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: gicv3_fdt.c,v 1.11 2021/01/15 00:38:22 jmcneill Exp $ */ +/* $NetBSD: gicv3_fdt.c,v 1.12 2021/01/19 00:40:17 thorpej Exp $ */ /*- * Copyright (c) 2015-2018 Jared McNeill @@ -31,7 +31,7 @@ #define _INTR_PRIVATE #include -__KERNEL_RCSID(0, "$NetBSD: gicv3_fdt.c,v 1.11 2021/01/15 00:38:22 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: gicv3_fdt.c,v 1.12 2021/01/19 00:40:17 thorpej Exp $"); #include #include @@ -107,29 +107,26 @@ struct gicv3_fdt_softc { struct gicv3_fdt_irq *sc_irq[GICV3_MAXIRQ]; }; -struct gicv3_fdt_quirk { - const char *compat; - u_int quirks; -}; - -static const struct gicv3_fdt_quirk gicv3_fdt_quirks[] = { - { "rockchip,rk3399", GICV3_QUIRK_RK3399 }, +static const struct device_compatible_entry gicv3_fdt_quirks[] = { + { .compat = "rockchip,rk3399", .value = GICV3_QUIRK_RK3399 }, + { 0 } }; CFATTACH_DECL_NEW(gicv3_fdt, sizeof(struct gicv3_fdt_softc), gicv3_fdt_match, gicv3_fdt_attach, NULL, NULL); +static const struct device_compatible_entry compat_data[] = { + { .compat = "arm,gic-v3" }, + { 0 } +}; + static int gicv3_fdt_match(device_t parent, cfdata_t cf, void *aux) { - const char * const compatible[] = { - "arm,gic-v3", - NULL - }; struct fdt_attach_args * const faa = aux; const int phandle = faa->faa_phandle; - return of_match_compatible(phandle, compatible); + return of_match_compat_data(phandle, compat_data); } static void @@ -138,7 +135,7 @@ gicv3_fdt_attach(device_t parent, device struct gicv3_fdt_softc * const sc = device_private(self); struct fdt_attach_args * const faa = aux; const int phandle = faa->faa_phandle; - int error, n; + int error; error = fdtbus_register_interrupt_controller(self, phandle, _fdt_funcs); @@ -164,11 +161,10 @@ gicv3_fdt_attach(device_t parent, device aprint_debug_dev(self, "%d redistributors\n", sc->sc_gic.sc_bsh_r_count); /* Apply quirks */ - for (n = 0; n < __arraycount(gicv3_fdt_quirks); n++) { - const char *compat[] = { gicv3_fdt_quirks[n].compat, NULL }; - if (of_match_compatible(OF_finddevice("/"), compat)) { - sc->sc_gic.sc_quirks |= gicv3_fdt_quirks[n].quirks; - } + const struct device_compatible_entry *dce = + of_search_compatible(OF_finddevice("/"), gicv3_fdt_quirks); + if (dce != NULL) { + sc->sc_gic.sc_quirks |= dce->value; } error = gicv3_init(>sc_gic); @@ -183,11 +179,16 @@ gicv3_fdt_attach(device_t parent, device gicv3_fdt_attach_mbi(sc); } else { /* Interrupt Translation Services */ - for (int child = OF_child(phandle); child; child = OF_peer(child)) { + static const struct device_compatible_entry its_compat[] = { + { .compat = "arm,gic-v3-its" }, + { 0 } + }; + + for (int child = OF_child(phandle); child; + child = OF_peer(child)) { if (!fdtbus_status_okay(child)) continue; - const char * const its_compat[] = { "arm,gic-v3-its", NULL }; - if (of_match_compatible(child, its_compat)) + if (of_match_compat_data(child, its_compat)) gicv3_fdt_attach_its(sc, faa->faa_bst, child); } }
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Sun Jan 17 19:53:05 UTC 2021 Modified Files: src/sys/arch/arm/fdt: acpi_fdt.c Log Message: trailing whitespace To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/sys/arch/arm/fdt/acpi_fdt.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/acpi_fdt.c diff -u src/sys/arch/arm/fdt/acpi_fdt.c:1.16 src/sys/arch/arm/fdt/acpi_fdt.c:1.17 --- src/sys/arch/arm/fdt/acpi_fdt.c:1.16 Sat Oct 10 15:34:05 2020 +++ src/sys/arch/arm/fdt/acpi_fdt.c Sun Jan 17 19:53:05 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_fdt.c,v 1.16 2020/10/10 15:34:05 jmcneill Exp $ */ +/* $NetBSD: acpi_fdt.c,v 1.17 2021/01/17 19:53:05 jmcneill Exp $ */ /*- * Copyright (c) 2015-2017 Jared McNeill @@ -30,7 +30,7 @@ #include "opt_efi.h" #include -__KERNEL_RCSID(0, "$NetBSD: acpi_fdt.c,v 1.16 2020/10/10 15:34:05 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_fdt.c,v 1.17 2021/01/17 19:53:05 jmcneill Exp $"); #include #include @@ -105,7 +105,7 @@ acpi_fdt_attach(device_t parent, device_ #if NPCI > 0 aa.aa_pciflags = /*PCI_FLAGS_IO_OKAY |*/ PCI_FLAGS_MEM_OKAY | - PCI_FLAGS_MRL_OKAY | PCI_FLAGS_MRM_OKAY | + PCI_FLAGS_MRL_OKAY | PCI_FLAGS_MRM_OKAY | PCI_FLAGS_MWI_OKAY; #ifdef __HAVE_PCI_MSI_MSIX aa.aa_pciflags |= PCI_FLAGS_MSI_OKAY | PCI_FLAGS_MSIX_OKAY;
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Sun Jan 17 19:51:43 UTC 2021 Modified Files: src/sys/arch/arm/fdt: arm_simplefb.c Log Message: Fit in 80 columns. NFC. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/fdt/arm_simplefb.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/arm_simplefb.c diff -u src/sys/arch/arm/fdt/arm_simplefb.c:1.6 src/sys/arch/arm/fdt/arm_simplefb.c:1.7 --- src/sys/arch/arm/fdt/arm_simplefb.c:1.6 Sun Jan 17 19:03:49 2021 +++ src/sys/arch/arm/fdt/arm_simplefb.c Sun Jan 17 19:51:43 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: arm_simplefb.c,v 1.6 2021/01/17 19:03:49 jmcneill Exp $ */ +/* $NetBSD: arm_simplefb.c,v 1.7 2021/01/17 19:51:43 jmcneill Exp $ */ /*- * Copyright (c) 2019 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ #include "opt_vcons.h" #include -__KERNEL_RCSID(0, "$NetBSD: arm_simplefb.c,v 1.6 2021/01/17 19:03:49 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: arm_simplefb.c,v 1.7 2021/01/17 19:51:43 jmcneill Exp $"); #include #include @@ -93,7 +93,9 @@ static bus_space_handle_t arm_simplefb_b static int arm_simplefb_find_node(void) { - static const char * simplefb_compatible[] = { "simple-framebuffer", NULL }; + static const char * simplefb_compatible[] = { + "simple-framebuffer", NULL + }; int chosen_phandle, child; chosen_phandle = OF_finddevice("/chosen"); @@ -146,7 +148,8 @@ arm_simplefb_init_screen(void *cookie, s } static int -arm_simplefb_ioctl(void *v, void *vs, u_long cmd, void *data, int flag, lwp_t *l) +arm_simplefb_ioctl(void *v, void *vs, u_long cmd, void *data, int flag, +lwp_t *l) { return EPASSTHROUGH; } @@ -172,7 +175,8 @@ arm_simplefb_reconfig(void *arg, uint64_ bus_space_unmap(bst, arm_simplefb_bsh, arm_simplefb_size); bus_space_map(bst, new_addr, arm_simplefb_size, - BUS_SPACE_MAP_LINEAR | BUS_SPACE_MAP_PREFETCHABLE, _simplefb_bsh); + BUS_SPACE_MAP_LINEAR | BUS_SPACE_MAP_PREFETCHABLE, + _simplefb_bsh); sc->sc_bits = bus_space_vaddr(bst, arm_simplefb_bsh); ri->ri_bits = sc->sc_bits; @@ -258,7 +262,8 @@ arm_simplefb_preattach(void) #ifdef VCONS_DRAW_INTR arm_simplefb_vcons_data.use_intr = 0; #endif - vcons_init_screen(_simplefb_vcons_data, _simplefb_screen, 1, ); + vcons_init_screen(_simplefb_vcons_data, _simplefb_screen, 1, + ); arm_simplefb_screen.scr_flags |= VCONS_SCREEN_IS_STATIC; if (ri->ri_rows < 1 || ri->ri_cols < 1)
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Sun Jan 17 19:03:50 UTC 2021 Modified Files: src/sys/arch/arm/fdt: arm_simplefb.c Log Message: Use vcons_earlyinit To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/fdt/arm_simplefb.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/arm_simplefb.c diff -u src/sys/arch/arm/fdt/arm_simplefb.c:1.5 src/sys/arch/arm/fdt/arm_simplefb.c:1.6 --- src/sys/arch/arm/fdt/arm_simplefb.c:1.5 Sun Jan 17 14:28:25 2021 +++ src/sys/arch/arm/fdt/arm_simplefb.c Sun Jan 17 19:03:49 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: arm_simplefb.c,v 1.5 2021/01/17 14:28:25 jmcneill Exp $ */ +/* $NetBSD: arm_simplefb.c,v 1.6 2021/01/17 19:03:49 jmcneill Exp $ */ /*- * Copyright (c) 2019 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ #include "opt_vcons.h" #include -__KERNEL_RCSID(0, "$NetBSD: arm_simplefb.c,v 1.5 2021/01/17 14:28:25 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: arm_simplefb.c,v 1.6 2021/01/17 19:03:49 jmcneill Exp $"); #include #include @@ -252,8 +252,8 @@ arm_simplefb_preattach(void) arm_simplefb_accessops.mmap = arm_simplefb_mmap; arm_simplefb_accessops.pollc = arm_simplefb_pollc; - vcons_init(_simplefb_vcons_data, sc, _simplefb_stdscreen, - _simplefb_accessops); + vcons_earlyinit(_simplefb_vcons_data, sc, _simplefb_stdscreen, + _simplefb_accessops); arm_simplefb_vcons_data.init_screen = arm_simplefb_init_screen; #ifdef VCONS_DRAW_INTR arm_simplefb_vcons_data.use_intr = 0;
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Sun Jan 17 14:28:25 UTC 2021 Modified Files: src/sys/arch/arm/fdt: arm_simplefb.c Log Message: fix build without VCONS_DRAW_INTR To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/fdt/arm_simplefb.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/arm_simplefb.c diff -u src/sys/arch/arm/fdt/arm_simplefb.c:1.4 src/sys/arch/arm/fdt/arm_simplefb.c:1.5 --- src/sys/arch/arm/fdt/arm_simplefb.c:1.4 Wed Oct 21 11:06:13 2020 +++ src/sys/arch/arm/fdt/arm_simplefb.c Sun Jan 17 14:28:25 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: arm_simplefb.c,v 1.4 2020/10/21 11:06:13 rin Exp $ */ +/* $NetBSD: arm_simplefb.c,v 1.5 2021/01/17 14:28:25 jmcneill Exp $ */ /*- * Copyright (c) 2019 The NetBSD Foundation, Inc. @@ -31,9 +31,10 @@ #include "pci.h" #include "opt_pci.h" +#include "opt_vcons.h" #include -__KERNEL_RCSID(0, "$NetBSD: arm_simplefb.c,v 1.4 2020/10/21 11:06:13 rin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: arm_simplefb.c,v 1.5 2021/01/17 14:28:25 jmcneill Exp $"); #include #include @@ -254,9 +255,11 @@ arm_simplefb_preattach(void) vcons_init(_simplefb_vcons_data, sc, _simplefb_stdscreen, _simplefb_accessops); arm_simplefb_vcons_data.init_screen = arm_simplefb_init_screen; +#ifdef VCONS_DRAW_INTR arm_simplefb_vcons_data.use_intr = 0; +#endif vcons_init_screen(_simplefb_vcons_data, _simplefb_screen, 1, ); - arm_simplefb_screen.scr_flags |= VCONS_SCREEN_IS_STATIC; + arm_simplefb_screen.scr_flags |= VCONS_SCREEN_IS_STATIC; if (ri->ri_rows < 1 || ri->ri_cols < 1) return;
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: skrll Date: Thu Dec 17 08:47:18 UTC 2020 Modified Files: src/sys/arch/arm/fdt: arm_fdt.c Log Message: No need for PMAP_WRITE_BACK here (also aa32 pmap doesn't know about it) To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/sys/arch/arm/fdt/arm_fdt.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/arm_fdt.c diff -u src/sys/arch/arm/fdt/arm_fdt.c:1.12 src/sys/arch/arm/fdt/arm_fdt.c:1.13 --- src/sys/arch/arm/fdt/arm_fdt.c:1.12 Sat Oct 10 15:34:05 2020 +++ src/sys/arch/arm/fdt/arm_fdt.c Thu Dec 17 08:47:18 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: arm_fdt.c,v 1.12 2020/10/10 15:34:05 jmcneill Exp $ */ +/* $NetBSD: arm_fdt.c,v 1.13 2020/12/17 08:47:18 skrll Exp $ */ /*- * Copyright (c) 2017 Jared D. McNeill @@ -31,7 +31,7 @@ #include "opt_modular.h" #include -__KERNEL_RCSID(0, "$NetBSD: arm_fdt.c,v 1.12 2020/10/10 15:34:05 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: arm_fdt.c,v 1.13 2020/12/17 08:47:18 skrll Exp $"); #include #include @@ -263,7 +263,7 @@ arm_fdt_module_init(void) for (pa = startpa, va = startva; pa < endpa; pa += PAGE_SIZE, va += PAGE_SIZE) { - pmap_kenter_pa(va, pa, VM_PROT_ALL, PMAP_WRITE_BACK); + pmap_kenter_pa(va, pa, VM_PROT_ALL, 0); } pmap_update(pmap_kernel());
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Wed Nov 25 21:02:35 UTC 2020 Modified Files: src/sys/arch/arm/fdt: gicv3_fdt.c Log Message: Add support for message-based interrupts. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/fdt/gicv3_fdt.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/gicv3_fdt.c diff -u src/sys/arch/arm/fdt/gicv3_fdt.c:1.9 src/sys/arch/arm/fdt/gicv3_fdt.c:1.10 --- src/sys/arch/arm/fdt/gicv3_fdt.c:1.9 Tue Nov 24 23:31:55 2020 +++ src/sys/arch/arm/fdt/gicv3_fdt.c Wed Nov 25 21:02:35 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: gicv3_fdt.c,v 1.9 2020/11/24 23:31:55 jmcneill Exp $ */ +/* $NetBSD: gicv3_fdt.c,v 1.10 2020/11/25 21:02:35 jmcneill Exp $ */ /*- * Copyright (c) 2015-2018 Jared McNeill @@ -31,7 +31,7 @@ #define _INTR_PRIVATE #include -__KERNEL_RCSID(0, "$NetBSD: gicv3_fdt.c,v 1.9 2020/11/24 23:31:55 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: gicv3_fdt.c,v 1.10 2020/11/25 21:02:35 jmcneill Exp $"); #include #include @@ -48,6 +48,7 @@ __KERNEL_RCSID(0, "$NetBSD: gicv3_fdt.c, #include #include #include +#include #define GICV3_MAXIRQ 1020 @@ -62,6 +63,7 @@ static void gicv3_fdt_attach(device_t, d static int gicv3_fdt_map_registers(struct gicv3_fdt_softc *); #if NPCI > 0 && defined(__HAVE_PCI_MSI_MSIX) +static void gicv3_fdt_attach_mbi(struct gicv3_fdt_softc *); static void gicv3_fdt_attach_its(struct gicv3_fdt_softc *, bus_space_tag_t, int); #endif @@ -176,12 +178,18 @@ gicv3_fdt_attach(device_t parent, device } #if NPCI > 0 && defined(__HAVE_PCI_MSI_MSIX) - for (int child = OF_child(phandle); child; child = OF_peer(child)) { - if (!fdtbus_status_okay(child)) - continue; - const char * const its_compat[] = { "arm,gic-v3-its", NULL }; - if (of_match_compatible(child, its_compat)) - gicv3_fdt_attach_its(sc, faa->faa_bst, child); + if (of_hasprop(phandle, "msi-controller")) { + /* Message Based Interrupts */ + gicv3_fdt_attach_mbi(sc); + } else { + /* Interrupt Translation Services */ + for (int child = OF_child(phandle); child; child = OF_peer(child)) { + if (!fdtbus_status_okay(child)) +continue; + const char * const its_compat[] = { "arm,gic-v3-its", NULL }; + if (of_match_compatible(child, its_compat)) +gicv3_fdt_attach_its(sc, faa->faa_bst, child); + } } #endif @@ -257,6 +265,52 @@ gicv3_fdt_map_registers(struct gicv3_fdt #if NPCI > 0 && defined(__HAVE_PCI_MSI_MSIX) static void +gicv3_fdt_attach_mbi(struct gicv3_fdt_softc *sc) +{ + struct gic_v2m_frame *frame; + const u_int *ranges; + bus_addr_t addr; + int len, frame_count; + + if (of_hasprop(sc->sc_phandle, "mbi-alias")) { + aprint_error_dev(sc->sc_gic.sc_dev, "'mbi-alias' property not supported\n"); + return; + } + + if (fdtbus_get_reg(sc->sc_phandle, 0, , NULL) != 0) + return; + + ranges = fdtbus_get_prop(sc->sc_phandle, "mbi-ranges", ); + if (ranges == NULL) { + aprint_error_dev(sc->sc_gic.sc_dev, "missing 'mbi-ranges' property\n"); + return; + } + + frame_count = 0; + while (len >= 8) { + const u_int base_spi = be32dec([0]); + const u_int num_spis = be32dec([1]); + + frame = kmem_zalloc(sizeof(*frame), KM_SLEEP); + frame->frame_reg = addr; + frame->frame_pic = pic_list[0]; + frame->frame_base = base_spi; + frame->frame_count = num_spis; + + if (gic_v2m_init(frame, sc->sc_gic.sc_dev, frame_count++) != 0) { + aprint_error_dev(sc->sc_gic.sc_dev, "failed to initialize MBI frame\n"); + } else { + aprint_normal_dev(sc->sc_gic.sc_dev, "MBI frame @ %#" PRIx64 + ", SPIs %u-%u\n", frame->frame_reg, + frame->frame_base, frame->frame_base + frame->frame_count - 1); + } + + ranges += 2; + len -= 8; + } +} + +static void gicv3_fdt_attach_its(struct gicv3_fdt_softc *sc, bus_space_tag_t bst, int phandle) { bus_space_handle_t bsh;
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Wed Nov 25 20:59:20 UTC 2020 Modified Files: src/sys/arch/arm/fdt: gic_fdt.c Log Message: Fix off-by-one when printing the range of SPIs in a GICv2m frame To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/sys/arch/arm/fdt/gic_fdt.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/gic_fdt.c diff -u src/sys/arch/arm/fdt/gic_fdt.c:1.18 src/sys/arch/arm/fdt/gic_fdt.c:1.19 --- src/sys/arch/arm/fdt/gic_fdt.c:1.18 Sun Nov 24 11:10:12 2019 +++ src/sys/arch/arm/fdt/gic_fdt.c Wed Nov 25 20:59:20 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: gic_fdt.c,v 1.18 2019/11/24 11:10:12 skrll Exp $ */ +/* $NetBSD: gic_fdt.c,v 1.19 2020/11/25 20:59:20 jmcneill Exp $ */ /*- * Copyright (c) 2015-2017 Jared McNeill @@ -29,7 +29,7 @@ #include "pci.h" #include -__KERNEL_RCSID(0, "$NetBSD: gic_fdt.c,v 1.18 2019/11/24 11:10:12 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: gic_fdt.c,v 1.19 2020/11/25 20:59:20 jmcneill Exp $"); #include #include @@ -227,8 +227,8 @@ gic_fdt_attach_v2m(struct gic_fdt_softc aprint_error_dev(sc->sc_gicdev, "failed to initialize GICv2m\n"); } else { aprint_normal_dev(sc->sc_gicdev, "GICv2m @ %#" PRIx64 - ", SPIs %u-%u\n", frame->frame_reg, - frame->frame_base, frame->frame_base + frame->frame_count); + ", SPIs %u-%u\n", frame->frame_reg, frame->frame_base, + frame->frame_base + frame->frame_count - 1); } } #endif
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: skrll Date: Wed Nov 25 19:50:06 UTC 2020 Modified Files: src/sys/arch/arm/fdt: cpu_fdt.c Log Message: Fix comment. Spotted by jmcneill@ To generate a diff of this commit: cvs rdiff -u -r1.36 -r1.37 src/sys/arch/arm/fdt/cpu_fdt.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/cpu_fdt.c diff -u src/sys/arch/arm/fdt/cpu_fdt.c:1.36 src/sys/arch/arm/fdt/cpu_fdt.c:1.37 --- src/sys/arch/arm/fdt/cpu_fdt.c:1.36 Wed Jun 10 19:29:48 2020 +++ src/sys/arch/arm/fdt/cpu_fdt.c Wed Nov 25 19:50:06 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu_fdt.c,v 1.36 2020/06/10 19:29:48 jmcneill Exp $ */ +/* $NetBSD: cpu_fdt.c,v 1.37 2020/11/25 19:50:06 skrll Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -30,7 +30,7 @@ #include "psci_fdt.h" #include -__KERNEL_RCSID(0, "$NetBSD: cpu_fdt.c,v 1.36 2020/06/10 19:29:48 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu_fdt.c,v 1.37 2020/11/25 19:50:06 skrll Exp $"); #include #include @@ -167,7 +167,7 @@ arm_fdt_cpu_bootstrap(void) /* MPIDR affinity levels of boot processor. */ bp_mpidr = cpu_mpidr_aff_read(); - /* Boot APs */ + /* Add APs to cpu_mpidr array */ cpuindex = 1; for (child = OF_child(cpus); child; child = OF_peer(child)) { if (!arm_fdt_cpu_okay(child))
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: rin Date: Wed Oct 21 11:06:14 UTC 2020 Modified Files: src/sys/arch/arm/fdt: arm_simplefb.c Log Message: Fix build for some arm32 kernels; arm_simplefb_reconfig() is used only when NPCI > 0 && defined(PCI_NETBSD_CONFIGURE). To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/fdt/arm_simplefb.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/arm_simplefb.c diff -u src/sys/arch/arm/fdt/arm_simplefb.c:1.3 src/sys/arch/arm/fdt/arm_simplefb.c:1.4 --- src/sys/arch/arm/fdt/arm_simplefb.c:1.3 Tue Oct 20 23:03:30 2020 +++ src/sys/arch/arm/fdt/arm_simplefb.c Wed Oct 21 11:06:13 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: arm_simplefb.c,v 1.3 2020/10/20 23:03:30 jmcneill Exp $ */ +/* $NetBSD: arm_simplefb.c,v 1.4 2020/10/21 11:06:13 rin Exp $ */ /*- * Copyright (c) 2019 The NetBSD Foundation, Inc. @@ -33,7 +33,7 @@ #include "opt_pci.h" #include -__KERNEL_RCSID(0, "$NetBSD: arm_simplefb.c,v 1.3 2020/10/20 23:03:30 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: arm_simplefb.c,v 1.4 2020/10/21 11:06:13 rin Exp $"); #include #include @@ -161,6 +161,7 @@ arm_simplefb_pollc(void *v, int on) { } +#if NPCI > 0 && defined(PCI_NETBSD_CONFIGURE) static void arm_simplefb_reconfig(void *arg, uint64_t new_addr) { @@ -177,6 +178,7 @@ arm_simplefb_reconfig(void *arg, uint64_ arm_simplefb_addr = (bus_addr_t)new_addr; } +#endif uint64_t arm_simplefb_physaddr(void)
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Sat Oct 10 15:34:05 UTC 2020 Modified Files: src/sys/arch/arm/fdt: acpi_fdt.c arm_fdt.c Log Message: Support using EFI runtime services for RTC when booting in devicetree mode. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/sys/arch/arm/fdt/acpi_fdt.c cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/fdt/arm_fdt.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/acpi_fdt.c diff -u src/sys/arch/arm/fdt/acpi_fdt.c:1.15 src/sys/arch/arm/fdt/acpi_fdt.c:1.16 --- src/sys/arch/arm/fdt/acpi_fdt.c:1.15 Tue Sep 15 10:33:58 2020 +++ src/sys/arch/arm/fdt/acpi_fdt.c Sat Oct 10 15:34:05 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_fdt.c,v 1.15 2020/09/15 10:33:58 jmcneill Exp $ */ +/* $NetBSD: acpi_fdt.c,v 1.16 2020/10/10 15:34:05 jmcneill Exp $ */ /*- * Copyright (c) 2015-2017 Jared McNeill @@ -30,7 +30,7 @@ #include "opt_efi.h" #include -__KERNEL_RCSID(0, "$NetBSD: acpi_fdt.c,v 1.15 2020/09/15 10:33:58 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_fdt.c,v 1.16 2020/10/10 15:34:05 jmcneill Exp $"); #include #include @@ -54,7 +54,6 @@ __KERNEL_RCSID(0, "$NetBSD: acpi_fdt.c,v #ifdef EFI_RUNTIME #include -#include #endif static int acpi_fdt_match(device_t, cfdata_t, void *); @@ -62,22 +61,12 @@ static void acpi_fdt_attach(device_t, de static void acpi_fdt_poweroff(device_t); -#ifdef EFI_RUNTIME -static void acpi_fdt_efi_init(device_t); -static int acpi_fdt_efi_rtc_gettime(todr_chip_handle_t, struct clock_ymdhms *); -static int acpi_fdt_efi_rtc_settime(todr_chip_handle_t, struct clock_ymdhms *); -#endif - static void acpi_fdt_sysctl_init(void); extern struct arm32_bus_dma_tag acpi_coherent_dma_tag; static uint64_t smbios_table = 0; -#ifdef EFI_RUNTIME -static struct todr_chip_handle efi_todr; -#endif - static const char * const compatible[] = { "netbsd,acpi", NULL @@ -106,10 +95,6 @@ acpi_fdt_attach(device_t parent, device_ aprint_naive("\n"); aprint_normal("\n"); -#ifdef EFI_RUNTIME - acpi_fdt_efi_init(self); -#endif - fdtbus_register_power_controller(self, faa->faa_phandle, _fdt_power_funcs); @@ -171,71 +156,3 @@ acpi_fdt_sysctl_init(void) CTL_CREATE, CTL_EOL); } } - -#ifdef EFI_RUNTIME -static void -acpi_fdt_efi_init(device_t dev) -{ - uint64_t efi_system_table; - struct efi_tm tm; - int error; - - const int chosen = OF_finddevice("/chosen"); - if (chosen < 0) - return; - - if (of_getprop_uint64(chosen, "netbsd,uefi-system-table", _system_table) != 0) - return; - - error = arm_efirt_init(efi_system_table); - if (error) - return; - - aprint_debug_dev(dev, "EFI system table at %#" PRIx64 "\n", efi_system_table); - - if (arm_efirt_gettime() == 0) { - aprint_normal_dev(dev, "using EFI runtime services for RTC\n"); - efi_todr.cookie = NULL; - efi_todr.todr_gettime_ymdhms = acpi_fdt_efi_rtc_gettime; - efi_todr.todr_settime_ymdhms = acpi_fdt_efi_rtc_settime; - todr_attach(_todr); - } -} - -static int -acpi_fdt_efi_rtc_gettime(todr_chip_handle_t tch, struct clock_ymdhms *dt) -{ - struct efi_tm tm; - int error; - - error = arm_efirt_gettime(); - if (error) - return error; - - dt->dt_year = tm.tm_year; - dt->dt_mon = tm.tm_mon; - dt->dt_day = tm.tm_mday; - dt->dt_wday = 0; - dt->dt_hour = tm.tm_hour; - dt->dt_min = tm.tm_min; - dt->dt_sec = tm.tm_sec; - - return 0; -} - -static int -acpi_fdt_efi_rtc_settime(todr_chip_handle_t tch, struct clock_ymdhms *dt) -{ - struct efi_tm tm; - - memset(, 0, sizeof(tm)); - tm.tm_year = dt->dt_year; - tm.tm_mon = dt->dt_mon; - tm.tm_mday = dt->dt_day; - tm.tm_hour = dt->dt_hour; - tm.tm_min = dt->dt_min; - tm.tm_sec = dt->dt_sec; - - return arm_efirt_settime(); -} -#endif Index: src/sys/arch/arm/fdt/arm_fdt.c diff -u src/sys/arch/arm/fdt/arm_fdt.c:1.11 src/sys/arch/arm/fdt/arm_fdt.c:1.12 --- src/sys/arch/arm/fdt/arm_fdt.c:1.11 Sun Jun 21 17:25:03 2020 +++ src/sys/arch/arm/fdt/arm_fdt.c Sat Oct 10 15:34:05 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: arm_fdt.c,v 1.11 2020/06/21 17:25:03 jmcneill Exp $ */ +/* $NetBSD: arm_fdt.c,v 1.12 2020/10/10 15:34:05 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared D. McNeill @@ -27,10 +27,11 @@ */ #include "opt_arm_timer.h" +#include "opt_efi.h" #include "opt_modular.h" #include -__KERNEL_RCSID(0, "$NetBSD: arm_fdt.c,v 1.11 2020/06/21 17:25:03 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: arm_fdt.c,v 1.12 2020/10/10 15:34:05 jmcneill Exp $"); #include #include @@ -47,9 +48,22 @@ __KERNEL_RCSID(0, "$NetBSD: arm_fdt.c,v #include +#ifdef EFI_RUNTIME +#include +#include +#endif + static int arm_fdt_match(device_t, cfdata_t, void *); static void arm_fdt_attach(device_t, device_t, void *); +#ifdef EFI_RUNTIME +static void arm_fdt_efi_init(device_t); +static int arm_fdt_efi_rtc_gettime(todr_chip_handle_t, struct clock_ymdhms *); +static int
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Sat Oct 10 09:58:17 UTC 2020 Modified Files: src/sys/arch/arm/fdt: pcihost_fdt.c Log Message: Read the linux,pci-probe-only property from the /chosen node, not the PCI host controller node To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/sys/arch/arm/fdt/pcihost_fdt.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/pcihost_fdt.c diff -u src/sys/arch/arm/fdt/pcihost_fdt.c:1.17 src/sys/arch/arm/fdt/pcihost_fdt.c:1.18 --- src/sys/arch/arm/fdt/pcihost_fdt.c:1.17 Tue Jul 7 03:38:45 2020 +++ src/sys/arch/arm/fdt/pcihost_fdt.c Sat Oct 10 09:58:16 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: pcihost_fdt.c,v 1.17 2020/07/07 03:38:45 thorpej Exp $ */ +/* $NetBSD: pcihost_fdt.c,v 1.18 2020/10/10 09:58:16 jmcneill Exp $ */ /*- * Copyright (c) 2018 Jared D. McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pcihost_fdt.c,v 1.17 2020/07/07 03:38:45 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pcihost_fdt.c,v 1.18 2020/10/10 09:58:16 jmcneill Exp $"); #include @@ -245,7 +245,8 @@ pcihost_config(struct pcihost_softc *sc) /* * If this flag is set, skip configuration of the PCI bus and use existing config. */ - if (of_getprop_uint32(sc->sc_phandle, "linux,pci-probe-only", _only)) + const int chosen = OF_finddevice("/chosen"); + if (chosen <= 0 || of_getprop_uint32(chosen, "linux,pci-probe-only", _only)) probe_only = 0; if (probe_only) return 0;
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Tue Sep 15 10:33:58 UTC 2020 Modified Files: src/sys/arch/arm/fdt: acpi_fdt.c Log Message: If acpi_probe() falis, just panic now instead of failing mysteriously later. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/sys/arch/arm/fdt/acpi_fdt.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/acpi_fdt.c diff -u src/sys/arch/arm/fdt/acpi_fdt.c:1.14 src/sys/arch/arm/fdt/acpi_fdt.c:1.15 --- src/sys/arch/arm/fdt/acpi_fdt.c:1.14 Fri Jan 17 17:06:33 2020 +++ src/sys/arch/arm/fdt/acpi_fdt.c Tue Sep 15 10:33:58 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_fdt.c,v 1.14 2020/01/17 17:06:33 jmcneill Exp $ */ +/* $NetBSD: acpi_fdt.c,v 1.15 2020/09/15 10:33:58 jmcneill Exp $ */ /*- * Copyright (c) 2015-2017 Jared McNeill @@ -30,7 +30,7 @@ #include "opt_efi.h" #include -__KERNEL_RCSID(0, "$NetBSD: acpi_fdt.c,v 1.14 2020/01/17 17:06:33 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_fdt.c,v 1.15 2020/09/15 10:33:58 jmcneill Exp $"); #include #include @@ -114,7 +114,7 @@ acpi_fdt_attach(device_t parent, device_ _fdt_power_funcs); if (!acpi_probe()) - aprint_error_dev(self, "failed to probe ACPI\n"); + panic("ACPI subsystem failed to initialize"); memset(, 0, sizeof(aa)); #if NPCI > 0
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Wed Jun 10 19:29:48 UTC 2020 Modified Files: src/sys/arch/arm/fdt: cpu_fdt.c Log Message: If enable-method is missing, try psci To generate a diff of this commit: cvs rdiff -u -r1.35 -r1.36 src/sys/arch/arm/fdt/cpu_fdt.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/cpu_fdt.c diff -u src/sys/arch/arm/fdt/cpu_fdt.c:1.35 src/sys/arch/arm/fdt/cpu_fdt.c:1.36 --- src/sys/arch/arm/fdt/cpu_fdt.c:1.35 Fri Feb 21 13:15:54 2020 +++ src/sys/arch/arm/fdt/cpu_fdt.c Wed Jun 10 19:29:48 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu_fdt.c,v 1.35 2020/02/21 13:15:54 skrll Exp $ */ +/* $NetBSD: cpu_fdt.c,v 1.36 2020/06/10 19:29:48 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -30,7 +30,7 @@ #include "psci_fdt.h" #include -__KERNEL_RCSID(0, "$NetBSD: cpu_fdt.c,v 1.35 2020/02/21 13:15:54 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu_fdt.c,v 1.36 2020/06/10 19:29:48 jmcneill Exp $"); #include #include @@ -191,16 +191,11 @@ arm_fdt_cpu_bootstrap(void) #ifdef MULTIPROCESSOR static struct arm_cpu_method * -arm_fdt_cpu_enable_method(int phandle) +arm_fdt_cpu_enable_method_byname(const char *method) { - const char *method; - - method = fdtbus_get_string(phandle, "enable-method"); - if (method == NULL) - return NULL; - __link_set_decl(arm_cpu_methods, struct arm_cpu_method); struct arm_cpu_method * const *acmp; + __link_set_foreach(acmp, arm_cpu_methods) { if (strcmp(method, (*acmp)->acm_compat) == 0) return *acmp; @@ -209,6 +204,18 @@ arm_fdt_cpu_enable_method(int phandle) return NULL; } +static struct arm_cpu_method * +arm_fdt_cpu_enable_method(int phandle) +{ + const char *method; + + method = fdtbus_get_string(phandle, "enable-method"); + if (method == NULL) + return NULL; + + return arm_fdt_cpu_enable_method_byname(method); +} + static int arm_fdt_cpu_enable(int phandle, struct arm_cpu_method *acm) { @@ -251,6 +258,8 @@ arm_fdt_cpu_mpstart(void) if (acm == NULL) acm = arm_fdt_cpu_enable_method(cpus); if (acm == NULL) + acm = arm_fdt_cpu_enable_method_byname("psci"); + if (acm == NULL) continue; error = arm_fdt_cpu_enable(child, acm);
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: skrll Date: Fri Feb 21 13:15:54 UTC 2020 Modified Files: src/sys/arch/arm/fdt: cpu_fdt.c Log Message: Improve a comment To generate a diff of this commit: cvs rdiff -u -r1.34 -r1.35 src/sys/arch/arm/fdt/cpu_fdt.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/cpu_fdt.c diff -u src/sys/arch/arm/fdt/cpu_fdt.c:1.34 src/sys/arch/arm/fdt/cpu_fdt.c:1.35 --- src/sys/arch/arm/fdt/cpu_fdt.c:1.34 Sat Feb 15 08:16:11 2020 +++ src/sys/arch/arm/fdt/cpu_fdt.c Fri Feb 21 13:15:54 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu_fdt.c,v 1.34 2020/02/15 08:16:11 skrll Exp $ */ +/* $NetBSD: cpu_fdt.c,v 1.35 2020/02/21 13:15:54 skrll Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -30,7 +30,7 @@ #include "psci_fdt.h" #include -__KERNEL_RCSID(0, "$NetBSD: cpu_fdt.c,v 1.34 2020/02/15 08:16:11 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu_fdt.c,v 1.35 2020/02/21 13:15:54 skrll Exp $"); #include #include @@ -327,7 +327,7 @@ spintable_cpu_on(u_int cpuindex, paddr_t { /* * we need devmap for cpu-release-addr in advance. - * __HAVE_MM_MD_DIRECT_MAPPED_PHYS nor pmap didn't work at this point. + * __HAVE_MM_MD_DIRECT_MAPPED_PHYS nor pmap work at this point. */ if (pmap_devmap_find_pa(cpu_release_addr, sizeof(paddr_t)) == NULL) { aprint_error("%s: devmap for cpu-release-addr"
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Mon Jan 27 23:26:15 UTC 2020 Modified Files: src/sys/arch/arm/fdt: cpu_fdt.c Log Message: Match any node with device_type = "cpu" To generate a diff of this commit: cvs rdiff -u -r1.32 -r1.33 src/sys/arch/arm/fdt/cpu_fdt.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/cpu_fdt.c diff -u src/sys/arch/arm/fdt/cpu_fdt.c:1.32 src/sys/arch/arm/fdt/cpu_fdt.c:1.33 --- src/sys/arch/arm/fdt/cpu_fdt.c:1.32 Sat Jan 25 18:21:37 2020 +++ src/sys/arch/arm/fdt/cpu_fdt.c Mon Jan 27 23:26:15 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu_fdt.c,v 1.32 2020/01/25 18:21:37 skrll Exp $ */ +/* $NetBSD: cpu_fdt.c,v 1.33 2020/01/27 23:26:15 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -30,7 +30,7 @@ #include "psci_fdt.h" #include -__KERNEL_RCSID(0, "$NetBSD: cpu_fdt.c,v 1.32 2020/01/25 18:21:37 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu_fdt.c,v 1.33 2020/01/27 23:26:15 jmcneill Exp $"); #include #include @@ -56,38 +56,11 @@ __KERNEL_RCSID(0, "$NetBSD: cpu_fdt.c,v static int cpu_fdt_match(device_t, cfdata_t, void *); static void cpu_fdt_attach(device_t, device_t, void *); -enum cpu_fdt_type { - ARM_CPU_UP = 1, - ARM_CPU_ARMV7, - ARM_CPU_ARMV8, -}; - struct cpu_fdt_softc { device_t sc_dev; int sc_phandle; }; -static const struct of_compat_data compat_data[] = { - { "arm,arm1176jzf-s", ARM_CPU_UP }, - - { "arm,arm-v7", ARM_CPU_ARMV7 }, - { "arm,cortex-a5", ARM_CPU_ARMV7 }, - { "arm,cortex-a7", ARM_CPU_ARMV7 }, - { "arm,cortex-a8", ARM_CPU_ARMV7 }, - { "arm,cortex-a9", ARM_CPU_ARMV7 }, - { "arm,cortex-a12", ARM_CPU_ARMV7 }, - { "arm,cortex-a15", ARM_CPU_ARMV7 }, - { "arm,cortex-a17", ARM_CPU_ARMV7 }, - - { "arm,armv8", ARM_CPU_ARMV8 }, - { "arm,cortex-a53", ARM_CPU_ARMV8 }, - { "arm,cortex-a57", ARM_CPU_ARMV8 }, - { "arm,cortex-a72", ARM_CPU_ARMV8 }, - { "arm,cortex-a73", ARM_CPU_ARMV8 }, - - { NULL } -}; - CFATTACH_DECL_NEW(cpu_fdt, sizeof(struct cpu_fdt_softc), cpu_fdt_match, cpu_fdt_attach, NULL, NULL); @@ -96,25 +69,11 @@ cpu_fdt_match(device_t parent, cfdata_t { struct fdt_attach_args * const faa = aux; const int phandle = faa->faa_phandle; - enum cpu_fdt_type type; - int is_compatible; - bus_addr_t mpidr; + const char *device_type; - is_compatible = of_match_compat_data(phandle, compat_data); - if (!is_compatible) - return 0; - - type = of_search_compatible(phandle, compat_data)->data; - switch (type) { - case ARM_CPU_ARMV7: - case ARM_CPU_ARMV8: - if (fdtbus_get_reg(phandle, 0, , NULL) != 0) - return 0; - default: - break; - } + device_type = fdtbus_get_string(phandle, "device_type"); - return is_compatible; + return device_type != NULL && strcmp(device_type, "cpu") == 0; } static void @@ -123,9 +82,7 @@ cpu_fdt_attach(device_t parent, device_t struct cpu_fdt_softc * const sc = device_private(self); struct fdt_attach_args * const faa = aux; const int phandle = faa->faa_phandle; - enum cpu_fdt_type type; - bus_addr_t mpidr; - cpuid_t cpuid; + bus_addr_t cpuid; const uint32_t *cap_ptr; int len; @@ -141,21 +98,8 @@ cpu_fdt_attach(device_t parent, device_t capacity_dmips_mhz); } - type = of_search_compatible(phandle, compat_data)->data; - - switch (type) { - case ARM_CPU_ARMV7: - case ARM_CPU_ARMV8: - if (fdtbus_get_reg(phandle, 0, , NULL) != 0) { - aprint_error(": missing 'reg' property\n"); - return; - } - cpuid = mpidr; - break; - default: + if (fdtbus_get_reg(phandle, 0, , NULL) != 0) cpuid = 0; - break; - } /* Attach the CPU */ cpu_attach(self, cpuid);
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: skrll Date: Sat Jan 25 18:21:37 UTC 2020 Modified Files: src/sys/arch/arm/fdt: cpu_fdt.c Log Message: Wrap a long line To generate a diff of this commit: cvs rdiff -u -r1.31 -r1.32 src/sys/arch/arm/fdt/cpu_fdt.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/cpu_fdt.c diff -u src/sys/arch/arm/fdt/cpu_fdt.c:1.31 src/sys/arch/arm/fdt/cpu_fdt.c:1.32 --- src/sys/arch/arm/fdt/cpu_fdt.c:1.31 Sun Jan 12 09:29:18 2020 +++ src/sys/arch/arm/fdt/cpu_fdt.c Sat Jan 25 18:21:37 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu_fdt.c,v 1.31 2020/01/12 09:29:18 mrg Exp $ */ +/* $NetBSD: cpu_fdt.c,v 1.32 2020/01/25 18:21:37 skrll Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -30,7 +30,7 @@ #include "psci_fdt.h" #include -__KERNEL_RCSID(0, "$NetBSD: cpu_fdt.c,v 1.31 2020/01/12 09:29:18 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu_fdt.c,v 1.32 2020/01/25 18:21:37 skrll Exp $"); #include #include @@ -310,7 +310,8 @@ arm_fdt_cpu_mpstart(void) error = arm_fdt_cpu_enable(child, acm); if (error != 0) { - aprint_error("%s: failed to enable CPU %#" PRIx64 "\n", __func__, mpidr); + aprint_error("%s: failed to enable CPU %#" PRIx64 "\n", + __func__, mpidr); continue; }
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: skrll Date: Tue Jan 7 10:01:09 UTC 2020 Modified Files: src/sys/arch/arm/fdt: pcihost_fdt.c Log Message: oops more KNF To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/sys/arch/arm/fdt/pcihost_fdt.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/pcihost_fdt.c diff -u src/sys/arch/arm/fdt/pcihost_fdt.c:1.13 src/sys/arch/arm/fdt/pcihost_fdt.c:1.14 --- src/sys/arch/arm/fdt/pcihost_fdt.c:1.13 Tue Jan 7 09:57:11 2020 +++ src/sys/arch/arm/fdt/pcihost_fdt.c Tue Jan 7 10:01:09 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: pcihost_fdt.c,v 1.13 2020/01/07 09:57:11 skrll Exp $ */ +/* $NetBSD: pcihost_fdt.c,v 1.14 2020/01/07 10:01:09 skrll Exp $ */ /*- * Copyright (c) 2018 Jared D. McNeill @@ -27,13 +27,13 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pcihost_fdt.c,v 1.13 2020/01/07 09:57:11 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pcihost_fdt.c,v 1.14 2020/01/07 10:01:09 skrll Exp $"); #include -#include #include #include +#include #include #include #include
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: skrll Date: Tue Jan 7 08:22:23 UTC 2020 Modified Files: src/sys/arch/arm/fdt: files.fdt Log Message: arm_platform requires gtmr and psci. Should fix build failures. To generate a diff of this commit: cvs rdiff -u -r1.30 -r1.31 src/sys/arch/arm/fdt/files.fdt 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.30 src/sys/arch/arm/fdt/files.fdt:1.31 --- src/sys/arch/arm/fdt/files.fdt:1.30 Sun Jan 5 17:26:31 2020 +++ src/sys/arch/arm/fdt/files.fdt Tue Jan 7 08:22:23 2020 @@ -1,11 +1,11 @@ -# $NetBSD: files.fdt,v 1.30 2020/01/05 17:26:31 jmcneill Exp $ +# $NetBSD: files.fdt,v 1.31 2020/01/07 08:22:23 skrll Exp $ include "dev/pckbport/files.pckbport" device armfdt { }: bus_space_generic, fdt attach armfdt at root with arm_fdt file arch/arm/fdt/arm_fdt.c arm_fdt -file arch/arm/fdt/arm_platform.c arm_fdt +file arch/arm/fdt/arm_platform.c arm_fdt & gtmr_fdt & psci_fdt attach cpu at fdt with cpu_fdt file arch/arm/fdt/cpu_fdt.c cpu_fdt
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Sun Jan 5 17:20:01 UTC 2020 Modified Files: src/sys/arch/arm/fdt: arm64_platform.c Log Message: Use arm_fdt_cpu_bootstrap To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/fdt/arm64_platform.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/arm64_platform.c diff -u src/sys/arch/arm/fdt/arm64_platform.c:1.1 src/sys/arch/arm/fdt/arm64_platform.c:1.2 --- src/sys/arch/arm/fdt/arm64_platform.c:1.1 Sun Jan 5 17:16:07 2020 +++ src/sys/arch/arm/fdt/arm64_platform.c Sun Jan 5 17:20:01 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: arm64_platform.c,v 1.1 2020/01/05 17:16:07 jmcneill Exp $ */ +/* $NetBSD: arm64_platform.c,v 1.2 2020/01/05 17:20:01 jmcneill Exp $ */ /*- * Copyright (c) 2020 Jared McNeill @@ -31,7 +31,7 @@ #include "opt_console.h" #include -__KERNEL_RCSID(0, "$NetBSD: arm64_platform.c,v 1.1 2020/01/05 17:16:07 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: arm64_platform.c,v 1.2 2020/01/05 17:20:01 jmcneill Exp $"); #include #include @@ -73,11 +73,6 @@ arm64_platform_device_register(device_t { } -static void -arm64_platform_bootstrap(void) -{ -} - static const struct pmap_devmap * arm64_platform_devmap(void) { @@ -110,7 +105,7 @@ arm64_platform_uart_freq(void) static const struct arm_platform arm64_platform = { .ap_devmap = arm64_platform_devmap, - .ap_bootstrap = arm64_platform_bootstrap, + .ap_bootstrap = arm_fdt_cpu_bootstrap, .ap_init_attach_args = arm64_platform_init_attach_args, .ap_device_register = arm64_platform_device_register, .ap_reset = psci_fdt_reset,
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Sat Apr 13 19:15:25 UTC 2019 Modified Files: src/sys/arch/arm/fdt: cpu_fdt.c Log Message: If an enable-method property is present on the cpu node and not supported by the kernel, try to use the enable-method from the cpus node instead. To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/sys/arch/arm/fdt/cpu_fdt.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/cpu_fdt.c diff -u src/sys/arch/arm/fdt/cpu_fdt.c:1.24 src/sys/arch/arm/fdt/cpu_fdt.c:1.25 --- src/sys/arch/arm/fdt/cpu_fdt.c:1.24 Sat Apr 13 17:34:38 2019 +++ src/sys/arch/arm/fdt/cpu_fdt.c Sat Apr 13 19:15:25 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu_fdt.c,v 1.24 2019/04/13 17:34:38 jmcneill Exp $ */ +/* $NetBSD: cpu_fdt.c,v 1.25 2019/04/13 19:15:25 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -30,7 +30,7 @@ #include "psci_fdt.h" #include -__KERNEL_RCSID(0, "$NetBSD: cpu_fdt.c,v 1.24 2019/04/13 17:34:38 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu_fdt.c,v 1.25 2019/04/13 19:15:25 jmcneill Exp $"); #include #include @@ -234,16 +234,29 @@ arm_fdt_cpu_bootstrap(void) } #ifdef MULTIPROCESSOR -static int -arm_fdt_cpu_enable(int phandle, const char *method) +static struct arm_cpu_method * +arm_fdt_cpu_enable_method(int phandle) { + const char *method; + + method = fdtbus_get_string(phandle, "enable-method"); + if (method == NULL) + return NULL; + __link_set_decl(arm_cpu_methods, struct arm_cpu_method); - struct arm_cpu_method * const *acm; - __link_set_foreach(acm, arm_cpu_methods) { - if (strcmp(method, (*acm)->acm_compat) == 0) - return (*acm)->acm_enable(phandle); + struct arm_cpu_method * const *acmp; + __link_set_foreach(acmp, arm_cpu_methods) { + if (strcmp(method, (*acmp)->acm_compat) == 0) + return *acmp; } - return ENOSYS; + + return NULL; +} + +static int +arm_fdt_cpu_enable(int phandle, struct arm_cpu_method *acm) +{ + return acm->acm_enable(phandle); } #endif @@ -255,7 +268,7 @@ arm_fdt_cpu_mpstart(void) uint64_t mpidr, bp_mpidr; u_int cpuindex, i; int child, error; - const char *method; + struct arm_cpu_method *acm; const int cpus = OF_finddevice("/cpus"); if (cpus == -1) { @@ -278,15 +291,15 @@ arm_fdt_cpu_mpstart(void) if (mpidr == bp_mpidr) continue; /* BP already started */ - method = fdtbus_get_string(child, "enable-method"); - if (method == NULL) - method = fdtbus_get_string(cpus, "enable-method"); - if (method == NULL) + acm = arm_fdt_cpu_enable_method(child); + if (acm == NULL) + acm = arm_fdt_cpu_enable_method(cpus); + if (acm == NULL) continue; - error = arm_fdt_cpu_enable(child, method); + error = arm_fdt_cpu_enable(child, acm); if (error != 0) { - aprint_error("%s: %s: unsupported enable-method\n", __func__, method); + aprint_error("%s: failed to enable CPU %#" PRIx64 "\n", __func__, mpidr); continue; }
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Sat Apr 13 17:34:38 UTC 2019 Modified Files: src/sys/arch/arm/fdt: cpu_fdt.c Log Message: Fix build w/o PSCI To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/sys/arch/arm/fdt/cpu_fdt.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/cpu_fdt.c diff -u src/sys/arch/arm/fdt/cpu_fdt.c:1.23 src/sys/arch/arm/fdt/cpu_fdt.c:1.24 --- src/sys/arch/arm/fdt/cpu_fdt.c:1.23 Sat Apr 13 17:21:49 2019 +++ src/sys/arch/arm/fdt/cpu_fdt.c Sat Apr 13 17:34:38 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu_fdt.c,v 1.23 2019/04/13 17:21:49 jmcneill Exp $ */ +/* $NetBSD: cpu_fdt.c,v 1.24 2019/04/13 17:34:38 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -30,7 +30,7 @@ #include "psci_fdt.h" #include -__KERNEL_RCSID(0, "$NetBSD: cpu_fdt.c,v 1.23 2019/04/13 17:21:49 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu_fdt.c,v 1.24 2019/04/13 17:34:38 jmcneill Exp $"); #include #include @@ -153,7 +153,7 @@ cpu_fdt_attach(device_t parent, device_t config_found(self, faa, NULL); } -#ifdef MULTIPROCESSOR +#if defined(MULTIPROCESSOR) && (NPSCI_FDT > 0 || defined(__aarch64__)) static register_t cpu_fdt_mpstart_pa(void) { @@ -165,7 +165,9 @@ cpu_fdt_mpstart_pa(void) return pa; } +#endif +#ifdef MULTIPROCESSOR static bool arm_fdt_cpu_okay(const int child) {
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Sat Apr 13 17:21:49 UTC 2019 Modified Files: src/sys/arch/arm/fdt: cpu_fdt.c Log Message: The spin-table CPU enable method is only valid for 64-bit kernels. To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/sys/arch/arm/fdt/cpu_fdt.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/cpu_fdt.c diff -u src/sys/arch/arm/fdt/cpu_fdt.c:1.22 src/sys/arch/arm/fdt/cpu_fdt.c:1.23 --- src/sys/arch/arm/fdt/cpu_fdt.c:1.22 Thu Jan 31 13:06:10 2019 +++ src/sys/arch/arm/fdt/cpu_fdt.c Sat Apr 13 17:21:49 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu_fdt.c,v 1.22 2019/01/31 13:06:10 skrll Exp $ */ +/* $NetBSD: cpu_fdt.c,v 1.23 2019/04/13 17:21:49 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -30,7 +30,7 @@ #include "psci_fdt.h" #include -__KERNEL_RCSID(0, "$NetBSD: cpu_fdt.c,v 1.22 2019/01/31 13:06:10 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu_fdt.c,v 1.23 2019/04/13 17:21:49 jmcneill Exp $"); #include #include @@ -166,33 +166,6 @@ cpu_fdt_mpstart_pa(void) return pa; } -static int -spintable_cpu_on(u_int cpuindex, paddr_t entry_point_address, paddr_t cpu_release_addr) -{ - /* - * we need devmap for cpu-release-addr in advance. - * __HAVE_MM_MD_DIRECT_MAPPED_PHYS nor pmap didn't work at this point. - */ - if (pmap_devmap_find_pa(cpu_release_addr, sizeof(paddr_t)) == NULL) { - aprint_error("%s: devmap for cpu-release-addr" - " 0x%08"PRIxPADDR" required\n", __func__, cpu_release_addr); - return -1; - } else { - extern struct bus_space arm_generic_bs_tag; - bus_space_handle_t ioh; - - bus_space_map(_generic_bs_tag, cpu_release_addr, - sizeof(paddr_t), 0, ); - bus_space_write_4(_generic_bs_tag, ioh, 0, - entry_point_address); - bus_space_unmap(_generic_bs_tag, ioh, sizeof(paddr_t)); - } - - return 0; -} -#endif /* MULTIPROCESSOR */ - -#ifdef MULTIPROCESSOR static bool arm_fdt_cpu_okay(const int child) { @@ -369,7 +342,32 @@ cpu_enable_psci(int phandle) ARM_CPU_METHOD(psci, "psci", cpu_enable_psci); #endif -#if defined(MULTIPROCESSOR) +#if defined(MULTIPROCESSOR) && defined(__aarch64__) +static int +spintable_cpu_on(u_int cpuindex, paddr_t entry_point_address, paddr_t cpu_release_addr) +{ + /* + * we need devmap for cpu-release-addr in advance. + * __HAVE_MM_MD_DIRECT_MAPPED_PHYS nor pmap didn't work at this point. + */ + if (pmap_devmap_find_pa(cpu_release_addr, sizeof(paddr_t)) == NULL) { + aprint_error("%s: devmap for cpu-release-addr" + " 0x%08"PRIxPADDR" required\n", __func__, cpu_release_addr); + return -1; + } else { + extern struct bus_space arm_generic_bs_tag; + bus_space_handle_t ioh; + + bus_space_map(_generic_bs_tag, cpu_release_addr, + sizeof(paddr_t), 0, ); + bus_space_write_4(_generic_bs_tag, ioh, 0, + entry_point_address); + bus_space_unmap(_generic_bs_tag, ioh, sizeof(paddr_t)); + } + + return 0; +} + static int cpu_enable_spin_table(int phandle) {
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jakllsch Date: Thu Feb 28 00:47:10 UTC 2019 Modified Files: src/sys/arch/arm/fdt: pcihost_fdt.c Added Files: src/sys/arch/arm/fdt: pcihost_fdtvar.h Log Message: Split up the initialization of pcihost_fdt so we can borrow and override its innards in an upcoming driver. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/fdt/pcihost_fdt.c cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/fdt/pcihost_fdtvar.h 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/pcihost_fdt.c diff -u src/sys/arch/arm/fdt/pcihost_fdt.c:1.7 src/sys/arch/arm/fdt/pcihost_fdt.c:1.8 --- src/sys/arch/arm/fdt/pcihost_fdt.c:1.7 Thu Feb 28 00:17:13 2019 +++ src/sys/arch/arm/fdt/pcihost_fdt.c Thu Feb 28 00:47:10 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: pcihost_fdt.c,v 1.7 2019/02/28 00:17:13 jakllsch Exp $ */ +/* $NetBSD: pcihost_fdt.c,v 1.8 2019/02/28 00:47:10 jakllsch Exp $ */ /*- * Copyright (c) 2018 Jared D. McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pcihost_fdt.c,v 1.7 2019/02/28 00:17:13 jakllsch Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pcihost_fdt.c,v 1.8 2019/02/28 00:47:10 jakllsch Exp $"); #include #include @@ -51,6 +51,7 @@ __KERNEL_RCSID(0, "$NetBSD: pcihost_fdt. #include #include +#include #define IH_INDEX_MASK 0x #define IH_MPSAFE 0x8000 @@ -60,63 +61,11 @@ __KERNEL_RCSID(0, "$NetBSD: pcihost_fdt. #define PCIHOST_CACHELINE_SIZE arm_dcache_align -/* Physical address format bit definitions */ -#define PHYS_HI_RELO __BIT(31) -#define PHYS_HI_PREFETCH __BIT(30) -#define PHYS_HI_ALIASED __BIT(29) -#define PHYS_HI_SPACE __BITS(25,24) -#define PHYS_HI_SPACE_CFG 0 -#define PHYS_HI_SPACE_IO 1 -#define PHYS_HI_SPACE_MEM32 2 -#define PHYS_HI_SPACE_MEM64 3 -#define PHYS_HI_BUS __BITS(23,16) -#define PHYS_HI_DEVICE __BITS(15,11) -#define PHYS_HI_FUNCTION __BITS(10,8) -#define PHYS_HI_REGISTER __BITS(7,0) - -static int pcihost_segment = 0; - -enum pcihost_type { - PCIHOST_CAM = 1, - PCIHOST_ECAM, -}; - -struct pcih_bus_space { - struct bus_space bst; - - int (*map)(void *, bus_addr_t, bus_size_t, - int, bus_space_handle_t *); - struct space_range { - bus_addr_t bpci; - bus_addr_t bbus; - bus_size_t size; - } ranges[4]; - size_t nranges; -}; - -struct pcihost_softc { - device_t sc_dev; - bus_dma_tag_t sc_dmat; - bus_space_tag_t sc_bst; - bus_space_handle_t sc_bsh; - int sc_phandle; - - enum pcihost_type sc_type; - - u_int sc_seg; - u_int sc_bus_min; - u_int sc_bus_max; - - struct arm32_pci_chipset sc_pc; - - struct pcih_bus_space sc_io; - struct pcih_bus_space sc_mem; -}; +int pcihost_segment = 0; static int pcihost_match(device_t, cfdata_t, void *); static void pcihost_attach(device_t, device_t, void *); -static void pcihost_init(pci_chipset_tag_t, void *); static int pcihost_config(struct pcihost_softc *); static void pcihost_attach_hook(device_t, device_t, @@ -167,11 +116,9 @@ pcihost_attach(device_t parent, device_t { struct pcihost_softc * const sc = device_private(self); struct fdt_attach_args * const faa = aux; - struct pcibus_attach_args pba; bus_addr_t cs_addr; bus_size_t cs_size; - const u_int *data; - int error, len; + int error; if (fdtbus_get_reg(faa->faa_phandle, 0, _addr, _size) != 0) { aprint_error(": couldn't get registers\n"); @@ -192,9 +139,20 @@ pcihost_attach(device_t parent, device_t aprint_naive("\n"); aprint_normal(": Generic PCI host controller\n"); + pcihost_init(>sc_pc, sc); + pcihost_init2(sc); +} + +void +pcihost_init2(struct pcihost_softc *sc) +{ + struct pcibus_attach_args pba; + const u_int *data; + int len; + if ((data = fdtbus_get_prop(sc->sc_phandle, "bus-range", )) != NULL) { if (len != 8) { - aprint_error_dev(self, "malformed 'bus-range' property\n"); + aprint_error_dev(sc->sc_dev, "malformed 'bus-range' property\n"); return; } sc->sc_bus_min = be32toh(data[0]); @@ -213,8 +171,6 @@ pcihost_attach(device_t parent, device_t if (of_getprop_uint32(sc->sc_phandle, "linux,pci-domain", >sc_seg)) sc->sc_seg = pcihost_segment++; - pcihost_init(>sc_pc, sc); - if (pcihost_config(sc) != 0) return; @@ -239,10 +195,10 @@ pcihost_attach(device_t parent, device_t pba.pba_pc = >sc_pc; pba.pba_bus = sc->sc_bus_min; - config_found_ia(self, "pcibus", , pcibusprint); + config_found_ia(sc->sc_dev, "pcibus", , pcibusprint); } -static void +void pcihost_init(pci_chipset_tag_t pc, void *priv) { pc->pc_conf_v = priv; Added files: Index: src/sys/arch/arm/fdt/pcihost_fdtvar.h diff -u /dev/null src/sys/arch/arm/fdt/pcihost_fdtvar.h:1.1 --- /dev/null Thu Feb 28 00:47:10 2019 +++ src/sys/arch/arm/fdt/pcihost_fdtvar.h Thu Feb 28 00:47:10 2019 @@ -0,0 +1,83 @@ +/* $NetBSD: pcihost_fdtvar.h,v 1.1 2019/02/28 00:47:10 jakllsch Exp $ */ + +/*- + * Copyright (c)
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jakllsch Date: Thu Feb 28 00:17:13 UTC 2019 Modified Files: src/sys/arch/arm/fdt: pcihost_fdt.c Log Message: Implement support for IO space, and better-handle both variants of MMIO space. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/fdt/pcihost_fdt.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/pcihost_fdt.c diff -u src/sys/arch/arm/fdt/pcihost_fdt.c:1.6 src/sys/arch/arm/fdt/pcihost_fdt.c:1.7 --- src/sys/arch/arm/fdt/pcihost_fdt.c:1.6 Mon Nov 19 11:08:16 2018 +++ src/sys/arch/arm/fdt/pcihost_fdt.c Thu Feb 28 00:17:13 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: pcihost_fdt.c,v 1.6 2018/11/19 11:08:16 jmcneill Exp $ */ +/* $NetBSD: pcihost_fdt.c,v 1.7 2019/02/28 00:17:13 jakllsch Exp $ */ /*- * Copyright (c) 2018 Jared D. McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pcihost_fdt.c,v 1.6 2018/11/19 11:08:16 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pcihost_fdt.c,v 1.7 2019/02/28 00:17:13 jakllsch Exp $"); #include #include @@ -81,6 +81,19 @@ enum pcihost_type { PCIHOST_ECAM, }; +struct pcih_bus_space { + struct bus_space bst; + + int (*map)(void *, bus_addr_t, bus_size_t, + int, bus_space_handle_t *); + struct space_range { + bus_addr_t bpci; + bus_addr_t bbus; + bus_size_t size; + } ranges[4]; + size_t nranges; +}; + struct pcihost_softc { device_t sc_dev; bus_dma_tag_t sc_dmat; @@ -95,6 +108,9 @@ struct pcihost_softc { u_int sc_bus_max; struct arm32_pci_chipset sc_pc; + + struct pcih_bus_space sc_io; + struct pcih_bus_space sc_mem; }; static int pcihost_match(device_t, cfdata_t, void *); @@ -126,6 +142,9 @@ static void * pcihost_intr_establish(voi const char *); static void pcihost_intr_disestablish(void *, void *); +static int pcihost_bus_space_map(void *, bus_addr_t, bus_size_t, + int, bus_space_handle_t *); + CFATTACH_DECL_NEW(pcihost_fdt, sizeof(struct pcihost_softc), pcihost_match, pcihost_attach, NULL, NULL); @@ -203,6 +222,7 @@ pcihost_attach(device_t parent, device_t pba.pba_flags = PCI_FLAGS_MRL_OKAY | PCI_FLAGS_MRM_OKAY | PCI_FLAGS_MWI_OKAY | + PCI_FLAGS_IO_OKAY | PCI_FLAGS_MEM_OKAY; #ifdef __HAVE_PCI_MSI_MSIX if (sc->sc_type == PCIHOST_ECAM) { @@ -210,8 +230,8 @@ pcihost_attach(device_t parent, device_t PCI_FLAGS_MSIX_OKAY; } #endif - pba.pba_iot = 0; - pba.pba_memt = sc->sc_bst; + pba.pba_iot = >sc_io.bst; + pba.pba_memt = >sc_mem.bst; pba.pba_dmat = sc->sc_dmat; #ifdef _PCI_HAVE_DMA64 pba.pba_dmat64 = sc->sc_dmat; @@ -253,6 +273,18 @@ pcihost_config(struct pcihost_softc *sc) u_int probe_only; int error, len; + struct pcih_bus_space * const pibs = >sc_io; + pibs->bst = *sc->sc_bst; + pibs->bst.bs_cookie = pibs; + pibs->map = pibs->bst.bs_map; + pibs->bst.bs_map = pcihost_bus_space_map; + + struct pcih_bus_space * const pmbs = >sc_mem; + pmbs->bst = *sc->sc_bst; + pmbs->bst.bs_cookie = pmbs; + pmbs->map = pmbs->bst.bs_map; + pmbs->bst.bs_map = pcihost_bus_space_map; + /* * If this flag is set, skip configuration of the PCI bus and use existing config. */ @@ -276,47 +308,73 @@ pcihost_config(struct pcihost_softc *sc) */ while (len >= 28) { const uint32_t phys_hi = be32dec([0]); + const uint64_t bus_phys = be64dec([1]); const uint64_t cpu_phys = be64dec([3]); const uint64_t size = be64dec([5]); + len -= 28; + ranges += 7; + + const bool is64 = (__SHIFTOUT(phys_hi, PHYS_HI_SPACE) == + PHYS_HI_SPACE_MEM64) ? true : false; switch (__SHIFTOUT(phys_hi, PHYS_HI_SPACE)) { case PHYS_HI_SPACE_IO: + if (pibs->nranges + 1 >= __arraycount(pibs->ranges)) { +aprint_error_dev(sc->sc_dev, "too many IO ranges\n"); +continue; + } + pibs->ranges[pibs->nranges].bpci = bus_phys; + pibs->ranges[pibs->nranges].bbus = cpu_phys; + pibs->ranges[pibs->nranges].size = size; + ++pibs->nranges; if (ioext != NULL) { aprint_error_dev(sc->sc_dev, "ignoring duplicate IO space range\n"); continue; } - ioext = extent_create("pciio", cpu_phys, cpu_phys + size - 1, NULL, 0, EX_NOWAIT); + ioext = extent_create("pciio", bus_phys, bus_phys + size - 1, NULL, 0, EX_NOWAIT); aprint_verbose_dev(sc->sc_dev, - "I/O memory @ 0x%" PRIx64 " size 0x%" PRIx64 "\n", - cpu_phys, size); + "IO: 0x%" PRIx64 "+0x%" PRIx64 "@0x%" PRIx64 "\n", + bus_phys, size, cpu_phys); + /* reserve a PC-like legacy IO ports range, perhaps for access to VGA registers */ + if (bus_phys == 0 && size >= 0x1) +extent_alloc_region(ioext, 0, 0x1000, EX_WAITOK); break; + case PHYS_HI_SPACE_MEM64: + /* FALLTHROUGH */ case PHYS_HI_SPACE_MEM32: - if ((phys_hi & PHYS_HI_PREFETCH) != 0) { + if (pmbs->nranges + 1 >= __arraycount(pmbs->ranges)) { +aprint_error_dev(sc->sc_dev, "too many mem ranges\n"); +continue; + }
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: thorpej Date: Sat Jan 26 14:43:46 UTC 2019 Modified Files: src/sys/arch/arm/fdt: gic_fdt.c gicv3_fdt.c Log Message: Define constants for representing the standard interrupt types ({pos,neg,double}-edge, {high,low}-level) from the FDT "interrupts" bindings. Use these defined constants rather than magic numbers. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/sys/arch/arm/fdt/gic_fdt.c cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/fdt/gicv3_fdt.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/gic_fdt.c diff -u src/sys/arch/arm/fdt/gic_fdt.c:1.15 src/sys/arch/arm/fdt/gic_fdt.c:1.16 --- src/sys/arch/arm/fdt/gic_fdt.c:1.15 Mon Nov 12 12:41:03 2018 +++ src/sys/arch/arm/fdt/gic_fdt.c Sat Jan 26 14:43:46 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: gic_fdt.c,v 1.15 2018/11/12 12:41:03 jmcneill Exp $ */ +/* $NetBSD: gic_fdt.c,v 1.16 2019/01/26 14:43:46 thorpej Exp $ */ /*- * Copyright (c) 2015-2017 Jared McNeill @@ -29,7 +29,7 @@ #include "pci.h" #include -__KERNEL_RCSID(0, "$NetBSD: gic_fdt.c,v 1.15 2018/11/12 12:41:03 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: gic_fdt.c,v 1.16 2019/01/26 14:43:46 thorpej Exp $"); #include #include @@ -249,7 +249,8 @@ gic_fdt_establish(device_t dev, u_int *s const u_int intr = be32toh(specifier[1]); const u_int irq = type == 0 ? IRQ_SPI(intr) : IRQ_PPI(intr); const u_int trig = be32toh(specifier[2]) & 0xf; - const u_int level = (trig & 0x3) ? IST_EDGE : IST_LEVEL; + const u_int level = (trig & FDT_INTR_TYPE_DOUBLE_EDGE) + ? IST_EDGE : IST_LEVEL; const u_int mpsafe = (flags & FDT_INTR_MPSAFE) ? IST_MPSAFE : 0; Index: src/sys/arch/arm/fdt/gicv3_fdt.c diff -u src/sys/arch/arm/fdt/gicv3_fdt.c:1.6 src/sys/arch/arm/fdt/gicv3_fdt.c:1.7 --- src/sys/arch/arm/fdt/gicv3_fdt.c:1.6 Sat Nov 24 22:18:57 2018 +++ src/sys/arch/arm/fdt/gicv3_fdt.c Sat Jan 26 14:43:46 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: gicv3_fdt.c,v 1.6 2018/11/24 22:18:57 jakllsch Exp $ */ +/* $NetBSD: gicv3_fdt.c,v 1.7 2019/01/26 14:43:46 thorpej Exp $ */ /*- * Copyright (c) 2015-2018 Jared McNeill @@ -31,7 +31,7 @@ #define _INTR_PRIVATE #include -__KERNEL_RCSID(0, "$NetBSD: gicv3_fdt.c,v 1.6 2018/11/24 22:18:57 jakllsch Exp $"); +__KERNEL_RCSID(0, "$NetBSD: gicv3_fdt.c,v 1.7 2019/01/26 14:43:46 thorpej Exp $"); #include #include @@ -280,7 +280,8 @@ gicv3_fdt_establish(device_t dev, u_int const u_int intr = be32toh(specifier[1]); const u_int irq = type == 0 ? IRQ_SPI(intr) : IRQ_PPI(intr); const u_int trig = be32toh(specifier[2]) & 0xf; - const u_int level = (trig & 0x3) ? IST_EDGE : IST_LEVEL; + const u_int level = (trig & FDT_INTR_TYPE_DOUBLE_EDGE) + ? IST_EDGE : IST_LEVEL; const u_int mpsafe = (flags & FDT_INTR_MPSAFE) ? IST_MPSAFE : 0;
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Tue Jan 22 15:17:33 UTC 2019 Modified Files: src/sys/arch/arm/fdt: a9tmr_fdt.c Log Message: Listen for PMFE_SPEED_CHANGED events and automatically update a9tmr frequency To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/fdt/a9tmr_fdt.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/a9tmr_fdt.c diff -u src/sys/arch/arm/fdt/a9tmr_fdt.c:1.2 src/sys/arch/arm/fdt/a9tmr_fdt.c:1.3 --- src/sys/arch/arm/fdt/a9tmr_fdt.c:1.2 Sat Jan 19 20:56:03 2019 +++ src/sys/arch/arm/fdt/a9tmr_fdt.c Tue Jan 22 15:17:33 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: a9tmr_fdt.c,v 1.2 2019/01/19 20:56:03 jmcneill Exp $ */ +/* $NetBSD: a9tmr_fdt.c,v 1.3 2019/01/22 15:17:33 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: a9tmr_fdt.c,v 1.2 2019/01/19 20:56:03 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: a9tmr_fdt.c,v 1.3 2019/01/22 15:17:33 jmcneill Exp $"); #include #include @@ -48,8 +48,15 @@ static int a9tmr_fdt_match(device_t, cfd static void a9tmr_fdt_attach(device_t, device_t, void *); static void a9tmr_fdt_cpu_hatch(void *, struct cpu_info *); +static void a9tmr_fdt_speed_changed(device_t); -CFATTACH_DECL_NEW(a9tmr_fdt, 0, a9tmr_fdt_match, a9tmr_fdt_attach, NULL, NULL); +struct a9tmr_fdt_softc { + device_t sc_dev; + struct clk *sc_clk; +}; + +CFATTACH_DECL_NEW(a9tmr_fdt, sizeof(struct a9tmr_fdt_softc), +a9tmr_fdt_match, a9tmr_fdt_attach, NULL, NULL); static int a9tmr_fdt_match(device_t parent, cfdata_t cf, void *aux) @@ -67,21 +74,23 @@ a9tmr_fdt_match(device_t parent, cfdata_ static void a9tmr_fdt_attach(device_t parent, device_t self, void *aux) { + struct a9tmr_fdt_softc * const sc = device_private(self); struct fdt_attach_args * const faa = aux; const int phandle = faa->faa_phandle; bus_space_handle_t bsh; - struct clk *clk = fdtbus_clock_get_index(phandle, 0); - if (clk == NULL) { + sc->sc_dev = self; + sc->sc_clk = fdtbus_clock_get_index(phandle, 0); + if (sc->sc_clk == NULL) { aprint_error(": couldn't get clock\n"); return; } - if (clk_enable(clk) != 0) { + if (clk_enable(sc->sc_clk) != 0) { aprint_error(": couldn't enable clock\n"); return; } - uint32_t rate = clk_get_rate(clk); + uint32_t rate = clk_get_rate(sc->sc_clk); prop_dictionary_t dict = device_properties(self); prop_dictionary_set_uint32(dict, "frequency", rate); @@ -124,6 +133,8 @@ a9tmr_fdt_attach(device_t parent, device arm_fdt_cpu_hatch_register(self, a9tmr_fdt_cpu_hatch); arm_fdt_timer_register(a9tmr_cpu_initclocks); + + pmf_event_register(self, PMFE_SPEED_CHANGED, a9tmr_fdt_speed_changed, true); } static void @@ -131,3 +142,16 @@ a9tmr_fdt_cpu_hatch(void *priv, struct c { a9tmr_init_cpu_clock(ci); } + +static void +a9tmr_fdt_speed_changed(device_t dev) +{ + struct a9tmr_fdt_softc * const sc = device_private(dev); + prop_dictionary_t dict = device_properties(dev); + uint32_t rate; + + rate = clk_get_rate(sc->sc_clk); + prop_dictionary_set_uint32(dict, "frequency", rate); + + a9tmr_update_freq(rate); +}
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Thu Jan 3 14:14:08 UTC 2019 Modified Files: src/sys/arch/arm/fdt: cpu_fdt.c Log Message: No need to swap cpu-release-addr twice To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/sys/arch/arm/fdt/cpu_fdt.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/cpu_fdt.c diff -u src/sys/arch/arm/fdt/cpu_fdt.c:1.19 src/sys/arch/arm/fdt/cpu_fdt.c:1.20 --- src/sys/arch/arm/fdt/cpu_fdt.c:1.19 Thu Jan 3 12:52:40 2019 +++ src/sys/arch/arm/fdt/cpu_fdt.c Thu Jan 3 14:14:08 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu_fdt.c,v 1.19 2019/01/03 12:52:40 jmcneill Exp $ */ +/* $NetBSD: cpu_fdt.c,v 1.20 2019/01/03 14:14:08 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -30,7 +30,7 @@ #include "psci_fdt.h" #include -__KERNEL_RCSID(0, "$NetBSD: cpu_fdt.c,v 1.19 2019/01/03 12:52:40 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu_fdt.c,v 1.20 2019/01/03 14:14:08 jmcneill Exp $"); #include #include @@ -368,17 +368,15 @@ ARM_CPU_METHOD(psci, "psci", cpu_enable_ static int cpu_enable_spin_table(int phandle) { - uint64_t mpidr, data; - paddr_t cpu_release_addr; + uint64_t mpidr, addr; int ret; fdtbus_get_reg64(phandle, 0, , NULL); - if (of_getprop_uint64(phandle, "cpu-release-addr", ) != 0) + if (of_getprop_uint64(phandle, "cpu-release-addr", ) != 0) return ENXIO; - cpu_release_addr = (paddr_t)be64toh(data); - ret = spintable_cpu_on(mpidr, cpu_fdt_mpstart_pa(), cpu_release_addr); + ret = spintable_cpu_on(mpidr, cpu_fdt_mpstart_pa(), (paddr_t)addr); if (ret != 0) return EIO;
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Thu Jan 3 12:54:25 UTC 2019 Modified Files: src/sys/arch/arm/fdt: arm_fdt.c arm_fdtvar.h Log Message: Remove unused variable To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/fdt/arm_fdt.c cvs rdiff -u -r1.13 -r1.14 src/sys/arch/arm/fdt/arm_fdtvar.h 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/arm_fdt.c diff -u src/sys/arch/arm/fdt/arm_fdt.c:1.8 src/sys/arch/arm/fdt/arm_fdt.c:1.9 --- src/sys/arch/arm/fdt/arm_fdt.c:1.8 Sun Aug 5 14:02:35 2018 +++ src/sys/arch/arm/fdt/arm_fdt.c Thu Jan 3 12:54:25 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: arm_fdt.c,v 1.8 2018/08/05 14:02:35 skrll Exp $ */ +/* $NetBSD: arm_fdt.c,v 1.9 2019/01/03 12:54:25 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared D. McNeill @@ -29,7 +29,7 @@ #include "opt_arm_timer.h" #include -__KERNEL_RCSID(0, "$NetBSD: arm_fdt.c,v 1.8 2018/08/05 14:02:35 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: arm_fdt.c,v 1.9 2019/01/03 12:54:25 jmcneill Exp $"); #include #include @@ -49,9 +49,6 @@ static void arm_fdt_attach(device_t, dev 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); - struct arm_fdt_cpu_hatch_cb { TAILQ_ENTRY(arm_fdt_cpu_hatch_cb) next; void (*cb)(void *, struct cpu_info *); Index: src/sys/arch/arm/fdt/arm_fdtvar.h diff -u src/sys/arch/arm/fdt/arm_fdtvar.h:1.13 src/sys/arch/arm/fdt/arm_fdtvar.h:1.14 --- src/sys/arch/arm/fdt/arm_fdtvar.h:1.13 Thu Jan 3 12:52:40 2019 +++ src/sys/arch/arm/fdt/arm_fdtvar.h Thu Jan 3 12:54:25 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: arm_fdtvar.h,v 1.13 2019/01/03 12:52:40 jmcneill Exp $ */ +/* $NetBSD: arm_fdtvar.h,v 1.14 2019/01/03 12:54:25 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared D. McNeill @@ -62,8 +62,6 @@ static const struct arm_platform_info __ }; \ _ARM_PLATFORM_REGISTER(_name) -TAILQ_HEAD(arm_platlist, arm_platform_info); - const struct arm_platform * arm_fdt_platform(void); /*
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: skrll Date: Wed Jan 2 16:13:49 UTC 2019 Modified Files: src/sys/arch/arm/fdt: cpu_fdt.c Log Message: Avoid double negative To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/sys/arch/arm/fdt/cpu_fdt.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/cpu_fdt.c diff -u src/sys/arch/arm/fdt/cpu_fdt.c:1.16 src/sys/arch/arm/fdt/cpu_fdt.c:1.17 --- src/sys/arch/arm/fdt/cpu_fdt.c:1.16 Thu Oct 18 09:01:52 2018 +++ src/sys/arch/arm/fdt/cpu_fdt.c Wed Jan 2 16:13:49 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu_fdt.c,v 1.16 2018/10/18 09:01:52 skrll Exp $ */ +/* $NetBSD: cpu_fdt.c,v 1.17 2019/01/02 16:13:49 skrll Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -30,7 +30,7 @@ #include "psci_fdt.h" #include -__KERNEL_RCSID(0, "$NetBSD: cpu_fdt.c,v 1.16 2018/10/18 09:01:52 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu_fdt.c,v 1.17 2019/01/02 16:13:49 skrll Exp $"); #include #include @@ -286,7 +286,7 @@ arm_fdt_cpu_mpstart(void) int child, ret; const char *method; #if NPSCI_FDT > 0 - bool nopsci = false; + bool psci_p = true; #endif const int cpus = OF_finddevice("/cpus"); @@ -297,7 +297,7 @@ arm_fdt_cpu_mpstart(void) #if NPSCI_FDT > 0 if (psci_fdt_preinit() != 0) - nopsci = true; + psci_p = false; #endif /* MPIDR affinity levels of boot processor. */ @@ -340,7 +340,7 @@ arm_fdt_cpu_mpstart(void) continue; #if NPSCI_FDT > 0 - } else if (!nopsci && (strcmp(method, "psci") == 0)) { + } else if (psci_p && (strcmp(method, "psci") == 0)) { ret = psci_cpu_on(mpidr, cpu_fdt_mpstart_pa(), 0); if (ret != PSCI_SUCCESS) continue;
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jakllsch Date: Sat Nov 24 22:18:58 UTC 2018 Modified Files: src/sys/arch/arm/fdt: gicv3_fdt.c Log Message: attach GICv3 ITS where applicable To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/fdt/gicv3_fdt.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/gicv3_fdt.c diff -u src/sys/arch/arm/fdt/gicv3_fdt.c:1.5 src/sys/arch/arm/fdt/gicv3_fdt.c:1.6 --- src/sys/arch/arm/fdt/gicv3_fdt.c:1.5 Mon Nov 19 13:54:15 2018 +++ src/sys/arch/arm/fdt/gicv3_fdt.c Sat Nov 24 22:18:57 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: gicv3_fdt.c,v 1.5 2018/11/19 13:54:15 jakllsch Exp $ */ +/* $NetBSD: gicv3_fdt.c,v 1.6 2018/11/24 22:18:57 jakllsch Exp $ */ /*- * Copyright (c) 2015-2018 Jared McNeill @@ -26,10 +26,12 @@ * SUCH DAMAGE. */ +#include "pci.h" + #define _INTR_PRIVATE #include -__KERNEL_RCSID(0, "$NetBSD: gicv3_fdt.c,v 1.5 2018/11/19 13:54:15 jakllsch Exp $"); +__KERNEL_RCSID(0, "$NetBSD: gicv3_fdt.c,v 1.6 2018/11/24 22:18:57 jakllsch Exp $"); #include #include @@ -44,6 +46,7 @@ __KERNEL_RCSID(0, "$NetBSD: gicv3_fdt.c, #include #include +#include #include #define GICV3_MAXIRQ 1020 @@ -58,6 +61,9 @@ static int gicv3_fdt_match(device_t, cfd static void gicv3_fdt_attach(device_t, device_t, void *); static int gicv3_fdt_map_registers(struct gicv3_fdt_softc *); +#if NPCI > 0 +static void gicv3_fdt_attach_its(struct gicv3_fdt_softc *, bus_space_tag_t, int); +#endif static int gicv3_fdt_intr(void *); @@ -152,6 +158,16 @@ gicv3_fdt_attach(device_t parent, device return; } +#if NPCI > 0 + for (int child = OF_child(phandle); child; child = OF_peer(child)) { + if (!fdtbus_status_okay(child)) + continue; + const char * const its_compat[] = { "arm,gic-v3-its", NULL }; + if (of_match_compatible(child, its_compat)) + gicv3_fdt_attach_its(sc, faa->faa_bst, child); + } +#endif + arm_fdt_irq_set_handler(gicv3_irq_handler); } @@ -222,6 +238,31 @@ gicv3_fdt_map_registers(struct gicv3_fdt return 0; } +#if NPCI > 0 +static void +gicv3_fdt_attach_its(struct gicv3_fdt_softc *sc, bus_space_tag_t bst, int phandle) +{ + bus_space_handle_t bsh; + bus_addr_t addr; + bus_size_t size; + + if (fdtbus_get_reg(phandle, 0, , ) != 0) { + aprint_error_dev(sc->sc_gic.sc_dev, "couldn't get ITS address\n"); + return; + } + + if (bus_space_map(bst, addr, size, 0, ) != 0) { + aprint_error_dev(sc->sc_gic.sc_dev, "couldn't map ITS\n"); + return; + } + + gicv3_its_init(>sc_gic, bsh, addr, 0); + + aprint_verbose_dev(sc->sc_gic.sc_dev, "ITS @ %#" PRIxBUSADDR "\n", + addr); +} +#endif + static void * gicv3_fdt_establish(device_t dev, u_int *specifier, int ipl, int flags, int (*func)(void *), void *arg)
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jakllsch Date: Mon Nov 19 13:54:15 UTC 2018 Modified Files: src/sys/arch/arm/fdt: gicv3_fdt.c Log Message: avoid NULL deref in gicv3_fdt_disestablish() To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/fdt/gicv3_fdt.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/gicv3_fdt.c diff -u src/sys/arch/arm/fdt/gicv3_fdt.c:1.4 src/sys/arch/arm/fdt/gicv3_fdt.c:1.5 --- src/sys/arch/arm/fdt/gicv3_fdt.c:1.4 Sat Nov 10 01:24:06 2018 +++ src/sys/arch/arm/fdt/gicv3_fdt.c Mon Nov 19 13:54:15 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: gicv3_fdt.c,v 1.4 2018/11/10 01:24:06 jmcneill Exp $ */ +/* $NetBSD: gicv3_fdt.c,v 1.5 2018/11/19 13:54:15 jakllsch Exp $ */ /*- * Copyright (c) 2015-2018 Jared McNeill @@ -29,7 +29,7 @@ #define _INTR_PRIVATE #include -__KERNEL_RCSID(0, "$NetBSD: gicv3_fdt.c,v 1.4 2018/11/10 01:24:06 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: gicv3_fdt.c,v 1.5 2018/11/19 13:54:15 jakllsch Exp $"); #include #include @@ -310,7 +310,7 @@ gicv3_fdt_disestablish(device_t dev, voi for (n = 0; n < GICV3_MAXIRQ; n++) { firq = sc->sc_irq[n]; - if (firq->intr_ih != ih) + if (firq == NULL || firq->intr_ih != ih) continue; KASSERT(firq->intr_refcnt > 0);
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Mon Nov 19 11:08:16 UTC 2018 Modified Files: src/sys/arch/arm/fdt: pcihost_fdt.c Log Message: Clear PCI_FLAGS_IO_OKAY as we don't support it yet. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/fdt/pcihost_fdt.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/pcihost_fdt.c diff -u src/sys/arch/arm/fdt/pcihost_fdt.c:1.5 src/sys/arch/arm/fdt/pcihost_fdt.c:1.6 --- src/sys/arch/arm/fdt/pcihost_fdt.c:1.5 Fri Nov 16 19:32:01 2018 +++ src/sys/arch/arm/fdt/pcihost_fdt.c Mon Nov 19 11:08:16 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: pcihost_fdt.c,v 1.5 2018/11/16 19:32:01 jakllsch Exp $ */ +/* $NetBSD: pcihost_fdt.c,v 1.6 2018/11/19 11:08:16 jmcneill Exp $ */ /*- * Copyright (c) 2018 Jared D. McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pcihost_fdt.c,v 1.5 2018/11/16 19:32:01 jakllsch Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pcihost_fdt.c,v 1.6 2018/11/19 11:08:16 jmcneill Exp $"); #include #include @@ -203,15 +203,14 @@ pcihost_attach(device_t parent, device_t pba.pba_flags = PCI_FLAGS_MRL_OKAY | PCI_FLAGS_MRM_OKAY | PCI_FLAGS_MWI_OKAY | - PCI_FLAGS_MEM_OKAY | - PCI_FLAGS_IO_OKAY; + PCI_FLAGS_MEM_OKAY; #ifdef __HAVE_PCI_MSI_MSIX if (sc->sc_type == PCIHOST_ECAM) { pba.pba_flags |= PCI_FLAGS_MSI_OKAY | PCI_FLAGS_MSIX_OKAY; } #endif - pba.pba_iot = sc->sc_bst; + pba.pba_iot = 0; pba.pba_memt = sc->sc_bst; pba.pba_dmat = sc->sc_dmat; #ifdef _PCI_HAVE_DMA64
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jakllsch Date: Fri Nov 16 19:32:01 UTC 2018 Modified Files: src/sys/arch/arm/fdt: pcihost_fdt.c Log Message: make pcihost_intr_evcnt static, like the other functions To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/fdt/pcihost_fdt.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/pcihost_fdt.c diff -u src/sys/arch/arm/fdt/pcihost_fdt.c:1.4 src/sys/arch/arm/fdt/pcihost_fdt.c:1.5 --- src/sys/arch/arm/fdt/pcihost_fdt.c:1.4 Fri Nov 16 15:06:21 2018 +++ src/sys/arch/arm/fdt/pcihost_fdt.c Fri Nov 16 19:32:01 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: pcihost_fdt.c,v 1.4 2018/11/16 15:06:21 jmcneill Exp $ */ +/* $NetBSD: pcihost_fdt.c,v 1.5 2018/11/16 19:32:01 jakllsch Exp $ */ /*- * Copyright (c) 2018 Jared D. McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pcihost_fdt.c,v 1.4 2018/11/16 15:06:21 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pcihost_fdt.c,v 1.5 2018/11/16 19:32:01 jakllsch Exp $"); #include #include @@ -118,7 +118,7 @@ static int pcihost_intr_map(const struct pci_intr_handle_t *); static const char *pcihost_intr_string(void *, pci_intr_handle_t, char *, size_t); -const struct evcnt *pcihost_intr_evcnt(void *, pci_intr_handle_t); +static const struct evcnt *pcihost_intr_evcnt(void *, pci_intr_handle_t); static int pcihost_intr_setattr(void *, pci_intr_handle_t *, int, uint64_t); static void * pcihost_intr_establish(void *, pci_intr_handle_t,
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Mon Nov 12 12:41:03 UTC 2018 Modified Files: src/sys/arch/arm/fdt: gic_fdt.c Log Message: Only attach v2m if PCI support is present To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/sys/arch/arm/fdt/gic_fdt.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/gic_fdt.c diff -u src/sys/arch/arm/fdt/gic_fdt.c:1.14 src/sys/arch/arm/fdt/gic_fdt.c:1.15 --- src/sys/arch/arm/fdt/gic_fdt.c:1.14 Sun Nov 11 21:24:28 2018 +++ src/sys/arch/arm/fdt/gic_fdt.c Mon Nov 12 12:41:03 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: gic_fdt.c,v 1.14 2018/11/11 21:24:28 jmcneill Exp $ */ +/* $NetBSD: gic_fdt.c,v 1.15 2018/11/12 12:41:03 jmcneill Exp $ */ /*- * Copyright (c) 2015-2017 Jared McNeill @@ -26,8 +26,10 @@ * SUCH DAMAGE. */ +#include "pci.h" + #include -__KERNEL_RCSID(0, "$NetBSD: gic_fdt.c,v 1.14 2018/11/11 21:24:28 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: gic_fdt.c,v 1.15 2018/11/12 12:41:03 jmcneill Exp $"); #include #include @@ -57,7 +59,9 @@ struct gic_fdt_irq; static int gic_fdt_match(device_t, cfdata_t, void *); static void gic_fdt_attach(device_t, device_t, void *); +#if NPCI > 0 static void gic_fdt_attach_v2m(struct gic_fdt_softc *, bus_space_tag_t, int); +#endif static int gic_fdt_intr(void *); @@ -129,7 +133,7 @@ gic_fdt_attach(device_t parent, device_t bus_addr_t addr_d, addr_c; bus_size_t size_d, size_c; bus_space_handle_t bsh; - int error, child; + int error; sc->sc_dev = self; sc->sc_phandle = phandle; @@ -175,15 +179,18 @@ gic_fdt_attach(device_t parent, device_t arm_fdt_irq_set_handler(armgic_irq_handler); - for (child = OF_child(phandle); child; child = OF_peer(child)) { +#if NPCI > 0 + for (int child = OF_child(phandle); child; child = OF_peer(child)) { if (!fdtbus_status_okay(child)) continue; const char * const v2m_compat[] = { "arm,gic-v2m-frame", NULL }; if (of_match_compatible(child, v2m_compat)) gic_fdt_attach_v2m(sc, faa->faa_bst, child); } +#endif } +#if NPCI > 0 static void gic_fdt_attach_v2m(struct gic_fdt_softc *sc, bus_space_tag_t bst, int phandle) { @@ -224,6 +231,7 @@ gic_fdt_attach_v2m(struct gic_fdt_softc frame->frame_base + frame->frame_count); } } +#endif static void * gic_fdt_establish(device_t dev, u_int *specifier, int ipl, int flags,
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Sun Nov 11 21:24:28 UTC 2018 Modified Files: src/sys/arch/arm/fdt: gic_fdt.c Log Message: Add GICv2m support To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/sys/arch/arm/fdt/gic_fdt.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/gic_fdt.c diff -u src/sys/arch/arm/fdt/gic_fdt.c:1.13 src/sys/arch/arm/fdt/gic_fdt.c:1.14 --- src/sys/arch/arm/fdt/gic_fdt.c:1.13 Mon Sep 3 16:29:23 2018 +++ src/sys/arch/arm/fdt/gic_fdt.c Sun Nov 11 21:24:28 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: gic_fdt.c,v 1.13 2018/09/03 16:29:23 riastradh Exp $ */ +/* $NetBSD: gic_fdt.c,v 1.14 2018/11/11 21:24:28 jmcneill Exp $ */ /*- * Copyright (c) 2015-2017 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: gic_fdt.c,v 1.13 2018/09/03 16:29:23 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: gic_fdt.c,v 1.14 2018/11/11 21:24:28 jmcneill Exp $"); #include #include @@ -39,15 +39,25 @@ __KERNEL_RCSID(0, "$NetBSD: gic_fdt.c,v #include #include +#include + #include +#include +#include #include #include #define GIC_MAXIRQ 1020 +extern struct pic_softc *pic_list[]; + +struct gic_fdt_softc; +struct gic_fdt_irq; + static int gic_fdt_match(device_t, cfdata_t, void *); static void gic_fdt_attach(device_t, device_t, void *); +static void gic_fdt_attach_v2m(struct gic_fdt_softc *, bus_space_tag_t, int); static int gic_fdt_intr(void *); @@ -62,9 +72,6 @@ struct fdtbus_interrupt_controller_func .intrstr = gic_fdt_intrstr }; -struct gic_fdt_softc; -struct gic_fdt_irq; - struct gic_fdt_irqhandler { struct gic_fdt_irq *ih_irq; int (*ih_fn)(void *); @@ -87,8 +94,11 @@ struct gic_fdt_irq { struct gic_fdt_softc { device_t sc_dev; + device_t sc_gicdev; int sc_phandle; + int sc_v2m_count; + struct gic_fdt_irq *sc_irq[GIC_MAXIRQ]; }; @@ -107,7 +117,7 @@ gic_fdt_match(device_t parent, cfdata_t }; struct fdt_attach_args * const faa = aux; - return of_compatible(faa->faa_phandle, compatible) >= 0; + return of_match_compatible(faa->faa_phandle, compatible); } static void @@ -115,15 +125,16 @@ gic_fdt_attach(device_t parent, device_t { struct gic_fdt_softc * const sc = device_private(self); struct fdt_attach_args * const faa = aux; + const int phandle = faa->faa_phandle; bus_addr_t addr_d, addr_c; bus_size_t size_d, size_c; bus_space_handle_t bsh; - int error; + int error, child; sc->sc_dev = self; - sc->sc_phandle = faa->faa_phandle; + sc->sc_phandle = phandle; - error = fdtbus_register_interrupt_controller(self, faa->faa_phandle, + error = fdtbus_register_interrupt_controller(self, phandle, _fdt_funcs); if (error) { aprint_error(": couldn't register with fdtbus: %d\n", error); @@ -160,9 +171,58 @@ gic_fdt_attach(device_t parent, device_t .mpcaa_off2 = addr_c - addr, }; - config_found(self, , NULL); + sc->sc_gicdev = config_found(self, , NULL); arm_fdt_irq_set_handler(armgic_irq_handler); + + for (child = OF_child(phandle); child; child = OF_peer(child)) { + if (!fdtbus_status_okay(child)) + continue; + const char * const v2m_compat[] = { "arm,gic-v2m-frame", NULL }; + if (of_match_compatible(child, v2m_compat)) + gic_fdt_attach_v2m(sc, faa->faa_bst, child); + } +} + +static void +gic_fdt_attach_v2m(struct gic_fdt_softc *sc, bus_space_tag_t bst, int phandle) +{ + struct gic_v2m_frame *frame; + u_int base_spi, num_spis; + bus_space_handle_t bsh; + bus_addr_t addr; + bus_size_t size; + + if (fdtbus_get_reg(phandle, 0, , ) != 0) { + aprint_error_dev(sc->sc_gicdev, "couldn't get V2M address\n"); + return; + } + + if (bus_space_map(bst, addr, size, 0, ) != 0) { + aprint_error_dev(sc->sc_gicdev, "couldn't map V2M frame\n"); + return; + } + const uint32_t typer = bus_space_read_4(bst, bsh, GIC_MSI_TYPER); + bus_space_unmap(bst, bsh, size); + + if (of_getprop_uint32(phandle, "arm,msi-base-spi", _spi)) + base_spi = __SHIFTOUT(typer, GIC_MSI_TYPER_BASE); + if (of_getprop_uint32(phandle, "arm,msi-num-spis", _spis)) + num_spis = __SHIFTOUT(typer, GIC_MSI_TYPER_NUMBER); + + frame = kmem_zalloc(sizeof(*frame), KM_SLEEP); + frame->frame_reg = addr; + frame->frame_pic = pic_list[0]; + frame->frame_base = base_spi; + frame->frame_count = num_spis; + + if (gic_v2m_init(frame, sc->sc_gicdev, sc->sc_v2m_count++) != 0) { + aprint_error_dev(sc->sc_gicdev, "failed to initialize GICv2m\n"); + } else { + aprint_normal_dev(sc->sc_gicdev, "GICv2m @ %#" PRIx64 ", SPIs %u-%u\n", + (uint64_t)frame->frame_reg, frame->frame_base, + frame->frame_base + frame->frame_count); + } } static void *
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Sun Nov 11 21:24:38 UTC 2018 Modified Files: src/sys/arch/arm/fdt: pcihost_fdt.c Log Message: Add MSI/MSI-X support. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/fdt/pcihost_fdt.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/pcihost_fdt.c diff -u src/sys/arch/arm/fdt/pcihost_fdt.c:1.2 src/sys/arch/arm/fdt/pcihost_fdt.c:1.3 --- src/sys/arch/arm/fdt/pcihost_fdt.c:1.2 Sun Sep 9 13:40:28 2018 +++ src/sys/arch/arm/fdt/pcihost_fdt.c Sun Nov 11 21:24:38 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: pcihost_fdt.c,v 1.2 2018/09/09 13:40:28 jmcneill Exp $ */ +/* $NetBSD: pcihost_fdt.c,v 1.3 2018/11/11 21:24:38 jmcneill Exp $ */ /*- * Copyright (c) 2018 Jared D. McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pcihost_fdt.c,v 1.2 2018/09/09 13:40:28 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pcihost_fdt.c,v 1.3 2018/11/11 21:24:38 jmcneill Exp $"); #include #include @@ -50,6 +50,8 @@ __KERNEL_RCSID(0, "$NetBSD: pcihost_fdt. #include +#include + #define IH_INDEX_MASK 0x #define IH_MPSAFE 0x8000 @@ -72,6 +74,8 @@ __KERNEL_RCSID(0, "$NetBSD: pcihost_fdt. #define PHYS_HI_FUNCTION __BITS(10,8) #define PHYS_HI_REGISTER __BITS(7,0) +static int pcihost_segment = 0; + enum pcihost_type { PCIHOST_CAM = 1, PCIHOST_ECAM, @@ -86,6 +90,7 @@ struct pcihost_softc { enum pcihost_type sc_type; + u_int sc_seg; u_int sc_bus_min; u_int sc_bus_max; @@ -103,6 +108,7 @@ static void pcihost_attach_hook(device_t static int pcihost_bus_maxdevs(void *, int); static pcitag_t pcihost_make_tag(void *, int, int, int); static void pcihost_decompose_tag(void *, pcitag_t, int *, int *, int *); +static u_int pcihost_get_segment(void *); static pcireg_t pcihost_conf_read(void *, pcitag_t, int); static void pcihost_conf_write(void *, pcitag_t, int, pcireg_t); static int pcihost_conf_hook(void *, int, int, int, pcireg_t); @@ -178,6 +184,15 @@ pcihost_attach(device_t parent, device_t sc->sc_bus_max = PCIHOST_DEFAULT_BUS_MAX; } + /* + * Assign a fixed PCI segment ("domain") number. If the property is not + * present, assign one. The binding spec says if this property is used to + * assign static segment numbers, all host bridges should have segments + * astatic assigned to prevent overlaps. + */ + if (of_getprop_uint32(sc->sc_phandle, "linux,pci-domain", >sc_seg)) + sc->sc_seg = pcihost_segment++; + pcihost_init(>sc_pc, sc); if (pcihost_config(sc) != 0) @@ -189,6 +204,12 @@ pcihost_attach(device_t parent, device_t PCI_FLAGS_MWI_OKAY | PCI_FLAGS_MEM_OKAY | PCI_FLAGS_IO_OKAY; +#ifdef __HAVE_PCI_MSI_MSIX + if (sc->sc_type == PCIHOST_ECAM) { + pba.pba_flags |= PCI_FLAGS_MSI_OKAY | + PCI_FLAGS_MSIX_OKAY; + } +#endif pba.pba_iot = sc->sc_bst; pba.pba_memt = sc->sc_bst; pba.pba_dmat = sc->sc_dmat; @@ -196,7 +217,7 @@ pcihost_attach(device_t parent, device_t pba.pba_dmat64 = sc->sc_dmat; #endif pba.pba_pc = >sc_pc; - pba.pba_bus = 0; + pba.pba_bus = sc->sc_bus_min; config_found_ia(self, "pcibus", , pcibusprint); } @@ -209,6 +230,7 @@ pcihost_init(pci_chipset_tag_t pc, void pc->pc_bus_maxdevs = pcihost_bus_maxdevs; pc->pc_make_tag = pcihost_make_tag; pc->pc_decompose_tag = pcihost_decompose_tag; + pc->pc_get_segment = pcihost_get_segment; pc->pc_conf_read = pcihost_conf_read; pc->pc_conf_write = pcihost_conf_write; pc->pc_conf_hook = pcihost_conf_hook; @@ -228,8 +250,17 @@ pcihost_config(struct pcihost_softc *sc) { struct extent *ioext = NULL, *memext = NULL, *pmemext = NULL; const u_int *ranges; + u_int probe_only; int error, len; + /* + * If this flag is set, skip configuration of the PCI bus and use existing config. + */ + if (of_getprop_uint32(sc->sc_phandle, "linux,pci-probe-only", _only)) + probe_only = 0; + if (probe_only) + return 0; + ranges = fdtbus_get_prop(sc->sc_phandle, "ranges", ); if (ranges == NULL) { aprint_error_dev(sc->sc_dev, "missing 'ranges' property\n"); @@ -334,6 +365,14 @@ pcihost_decompose_tag(void *v, pcitag_t *fp = (tag >> 8) & 0x7; } +static u_int +pcihost_get_segment(void *v) +{ + struct pcihost_softc *sc = v; + + return sc->sc_seg; +} + static pcireg_t pcihost_conf_read(void *v, pcitag_t tag, int offset) { @@ -489,16 +528,24 @@ pcihost_find_intr(struct pcihost_softc * static const char * pcihost_intr_string(void *v, pci_intr_handle_t ih, char *buf, size_t len) { + const int irq = __SHIFTOUT(ih, ARM_PCI_INTR_IRQ); + const int vec = __SHIFTOUT(ih, ARM_PCI_INTR_MSI_VEC); struct pcihost_softc *sc = v; const u_int *specifier; int ihandle; - specifier = pcihost_find_intr(sc, ih & IH_INDEX_MASK, ); - if (specifier == NULL) - return NULL; + if (ih & ARM_PCI_INTR_MSIX) { + snprintf(buf, len, "irq %d (MSI-X vec %d)", irq, vec); + }
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Sat Nov 10 01:24:06 UTC 2018 Modified Files: src/sys/arch/arm/fdt: gicv3_fdt.c Log Message: Initialize gic softc dma tag To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/fdt/gicv3_fdt.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/gicv3_fdt.c diff -u src/sys/arch/arm/fdt/gicv3_fdt.c:1.3 src/sys/arch/arm/fdt/gicv3_fdt.c:1.4 --- src/sys/arch/arm/fdt/gicv3_fdt.c:1.3 Sat Sep 29 18:27:36 2018 +++ src/sys/arch/arm/fdt/gicv3_fdt.c Sat Nov 10 01:24:06 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: gicv3_fdt.c,v 1.3 2018/09/29 18:27:36 jmcneill Exp $ */ +/* $NetBSD: gicv3_fdt.c,v 1.4 2018/11/10 01:24:06 jmcneill Exp $ */ /*- * Copyright (c) 2015-2018 Jared McNeill @@ -29,7 +29,7 @@ #define _INTR_PRIVATE #include -__KERNEL_RCSID(0, "$NetBSD: gicv3_fdt.c,v 1.3 2018/09/29 18:27:36 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: gicv3_fdt.c,v 1.4 2018/11/10 01:24:06 jmcneill Exp $"); #include #include @@ -136,6 +136,7 @@ gicv3_fdt_attach(device_t parent, device sc->sc_phandle = phandle; sc->sc_gic.sc_dev = self; sc->sc_gic.sc_bst = faa->faa_bst; + sc->sc_gic.sc_dmat = faa->faa_dmat; error = gicv3_fdt_map_registers(sc); if (error) {
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Fri Nov 9 23:35:06 UTC 2018 Modified Files: src/sys/arch/arm/fdt: fdt_intr.h Log Message: Increase max PIC sources To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/fdt/fdt_intr.h 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/fdt_intr.h diff -u src/sys/arch/arm/fdt/fdt_intr.h:1.4 src/sys/arch/arm/fdt/fdt_intr.h:1.5 --- src/sys/arch/arm/fdt/fdt_intr.h:1.4 Wed Sep 5 10:20:47 2018 +++ src/sys/arch/arm/fdt/fdt_intr.h Fri Nov 9 23:35:06 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: fdt_intr.h,v 1.4 2018/09/05 10:20:47 jmcneill Exp $ */ +/* $NetBSD: fdt_intr.h,v 1.5 2018/11/09 23:35:06 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -36,8 +36,8 @@ #define __HAVE_PIC_SET_PRIORITY #define __HAVE_PIC_PENDING_INTRS -#define PIC_MAXSOURCES 480 -#define PIC_MAXMAXSOURCES (PIC_MAXSOURCES + 32) +#define PIC_MAXSOURCES 8192 +#define PIC_MAXMAXSOURCES (PIC_MAXSOURCES * 2 + 32) void arm_fdt_irq_set_handler(void (*)(void *)); void arm_fdt_irq_handler(void *);
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Wed Oct 31 15:42:54 UTC 2018 Modified Files: src/sys/arch/arm/fdt: acpi_fdt.c Log Message: Add MSI-X support To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/fdt/acpi_fdt.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/acpi_fdt.c diff -u src/sys/arch/arm/fdt/acpi_fdt.c:1.7 src/sys/arch/arm/fdt/acpi_fdt.c:1.8 --- src/sys/arch/arm/fdt/acpi_fdt.c:1.7 Sun Oct 28 10:21:42 2018 +++ src/sys/arch/arm/fdt/acpi_fdt.c Wed Oct 31 15:42:54 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_fdt.c,v 1.7 2018/10/28 10:21:42 jmcneill Exp $ */ +/* $NetBSD: acpi_fdt.c,v 1.8 2018/10/31 15:42:54 jmcneill Exp $ */ /*- * Copyright (c) 2015-2017 Jared McNeill @@ -29,7 +29,7 @@ #include "opt_efi.h" #include -__KERNEL_RCSID(0, "$NetBSD: acpi_fdt.c,v 1.7 2018/10/28 10:21:42 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_fdt.c,v 1.8 2018/10/31 15:42:54 jmcneill Exp $"); #include #include @@ -127,7 +127,7 @@ acpi_fdt_attach(device_t parent, device_ PCI_FLAGS_MRL_OKAY | PCI_FLAGS_MRM_OKAY | PCI_FLAGS_MWI_OKAY; #ifdef __HAVE_PCI_MSI_MSIX - aa.aa_pciflags |= PCI_FLAGS_MSI_OKAY; + aa.aa_pciflags |= PCI_FLAGS_MSI_OKAY | PCI_FLAGS_MSIX_OKAY; #endif aa.aa_ic = 0; aa.aa_dmat = faa->faa_dmat;
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Tue Oct 23 10:13:34 UTC 2018 Modified Files: src/sys/arch/arm/fdt: acpi_fdt.c Log Message: Expose SMBIOS table pointer via machdep.smbios sysctl To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/fdt/acpi_fdt.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/acpi_fdt.c diff -u src/sys/arch/arm/fdt/acpi_fdt.c:1.5 src/sys/arch/arm/fdt/acpi_fdt.c:1.6 --- src/sys/arch/arm/fdt/acpi_fdt.c:1.5 Sun Oct 21 12:06:22 2018 +++ src/sys/arch/arm/fdt/acpi_fdt.c Tue Oct 23 10:13:34 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_fdt.c,v 1.5 2018/10/21 12:06:22 jmcneill Exp $ */ +/* $NetBSD: acpi_fdt.c,v 1.6 2018/10/23 10:13:34 jmcneill Exp $ */ /*- * Copyright (c) 2015-2017 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_fdt.c,v 1.5 2018/10/21 12:06:22 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_fdt.c,v 1.6 2018/10/23 10:13:34 jmcneill Exp $"); #include #include @@ -38,6 +38,7 @@ __KERNEL_RCSID(0, "$NetBSD: acpi_fdt.c,v #include #include #include +#include #include @@ -53,8 +54,12 @@ static void acpi_fdt_attach(device_t, de static void acpi_fdt_poweroff(device_t); +static void acpi_fdt_sysctl_init(void); + static struct acpi_pci_context acpi_fdt_pci_context; +static uint64_t smbios_table = 0; + static const char * const compatible[] = { "netbsd,acpi", NULL @@ -109,6 +114,8 @@ acpi_fdt_attach(device_t parent, device_ aa.aa_dmat64 = faa->faa_dmat; #endif config_found_ia(self, "acpibus", , 0); + + acpi_fdt_sysctl_init(); } static void @@ -118,3 +125,28 @@ acpi_fdt_poweroff(device_t dev) if (psci_available()) psci_system_off(); } + +static void +acpi_fdt_sysctl_init(void) +{ + const struct sysctlnode *rnode; + int error; + + const int chosen = OF_finddevice("/chosen"); + if (chosen >= 0) + of_getprop_uint64(chosen, "netbsd,smbios-table", _table); + + error = sysctl_createv(NULL, 0, NULL, , + CTLFLAG_PERMANENT, CTLTYPE_NODE, "machdep", NULL, + NULL, 0, NULL, 0, CTL_MACHDEP, CTL_EOL); + if (error) + return; + + if (smbios_table != 0) { + (void)sysctl_createv(NULL, 0, , NULL, + CTLFLAG_PERMANENT | CTLFLAG_READONLY | CTLFLAG_HEX, CTLTYPE_QUAD, + "smbios", SYSCTL_DESCR("SMBIOS table pointer"), + NULL, 0, _table, sizeof(smbios_table), + CTL_CREATE, CTL_EOL); + } +}
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Sun Oct 21 12:06:22 UTC 2018 Modified Files: src/sys/arch/arm/fdt: acpi_fdt.c Log Message: Some parts of the ACPI subsystem depend on a valid PCI chipset tag in the ACPI softc. Provide one here, and assume segment 0. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/fdt/acpi_fdt.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/acpi_fdt.c diff -u src/sys/arch/arm/fdt/acpi_fdt.c:1.4 src/sys/arch/arm/fdt/acpi_fdt.c:1.5 --- src/sys/arch/arm/fdt/acpi_fdt.c:1.4 Sun Oct 21 00:42:05 2018 +++ src/sys/arch/arm/fdt/acpi_fdt.c Sun Oct 21 12:06:22 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_fdt.c,v 1.4 2018/10/21 00:42:05 jmcneill Exp $ */ +/* $NetBSD: acpi_fdt.c,v 1.5 2018/10/21 12:06:22 jmcneill Exp $ */ /*- * Copyright (c) 2015-2017 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_fdt.c,v 1.4 2018/10/21 00:42:05 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_fdt.c,v 1.5 2018/10/21 12:06:22 jmcneill Exp $"); #include #include @@ -53,6 +53,8 @@ static void acpi_fdt_attach(device_t, de static void acpi_fdt_poweroff(device_t); +static struct acpi_pci_context acpi_fdt_pci_context; + static const char * const compatible[] = { "netbsd,acpi", NULL @@ -87,9 +89,13 @@ acpi_fdt_attach(device_t parent, device_ if (!acpi_probe()) aprint_error_dev(self, "failed to probe ACPI\n"); + acpi_fdt_pci_context.ap_pc = arm_acpi_pci_chipset; + acpi_fdt_pci_context.ap_pc.pc_conf_v = _fdt_pci_context; + acpi_fdt_pci_context.ap_seg = 0; + aa.aa_iot = 0; aa.aa_memt = faa->faa_bst; - aa.aa_pc = _acpi_pci_chipset; + aa.aa_pc = _fdt_pci_context.ap_pc; aa.aa_pciflags = /*PCI_FLAGS_IO_OKAY |*/ PCI_FLAGS_MEM_OKAY | PCI_FLAGS_MRL_OKAY | PCI_FLAGS_MRM_OKAY |
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: skrll Date: Wed Oct 17 05:30:24 UTC 2018 Modified Files: src/sys/arch/arm/fdt: psci_fdt.c Log Message: KNF To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/sys/arch/arm/fdt/psci_fdt.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/psci_fdt.c diff -u src/sys/arch/arm/fdt/psci_fdt.c:1.18 src/sys/arch/arm/fdt/psci_fdt.c:1.19 --- src/sys/arch/arm/fdt/psci_fdt.c:1.18 Mon Sep 10 11:05:12 2018 +++ src/sys/arch/arm/fdt/psci_fdt.c Wed Oct 17 05:30:24 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: psci_fdt.c,v 1.18 2018/09/10 11:05:12 ryo Exp $ */ +/* $NetBSD: psci_fdt.c,v 1.19 2018/10/17 05:30:24 skrll Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -29,14 +29,14 @@ #include "opt_multiprocessor.h" #include -__KERNEL_RCSID(0, "$NetBSD: psci_fdt.c,v 1.18 2018/09/10 11:05:12 ryo Exp $"); +__KERNEL_RCSID(0, "$NetBSD: psci_fdt.c,v 1.19 2018/10/17 05:30:24 skrll Exp $"); #include +#include #include #include -#include #include -#include +#include #include
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Sat Oct 13 00:15:11 UTC 2018 Modified Files: src/sys/arch/arm/fdt: acpi_fdt.c Log Message: Support poweroff via PSCI To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/fdt/acpi_fdt.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/acpi_fdt.c diff -u src/sys/arch/arm/fdt/acpi_fdt.c:1.1 src/sys/arch/arm/fdt/acpi_fdt.c:1.2 --- src/sys/arch/arm/fdt/acpi_fdt.c:1.1 Fri Oct 12 22:20:48 2018 +++ src/sys/arch/arm/fdt/acpi_fdt.c Sat Oct 13 00:15:10 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_fdt.c,v 1.1 2018/10/12 22:20:48 jmcneill Exp $ */ +/* $NetBSD: acpi_fdt.c,v 1.2 2018/10/13 00:15:10 jmcneill Exp $ */ /*- * Copyright (c) 2015-2017 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_fdt.c,v 1.1 2018/10/12 22:20:48 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_fdt.c,v 1.2 2018/10/13 00:15:10 jmcneill Exp $"); #include #include @@ -44,14 +44,22 @@ __KERNEL_RCSID(0, "$NetBSD: acpi_fdt.c,v #include #include +#include + static int acpi_fdt_match(device_t, cfdata_t, void *); static void acpi_fdt_attach(device_t, device_t, void *); +static void acpi_fdt_poweroff(device_t); + static const char * const compatible[] = { "netbsd,acpi", NULL }; +static const struct fdtbus_power_controller_func acpi_fdt_power_funcs = { + .poweroff = acpi_fdt_poweroff, +}; + CFATTACH_DECL_NEW(acpi_fdt, 0, acpi_fdt_match, acpi_fdt_attach, NULL, NULL); static int @@ -71,6 +79,9 @@ acpi_fdt_attach(device_t parent, device_ aprint_naive("\n"); aprint_normal(": ACPI Platform support\n"); + fdtbus_register_power_controller(self, faa->faa_phandle, + _fdt_power_funcs); + if (!acpi_probe()) aprint_error_dev(self, "failed to probe ACPI\n"); @@ -88,3 +99,11 @@ acpi_fdt_attach(device_t parent, device_ #endif config_found_ia(self, "acpibus", , 0); } + +static void +acpi_fdt_poweroff(device_t dev) +{ + delay(50); + if (psci_available()) + psci_system_off(); +}
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Fri Oct 12 22:20:48 UTC 2018 Modified Files: src/sys/arch/arm/fdt: files.fdt Added Files: src/sys/arch/arm/fdt: acpi_fdt.c Log Message: Add acpi @ fdt glue To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/fdt/acpi_fdt.c cvs rdiff -u -r1.26 -r1.27 src/sys/arch/arm/fdt/files.fdt 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.26 src/sys/arch/arm/fdt/files.fdt:1.27 --- src/sys/arch/arm/fdt/files.fdt:1.26 Fri Sep 21 12:04:06 2018 +++ src/sys/arch/arm/fdt/files.fdt Fri Oct 12 22:20:48 2018 @@ -1,4 +1,4 @@ -# $NetBSD: files.fdt,v 1.26 2018/09/21 12:04:06 skrll Exp $ +# $NetBSD: files.fdt,v 1.27 2018/10/12 22:20:48 jmcneill Exp $ include "dev/pckbport/files.pckbport" @@ -67,3 +67,6 @@ file dev/tprof/tprof_armv8.c pmu_fdt & attach genfb at fdt with plfb_fdt: fdt_display_timing file arch/arm/fdt/plfb_fdt.c plfb_fdt +device acpifdt: acpibus +attach acpifdt at fdt with acpi_fdt +file arch/arm/fdt/acpi_fdt.c acpi_fdt Added files: Index: src/sys/arch/arm/fdt/acpi_fdt.c diff -u /dev/null src/sys/arch/arm/fdt/acpi_fdt.c:1.1 --- /dev/null Fri Oct 12 22:20:48 2018 +++ src/sys/arch/arm/fdt/acpi_fdt.c Fri Oct 12 22:20:48 2018 @@ -0,0 +1,90 @@ +/* $NetBSD: acpi_fdt.c,v 1.1 2018/10/12 22:20:48 jmcneill Exp $ */ + +/*- + * Copyright (c) 2015-2017 Jared McNeill + * 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 +__KERNEL_RCSID(0, "$NetBSD: acpi_fdt.c,v 1.1 2018/10/12 22:20:48 jmcneill Exp $"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +static int acpi_fdt_match(device_t, cfdata_t, void *); +static void acpi_fdt_attach(device_t, device_t, void *); + +static const char * const compatible[] = { + "netbsd,acpi", + NULL +}; + +CFATTACH_DECL_NEW(acpi_fdt, 0, acpi_fdt_match, acpi_fdt_attach, NULL, NULL); + +static int +acpi_fdt_match(device_t parent, cfdata_t cf, void *aux) +{ + struct fdt_attach_args * const faa = aux; + + return of_compatible(faa->faa_phandle, compatible) >= 0; +} + +static void +acpi_fdt_attach(device_t parent, device_t self, void *aux) +{ + struct fdt_attach_args * const faa = aux; + struct acpibus_attach_args aa; + + aprint_naive("\n"); + aprint_normal(": ACPI Platform support\n"); + + if (!acpi_probe()) + aprint_error_dev(self, "failed to probe ACPI\n"); + + aa.aa_iot = 0; + aa.aa_memt = faa->faa_bst; + aa.aa_pc = NULL; + aa.aa_pciflags = + PCI_FLAGS_IO_OKAY | PCI_FLAGS_MEM_OKAY | + PCI_FLAGS_MRL_OKAY | PCI_FLAGS_MRM_OKAY | + PCI_FLAGS_MWI_OKAY; + aa.aa_ic = 0; + aa.aa_dmat = faa->faa_dmat; +#ifdef _PCI_HAVE_DMA64 + aa.aa_dmat64 = faa->faa_dmat; +#endif + config_found_ia(self, "acpibus", , 0); +}
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: ryo Date: Thu Oct 4 08:58:13 UTC 2018 Modified Files: src/sys/arch/arm/fdt: cpu_fdt.c Log Message: fix to boot APs of RPI3 with GENERIC64. if no psci, try other methods. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/sys/arch/arm/fdt/cpu_fdt.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/cpu_fdt.c diff -u src/sys/arch/arm/fdt/cpu_fdt.c:1.14 src/sys/arch/arm/fdt/cpu_fdt.c:1.15 --- src/sys/arch/arm/fdt/cpu_fdt.c:1.14 Thu Sep 13 12:53:00 2018 +++ src/sys/arch/arm/fdt/cpu_fdt.c Thu Oct 4 08:58:13 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu_fdt.c,v 1.14 2018/09/13 12:53:00 jmcneill Exp $ */ +/* $NetBSD: cpu_fdt.c,v 1.15 2018/10/04 08:58:13 ryo Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -30,7 +30,7 @@ #include "psci_fdt.h" #include -__KERNEL_RCSID(0, "$NetBSD: cpu_fdt.c,v 1.14 2018/09/13 12:53:00 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu_fdt.c,v 1.15 2018/10/04 08:58:13 ryo Exp $"); #include #include @@ -236,6 +236,9 @@ arm_fdt_cpu_bootstrap(void) u_int cpuindex; int child, ret; const char *method; +#if NPSCI_FDT > 0 + bool nopsci = false; +#endif const int cpus = OF_finddevice("/cpus"); if (cpus == -1) { @@ -252,7 +255,7 @@ arm_fdt_cpu_bootstrap(void) #if NPSCI_FDT > 0 if (psci_fdt_preinit() != 0) - return; + nopsci = true; #endif /* MPIDR affinity levels of boot processor. */ @@ -299,7 +302,7 @@ arm_fdt_cpu_bootstrap(void) continue; #if NPSCI_FDT > 0 - } else if (strcmp(method, "psci") == 0) { + } else if (!nopsci && (strcmp(method, "psci") == 0)) { ret = psci_cpu_on(mpidr, cpu_fdt_mpstart_pa(), 0); if (ret != PSCI_SUCCESS) continue;
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Sat Sep 29 18:27:36 UTC 2018 Modified Files: src/sys/arch/arm/fdt: gicv3_fdt.c Log Message: Stop searching for redistributors in a region after we find a redistributor with the Last bit set in GICR_TYPER. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/fdt/gicv3_fdt.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/gicv3_fdt.c diff -u src/sys/arch/arm/fdt/gicv3_fdt.c:1.2 src/sys/arch/arm/fdt/gicv3_fdt.c:1.3 --- src/sys/arch/arm/fdt/gicv3_fdt.c:1.2 Sun Aug 12 21:44:17 2018 +++ src/sys/arch/arm/fdt/gicv3_fdt.c Sat Sep 29 18:27:36 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: gicv3_fdt.c,v 1.2 2018/08/12 21:44:17 jmcneill Exp $ */ +/* $NetBSD: gicv3_fdt.c,v 1.3 2018/09/29 18:27:36 jmcneill Exp $ */ /*- * Copyright (c) 2015-2018 Jared McNeill @@ -29,7 +29,7 @@ #define _INTR_PRIVATE #include -__KERNEL_RCSID(0, "$NetBSD: gicv3_fdt.c,v 1.2 2018/08/12 21:44:17 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: gicv3_fdt.c,v 1.3 2018/09/29 18:27:36 jmcneill Exp $"); #include #include @@ -44,6 +44,7 @@ __KERNEL_RCSID(0, "$NetBSD: gicv3_fdt.c, #include #include +#include #define GICV3_MAXIRQ 1020 @@ -163,7 +164,7 @@ gicv3_fdt_map_registers(struct gicv3_fdt bus_size_t size, region_off; bus_addr_t addr; size_t reg_off; - int n, r; + int n, r, max_redist, redist; if (of_getprop_uint32(phandle, "#redistributor-regions", _regions)) redistributor_regions = 1; @@ -185,15 +186,15 @@ gicv3_fdt_map_registers(struct gicv3_fdt /* * GIC Redistributors (GICR) */ - for (reg_off = 1, n = 0; n < redistributor_regions; n++, reg_off++) { + for (reg_off = 1, max_redist = 0, n = 0; n < redistributor_regions; n++, reg_off++) { if (fdtbus_get_reg(phandle, reg_off, NULL, ) != 0) { aprint_error_dev(gic->sc_dev, "couldn't get redistributor registers\n"); return ENXIO; } - gic->sc_bsh_r_count += howmany(size, redistributor_stride); + max_redist += howmany(size, redistributor_stride); } - gic->sc_bsh_r = kmem_alloc(sizeof(bus_space_handle_t) * gic->sc_bsh_r_count, KM_SLEEP); - for (reg_off = 1, n = 0; n < redistributor_regions; n++, reg_off++) { + gic->sc_bsh_r = kmem_alloc(sizeof(bus_space_handle_t) * max_redist, KM_SLEEP); + for (reg_off = 1, redist = 0, n = 0; n < redistributor_regions; n++, reg_off++) { if (fdtbus_get_reg(phandle, reg_off, , ) != 0) { aprint_error_dev(gic->sc_dev, "couldn't get redistributor registers\n"); return ENXIO; @@ -204,12 +205,18 @@ gicv3_fdt_map_registers(struct gicv3_fdt } const int count = howmany(size, redistributor_stride); for (r = 0, region_off = 0; r < count; r++, region_off += redistributor_stride) { - if (bus_space_subregion(sc->sc_gic.sc_bst, bsh, region_off, redistributor_stride, >sc_bsh_r[r]) != 0) { + if (bus_space_subregion(sc->sc_gic.sc_bst, bsh, region_off, redistributor_stride, >sc_bsh_r[redist++]) != 0) { aprint_error_dev(gic->sc_dev, "couldn't subregion redistributor registers\n"); return ENXIO; } + + /* If this is the last redist in this region, skip to the next one */ + const uint32_t typer = bus_space_read_4(sc->sc_gic.sc_bst, gic->sc_bsh_r[redist - 1], GICR_TYPER); + if (typer & GICR_TYPER_Last) +break; } } + gic->sc_bsh_r_count = redist; return 0; }
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Thu Sep 13 12:53:00 UTC 2018 Modified Files: src/sys/arch/arm/fdt: cpu_fdt.c Log Message: Wrap arm_fdt_cpu_okay with #ifdef MULTIPROCESSOR To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/sys/arch/arm/fdt/cpu_fdt.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/cpu_fdt.c diff -u src/sys/arch/arm/fdt/cpu_fdt.c:1.13 src/sys/arch/arm/fdt/cpu_fdt.c:1.14 --- src/sys/arch/arm/fdt/cpu_fdt.c:1.13 Mon Sep 10 19:15:16 2018 +++ src/sys/arch/arm/fdt/cpu_fdt.c Thu Sep 13 12:53:00 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu_fdt.c,v 1.13 2018/09/10 19:15:16 jmcneill Exp $ */ +/* $NetBSD: cpu_fdt.c,v 1.14 2018/09/13 12:53:00 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -30,7 +30,7 @@ #include "psci_fdt.h" #include -__KERNEL_RCSID(0, "$NetBSD: cpu_fdt.c,v 1.13 2018/09/10 19:15:16 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu_fdt.c,v 1.14 2018/09/13 12:53:00 jmcneill Exp $"); #include #include @@ -205,6 +205,7 @@ spintable_cpu_on(u_int cpuindex, paddr_t } #endif /* MULTIPROCESSOR */ +#ifdef MULTIPROCESSOR static bool arm_fdt_cpu_okay(const int child) { @@ -225,6 +226,7 @@ arm_fdt_cpu_okay(const int child) return true; } } +#endif /* MULTIPROCESSOR */ void arm_fdt_cpu_bootstrap(void)
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Mon Sep 10 19:15:17 UTC 2018 Modified Files: src/sys/arch/arm/fdt: cpu_fdt.c Log Message: Re-add support for cpu nodes with status = "disabled", lost in previous commit To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/sys/arch/arm/fdt/cpu_fdt.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/cpu_fdt.c diff -u src/sys/arch/arm/fdt/cpu_fdt.c:1.12 src/sys/arch/arm/fdt/cpu_fdt.c:1.13 --- src/sys/arch/arm/fdt/cpu_fdt.c:1.12 Mon Sep 10 11:05:12 2018 +++ src/sys/arch/arm/fdt/cpu_fdt.c Mon Sep 10 19:15:16 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu_fdt.c,v 1.12 2018/09/10 11:05:12 ryo Exp $ */ +/* $NetBSD: cpu_fdt.c,v 1.13 2018/09/10 19:15:16 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -30,7 +30,7 @@ #include "psci_fdt.h" #include -__KERNEL_RCSID(0, "$NetBSD: cpu_fdt.c,v 1.12 2018/09/10 11:05:12 ryo Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu_fdt.c,v 1.13 2018/09/10 19:15:16 jmcneill Exp $"); #include #include @@ -205,6 +205,26 @@ spintable_cpu_on(u_int cpuindex, paddr_t } #endif /* MULTIPROCESSOR */ +static bool +arm_fdt_cpu_okay(const int child) +{ + const char *s; + + s = fdtbus_get_string(child, "device_type"); + if (!s || strcmp(s, "cpu") != 0) + return false; + + s = fdtbus_get_string(child, "status"); + if (s) { + if (strcmp(s, "okay") == 0) + return false; + if (strcmp(s, "disabled") == 0) + return of_hasprop(child, "enable-method"); + return false; + } else { + return true; + } +} void arm_fdt_cpu_bootstrap(void) @@ -213,7 +233,7 @@ arm_fdt_cpu_bootstrap(void) uint64_t mpidr, bp_mpidr; u_int cpuindex; int child, ret; - const char *devtype, *method; + const char *method; const int cpus = OF_finddevice("/cpus"); if (cpus == -1) { @@ -225,9 +245,7 @@ arm_fdt_cpu_bootstrap(void) /* Count CPUs */ arm_cpu_max = 0; for (child = OF_child(cpus); child; child = OF_peer(child)) - if (fdtbus_status_okay(child) && ((devtype = - fdtbus_get_string(child, "device_type")) != NULL) && - (strcmp(devtype, "cpu") == 0)) + if (arm_fdt_cpu_okay(child)) arm_cpu_max++; #if NPSCI_FDT > 0 @@ -242,7 +260,7 @@ arm_fdt_cpu_bootstrap(void) uint32_t started = 0; cpuindex = 1; for (child = OF_child(cpus); child; child = OF_peer(child)) { - if (!fdtbus_status_okay(child)) + if (!arm_fdt_cpu_okay(child)) continue; if (fdtbus_get_reg64(child, 0, , NULL) != 0) continue;
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Sun Sep 9 21:16:05 UTC 2018 Modified Files: src/sys/arch/arm/fdt: psci_fdt.c Log Message: Boot APs with status "disabled" if they have an enable-method property To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/sys/arch/arm/fdt/psci_fdt.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/psci_fdt.c diff -u src/sys/arch/arm/fdt/psci_fdt.c:1.16 src/sys/arch/arm/fdt/psci_fdt.c:1.17 --- src/sys/arch/arm/fdt/psci_fdt.c:1.16 Sun Sep 9 13:32:26 2018 +++ src/sys/arch/arm/fdt/psci_fdt.c Sun Sep 9 21:16:05 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: psci_fdt.c,v 1.16 2018/09/09 13:32:26 jmcneill Exp $ */ +/* $NetBSD: psci_fdt.c,v 1.17 2018/09/09 21:16:05 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -29,7 +29,7 @@ #include "opt_multiprocessor.h" #include -__KERNEL_RCSID(0, "$NetBSD: psci_fdt.c,v 1.16 2018/09/09 13:32:26 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: psci_fdt.c,v 1.17 2018/09/09 21:16:05 jmcneill Exp $"); #include #include @@ -169,6 +169,27 @@ psci_fdt_mpstart_pa(void) } #endif +static bool +psci_fdt_cpu_okay(const int child) +{ + const char *s; + + s = fdtbus_get_string(child, "device_type"); + if (!s || strcmp(s, "cpu") != 0) + return false; + + s = fdtbus_get_string(child, "status"); + if (s) { + if (strcmp(s, "okay") == 0) + return false; + if (strcmp(s, "disabled") == 0) + return of_hasprop(child, "enable-method"); + return false; + } else { + return true; + } +} + void psci_fdt_bootstrap(void) { @@ -202,7 +223,7 @@ psci_fdt_bootstrap(void) /* Boot APs */ cpuindex = 1; for (child = OF_child(cpus); child; child = OF_peer(child)) { - if (!fdtbus_status_okay(child)) + if (!psci_fdt_cpu_okay(child)) continue; if (fdtbus_get_reg64(child, 0, , NULL) != 0) continue;
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Sun Sep 9 13:40:28 UTC 2018 Modified Files: src/sys/arch/arm/fdt: pcihost_fdt.c Log Message: Take interrupt-map-mask into consideration when mapping PCI interrupts. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/fdt/pcihost_fdt.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/pcihost_fdt.c diff -u src/sys/arch/arm/fdt/pcihost_fdt.c:1.1 src/sys/arch/arm/fdt/pcihost_fdt.c:1.2 --- src/sys/arch/arm/fdt/pcihost_fdt.c:1.1 Sat Sep 8 00:40:57 2018 +++ src/sys/arch/arm/fdt/pcihost_fdt.c Sun Sep 9 13:40:28 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: pcihost_fdt.c,v 1.1 2018/09/08 00:40:57 jmcneill Exp $ */ +/* $NetBSD: pcihost_fdt.c,v 1.2 2018/09/09 13:40:28 jmcneill Exp $ */ /*- * Copyright (c) 2018 Jared D. McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pcihost_fdt.c,v 1.1 2018/09/08 00:40:57 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pcihost_fdt.c,v 1.2 2018/09/09 13:40:28 jmcneill Exp $"); #include #include @@ -50,7 +50,7 @@ __KERNEL_RCSID(0, "$NetBSD: pcihost_fdt. #include -#define IH_PIN_MASK 0x000f +#define IH_INDEX_MASK 0x #define IH_MPSAFE 0x8000 #define PCIHOST_DEFAULT_BUS_MIN 0 @@ -402,25 +402,69 @@ pcihost_conf_interrupt(void *v, int bus, static int pcihost_intr_map(const struct pci_attach_args *pa, pci_intr_handle_t *ih) { + struct pcihost_softc *sc = pa->pa_pc->pc_intr_v; + u_int addr_cells, interrupt_cells; + const u_int *imap, *imask; + int imaplen, imasklen; + u_int match[4]; + int index; + if (pa->pa_intrpin == 0) return EINVAL; - *ih = pa->pa_intrpin; - return 0; + + imap = fdtbus_get_prop(sc->sc_phandle, "interrupt-map", ); + imask = fdtbus_get_prop(sc->sc_phandle, "interrupt-map-mask", ); + if (imap == NULL || imask == NULL || imasklen != 16) + return EINVAL; + + /* Convert attach args to specifier */ + match[0] = htobe32( + __SHIFTIN(pa->pa_bus, PHYS_HI_BUS) | + __SHIFTIN(pa->pa_device, PHYS_HI_DEVICE) | + __SHIFTIN(pa->pa_function, PHYS_HI_FUNCTION) + ) & imask[0]; + match[1] = htobe32(0) & imask[1]; + match[2] = htobe32(0) & imask[2]; + match[3] = htobe32(pa->pa_intrpin) & imask[3]; + + index = 0; + while (imaplen >= 20) { + const int map_ihandle = fdtbus_get_phandle_from_native(be32toh(imap[4])); + if (of_getprop_uint32(map_ihandle, "#address-cells", _cells)) + addr_cells = 2; + if (of_getprop_uint32(map_ihandle, "#interrupt-cells", _cells)) + interrupt_cells = 0; + if (imaplen < (addr_cells + interrupt_cells) * 4) + return ENXIO; + + if ((imap[0] & imask[0]) == match[0] && + (imap[1] & imask[1]) == match[1] && + (imap[2] & imask[2]) == match[2] && + (imap[3] & imask[3]) == match[3]) { + *ih = index; + return 0; + } + + imap += (5 + addr_cells + interrupt_cells); + imaplen -= (5 + addr_cells + interrupt_cells) * 4; + index++; + } + + return EINVAL; } static const u_int * -pcihost_find_intr(struct pcihost_softc *sc, int pin, int *pihandle) +pcihost_find_intr(struct pcihost_softc *sc, pci_intr_handle_t ih, int *pihandle) { u_int addr_cells, interrupt_cells; + int imaplen, index; const u_int *imap; - int imaplen; imap = fdtbus_get_prop(sc->sc_phandle, "interrupt-map", ); - if (imap == NULL) - return NULL; + KASSERT(imap != NULL); + index = 0; while (imaplen >= 20) { - const int map_pin = be32toh(imap[3]); const int map_ihandle = fdtbus_get_phandle_from_native(be32toh(imap[4])); if (of_getprop_uint32(map_ihandle, "#address-cells", _cells)) addr_cells = 2; @@ -429,13 +473,14 @@ pcihost_find_intr(struct pcihost_softc * if (imaplen < (addr_cells + interrupt_cells) * 4) return NULL; - if (map_pin == pin) { + if (index == ih) { *pihandle = map_ihandle; return imap + 5 + addr_cells; } - imap += (addr_cells + interrupt_cells); - imaplen -= (addr_cells + interrupt_cells) * 4; + imap += (5 + addr_cells + interrupt_cells); + imaplen -= (5 + addr_cells + interrupt_cells) * 4; + index++; } return NULL; @@ -445,14 +490,10 @@ static const char * pcihost_intr_string(void *v, pci_intr_handle_t ih, char *buf, size_t len) { struct pcihost_softc *sc = v; - u_int pin = ih & IH_PIN_MASK; const u_int *specifier; int ihandle; - if (pin == PCI_INTERRUPT_PIN_NONE || pin > PCI_INTERRUPT_PIN_MAX) - return NULL; - - specifier = pcihost_find_intr(sc, pin, ); + specifier = pcihost_find_intr(sc, ih & IH_INDEX_MASK, ); if (specifier == NULL) return NULL; @@ -488,15 +529,11 @@ pcihost_intr_establish(void *v, pci_intr int (*callback)(void *), void *arg) { struct pcihost_softc *sc = v; - u_int pin = ih & IH_PIN_MASK; const int flags = (ih & IH_MPSAFE) ? FDT_INTR_MPSAFE : 0; const u_int *specifier; int ihandle; - if (pin == PCI_INTERRUPT_PIN_NONE || pin >
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Sun Sep 9 13:32:26 UTC 2018 Modified Files: src/sys/arch/arm/fdt: psci_fdt.c Log Message: Fix previous; PSCI_CPU_ON requires an MPIDR! To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/sys/arch/arm/fdt/psci_fdt.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/psci_fdt.c diff -u src/sys/arch/arm/fdt/psci_fdt.c:1.15 src/sys/arch/arm/fdt/psci_fdt.c:1.16 --- src/sys/arch/arm/fdt/psci_fdt.c:1.15 Sun Aug 26 18:15:49 2018 +++ src/sys/arch/arm/fdt/psci_fdt.c Sun Sep 9 13:32:26 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: psci_fdt.c,v 1.15 2018/08/26 18:15:49 ryo Exp $ */ +/* $NetBSD: psci_fdt.c,v 1.16 2018/09/09 13:32:26 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -29,7 +29,7 @@ #include "opt_multiprocessor.h" #include -__KERNEL_RCSID(0, "$NetBSD: psci_fdt.c,v 1.15 2018/08/26 18:15:49 ryo Exp $"); +__KERNEL_RCSID(0, "$NetBSD: psci_fdt.c,v 1.16 2018/09/09 13:32:26 jmcneill Exp $"); #include #include @@ -216,7 +216,7 @@ psci_fdt_bootstrap(void) sizeof(arm_cpu_hatch_arg)); #endif - int ret = psci_cpu_on(cpuindex, psci_fdt_mpstart_pa(), 0); + int ret = psci_cpu_on(mpidr, psci_fdt_mpstart_pa(), 0); if (ret != PSCI_SUCCESS) continue;
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Sun Sep 9 13:22:50 UTC 2018 Modified Files: src/sys/arch/arm/fdt: cpu_fdt.c Log Message: Ditch arm,arm-v8 compatible string (everything uses arm,armv8) To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/sys/arch/arm/fdt/cpu_fdt.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/cpu_fdt.c diff -u src/sys/arch/arm/fdt/cpu_fdt.c:1.10 src/sys/arch/arm/fdt/cpu_fdt.c:1.11 --- src/sys/arch/arm/fdt/cpu_fdt.c:1.10 Wed Sep 5 10:38:29 2018 +++ src/sys/arch/arm/fdt/cpu_fdt.c Sun Sep 9 13:22:50 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu_fdt.c,v 1.10 2018/09/05 10:38:29 jmcneill Exp $ */ +/* $NetBSD: cpu_fdt.c,v 1.11 2018/09/09 13:22:50 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cpu_fdt.c,v 1.10 2018/09/05 10:38:29 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu_fdt.c,v 1.11 2018/09/09 13:22:50 jmcneill Exp $"); #include #include @@ -68,8 +68,7 @@ static const struct of_compat_data compa { "arm,cortex-a15", ARM_CPU_ARMV7 }, { "arm,cortex-a17", ARM_CPU_ARMV7 }, - { "arm,armv8", ARM_CPU_ARMV8 }, /* nonstandard */ - { "arm,arm-v8", ARM_CPU_ARMV8 }, + { "arm,armv8", ARM_CPU_ARMV8 }, { "arm,cortex-a53", ARM_CPU_ARMV8 }, { "arm,cortex-a57", ARM_CPU_ARMV8 }, { "arm,cortex-a72", ARM_CPU_ARMV8 },
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Sat Sep 8 00:40:57 UTC 2018 Modified Files: src/sys/arch/arm/fdt: files.fdt Added Files: src/sys/arch/arm/fdt: pcihost_fdt.c Log Message: Add FDT generic PCI host controller driver. To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/sys/arch/arm/fdt/files.fdt cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/fdt/pcihost_fdt.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.23 src/sys/arch/arm/fdt/files.fdt:1.24 --- src/sys/arch/arm/fdt/files.fdt:1.23 Fri Aug 17 14:21:30 2018 +++ src/sys/arch/arm/fdt/files.fdt Sat Sep 8 00:40:57 2018 @@ -1,4 +1,4 @@ -# $NetBSD: files.fdt,v 1.23 2018/08/17 14:21:30 skrll Exp $ +# $NetBSD: files.fdt,v 1.24 2018/09/08 00:40:57 jmcneill Exp $ include "dev/pckbport/files.pckbport" @@ -53,6 +53,11 @@ file arch/arm/fdt/plrtc_fdt.c plrtc_fdt attach psci at fdt with psci_fdt file arch/arm/fdt/psci_fdt.c psci_fdt +# Generic PCI host controller +device pcihost: pcibus +attach pcihost at fdt with pcihost_fdt +file arch/arm/fdt/pcihost_fdt.c pcihost_fdt + device armpmu attach armpmu at fdt with pmu_fdt file arch/arm/fdt/pmu_fdt.c pmu_fdt Added files: Index: src/sys/arch/arm/fdt/pcihost_fdt.c diff -u /dev/null src/sys/arch/arm/fdt/pcihost_fdt.c:1.1 --- /dev/null Sat Sep 8 00:40:57 2018 +++ src/sys/arch/arm/fdt/pcihost_fdt.c Sat Sep 8 00:40:57 2018 @@ -0,0 +1,512 @@ +/* $NetBSD: pcihost_fdt.c,v 1.1 2018/09/08 00:40:57 jmcneill Exp $ */ + +/*- + * Copyright (c) 2018 Jared D. McNeill + * 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 +__KERNEL_RCSID(0, "$NetBSD: pcihost_fdt.c,v 1.1 2018/09/08 00:40:57 jmcneill Exp $"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include +#include +#include + +#include + +#define IH_PIN_MASK 0x000f +#define IH_MPSAFE 0x8000 + +#define PCIHOST_DEFAULT_BUS_MIN 0 +#define PCIHOST_DEFAULT_BUS_MAX 255 + +#define PCIHOST_CACHELINE_SIZE arm_dcache_align + +/* Physical address format bit definitions */ +#define PHYS_HI_RELO __BIT(31) +#define PHYS_HI_PREFETCH __BIT(30) +#define PHYS_HI_ALIASED __BIT(29) +#define PHYS_HI_SPACE __BITS(25,24) +#define PHYS_HI_SPACE_CFG 0 +#define PHYS_HI_SPACE_IO 1 +#define PHYS_HI_SPACE_MEM32 2 +#define PHYS_HI_SPACE_MEM64 3 +#define PHYS_HI_BUS __BITS(23,16) +#define PHYS_HI_DEVICE __BITS(15,11) +#define PHYS_HI_FUNCTION __BITS(10,8) +#define PHYS_HI_REGISTER __BITS(7,0) + +enum pcihost_type { + PCIHOST_CAM = 1, + PCIHOST_ECAM, +}; + +struct pcihost_softc { + device_t sc_dev; + bus_dma_tag_t sc_dmat; + bus_space_tag_t sc_bst; + bus_space_handle_t sc_bsh; + int sc_phandle; + + enum pcihost_type sc_type; + + u_int sc_bus_min; + u_int sc_bus_max; + + struct arm32_pci_chipset sc_pc; +}; + +static int pcihost_match(device_t, cfdata_t, void *); +static void pcihost_attach(device_t, device_t, void *); + +static void pcihost_init(pci_chipset_tag_t, void *); +static int pcihost_config(struct pcihost_softc *); + +static void pcihost_attach_hook(device_t, device_t, + struct pcibus_attach_args *); +static int pcihost_bus_maxdevs(void *, int); +static pcitag_t pcihost_make_tag(void *, int, int, int); +static void pcihost_decompose_tag(void *, pcitag_t, int *, int *, int *); +static pcireg_t pcihost_conf_read(void *, pcitag_t, int); +static void pcihost_conf_write(void *, pcitag_t, int, pcireg_t); +static int pcihost_conf_hook(void *, int, int, int, pcireg_t); +static void
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Fri Sep 7 12:50:58 UTC 2018 Modified Files: src/sys/arch/arm/fdt: plcom_fdt.c Log Message: Print interrupt info To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/fdt/plcom_fdt.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/plcom_fdt.c diff -u src/sys/arch/arm/fdt/plcom_fdt.c:1.1 src/sys/arch/arm/fdt/plcom_fdt.c:1.2 --- src/sys/arch/arm/fdt/plcom_fdt.c:1.1 Fri Jun 2 14:30:58 2017 +++ src/sys/arch/arm/fdt/plcom_fdt.c Fri Sep 7 12:50:58 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: plcom_fdt.c,v 1.1 2017/06/02 14:30:58 jmcneill Exp $ */ +/* $NetBSD: plcom_fdt.c,v 1.2 2018/09/07 12:50:58 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: plcom_fdt.c,v 1.1 2017/06/02 14:30:58 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: plcom_fdt.c,v 1.2 2018/09/07 12:50:58 jmcneill Exp $"); #include #include @@ -62,6 +62,7 @@ plcom_fdt_attach(device_t parent, device struct plcom_softc * const sc = device_private(self); struct fdt_attach_args * const faa = aux; const int phandle = faa->faa_phandle; + char intrstr[128]; struct clk *clk; bus_addr_t addr; bus_size_t size; @@ -72,6 +73,11 @@ plcom_fdt_attach(device_t parent, device return; } + if (!fdtbus_intr_str(phandle, 0, intrstr, sizeof(intrstr))) { + aprint_error(": failed to decode interrupt\n"); + return; + } + sc->sc_dev = self; /* Enable clocks */ @@ -98,6 +104,8 @@ plcom_fdt_attach(device_t parent, device } plcom_attach_subr(sc); + aprint_normal_dev(self, "interrupting on %s\n", intrstr); + ih = fdtbus_intr_establish(phandle, 0, IPL_SERIAL, FDT_INTR_MPSAFE, plcomintr, sc); if (ih == NULL) {
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Wed Sep 5 10:38:30 UTC 2018 Modified Files: src/sys/arch/arm/fdt: cpu_fdt.c Log Message: Match non-standard compat string "arm,armv8" (should be "arm,arm-v8") To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/fdt/cpu_fdt.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/cpu_fdt.c diff -u src/sys/arch/arm/fdt/cpu_fdt.c:1.9 src/sys/arch/arm/fdt/cpu_fdt.c:1.10 --- src/sys/arch/arm/fdt/cpu_fdt.c:1.9 Sun Aug 26 18:15:49 2018 +++ src/sys/arch/arm/fdt/cpu_fdt.c Wed Sep 5 10:38:29 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu_fdt.c,v 1.9 2018/08/26 18:15:49 ryo Exp $ */ +/* $NetBSD: cpu_fdt.c,v 1.10 2018/09/05 10:38:29 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cpu_fdt.c,v 1.9 2018/08/26 18:15:49 ryo Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu_fdt.c,v 1.10 2018/09/05 10:38:29 jmcneill Exp $"); #include #include @@ -68,6 +68,7 @@ static const struct of_compat_data compa { "arm,cortex-a15", ARM_CPU_ARMV7 }, { "arm,cortex-a17", ARM_CPU_ARMV7 }, + { "arm,armv8", ARM_CPU_ARMV8 }, /* nonstandard */ { "arm,arm-v8", ARM_CPU_ARMV8 }, { "arm,cortex-a53", ARM_CPU_ARMV8 }, { "arm,cortex-a57", ARM_CPU_ARMV8 },
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Wed Sep 5 10:20:47 UTC 2018 Modified Files: src/sys/arch/arm/fdt: fdt_intr.h Log Message: Bump PIX_MAXSOURCES to 480 To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/fdt/fdt_intr.h 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/fdt_intr.h diff -u src/sys/arch/arm/fdt/fdt_intr.h:1.3 src/sys/arch/arm/fdt/fdt_intr.h:1.4 --- src/sys/arch/arm/fdt/fdt_intr.h:1.3 Fri Jun 15 14:25:22 2018 +++ src/sys/arch/arm/fdt/fdt_intr.h Wed Sep 5 10:20:47 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: fdt_intr.h,v 1.3 2018/06/15 14:25:22 jakllsch Exp $ */ +/* $NetBSD: fdt_intr.h,v 1.4 2018/09/05 10:20:47 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -36,7 +36,7 @@ #define __HAVE_PIC_SET_PRIORITY #define __HAVE_PIC_PENDING_INTRS -#define PIC_MAXSOURCES 352 +#define PIC_MAXSOURCES 480 #define PIC_MAXMAXSOURCES (PIC_MAXSOURCES + 32) void arm_fdt_irq_set_handler(void (*)(void *));
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: ryo Date: Fri Aug 24 21:56:13 UTC 2018 Modified Files: src/sys/arch/arm/fdt: psci_fdt.c Log Message: /cpus node may have any nodes except cpu. count only nodes of device_type "cpu" To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/sys/arch/arm/fdt/psci_fdt.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/psci_fdt.c diff -u src/sys/arch/arm/fdt/psci_fdt.c:1.13 src/sys/arch/arm/fdt/psci_fdt.c:1.14 --- src/sys/arch/arm/fdt/psci_fdt.c:1.13 Mon Aug 13 12:28:02 2018 +++ src/sys/arch/arm/fdt/psci_fdt.c Fri Aug 24 21:56:13 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: psci_fdt.c,v 1.13 2018/08/13 12:28:02 skrll Exp $ */ +/* $NetBSD: psci_fdt.c,v 1.14 2018/08/24 21:56:13 ryo Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -29,7 +29,7 @@ #include "opt_multiprocessor.h" #include -__KERNEL_RCSID(0, "$NetBSD: psci_fdt.c,v 1.13 2018/08/13 12:28:02 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: psci_fdt.c,v 1.14 2018/08/24 21:56:13 ryo Exp $"); #include #include @@ -175,6 +175,7 @@ psci_fdt_bootstrap(void) extern void cortex_mpstart(void); uint64_t mpidr, bp_mpidr; int child; + const char *devtype; const int cpus = OF_finddevice("/cpus"); if (cpus == -1) { @@ -186,7 +187,9 @@ psci_fdt_bootstrap(void) /* Count CPUs */ arm_cpu_max = 0; for (child = OF_child(cpus); child; child = OF_peer(child)) - if (fdtbus_status_okay(child)) + if (fdtbus_status_okay(child) && ((devtype = + fdtbus_get_string(child, "device_type")) != NULL) && + (strcmp(devtype, "cpu") == 0)) arm_cpu_max++; if (psci_fdt_preinit() != 0)
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: skrll Date: Fri Aug 17 14:21:30 UTC 2018 Modified Files: src/sys/arch/arm/fdt: files.fdt Log Message: Whitespace To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/sys/arch/arm/fdt/files.fdt 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.22 src/sys/arch/arm/fdt/files.fdt:1.23 --- src/sys/arch/arm/fdt/files.fdt:1.22 Wed Aug 8 19:03:08 2018 +++ src/sys/arch/arm/fdt/files.fdt Fri Aug 17 14:21:30 2018 @@ -1,4 +1,4 @@ -# $NetBSD: files.fdt,v 1.22 2018/08/08 19:03:08 jmcneill Exp $ +# $NetBSD: files.fdt,v 1.23 2018/08/17 14:21:30 skrll Exp $ include "dev/pckbport/files.pckbport" @@ -23,14 +23,14 @@ file arch/arm/fdt/gtmr_fdt.c gtmr_fdt device gic: mpcorebus attach gic at fdt with gic_fdt -filearch/arm/fdt/gic_fdt.c gic_fdt +filearch/arm/fdt/gic_fdt.c gic_fdt attach gicvthree at fdt with gicv3_fdt file arch/arm/fdt/gicv3_fdt.c gicv3_fdt device l2cc: mpcorebus attach l2cc at fdt with l2cc_fdt -filearch/arm/fdt/l2cc_fdt.c l2cc_fdt +filearch/arm/fdt/l2cc_fdt.c l2cc_fdt attach plcom at fdt with plcom_fdt file arch/arm/fdt/plcom_fdt.c plcom_fdt
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: skrll Date: Mon Aug 13 12:28:02 UTC 2018 Modified Files: src/sys/arch/arm/fdt: psci_fdt.c Log Message: Need to use fdtbus_get_reg64 for mpidr To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/sys/arch/arm/fdt/psci_fdt.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/psci_fdt.c diff -u src/sys/arch/arm/fdt/psci_fdt.c:1.12 src/sys/arch/arm/fdt/psci_fdt.c:1.13 --- src/sys/arch/arm/fdt/psci_fdt.c:1.12 Sun Aug 12 17:21:36 2018 +++ src/sys/arch/arm/fdt/psci_fdt.c Mon Aug 13 12:28:02 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: psci_fdt.c,v 1.12 2018/08/12 17:21:36 skrll Exp $ */ +/* $NetBSD: psci_fdt.c,v 1.13 2018/08/13 12:28:02 skrll Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -29,7 +29,7 @@ #include "opt_multiprocessor.h" #include -__KERNEL_RCSID(0, "$NetBSD: psci_fdt.c,v 1.12 2018/08/12 17:21:36 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: psci_fdt.c,v 1.13 2018/08/13 12:28:02 skrll Exp $"); #include #include @@ -200,7 +200,7 @@ psci_fdt_bootstrap(void) for (child = OF_child(cpus); child; child = OF_peer(child)) { if (!fdtbus_status_okay(child)) continue; - if (fdtbus_get_reg(child, 0, , NULL) != 0) + if (fdtbus_get_reg64(child, 0, , NULL) != 0) continue; if (mpidr == bp_mpidr) continue; /* BP already started */
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Sun Aug 12 21:44:17 UTC 2018 Modified Files: src/sys/arch/arm/fdt: gicv3_fdt.c Log Message: Use aprint_debug for redist count print To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/fdt/gicv3_fdt.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/gicv3_fdt.c diff -u src/sys/arch/arm/fdt/gicv3_fdt.c:1.1 src/sys/arch/arm/fdt/gicv3_fdt.c:1.2 --- src/sys/arch/arm/fdt/gicv3_fdt.c:1.1 Wed Aug 8 19:03:08 2018 +++ src/sys/arch/arm/fdt/gicv3_fdt.c Sun Aug 12 21:44:17 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: gicv3_fdt.c,v 1.1 2018/08/08 19:03:08 jmcneill Exp $ */ +/* $NetBSD: gicv3_fdt.c,v 1.2 2018/08/12 21:44:17 jmcneill Exp $ */ /*- * Copyright (c) 2015-2018 Jared McNeill @@ -29,7 +29,7 @@ #define _INTR_PRIVATE #include -__KERNEL_RCSID(0, "$NetBSD: gicv3_fdt.c,v 1.1 2018/08/08 19:03:08 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: gicv3_fdt.c,v 1.2 2018/08/12 21:44:17 jmcneill Exp $"); #include #include @@ -142,7 +142,7 @@ gicv3_fdt_attach(device_t parent, device return; } - aprint_normal_dev(self, "%d redistributors\n", sc->sc_gic.sc_bsh_r_count); + aprint_debug_dev(self, "%d redistributors\n", sc->sc_gic.sc_bsh_r_count); error = gicv3_init(>sc_gic); if (error) {
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Sun Aug 12 18:39:59 UTC 2018 Modified Files: src/sys/arch/arm/fdt: pmu_fdt.c Log Message: Only attempt to set interrupt affinity if we have more than one IRQ. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/fdt/pmu_fdt.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/pmu_fdt.c diff -u src/sys/arch/arm/fdt/pmu_fdt.c:1.3 src/sys/arch/arm/fdt/pmu_fdt.c:1.4 --- src/sys/arch/arm/fdt/pmu_fdt.c:1.3 Mon Jul 16 10:49:52 2018 +++ src/sys/arch/arm/fdt/pmu_fdt.c Sun Aug 12 18:39:59 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: pmu_fdt.c,v 1.3 2018/07/16 10:49:52 jmcneill Exp $ */ +/* $NetBSD: pmu_fdt.c,v 1.4 2018/08/12 18:39:59 jmcneill Exp $ */ /*- * Copyright (c) 2018 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pmu_fdt.c,v 1.3 2018/07/16 10:49:52 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmu_fdt.c,v 1.4 2018/08/12 18:39:59 jmcneill Exp $"); #include #include @@ -36,6 +36,7 @@ __KERNEL_RCSID(0, "$NetBSD: pmu_fdt.c,v #include #include #include +#include #include @@ -114,38 +115,51 @@ pmu_fdt_init(device_t self) const int phandle = sc->sc_phandle; char intrstr[128]; int error, n; - void *ih; + void **ih; - for (n = 0; ; n++) { - ih = fdtbus_intr_establish(phandle, n, IPL_HIGH, + error = arm_pmu_init(); + if (error != 0) { + aprint_error_dev(self, "failed to initialize PMU\n"); + return; + } + + ih = kmem_zalloc(sizeof(void *) * ncpu, KM_SLEEP); + + for (n = 0; n < ncpu; n++) { + ih[n] = fdtbus_intr_establish(phandle, n, IPL_HIGH, FDT_INTR_MPSAFE, arm_pmu_intr, NULL); - if (ih == NULL) + if (ih[n] == NULL) break; if (!fdtbus_intr_str(phandle, n, intrstr, sizeof(intrstr))) { aprint_error_dev(self, "couldn't decode interrupt %u\n", n); - return; + goto cleanup; } aprint_normal_dev(self, "interrupting on %s\n", intrstr); - error = pmu_fdt_intr_distribute(phandle, n, ih); - if (error != 0) { - aprint_error_dev(self, - "failed to distribute interrupt %u: %d\n", - n, error); - return; - } } + /* We need either one IRQ (PPI), or one per CPU (SPI) */ - if (n == 0) { + const int nirq = n; + if (nirq == 0) { aprint_error_dev(self, "couldn't establish interrupts\n"); - return; + goto cleanup; } - error = arm_pmu_init(); - if (error != 0) { - aprint_error_dev(self, "failed to initialize PMU\n"); - return; + /* Set interrupt affinity if we have more than one interrupt */ + if (nirq > 1) { + for (n = 0; n < nirq; n++) { + error = pmu_fdt_intr_distribute(phandle, n, ih[n]); + if (error != 0) { +aprint_error_dev(self, +"failed to distribute interrupt %u: %d\n", +n, error); +goto cleanup; + } + } } + +cleanup: + kmem_free(ih, sizeof(void *) * ncpu); } static int
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Fri Aug 10 22:34:36 UTC 2018 Modified Files: src/sys/arch/arm/fdt: psci_fdt.c Log Message: Pass full mpidr (instead of just aff0) to psci_cpu_on To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/sys/arch/arm/fdt/psci_fdt.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/psci_fdt.c diff -u src/sys/arch/arm/fdt/psci_fdt.c:1.10 src/sys/arch/arm/fdt/psci_fdt.c:1.11 --- src/sys/arch/arm/fdt/psci_fdt.c:1.10 Mon Jul 16 23:11:47 2018 +++ src/sys/arch/arm/fdt/psci_fdt.c Fri Aug 10 22:34:36 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: psci_fdt.c,v 1.10 2018/07/16 23:11:47 christos Exp $ */ +/* $NetBSD: psci_fdt.c,v 1.11 2018/08/10 22:34:36 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -29,7 +29,7 @@ #include "opt_multiprocessor.h" #include -__KERNEL_RCSID(0, "$NetBSD: psci_fdt.c,v 1.10 2018/07/16 23:11:47 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: psci_fdt.c,v 1.11 2018/08/10 22:34:36 jmcneill Exp $"); #include #include @@ -218,7 +218,7 @@ psci_fdt_bootstrap(void) continue; const u_int cpuid = __SHIFTOUT(mpidr, MPIDR_AFF0); - int ret = psci_cpu_on(cpuid, psci_fdt_mpstart_pa(), 0); + int ret = psci_cpu_on(mpidr, psci_fdt_mpstart_pa(), 0); if (ret == PSCI_SUCCESS) started |= __BIT(cpuid); }
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Wed Aug 8 19:03:08 UTC 2018 Modified Files: src/sys/arch/arm/fdt: files.fdt Added Files: src/sys/arch/arm/fdt: gicv3_fdt.c Log Message: Add GICv3 FDT glue To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/sys/arch/arm/fdt/files.fdt cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/fdt/gicv3_fdt.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.21 src/sys/arch/arm/fdt/files.fdt:1.22 --- src/sys/arch/arm/fdt/files.fdt:1.21 Sun Jul 15 23:48:08 2018 +++ src/sys/arch/arm/fdt/files.fdt Wed Aug 8 19:03:08 2018 @@ -1,4 +1,4 @@ -# $NetBSD: files.fdt,v 1.21 2018/07/15 23:48:08 jmcneill Exp $ +# $NetBSD: files.fdt,v 1.22 2018/08/08 19:03:08 jmcneill Exp $ include "dev/pckbport/files.pckbport" @@ -25,6 +25,9 @@ device gic: mpcorebus attach gic at fdt with gic_fdt filearch/arm/fdt/gic_fdt.c gic_fdt +attach gicvthree at fdt with gicv3_fdt +file arch/arm/fdt/gicv3_fdt.c gicv3_fdt + device l2cc: mpcorebus attach l2cc at fdt with l2cc_fdt filearch/arm/fdt/l2cc_fdt.c l2cc_fdt Added files: Index: src/sys/arch/arm/fdt/gicv3_fdt.c diff -u /dev/null src/sys/arch/arm/fdt/gicv3_fdt.c:1.1 --- /dev/null Wed Aug 8 19:03:09 2018 +++ src/sys/arch/arm/fdt/gicv3_fdt.c Wed Aug 8 19:03:08 2018 @@ -0,0 +1,354 @@ +/* $NetBSD: gicv3_fdt.c,v 1.1 2018/08/08 19:03:08 jmcneill Exp $ */ + +/*- + * Copyright (c) 2015-2018 Jared McNeill + * 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. + */ + +#define _INTR_PRIVATE + +#include +__KERNEL_RCSID(0, "$NetBSD: gicv3_fdt.c,v 1.1 2018/08/08 19:03:08 jmcneill Exp $"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#define GICV3_MAXIRQ 1020 + +#define IRQ_PPI(n) ((n) + 16) +#define IRQ_SPI(n) ((n) + 32) + +struct gicv3_fdt_softc; +struct gicv3_fdt_irq; + +static int gicv3_fdt_match(device_t, cfdata_t, void *); +static void gicv3_fdt_attach(device_t, device_t, void *); + +static int gicv3_fdt_map_registers(struct gicv3_fdt_softc *); + +static int gicv3_fdt_intr(void *); + +static void * gicv3_fdt_establish(device_t, u_int *, int, int, + int (*)(void *), void *); +static void gicv3_fdt_disestablish(device_t, void *); +static bool gicv3_fdt_intrstr(device_t, u_int *, char *, size_t); + +struct fdtbus_interrupt_controller_func gicv3_fdt_funcs = { + .establish = gicv3_fdt_establish, + .disestablish = gicv3_fdt_disestablish, + .intrstr = gicv3_fdt_intrstr +}; + +struct gicv3_fdt_irqhandler { + struct gicv3_fdt_irq *ih_irq; + int (*ih_fn)(void *); + void *ih_arg; + bool ih_mpsafe; + TAILQ_ENTRY(gicv3_fdt_irqhandler) ih_next; +}; + +struct gicv3_fdt_irq { + struct gicv3_fdt_softc *intr_sc; + void *intr_ih; + void *intr_arg; + int intr_refcnt; + int intr_ipl; + int intr_level; + int intr_mpsafe; + TAILQ_HEAD(, gicv3_fdt_irqhandler) intr_handlers; + int intr_irq; +}; + +struct gicv3_fdt_softc { + struct gicv3_softc sc_gic; + int sc_phandle; + + struct gicv3_fdt_irq *sc_irq[GICV3_MAXIRQ]; +}; + +CFATTACH_DECL_NEW(gicv3_fdt, sizeof(struct gicv3_fdt_softc), + gicv3_fdt_match, gicv3_fdt_attach, NULL, NULL); + +static int +gicv3_fdt_match(device_t parent, cfdata_t cf, void *aux) +{ + const char * const compatible[] = { + "arm,gic-v3", + NULL + }; + struct fdt_attach_args * const faa = aux; + const int phandle = faa->faa_phandle; + + return of_match_compatible(phandle, compatible); +} + +static void +gicv3_fdt_attach(device_t parent, device_t self, void *aux) +{ + struct gicv3_fdt_softc
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Mon Jul 16 10:49:53 UTC 2018 Modified Files: src/sys/arch/arm/fdt: pmu_fdt.c Log Message: aarch64 build fix To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/fdt/pmu_fdt.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/pmu_fdt.c diff -u src/sys/arch/arm/fdt/pmu_fdt.c:1.2 src/sys/arch/arm/fdt/pmu_fdt.c:1.3 --- src/sys/arch/arm/fdt/pmu_fdt.c:1.2 Sun Jul 15 23:48:08 2018 +++ src/sys/arch/arm/fdt/pmu_fdt.c Mon Jul 16 10:49:52 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: pmu_fdt.c,v 1.2 2018/07/15 23:48:08 jmcneill Exp $ */ +/* $NetBSD: pmu_fdt.c,v 1.3 2018/07/16 10:49:52 jmcneill Exp $ */ /*- * Copyright (c) 2018 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pmu_fdt.c,v 1.2 2018/07/15 23:48:08 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmu_fdt.c,v 1.3 2018/07/16 10:49:52 jmcneill Exp $"); #include #include @@ -39,7 +39,7 @@ __KERNEL_RCSID(0, "$NetBSD: pmu_fdt.c,v #include -#if defined(_ARM_ARCH_8) +#if defined(__aarch64__) #include #define arm_pmu_intr armv8_pmu_intr #define arm_pmu_init armv8_pmu_init
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Sun Jul 15 23:48:08 UTC 2018 Modified Files: src/sys/arch/arm/fdt: files.fdt pmu_fdt.c Log Message: Add support for ARMv7 performance monitor (PMU). To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/sys/arch/arm/fdt/files.fdt cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/fdt/pmu_fdt.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.20 src/sys/arch/arm/fdt/files.fdt:1.21 --- src/sys/arch/arm/fdt/files.fdt:1.20 Sun Jul 15 16:07:49 2018 +++ src/sys/arch/arm/fdt/files.fdt Sun Jul 15 23:48:08 2018 @@ -1,4 +1,4 @@ -# $NetBSD: files.fdt,v 1.20 2018/07/15 16:07:49 jmcneill Exp $ +# $NetBSD: files.fdt,v 1.21 2018/07/15 23:48:08 jmcneill Exp $ include "dev/pckbport/files.pckbport" @@ -53,6 +53,7 @@ file arch/arm/fdt/psci_fdt.c psci_fdt device armpmu attach armpmu at fdt with pmu_fdt file arch/arm/fdt/pmu_fdt.c pmu_fdt +file dev/tprof/tprof_armv7.c pmu_fdt & arm32 file dev/tprof/tprof_armv8.c pmu_fdt & aarch64 attach genfb at fdt with plfb_fdt: fdt_display_timing Index: src/sys/arch/arm/fdt/pmu_fdt.c diff -u src/sys/arch/arm/fdt/pmu_fdt.c:1.1 src/sys/arch/arm/fdt/pmu_fdt.c:1.2 --- src/sys/arch/arm/fdt/pmu_fdt.c:1.1 Sun Jul 15 16:07:49 2018 +++ src/sys/arch/arm/fdt/pmu_fdt.c Sun Jul 15 23:48:08 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: pmu_fdt.c,v 1.1 2018/07/15 16:07:49 jmcneill Exp $ */ +/* $NetBSD: pmu_fdt.c,v 1.2 2018/07/15 23:48:08 jmcneill Exp $ */ /*- * Copyright (c) 2018 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pmu_fdt.c,v 1.1 2018/07/15 16:07:49 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmu_fdt.c,v 1.2 2018/07/15 23:48:08 jmcneill Exp $"); #include #include @@ -39,10 +39,14 @@ __KERNEL_RCSID(0, "$NetBSD: pmu_fdt.c,v #include -#if defined(__aarch64__) +#if defined(_ARM_ARCH_8) #include #define arm_pmu_intr armv8_pmu_intr #define arm_pmu_init armv8_pmu_init +#elif defined(_ARM_ARCH_7) +#include +#define arm_pmu_intr armv7_pmu_intr +#define arm_pmu_init armv7_pmu_init #endif #include @@ -59,6 +63,15 @@ static const char * const compatible[] = "arm,cortex-a72-pmu", "arm,cortex-a57-pmu", "arm,cortex-a53-pmu", + + "arm,cortex-a35-pmu", + "arm,cortex-a17-pmu", + "arm,cortex-a12-pmu", + "arm,cortex-a9-pmu", + "arm,cortex-a8-pmu", + "arm,cortex-a7-pmu", + "arm,cortex-a5-pmu", + NULL };
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Sun Jul 15 16:07:49 UTC 2018 Modified Files: src/sys/arch/arm/fdt: files.fdt Added Files: src/sys/arch/arm/fdt: pmu_fdt.c Log Message: Add glue for ARMv8 performance monitor (PMU). To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/sys/arch/arm/fdt/files.fdt cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/fdt/pmu_fdt.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.19 src/sys/arch/arm/fdt/files.fdt:1.20 --- src/sys/arch/arm/fdt/files.fdt:1.19 Sat Jun 30 16:30:35 2018 +++ src/sys/arch/arm/fdt/files.fdt Sun Jul 15 16:07:49 2018 @@ -1,4 +1,4 @@ -# $NetBSD: files.fdt,v 1.19 2018/06/30 16:30:35 jmcneill Exp $ +# $NetBSD: files.fdt,v 1.20 2018/07/15 16:07:49 jmcneill Exp $ include "dev/pckbport/files.pckbport" @@ -50,6 +50,11 @@ file arch/arm/fdt/plrtc_fdt.c plrtc_fdt attach psci at fdt with psci_fdt file arch/arm/fdt/psci_fdt.c psci_fdt +device armpmu +attach armpmu at fdt with pmu_fdt +file arch/arm/fdt/pmu_fdt.c pmu_fdt +file dev/tprof/tprof_armv8.c pmu_fdt & aarch64 + attach genfb at fdt with plfb_fdt: fdt_display_timing file arch/arm/fdt/plfb_fdt.c plfb_fdt Added files: Index: src/sys/arch/arm/fdt/pmu_fdt.c diff -u /dev/null src/sys/arch/arm/fdt/pmu_fdt.c:1.1 --- /dev/null Sun Jul 15 16:07:49 2018 +++ src/sys/arch/arm/fdt/pmu_fdt.c Sun Jul 15 16:07:49 2018 @@ -0,0 +1,181 @@ +/* $NetBSD: pmu_fdt.c,v 1.1 2018/07/15 16:07:49 jmcneill Exp $ */ + +/*- + * Copyright (c) 2018 Jared McNeill + * 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 +__KERNEL_RCSID(0, "$NetBSD: pmu_fdt.c,v 1.1 2018/07/15 16:07:49 jmcneill Exp $"); + +#include +#include +#include +#include +#include +#include +#include + +#include + +#if defined(__aarch64__) +#include +#define arm_pmu_intr armv8_pmu_intr +#define arm_pmu_init armv8_pmu_init +#endif + +#include + +static int pmu_fdt_match(device_t, cfdata_t, void *); +static void pmu_fdt_attach(device_t, device_t, void *); + +static void pmu_fdt_init(device_t); +static int pmu_fdt_intr_distribute(const int, int, void *); + +static const char * const compatible[] = { + "arm,armv8-pmuv3", + "arm,cortex-a73-pmu", + "arm,cortex-a72-pmu", + "arm,cortex-a57-pmu", + "arm,cortex-a53-pmu", + NULL +}; + +struct pmu_fdt_softc { + device_t sc_dev; + int sc_phandle; +}; + +CFATTACH_DECL_NEW(pmu_fdt, sizeof(struct pmu_fdt_softc), +pmu_fdt_match, pmu_fdt_attach, NULL, NULL); + +static int +pmu_fdt_match(device_t parent, cfdata_t cf, void *aux) +{ + struct fdt_attach_args * const faa = aux; + + return of_match_compatible(faa->faa_phandle, compatible); +} + +static void +pmu_fdt_attach(device_t parent, device_t self, void *aux) +{ + struct pmu_fdt_softc * const sc = device_private(self); + struct fdt_attach_args * const faa = aux; + const int phandle = faa->faa_phandle; + + aprint_naive("\n"); + aprint_normal(": Performance Monitor Unit\n"); + + sc->sc_dev = self; + sc->sc_phandle = phandle; + + config_interrupts(self, pmu_fdt_init); +} + +static void +pmu_fdt_init(device_t self) +{ + struct pmu_fdt_softc * const sc = device_private(self); + const int phandle = sc->sc_phandle; + char intrstr[128]; + int error, n; + void *ih; + + for (n = 0; ; n++) { + ih = fdtbus_intr_establish(phandle, n, IPL_HIGH, + FDT_INTR_MPSAFE, arm_pmu_intr, NULL); + if (ih == NULL) + break; + if (!fdtbus_intr_str(phandle, n, intrstr, sizeof(intrstr))) { + aprint_error_dev(self, + "couldn't decode interrupt %u\n", n); + return; + } + aprint_normal_dev(self, "interrupting on %s\n",
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Sun Jul 15 13:34:43 UTC 2018 Modified Files: src/sys/arch/arm/fdt: gic_fdt.c Log Message: Return the real interrupt handle from gic_fdt_establish To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/fdt/gic_fdt.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/gic_fdt.c diff -u src/sys/arch/arm/fdt/gic_fdt.c:1.11 src/sys/arch/arm/fdt/gic_fdt.c:1.12 --- src/sys/arch/arm/fdt/gic_fdt.c:1.11 Tue Jul 3 12:12:03 2018 +++ src/sys/arch/arm/fdt/gic_fdt.c Sun Jul 15 13:34:43 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: gic_fdt.c,v 1.11 2018/07/03 12:12:03 jmcneill Exp $ */ +/* $NetBSD: gic_fdt.c,v 1.12 2018/07/15 13:34:43 jmcneill Exp $ */ /*- * Copyright (c) 2015-2017 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: gic_fdt.c,v 1.11 2018/07/03 12:12:03 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: gic_fdt.c,v 1.12 2018/07/15 13:34:43 jmcneill Exp $"); #include #include @@ -37,6 +37,7 @@ __KERNEL_RCSID(0, "$NetBSD: gic_fdt.c,v #include #include #include +#include #include #include @@ -238,28 +239,36 @@ gic_fdt_establish(device_t dev, u_int *s firqh->ih_arg = arg; TAILQ_INSERT_TAIL(>intr_handlers, firqh, ih_next); - return firqh; + return firq->intr_ih; } static void gic_fdt_disestablish(device_t dev, void *ih) { struct gic_fdt_softc * const sc = device_private(dev); - struct gic_fdt_irqhandler *firqh = ih; - struct gic_fdt_irq *firq = firqh->ih_irq; - const int irq = firq->intr_irq; + struct gic_fdt_irqhandler *firqh; + struct gic_fdt_irq *firq; + u_int n; + + for (n = 0; n < GIC_MAXIRQ; n++) { + firq = sc->sc_irq[n]; + if (firq->intr_ih != ih) + continue; - KASSERT(firq->intr_refcnt > 0); + KASSERT(firq->intr_refcnt > 0); - TAILQ_REMOVE(>intr_handlers, firqh, ih_next); - kmem_free(firqh, sizeof(*firqh)); + if (firq->intr_refcnt > 1) + panic("%s: cannot disestablish shared irq", __func__); - firq->intr_refcnt--; - if (firq->intr_refcnt == 0) { + firqh = TAILQ_FIRST(>intr_handlers); + kmem_free(firqh, sizeof(*firqh)); intr_disestablish(firq->intr_ih); kmem_free(firq, sizeof(*firq)); - sc->sc_irq[irq] = NULL; + sc->sc_irq[n] = NULL; + return; } + + panic("%s: interrupt not established", __func__); } static int
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Sat Jul 14 15:06:05 UTC 2018 Modified Files: src/sys/arch/arm/fdt: psci_fdt.c Log Message: Fix non-MULTIPROCESSOR build To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/fdt/psci_fdt.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/psci_fdt.c diff -u src/sys/arch/arm/fdt/psci_fdt.c:1.8 src/sys/arch/arm/fdt/psci_fdt.c:1.9 --- src/sys/arch/arm/fdt/psci_fdt.c:1.8 Mon Jul 9 09:13:20 2018 +++ src/sys/arch/arm/fdt/psci_fdt.c Sat Jul 14 15:06:05 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: psci_fdt.c,v 1.8 2018/07/09 09:13:20 jmcneill Exp $ */ +/* $NetBSD: psci_fdt.c,v 1.9 2018/07/14 15:06:05 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -29,7 +29,7 @@ #include "opt_multiprocessor.h" #include -__KERNEL_RCSID(0, "$NetBSD: psci_fdt.c,v 1.8 2018/07/09 09:13:20 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: psci_fdt.c,v 1.9 2018/07/14 15:06:05 jmcneill Exp $"); #include #include @@ -153,6 +153,7 @@ psci_fdt_preinit(void) return psci_fdt_init(phandle); } +#ifdef MULTIPROCESSOR static bus_addr_t psci_fdt_read_mpidr_aff(void) { #ifdef __aarch64__ @@ -173,6 +174,7 @@ psci_fdt_mpstart_pa(void) return (register_t)cortex_mpstart; #endif } +#endif void psci_fdt_bootstrap(void)
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Mon Jul 9 09:13:20 UTC 2018 Modified Files: src/sys/arch/arm/fdt: psci_fdt.c Log Message: Fix arm32 build To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/fdt/psci_fdt.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/psci_fdt.c diff -u src/sys/arch/arm/fdt/psci_fdt.c:1.7 src/sys/arch/arm/fdt/psci_fdt.c:1.8 --- src/sys/arch/arm/fdt/psci_fdt.c:1.7 Mon Jul 9 09:10:28 2018 +++ src/sys/arch/arm/fdt/psci_fdt.c Mon Jul 9 09:13:20 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: psci_fdt.c,v 1.7 2018/07/09 09:10:28 jmcneill Exp $ */ +/* $NetBSD: psci_fdt.c,v 1.8 2018/07/09 09:13:20 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -29,7 +29,7 @@ #include "opt_multiprocessor.h" #include -__KERNEL_RCSID(0, "$NetBSD: psci_fdt.c,v 1.7 2018/07/09 09:10:28 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: psci_fdt.c,v 1.8 2018/07/09 09:13:20 jmcneill Exp $"); #include #include @@ -169,6 +169,7 @@ psci_fdt_mpstart_pa(void) extern void aarch64_mpstart(void); return (register_t)aarch64_kern_vtophys(aarch64_mpstart); #else + extern void cortex_mpstart(void); return (register_t)cortex_mpstart; #endif }
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Mon Jul 9 09:10:29 UTC 2018 Modified Files: src/sys/arch/arm/fdt: psci_fdt.c Log Message: Add aarch64 support. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/fdt/psci_fdt.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/psci_fdt.c diff -u src/sys/arch/arm/fdt/psci_fdt.c:1.6 src/sys/arch/arm/fdt/psci_fdt.c:1.7 --- src/sys/arch/arm/fdt/psci_fdt.c:1.6 Sat Jul 7 15:11:07 2018 +++ src/sys/arch/arm/fdt/psci_fdt.c Mon Jul 9 09:10:28 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: psci_fdt.c,v 1.6 2018/07/07 15:11:07 jmcneill Exp $ */ +/* $NetBSD: psci_fdt.c,v 1.7 2018/07/09 09:10:28 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -29,13 +29,14 @@ #include "opt_multiprocessor.h" #include -__KERNEL_RCSID(0, "$NetBSD: psci_fdt.c,v 1.6 2018/07/07 15:11:07 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: psci_fdt.c,v 1.7 2018/07/09 09:10:28 jmcneill Exp $"); #include #include #include #include #include +#include #include @@ -152,13 +153,32 @@ psci_fdt_preinit(void) return psci_fdt_init(phandle); } +static bus_addr_t psci_fdt_read_mpidr_aff(void) +{ +#ifdef __aarch64__ + return reg_mpidr_el1_read() & (MPIDR_AFF3|MPIDR_AFF2|MPIDR_AFF1|MPIDR_AFF0); +#else + return armreg_mpidr_read() & (MPIDR_AFF2|MPIDR_AFF1|MPIDR_AFF0); +#endif +} + +static register_t +psci_fdt_mpstart_pa(void) +{ +#ifdef __aarch64__ + extern void aarch64_mpstart(void); + return (register_t)aarch64_kern_vtophys(aarch64_mpstart); +#else + return (register_t)cortex_mpstart; +#endif +} + void psci_fdt_bootstrap(void) { #ifdef MULTIPROCESSOR extern void cortex_mpstart(void); - bus_addr_t mpidr; - uint32_t bp_mpidr; + bus_addr_t mpidr, bp_mpidr; int child; const int cpus = OF_finddevice("/cpus"); @@ -178,7 +198,7 @@ psci_fdt_bootstrap(void) return; /* MPIDR affinity levels of boot processor. */ - bp_mpidr = armreg_mpidr_read() & (MPIDR_AFF2|MPIDR_AFF1|MPIDR_AFF0); + bp_mpidr = psci_fdt_read_mpidr_aff(); /* Boot APs */ uint32_t started = 0; @@ -191,20 +211,18 @@ psci_fdt_bootstrap(void) continue; /* BP already started */ /* XXX NetBSD requires all CPUs to be in the same cluster */ - const u_int bp_clid = __SHIFTOUT(bp_mpidr, CORTEXA9_MPIDR_CLID); - const u_int clid = __SHIFTOUT(mpidr, CORTEXA9_MPIDR_CLID); - if (bp_clid != clid) + if ((mpidr & ~MPIDR_AFF0) != (bp_mpidr & ~MPIDR_AFF0)) continue; - const u_int cpuid = __SHIFTOUT(mpidr, CORTEXA9_MPIDR_CPUID); - int ret = psci_cpu_on(cpuid, (register_t)cortex_mpstart, 0); + const u_int cpuid = __SHIFTOUT(mpidr, MPIDR_AFF0); + int ret = psci_cpu_on(cpuid, psci_fdt_mpstart_pa(), 0); if (ret == PSCI_SUCCESS) started |= __BIT(cpuid); } /* Wait for APs to start */ for (u_int i = 0x1000; i > 0; i--) { - arm_dmb(); + membar_consumer(); if (arm_cpu_hatched == started) break; }
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Sat Jul 7 15:11:07 UTC 2018 Modified Files: src/sys/arch/arm/fdt: psci_fdt.c Log Message: Switch to PSCI 0.1 mode only if the first compatible string listed on /psci is "arm,psci" To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/fdt/psci_fdt.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/psci_fdt.c diff -u src/sys/arch/arm/fdt/psci_fdt.c:1.5 src/sys/arch/arm/fdt/psci_fdt.c:1.6 --- src/sys/arch/arm/fdt/psci_fdt.c:1.5 Fri Jun 15 16:03:59 2018 +++ src/sys/arch/arm/fdt/psci_fdt.c Sat Jul 7 15:11:07 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: psci_fdt.c,v 1.5 2018/06/15 16:03:59 jakllsch Exp $ */ +/* $NetBSD: psci_fdt.c,v 1.6 2018/07/07 15:11:07 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -29,7 +29,7 @@ #include "opt_multiprocessor.h" #include -__KERNEL_RCSID(0, "$NetBSD: psci_fdt.c,v 1.5 2018/06/15 16:03:59 jakllsch Exp $"); +__KERNEL_RCSID(0, "$NetBSD: psci_fdt.c,v 1.6 2018/07/07 15:11:07 jmcneill Exp $"); #include #include @@ -108,15 +108,16 @@ psci_fdt_attach(device_t parent, device_ static int psci_fdt_init(const int phandle) { - char method[4]; + const char *method, *psciver; uint32_t val; - if (!of_hasprop(phandle, "method")) { - aprint_error("PSCI: missing 'method' property\n"); + method = fdtbus_get_string(phandle, "method"); + psciver = fdtbus_get_string(phandle, "compatible"); + if (method == NULL || psciver == NULL) { + aprint_error("PSCI: missing required property on /psci\n"); return EINVAL; } - OF_getprop(phandle, "method", method, sizeof(method)); if (strcmp(method, "smc") == 0) psci_init(psci_call_smc); else if (strcmp(method, "hvc") == 0) @@ -126,7 +127,11 @@ psci_fdt_init(const int phandle) return EINVAL; } - if (of_match_compatible(phandle, compatible) == 1) { + /* + * If the first compatible string is "arm,psci" then we + * are dealing with PSCI 0.1 + */ + if (strcmp(psciver, "arm,psci") == 0) { psci_clearfunc(); if (of_getprop_uint32(phandle, "cpu_on", ) == 0) psci_setfunc(PSCI_FUNC_CPU_ON, val);
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Tue Jul 3 12:12:03 UTC 2018 Modified Files: src/sys/arch/arm/fdt: gic_fdt.c Log Message: Make IRQ sharing work again To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/sys/arch/arm/fdt/gic_fdt.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/gic_fdt.c diff -u src/sys/arch/arm/fdt/gic_fdt.c:1.10 src/sys/arch/arm/fdt/gic_fdt.c:1.11 --- src/sys/arch/arm/fdt/gic_fdt.c:1.10 Wed Jun 20 05:50:09 2018 +++ src/sys/arch/arm/fdt/gic_fdt.c Tue Jul 3 12:12:03 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: gic_fdt.c,v 1.10 2018/06/20 05:50:09 hkenken Exp $ */ +/* $NetBSD: gic_fdt.c,v 1.11 2018/07/03 12:12:03 jmcneill Exp $ */ /*- * Copyright (c) 2015-2017 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: gic_fdt.c,v 1.10 2018/06/20 05:50:09 hkenken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: gic_fdt.c,v 1.11 2018/07/03 12:12:03 jmcneill Exp $"); #include #include @@ -75,6 +75,7 @@ struct gic_fdt_irqhandler { struct gic_fdt_irq { struct gic_fdt_softc *intr_sc; void *intr_ih; + void *intr_arg; int intr_refcnt; int intr_ipl; int intr_level; @@ -188,6 +189,7 @@ gic_fdt_establish(device_t dev, u_int *s firq = kmem_alloc(sizeof(*firq), KM_SLEEP); firq->intr_sc = sc; firq->intr_refcnt = 0; + firq->intr_arg = arg; firq->intr_ipl = ipl; firq->intr_level = level; firq->intr_mpsafe = mpsafe; @@ -206,7 +208,7 @@ gic_fdt_establish(device_t dev, u_int *s } sc->sc_irq[irq] = firq; } else { - if (arg) { + if (firq->intr_arg == NULL && arg != NULL) { device_printf(dev, "cannot share irq with NULL arg\n"); return NULL; }
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Mon Jul 2 16:36:50 UTC 2018 Modified Files: src/sys/arch/arm/fdt: cpu_fdt.c Log Message: Attach cpufreq scaling provider to ourself, as cpus doesn't do this anymore To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/fdt/cpu_fdt.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/cpu_fdt.c diff -u src/sys/arch/arm/fdt/cpu_fdt.c:1.7 src/sys/arch/arm/fdt/cpu_fdt.c:1.8 --- src/sys/arch/arm/fdt/cpu_fdt.c:1.7 Fri Jun 22 23:46:04 2018 +++ src/sys/arch/arm/fdt/cpu_fdt.c Mon Jul 2 16:36:49 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu_fdt.c,v 1.7 2018/06/22 23:46:04 jmcneill Exp $ */ +/* $NetBSD: cpu_fdt.c,v 1.8 2018/07/02 16:36:49 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cpu_fdt.c,v 1.7 2018/06/22 23:46:04 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu_fdt.c,v 1.8 2018/07/02 16:36:49 jmcneill Exp $"); #include #include @@ -146,4 +146,7 @@ cpu_fdt_attach(device_t parent, device_t /* Attach the CPU */ cpu_attach(self, cpuid); + + /* Attach CPU frequency scaling provider */ + config_found(self, faa, NULL); }
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Fri Jun 22 23:46:04 UTC 2018 Modified Files: src/sys/arch/arm/fdt: cpu_fdt.c Log Message: Match generic arm,arm-v8 compatible string To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/fdt/cpu_fdt.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/cpu_fdt.c diff -u src/sys/arch/arm/fdt/cpu_fdt.c:1.6 src/sys/arch/arm/fdt/cpu_fdt.c:1.7 --- src/sys/arch/arm/fdt/cpu_fdt.c:1.6 Fri Jun 15 14:27:57 2018 +++ src/sys/arch/arm/fdt/cpu_fdt.c Fri Jun 22 23:46:04 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu_fdt.c,v 1.6 2018/06/15 14:27:57 jakllsch Exp $ */ +/* $NetBSD: cpu_fdt.c,v 1.7 2018/06/22 23:46:04 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cpu_fdt.c,v 1.6 2018/06/15 14:27:57 jakllsch Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu_fdt.c,v 1.7 2018/06/22 23:46:04 jmcneill Exp $"); #include #include @@ -68,10 +68,12 @@ static const struct of_compat_data compa { "arm,cortex-a15", ARM_CPU_ARMV7 }, { "arm,cortex-a17", ARM_CPU_ARMV7 }, + { "arm,arm-v8", ARM_CPU_ARMV8 }, { "arm,cortex-a53", ARM_CPU_ARMV8 }, { "arm,cortex-a57", ARM_CPU_ARMV8 }, { "arm,cortex-a72", ARM_CPU_ARMV8 }, { "arm,cortex-a73", ARM_CPU_ARMV8 }, + { NULL } };
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: hkenken Date: Wed Jun 20 05:50:09 UTC 2018 Modified Files: src/sys/arch/arm/fdt: gic_fdt.c Log Message: Support Cortex-A9 (addr_d > addr_c). To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/fdt/gic_fdt.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/gic_fdt.c diff -u src/sys/arch/arm/fdt/gic_fdt.c:1.9 src/sys/arch/arm/fdt/gic_fdt.c:1.10 --- src/sys/arch/arm/fdt/gic_fdt.c:1.9 Wed Jun 6 19:49:51 2018 +++ src/sys/arch/arm/fdt/gic_fdt.c Wed Jun 20 05:50:09 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: gic_fdt.c,v 1.9 2018/06/06 19:49:51 jakllsch Exp $ */ +/* $NetBSD: gic_fdt.c,v 1.10 2018/06/20 05:50:09 hkenken Exp $ */ /*- * Copyright (c) 2015-2017 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: gic_fdt.c,v 1.9 2018/06/06 19:49:51 jakllsch Exp $"); +__KERNEL_RCSID(0, "$NetBSD: gic_fdt.c,v 1.10 2018/06/20 05:50:09 hkenken Exp $"); #include #include @@ -140,8 +140,9 @@ gic_fdt_attach(device_t parent, device_t return; } - const bus_addr_t addr = addr_d; - const bus_size_t size = (addr_c + size_c) - addr_d; + const bus_addr_t addr = min(addr_d, addr_c); + const bus_size_t end = max(addr_d + size_d, addr_c + size_c); + const bus_size_t size = end - addr; error = bus_space_map(faa->faa_bst, addr, size, 0, ); if (error) { @@ -153,8 +154,8 @@ gic_fdt_attach(device_t parent, device_t .mpcaa_name = "armgic", .mpcaa_memt = faa->faa_bst, .mpcaa_memh = bsh, - .mpcaa_off1 = 0, - .mpcaa_off2 = addr_c - addr_d + .mpcaa_off1 = addr_d - addr, + .mpcaa_off2 = addr_c - addr, }; config_found(self, , NULL);
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jakllsch Date: Fri Jun 15 16:03:59 UTC 2018 Modified Files: src/sys/arch/arm/fdt: psci_fdt.c Log Message: Fix PSCI 0.1 detection. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/fdt/psci_fdt.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/psci_fdt.c diff -u src/sys/arch/arm/fdt/psci_fdt.c:1.4 src/sys/arch/arm/fdt/psci_fdt.c:1.5 --- src/sys/arch/arm/fdt/psci_fdt.c:1.4 Sat May 26 22:49:03 2018 +++ src/sys/arch/arm/fdt/psci_fdt.c Fri Jun 15 16:03:59 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: psci_fdt.c,v 1.4 2018/05/26 22:49:03 jmcneill Exp $ */ +/* $NetBSD: psci_fdt.c,v 1.5 2018/06/15 16:03:59 jakllsch Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -29,7 +29,7 @@ #include "opt_multiprocessor.h" #include -__KERNEL_RCSID(0, "$NetBSD: psci_fdt.c,v 1.4 2018/05/26 22:49:03 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: psci_fdt.c,v 1.5 2018/06/15 16:03:59 jakllsch Exp $"); #include #include @@ -126,8 +126,7 @@ psci_fdt_init(const int phandle) return EINVAL; } - const char * const compat_0_1[] = { "arm,psci", NULL }; - if (of_match_compatible(phandle, compat_0_1)) { + if (of_match_compatible(phandle, compatible) == 1) { psci_clearfunc(); if (of_getprop_uint32(phandle, "cpu_on", ) == 0) psci_setfunc(PSCI_FUNC_CPU_ON, val);
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jakllsch Date: Fri Jun 15 14:27:57 UTC 2018 Modified Files: src/sys/arch/arm/fdt: cpu_fdt.c Log Message: Add "arm,arm-v7" to compatible strings. (for `qemu-system-arm -M virt`) To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/fdt/cpu_fdt.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/cpu_fdt.c diff -u src/sys/arch/arm/fdt/cpu_fdt.c:1.5 src/sys/arch/arm/fdt/cpu_fdt.c:1.6 --- src/sys/arch/arm/fdt/cpu_fdt.c:1.5 Sun Apr 1 04:35:04 2018 +++ src/sys/arch/arm/fdt/cpu_fdt.c Fri Jun 15 14:27:57 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu_fdt.c,v 1.5 2018/04/01 04:35:04 ryo Exp $ */ +/* $NetBSD: cpu_fdt.c,v 1.6 2018/06/15 14:27:57 jakllsch Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cpu_fdt.c,v 1.5 2018/04/01 04:35:04 ryo Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu_fdt.c,v 1.6 2018/06/15 14:27:57 jakllsch Exp $"); #include #include @@ -59,6 +59,7 @@ struct cpu_fdt_softc { static const struct of_compat_data compat_data[] = { { "arm,arm1176jzf-s", ARM_CPU_UP }, + { "arm,arm-v7", ARM_CPU_ARMV7 }, { "arm,cortex-a5", ARM_CPU_ARMV7 }, { "arm,cortex-a7", ARM_CPU_ARMV7 }, { "arm,cortex-a8", ARM_CPU_ARMV7 },
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jakllsch Date: Fri Jun 15 14:25:22 UTC 2018 Modified Files: src/sys/arch/arm/fdt: fdt_intr.h Log Message: Bump PIC_MAXSOURCES to 352. (`qemu-system-arm -M virt` currently needs 288) To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/fdt/fdt_intr.h 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/fdt_intr.h diff -u src/sys/arch/arm/fdt/fdt_intr.h:1.2 src/sys/arch/arm/fdt/fdt_intr.h:1.3 --- src/sys/arch/arm/fdt/fdt_intr.h:1.2 Fri Aug 25 00:07:02 2017 +++ src/sys/arch/arm/fdt/fdt_intr.h Fri Jun 15 14:25:22 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: fdt_intr.h,v 1.2 2017/08/25 00:07:02 jmcneill Exp $ */ +/* $NetBSD: fdt_intr.h,v 1.3 2018/06/15 14:25:22 jakllsch Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -36,7 +36,7 @@ #define __HAVE_PIC_SET_PRIORITY #define __HAVE_PIC_PENDING_INTRS -#define PIC_MAXSOURCES 256 +#define PIC_MAXSOURCES 352 #define PIC_MAXMAXSOURCES (PIC_MAXSOURCES + 32) void arm_fdt_irq_set_handler(void (*)(void *));
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jakllsch Date: Wed Jun 6 19:49:51 UTC 2018 Modified Files: src/sys/arch/arm/fdt: gic_fdt.c Log Message: more completely gic_fdt_disestablish() such that it's possible to re-establish later To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/fdt/gic_fdt.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/gic_fdt.c diff -u src/sys/arch/arm/fdt/gic_fdt.c:1.8 src/sys/arch/arm/fdt/gic_fdt.c:1.9 --- src/sys/arch/arm/fdt/gic_fdt.c:1.8 Thu Nov 30 14:42:37 2017 +++ src/sys/arch/arm/fdt/gic_fdt.c Wed Jun 6 19:49:51 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: gic_fdt.c,v 1.8 2017/11/30 14:42:37 skrll Exp $ */ +/* $NetBSD: gic_fdt.c,v 1.9 2018/06/06 19:49:51 jakllsch Exp $ */ /*- * Copyright (c) 2015-2017 Jared McNeill @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: gic_fdt.c,v 1.8 2017/11/30 14:42:37 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: gic_fdt.c,v 1.9 2018/06/06 19:49:51 jakllsch Exp $"); #include #include @@ -80,6 +80,7 @@ struct gic_fdt_irq { int intr_level; int intr_mpsafe; TAILQ_HEAD(, gic_fdt_irqhandler) intr_handlers; + int intr_irq; }; struct gic_fdt_softc { @@ -190,6 +191,7 @@ gic_fdt_establish(device_t dev, u_int *s firq->intr_level = level; firq->intr_mpsafe = mpsafe; TAILQ_INIT(>intr_handlers); + firq->intr_irq = irq; if (arg == NULL) { firq->intr_ih = intr_establish(irq, ipl, level | mpsafe, func, NULL); @@ -239,8 +241,10 @@ gic_fdt_establish(device_t dev, u_int *s static void gic_fdt_disestablish(device_t dev, void *ih) { + struct gic_fdt_softc * const sc = device_private(dev); struct gic_fdt_irqhandler *firqh = ih; struct gic_fdt_irq *firq = firqh->ih_irq; + const int irq = firq->intr_irq; KASSERT(firq->intr_refcnt > 0); @@ -251,6 +255,7 @@ gic_fdt_disestablish(device_t dev, void if (firq->intr_refcnt == 0) { intr_disestablish(firq->intr_ih); kmem_free(firq, sizeof(*firq)); + sc->sc_irq[irq] = NULL; } }
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Sat May 26 22:49:03 UTC 2018 Modified Files: src/sys/arch/arm/fdt: psci_fdt.c psci_fdt.h Log Message: Export a psci_fdt_reset function, usable from FDT platform code. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/fdt/psci_fdt.c cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/fdt/psci_fdt.h 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/psci_fdt.c diff -u src/sys/arch/arm/fdt/psci_fdt.c:1.3 src/sys/arch/arm/fdt/psci_fdt.c:1.4 --- src/sys/arch/arm/fdt/psci_fdt.c:1.3 Mon Sep 11 09:21:56 2017 +++ src/sys/arch/arm/fdt/psci_fdt.c Sat May 26 22:49:03 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: psci_fdt.c,v 1.3 2017/09/11 09:21:56 jmcneill Exp $ */ +/* $NetBSD: psci_fdt.c,v 1.4 2018/05/26 22:49:03 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared McNeill@@ -29,7 +29,7 @@ #include "opt_multiprocessor.h" #include -__KERNEL_RCSID(0, "$NetBSD: psci_fdt.c,v 1.3 2017/09/11 09:21:56 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: psci_fdt.c,v 1.4 2018/05/26 22:49:03 jmcneill Exp $"); #include #include @@ -60,22 +60,22 @@ static const char * const compatible[] = CFATTACH_DECL_NEW(psci_fdt, 0, psci_fdt_match, psci_fdt_attach, NULL, NULL); static void -psci_fdt_reset(device_t dev) +psci_fdt_power_reset(device_t dev) { delay(50); psci_system_reset(); } static void -psci_fdt_poweroff(device_t dev) +psci_fdt_power_poweroff(device_t dev) { delay(50); psci_system_off(); } static const struct fdtbus_power_controller_func psci_power_funcs = { - .reset = psci_fdt_reset, - .poweroff = psci_fdt_poweroff, + .reset = psci_fdt_power_reset, + .poweroff = psci_fdt_power_poweroff, }; static int @@ -136,6 +136,18 @@ psci_fdt_init(const int phandle) return 0; } +static int +psci_fdt_preinit(void) +{ + const int phandle = OF_finddevice("/psci"); + if (phandle == -1) { + aprint_error("PSCI: no /psci node found\n"); + return ENODEV; + } + + return psci_fdt_init(phandle); +} + void psci_fdt_bootstrap(void) { @@ -158,13 +170,7 @@ psci_fdt_bootstrap(void) if (fdtbus_status_okay(child)) arm_cpu_max++; - const int phandle = OF_finddevice("/psci"); - if (phandle == -1) { - aprint_error("PSCI: no /psci node found\n"); - return; - } - - if (psci_fdt_init(phandle) != 0) + if (psci_fdt_preinit() != 0) return; /* MPIDR affinity levels of boot processor. */ @@ -200,3 +206,14 @@ psci_fdt_bootstrap(void) } #endif } + +void +psci_fdt_reset(void) +{ + if (psci_fdt_preinit() != 0) { + aprint_error("PSCI: reset failed\n"); + return; + } + + psci_system_reset(); +} Index: src/sys/arch/arm/fdt/psci_fdt.h diff -u src/sys/arch/arm/fdt/psci_fdt.h:1.1 src/sys/arch/arm/fdt/psci_fdt.h:1.2 --- src/sys/arch/arm/fdt/psci_fdt.h:1.1 Wed Jun 28 23:48:22 2017 +++ src/sys/arch/arm/fdt/psci_fdt.h Sat May 26 22:49:03 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: psci_fdt.h,v 1.1 2017/06/28 23:48:22 jmcneill Exp $ */ +/* $NetBSD: psci_fdt.h,v 1.2 2018/05/26 22:49:03 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -32,4 +32,7 @@ /* Initialize PSCI and boot APs */ void psci_fdt_bootstrap(void); +/* Board reset */ +void psci_fdt_reset(void); + #endif /* !_ARM_PSCI_FDT_H */
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: skrll Date: Thu Nov 30 14:51:01 UTC 2017 Modified Files: src/sys/arch/arm/fdt: gtmr_fdt.c Log Message: typo To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/fdt/gtmr_fdt.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/gtmr_fdt.c diff -u src/sys/arch/arm/fdt/gtmr_fdt.c:1.6 src/sys/arch/arm/fdt/gtmr_fdt.c:1.7 --- src/sys/arch/arm/fdt/gtmr_fdt.c:1.6 Thu Nov 30 14:50:34 2017 +++ src/sys/arch/arm/fdt/gtmr_fdt.c Thu Nov 30 14:51:01 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: gtmr_fdt.c,v 1.6 2017/11/30 14:50:34 skrll Exp $ */ +/* $NetBSD: gtmr_fdt.c,v 1.7 2017/11/30 14:51:01 skrll Exp $ */ /*- * Copyright (c) 2017 Jared McNeill@@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: gtmr_fdt.c,v 1.6 2017/11/30 14:50:34 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: gtmr_fdt.c,v 1.7 2017/11/30 14:51:01 skrll Exp $"); #include #include @@ -51,7 +51,7 @@ static void gtmr_fdt_cpu_hatch(void *, s CFATTACH_DECL_NEW(gtmr_fdt, 0, gtmr_fdt_match, gtmr_fdt_attach, NULL, NULL); -/* The vritual timer list entry */ +/* The virtual timer list entry */ #define GTMR_VTIMER 2 static int
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: skrll Date: Thu Nov 30 14:42:37 UTC 2017 Modified Files: src/sys/arch/arm/fdt: gic_fdt.c Log Message: Handle NULL arg interrupt handlers that want the clock frame. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/fdt/gic_fdt.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/gic_fdt.c diff -u src/sys/arch/arm/fdt/gic_fdt.c:1.7 src/sys/arch/arm/fdt/gic_fdt.c:1.8 --- src/sys/arch/arm/fdt/gic_fdt.c:1.7 Sun Jul 2 21:59:14 2017 +++ src/sys/arch/arm/fdt/gic_fdt.c Thu Nov 30 14:42:37 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: gic_fdt.c,v 1.7 2017/07/02 21:59:14 jmcneill Exp $ */ +/* $NetBSD: gic_fdt.c,v 1.8 2017/11/30 14:42:37 skrll Exp $ */ /*- * Copyright (c) 2015-2017 Jared McNeill@@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: gic_fdt.c,v 1.7 2017/07/02 21:59:14 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: gic_fdt.c,v 1.8 2017/11/30 14:42:37 skrll Exp $"); #include #include @@ -190,26 +190,38 @@ gic_fdt_establish(device_t dev, u_int *s firq->intr_level = level; firq->intr_mpsafe = mpsafe; TAILQ_INIT(>intr_handlers); - firq->intr_ih = intr_establish(irq, ipl, level | mpsafe, - gic_fdt_intr, firq); + if (arg == NULL) { + firq->intr_ih = intr_establish(irq, ipl, level | mpsafe, + func, NULL); + } else { + firq->intr_ih = intr_establish(irq, ipl, level | mpsafe, + gic_fdt_intr, firq); + } if (firq->intr_ih == NULL) { kmem_free(firq, sizeof(*firq)); return NULL; } sc->sc_irq[irq] = firq; - } - - if (firq->intr_ipl != ipl) { - device_printf(dev, "cannot share irq with different ipl\n"); - return NULL; - } - if (firq->intr_level != level) { - device_printf(dev, "cannot share edge and level interrupts\n"); - return NULL; - } - if (firq->intr_mpsafe != mpsafe) { - device_printf(dev, "cannot share between mpsafe/non-mpsafe\n"); - return NULL; + } else { + if (arg) { + device_printf(dev, "cannot share irq with NULL arg\n"); + return NULL; + } + if (firq->intr_ipl != ipl) { + device_printf(dev, "cannot share irq with different " + "ipl\n"); + return NULL; + } + if (firq->intr_level != level) { + device_printf(dev, "cannot share edge and level " + "interrupts\n"); + return NULL; + } + if (firq->intr_mpsafe != mpsafe) { + device_printf(dev, "cannot share between " + "mpsafe/non-mpsafe\n"); + return NULL; + } } firq->intr_refcnt++;
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: skrll Date: Thu Sep 21 19:28:37 UTC 2017 Modified Files: src/sys/arch/arm/fdt: arm_fdt.c Log Message: Spaces to TABs To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/fdt/arm_fdt.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/arm_fdt.c diff -u src/sys/arch/arm/fdt/arm_fdt.c:1.5 src/sys/arch/arm/fdt/arm_fdt.c:1.6 --- src/sys/arch/arm/fdt/arm_fdt.c:1.5 Thu Aug 24 13:06:23 2017 +++ src/sys/arch/arm/fdt/arm_fdt.c Thu Sep 21 19:28:37 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: arm_fdt.c,v 1.5 2017/08/24 13:06:23 jmcneill Exp $ */ +/* $NetBSD: arm_fdt.c,v 1.6 2017/09/21 19:28:37 skrll Exp $ */ /*- * Copyright (c) 2017 Jared D. McNeill@@ -29,7 +29,7 @@ #include "opt_arm_timer.h" #include -__KERNEL_RCSID(0, "$NetBSD: arm_fdt.c,v 1.5 2017/08/24 13:06:23 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: arm_fdt.c,v 1.6 2017/09/21 19:28:37 skrll Exp $"); #include #include @@ -173,8 +173,8 @@ arm_fdt_memory_dump(paddr_t pa) bus_space_map(bst, pa, 0x100, 0, ); for (int i = 0; i < 0x100; i += 0x10) { -printf("%" PRIxPTR ": %08x %08x %08x %08x\n", -(uintptr_t)(pa + i), + printf("%" PRIxPTR ": %08x %08x %08x %08x\n", + (uintptr_t)(pa + i), bus_space_read_4(bst, bsh, i + 0), bus_space_read_4(bst, bsh, i + 4), bus_space_read_4(bst, bsh, i + 8),
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Mon Sep 18 16:58:04 UTC 2017 Modified Files: src/sys/arch/arm/fdt: cpu_fdt.c Log Message: Add support for arm,arm1176jzf-s To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/fdt/cpu_fdt.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/cpu_fdt.c diff -u src/sys/arch/arm/fdt/cpu_fdt.c:1.2 src/sys/arch/arm/fdt/cpu_fdt.c:1.3 --- src/sys/arch/arm/fdt/cpu_fdt.c:1.2 Sun Jun 18 23:20:20 2017 +++ src/sys/arch/arm/fdt/cpu_fdt.c Mon Sep 18 16:58:04 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu_fdt.c,v 1.2 2017/06/18 23:20:20 jmcneill Exp $ */ +/* $NetBSD: cpu_fdt.c,v 1.3 2017/09/18 16:58:04 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared McNeill@@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cpu_fdt.c,v 1.2 2017/06/18 23:20:20 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu_fdt.c,v 1.3 2017/09/18 16:58:04 jmcneill Exp $"); #include #include @@ -42,47 +42,67 @@ __KERNEL_RCSID(0, "$NetBSD: cpu_fdt.c,v static int cpu_fdt_match(device_t, cfdata_t, void *); static void cpu_fdt_attach(device_t, device_t, void *); +enum cpu_fdt_type { + ARM_CPU_UP = 1, + ARM_CPU_ARMV7, + ARM_CPU_ARMV8, +}; + struct cpu_fdt_softc { device_t sc_dev; int sc_phandle; }; +static const struct of_compat_data compat_data[] = { + { "arm,arm1176jzf-s", ARM_CPU_UP }, + + { "arm,cortex-a5", ARM_CPU_ARMV7 }, + { "arm,cortex-a7", ARM_CPU_ARMV7 }, + { "arm,cortex-a8", ARM_CPU_ARMV7 }, + { "arm,cortex-a9", ARM_CPU_ARMV7 }, + { "arm,cortex-a12", ARM_CPU_ARMV7 }, + { "arm,cortex-a15", ARM_CPU_ARMV7 }, + { "arm,cortex-a17", ARM_CPU_ARMV7 }, + + { "arm,cortex-a53", ARM_CPU_ARMV8 }, + { "arm,cortex-a57", ARM_CPU_ARMV8 }, + { "arm,cortex-a72", ARM_CPU_ARMV8 }, + { "arm,cortex-a73", ARM_CPU_ARMV8 }, + { NULL } +}; + CFATTACH_DECL_NEW(cpu_fdt, sizeof(struct cpu_fdt_softc), cpu_fdt_match, cpu_fdt_attach, NULL, NULL); static int cpu_fdt_match(device_t parent, cfdata_t cf, void *aux) { - const char * const compatible[] = { - "arm,cortex-a5", - "arm,cortex-a7", - "arm,cortex-a8", - "arm,cortex-a9", - "arm,cortex-a12", - "arm,cortex-a15", - "arm,cortex-a17", - "arm,cortex-a53", - "arm,cortex-a57", - "arm,cortex-a72", - "arm,cortex-a73", - NULL - }; struct fdt_attach_args * const faa = aux; + const int phandle = faa->faa_phandle; + enum cpu_fdt_type type; int is_compatible; bus_addr_t mpidr; - is_compatible = of_match_compatible(faa->faa_phandle, compatible); + is_compatible = of_match_compat_data(phandle, compat_data); if (!is_compatible) return 0; - /* XXX NetBSD requires all CPUs to be in the same cluster */ - if (fdtbus_get_reg(faa->faa_phandle, 0, , NULL) != 0) - return 0; - const uint32_t bp_mpidr = armreg_mpidr_read(); - const u_int bp_clid = __SHIFTOUT(bp_mpidr, CORTEXA9_MPIDR_CLID); - const u_int clid = __SHIFTOUT(mpidr, CORTEXA9_MPIDR_CLID); - if (bp_clid != clid) - return 0; + type = of_search_compatible(phandle, compat_data)->data; + switch (type) { + case ARM_CPU_ARMV7: + case ARM_CPU_ARMV8: + /* XXX NetBSD requires all CPUs to be in the same cluster */ + if (fdtbus_get_reg(phandle, 0, , NULL) != 0) + return 0; + const uint32_t bp_mpidr = armreg_mpidr_read(); + const u_int bp_clid = __SHIFTOUT(bp_mpidr, CORTEXA9_MPIDR_CLID); + const u_int clid = __SHIFTOUT(mpidr, CORTEXA9_MPIDR_CLID); + if (bp_clid != clid) + return 0; + break; + default: + break; + } return is_compatible; } @@ -92,16 +112,30 @@ cpu_fdt_attach(device_t parent, device_t { struct cpu_fdt_softc * const sc = device_private(self); struct fdt_attach_args * const faa = aux; + const int phandle = faa->faa_phandle; + enum cpu_fdt_type type; bus_addr_t mpidr; + cpuid_t cpuid; sc->sc_dev = self; - sc->sc_phandle = faa->faa_phandle; + sc->sc_phandle = phandle; + + type = of_search_compatible(phandle, compat_data)->data; - if (fdtbus_get_reg(sc->sc_phandle, 0, , NULL) != 0) { - aprint_error(": missing 'reg' property\n"); - return; + switch (type) { + case ARM_CPU_ARMV7: + case ARM_CPU_ARMV8: + if (fdtbus_get_reg(phandle, 0, , NULL) != 0) { + aprint_error(": missing 'reg' property\n"); + return; + } + cpuid = __SHIFTOUT(mpidr, CORTEXA9_MPIDR_CPUID); + break; + default: + cpuid = 0; + break; } /* Attach the CPU */ - cpu_attach(self, __SHIFTOUT(mpidr, CORTEXA9_MPIDR_CPUID)); + cpu_attach(self, cpuid); }
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Mon Sep 11 09:21:56 UTC 2017 Modified Files: src/sys/arch/arm/fdt: psci_fdt.c Log Message: Use PSCI for reset and poweroff when available. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/fdt/psci_fdt.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/psci_fdt.c diff -u src/sys/arch/arm/fdt/psci_fdt.c:1.2 src/sys/arch/arm/fdt/psci_fdt.c:1.3 --- src/sys/arch/arm/fdt/psci_fdt.c:1.2 Sat Aug 5 11:58:19 2017 +++ src/sys/arch/arm/fdt/psci_fdt.c Mon Sep 11 09:21:56 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: psci_fdt.c,v 1.2 2017/08/05 11:58:19 jmcneill Exp $ */ +/* $NetBSD: psci_fdt.c,v 1.3 2017/09/11 09:21:56 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared McNeill@@ -29,7 +29,7 @@ #include "opt_multiprocessor.h" #include -__KERNEL_RCSID(0, "$NetBSD: psci_fdt.c,v 1.2 2017/08/05 11:58:19 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: psci_fdt.c,v 1.3 2017/09/11 09:21:56 jmcneill Exp $"); #include #include @@ -59,6 +59,25 @@ static const char * const compatible[] = CFATTACH_DECL_NEW(psci_fdt, 0, psci_fdt_match, psci_fdt_attach, NULL, NULL); +static void +psci_fdt_reset(device_t dev) +{ + delay(50); + psci_system_reset(); +} + +static void +psci_fdt_poweroff(device_t dev) +{ + delay(50); + psci_system_off(); +} + +static const struct fdtbus_power_controller_func psci_power_funcs = { + .reset = psci_fdt_reset, + .poweroff = psci_fdt_poweroff, +}; + static int psci_fdt_match(device_t parent, cfdata_t cf, void *aux) { @@ -81,6 +100,9 @@ psci_fdt_attach(device_t parent, device_ aprint_naive("\n"); aprint_normal(": PSCI %u.%u\n", ver_maj, ver_min); + + fdtbus_register_power_controller(self, phandle, + _power_funcs); } static int
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Sat Aug 5 11:58:19 UTC 2017 Modified Files: src/sys/arch/arm/fdt: psci_fdt.c Log Message: Wrap MP-specific code in ifdef MULTIPROCESSOR To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/fdt/psci_fdt.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/psci_fdt.c diff -u src/sys/arch/arm/fdt/psci_fdt.c:1.1 src/sys/arch/arm/fdt/psci_fdt.c:1.2 --- src/sys/arch/arm/fdt/psci_fdt.c:1.1 Wed Jun 28 23:48:22 2017 +++ src/sys/arch/arm/fdt/psci_fdt.c Sat Aug 5 11:58:19 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: psci_fdt.c,v 1.1 2017/06/28 23:48:22 jmcneill Exp $ */ +/* $NetBSD: psci_fdt.c,v 1.2 2017/08/05 11:58:19 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared McNeill@@ -26,8 +26,10 @@ * SUCH DAMAGE. */ +#include "opt_multiprocessor.h" + #include -__KERNEL_RCSID(0, "$NetBSD: psci_fdt.c,v 1.1 2017/06/28 23:48:22 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: psci_fdt.c,v 1.2 2017/08/05 11:58:19 jmcneill Exp $"); #include #include @@ -115,6 +117,7 @@ psci_fdt_init(const int phandle) void psci_fdt_bootstrap(void) { +#ifdef MULTIPROCESSOR extern void cortex_mpstart(void); bus_addr_t mpidr; uint32_t bp_mpidr; @@ -173,4 +176,5 @@ psci_fdt_bootstrap(void) if (arm_cpu_hatched == started) break; } +#endif }
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Thu Jul 20 01:52:17 UTC 2017 Modified Files: src/sys/arch/arm/fdt: gtmr_fdt.c Log Message: Match arm,armv8-timer compat string To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/fdt/gtmr_fdt.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/gtmr_fdt.c diff -u src/sys/arch/arm/fdt/gtmr_fdt.c:1.3 src/sys/arch/arm/fdt/gtmr_fdt.c:1.4 --- src/sys/arch/arm/fdt/gtmr_fdt.c:1.3 Tue May 30 22:00:25 2017 +++ src/sys/arch/arm/fdt/gtmr_fdt.c Thu Jul 20 01:52:17 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: gtmr_fdt.c,v 1.3 2017/05/30 22:00:25 jmcneill Exp $ */ +/* $NetBSD: gtmr_fdt.c,v 1.4 2017/07/20 01:52:17 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared McNeill@@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: gtmr_fdt.c,v 1.3 2017/05/30 22:00:25 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: gtmr_fdt.c,v 1.4 2017/07/20 01:52:17 jmcneill Exp $"); #include #include @@ -56,6 +56,7 @@ gtmr_fdt_match(device_t parent, cfdata_t { const char * const compatible[] = { "arm,armv7-timer", + "arm,armv8-timer", NULL }; struct fdt_attach_args * const faa = aux;
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Sun Jul 2 21:59:14 UTC 2017 Modified Files: src/sys/arch/arm/fdt: gic_fdt.c Log Message: Disallow sharing between MPSAFE and non-MPSAFE handlers. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/fdt/gic_fdt.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/gic_fdt.c diff -u src/sys/arch/arm/fdt/gic_fdt.c:1.6 src/sys/arch/arm/fdt/gic_fdt.c:1.7 --- src/sys/arch/arm/fdt/gic_fdt.c:1.6 Thu Jun 29 20:54:28 2017 +++ src/sys/arch/arm/fdt/gic_fdt.c Sun Jul 2 21:59:14 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: gic_fdt.c,v 1.6 2017/06/29 20:54:28 jmcneill Exp $ */ +/* $NetBSD: gic_fdt.c,v 1.7 2017/07/02 21:59:14 jmcneill Exp $ */ /*- * Copyright (c) 2015-2017 Jared McNeill@@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: gic_fdt.c,v 1.6 2017/06/29 20:54:28 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: gic_fdt.c,v 1.7 2017/07/02 21:59:14 jmcneill Exp $"); #include #include @@ -78,6 +78,7 @@ struct gic_fdt_irq { int intr_refcnt; int intr_ipl; int intr_level; + int intr_mpsafe; TAILQ_HEAD(, gic_fdt_irqhandler) intr_handlers; }; @@ -178,6 +179,8 @@ gic_fdt_establish(device_t dev, u_int *s const u_int trig = be32toh(specifier[2]) & 0xf; const u_int level = (trig & 0x3) ? IST_EDGE : IST_LEVEL; + const u_int mpsafe = (flags & FDT_INTR_MPSAFE) ? IST_MPSAFE : 0; + firq = sc->sc_irq[irq]; if (firq == NULL) { firq = kmem_alloc(sizeof(*firq), KM_SLEEP); @@ -185,8 +188,9 @@ gic_fdt_establish(device_t dev, u_int *s firq->intr_refcnt = 0; firq->intr_ipl = ipl; firq->intr_level = level; + firq->intr_mpsafe = mpsafe; TAILQ_INIT(>intr_handlers); - firq->intr_ih = intr_establish(irq, ipl, level | IST_MPSAFE, + firq->intr_ih = intr_establish(irq, ipl, level | mpsafe, gic_fdt_intr, firq); if (firq->intr_ih == NULL) { kmem_free(firq, sizeof(*firq)); @@ -203,6 +207,10 @@ gic_fdt_establish(device_t dev, u_int *s device_printf(dev, "cannot share edge and level interrupts\n"); return NULL; } + if (firq->intr_mpsafe != mpsafe) { + device_printf(dev, "cannot share between mpsafe/non-mpsafe\n"); + return NULL; + } firq->intr_refcnt++; @@ -241,13 +249,8 @@ gic_fdt_intr(void *priv) struct gic_fdt_irqhandler *firqh; int handled = 0; - TAILQ_FOREACH(firqh, >intr_handlers, ih_next) { - if (!firqh->ih_mpsafe) - KERNEL_LOCK(1, curlwp); + TAILQ_FOREACH(firqh, >intr_handlers, ih_next) handled += firqh->ih_fn(firqh->ih_arg); - if (!firqh->ih_mpsafe) - KERNEL_UNLOCK_ONE(curlwp); - } return handled; }
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Thu Jun 29 20:55:10 UTC 2017 Modified Files: src/sys/arch/arm/fdt: arm_fdt.c arm_fdtvar.h Log Message: Add arm_fdt_memory_dump helper for dumping physical addresses from ddb To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/fdt/arm_fdt.c cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/fdt/arm_fdtvar.h 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/arm_fdt.c diff -u src/sys/arch/arm/fdt/arm_fdt.c:1.3 src/sys/arch/arm/fdt/arm_fdt.c:1.4 --- src/sys/arch/arm/fdt/arm_fdt.c:1.3 Tue May 30 22:00:25 2017 +++ src/sys/arch/arm/fdt/arm_fdt.c Thu Jun 29 20:55:10 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: arm_fdt.c,v 1.3 2017/05/30 22:00:25 jmcneill Exp $ */ +/* $NetBSD: arm_fdt.c,v 1.4 2017/06/29 20:55:10 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared D. McNeill@@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: arm_fdt.c,v 1.3 2017/05/30 22:00:25 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: arm_fdt.c,v 1.4 2017/06/29 20:55:10 jmcneill Exp $"); #include #include @@ -143,3 +143,26 @@ arm_fdt_irq_handler(void *tf) { _arm_fdt_irq_handler(tf); } + +void +arm_fdt_memory_dump(paddr_t pa) +{ + const struct arm_platform *plat = arm_fdt_platform(); + struct fdt_attach_args faa; + bus_space_tag_t bst; + bus_space_handle_t bsh; + + plat->init_attach_args(); + + bst = faa.faa_bst; + bus_space_map(bst, pa, 0x100, 0, ); + + for (int i = 0; i < 0x100; i += 0x10) { +printf("%" PRIxPTR ": %08x %08x %08x %08x\n", +(uintptr_t)(pa + i), + bus_space_read_4(bst, bsh, i + 0), + bus_space_read_4(bst, bsh, i + 4), + bus_space_read_4(bst, bsh, i + 8), + bus_space_read_4(bst, bsh, i + 12)); + } +} Index: src/sys/arch/arm/fdt/arm_fdtvar.h diff -u src/sys/arch/arm/fdt/arm_fdtvar.h:1.5 src/sys/arch/arm/fdt/arm_fdtvar.h:1.6 --- src/sys/arch/arm/fdt/arm_fdtvar.h:1.5 Fri Jun 2 13:53:28 2017 +++ src/sys/arch/arm/fdt/arm_fdtvar.h Thu Jun 29 20:55:10 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: arm_fdtvar.h,v 1.5 2017/06/02 13:53:28 jmcneill Exp $ */ +/* $NetBSD: arm_fdtvar.h,v 1.6 2017/06/29 20:55:10 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared D. McNeill @@ -71,4 +71,6 @@ voidarm_fdt_cpu_hatch(struct cpu_inf void arm_fdt_irq_set_handler(void (*)(void *)); void arm_fdt_irq_handler(void *); +void arm_fdt_memory_dump(paddr_t); + #endif /* !_ARM_ARM_FDTVAR_H */
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Thu Jun 29 20:54:28 UTC 2017 Modified Files: src/sys/arch/arm/fdt: gic_fdt.c Log Message: Don't allow sharing edge and level triggered interrupts. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/fdt/gic_fdt.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/gic_fdt.c diff -u src/sys/arch/arm/fdt/gic_fdt.c:1.5 src/sys/arch/arm/fdt/gic_fdt.c:1.6 --- src/sys/arch/arm/fdt/gic_fdt.c:1.5 Wed Jun 28 23:49:29 2017 +++ src/sys/arch/arm/fdt/gic_fdt.c Thu Jun 29 20:54:28 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: gic_fdt.c,v 1.5 2017/06/28 23:49:29 jmcneill Exp $ */ +/* $NetBSD: gic_fdt.c,v 1.6 2017/06/29 20:54:28 jmcneill Exp $ */ /*- * Copyright (c) 2015-2017 Jared McNeill@@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: gic_fdt.c,v 1.5 2017/06/28 23:49:29 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: gic_fdt.c,v 1.6 2017/06/29 20:54:28 jmcneill Exp $"); #include #include @@ -77,6 +77,7 @@ struct gic_fdt_irq { void *intr_ih; int intr_refcnt; int intr_ipl; + int intr_level; TAILQ_HEAD(, gic_fdt_irqhandler) intr_handlers; }; @@ -183,6 +184,7 @@ gic_fdt_establish(device_t dev, u_int *s firq->intr_sc = sc; firq->intr_refcnt = 0; firq->intr_ipl = ipl; + firq->intr_level = level; TAILQ_INIT(>intr_handlers); firq->intr_ih = intr_establish(irq, ipl, level | IST_MPSAFE, gic_fdt_intr, firq); @@ -197,6 +199,10 @@ gic_fdt_establish(device_t dev, u_int *s device_printf(dev, "cannot share irq with different ipl\n"); return NULL; } + if (firq->intr_level != level) { + device_printf(dev, "cannot share edge and level interrupts\n"); + return NULL; + } firq->intr_refcnt++;
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Wed Jun 28 23:49:30 UTC 2017 Modified Files: src/sys/arch/arm/fdt: gic_fdt.c Log Message: Support interrupt sharing. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/fdt/gic_fdt.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/gic_fdt.c diff -u src/sys/arch/arm/fdt/gic_fdt.c:1.4 src/sys/arch/arm/fdt/gic_fdt.c:1.5 --- src/sys/arch/arm/fdt/gic_fdt.c:1.4 Tue May 30 22:00:25 2017 +++ src/sys/arch/arm/fdt/gic_fdt.c Wed Jun 28 23:49:29 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: gic_fdt.c,v 1.4 2017/05/30 22:00:25 jmcneill Exp $ */ +/* $NetBSD: gic_fdt.c,v 1.5 2017/06/28 23:49:29 jmcneill Exp $ */ /*- * Copyright (c) 2015-2017 Jared McNeill@@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: gic_fdt.c,v 1.4 2017/05/30 22:00:25 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: gic_fdt.c,v 1.5 2017/06/28 23:49:29 jmcneill Exp $"); #include #include @@ -35,6 +35,7 @@ __KERNEL_RCSID(0, "$NetBSD: gic_fdt.c,v #include #include #include +#include #include #include @@ -42,9 +43,13 @@ __KERNEL_RCSID(0, "$NetBSD: gic_fdt.c,v #include +#define GIC_MAXIRQ 1020 + static int gic_fdt_match(device_t, cfdata_t, void *); static void gic_fdt_attach(device_t, device_t, void *); +static int gic_fdt_intr(void *); + static void * gic_fdt_establish(device_t, u_int *, int, int, int (*)(void *), void *); static void gic_fdt_disestablish(device_t, void *); @@ -56,9 +61,30 @@ struct fdtbus_interrupt_controller_func .intrstr = gic_fdt_intrstr }; +struct gic_fdt_softc; +struct gic_fdt_irq; + +struct gic_fdt_irqhandler { + struct gic_fdt_irq *ih_irq; + int (*ih_fn)(void *); + void *ih_arg; + bool ih_mpsafe; + TAILQ_ENTRY(gic_fdt_irqhandler) ih_next; +}; + +struct gic_fdt_irq { + struct gic_fdt_softc *intr_sc; + void *intr_ih; + int intr_refcnt; + int intr_ipl; + TAILQ_HEAD(, gic_fdt_irqhandler) intr_handlers; +}; + struct gic_fdt_softc { device_t sc_dev; int sc_phandle; + + struct gic_fdt_irq *sc_irq[GIC_MAXIRQ]; }; CFATTACH_DECL_NEW(gic_fdt, sizeof(struct gic_fdt_softc), @@ -137,7 +163,9 @@ static void * gic_fdt_establish(device_t dev, u_int *specifier, int ipl, int flags, int (*func)(void *), void *arg) { - int iflags = (flags & FDT_INTR_MPSAFE) ? IST_MPSAFE : 0; + struct gic_fdt_softc * const sc = device_private(dev); + struct gic_fdt_irq *firq; + struct gic_fdt_irqhandler *firqh; /* 1st cell is the interrupt type; 0 is SPI, 1 is PPI */ /* 2nd cell is the interrupt number */ @@ -149,13 +177,73 @@ gic_fdt_establish(device_t dev, u_int *s const u_int trig = be32toh(specifier[2]) & 0xf; const u_int level = (trig & 0x3) ? IST_EDGE : IST_LEVEL; - return intr_establish(irq, ipl, level | iflags, func, arg); + firq = sc->sc_irq[irq]; + if (firq == NULL) { + firq = kmem_alloc(sizeof(*firq), KM_SLEEP); + firq->intr_sc = sc; + firq->intr_refcnt = 0; + firq->intr_ipl = ipl; + TAILQ_INIT(>intr_handlers); + firq->intr_ih = intr_establish(irq, ipl, level | IST_MPSAFE, + gic_fdt_intr, firq); + if (firq->intr_ih == NULL) { + kmem_free(firq, sizeof(*firq)); + return NULL; + } + sc->sc_irq[irq] = firq; + } + + if (firq->intr_ipl != ipl) { + device_printf(dev, "cannot share irq with different ipl\n"); + return NULL; + } + + firq->intr_refcnt++; + + firqh = kmem_alloc(sizeof(*firqh), KM_SLEEP); + firqh->ih_mpsafe = (flags & FDT_INTR_MPSAFE) != 0; + firqh->ih_irq = firq; + firqh->ih_fn = func; + firqh->ih_arg = arg; + TAILQ_INSERT_TAIL(>intr_handlers, firqh, ih_next); + + return firqh; } static void gic_fdt_disestablish(device_t dev, void *ih) { - intr_disestablish(ih); + struct gic_fdt_irqhandler *firqh = ih; + struct gic_fdt_irq *firq = firqh->ih_irq; + + KASSERT(firq->intr_refcnt > 0); + + TAILQ_REMOVE(>intr_handlers, firqh, ih_next); + kmem_free(firqh, sizeof(*firqh)); + + firq->intr_refcnt--; + if (firq->intr_refcnt == 0) { + intr_disestablish(firq->intr_ih); + kmem_free(firq, sizeof(*firq)); + } +} + +static int +gic_fdt_intr(void *priv) +{ + struct gic_fdt_irq *firq = priv; + struct gic_fdt_irqhandler *firqh; + int handled = 0; + + TAILQ_FOREACH(firqh, >intr_handlers, ih_next) { + if (!firqh->ih_mpsafe) + KERNEL_LOCK(1, curlwp); + handled += firqh->ih_fn(firqh->ih_arg); + if (!firqh->ih_mpsafe) + KERNEL_UNLOCK_ONE(curlwp); + } + + return handled; } static bool
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Sun Jun 18 23:20:20 UTC 2017 Modified Files: src/sys/arch/arm/fdt: cpu_fdt.c Log Message: Only try to attach to CPUs with the same cluster ID as the boot processor. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/fdt/cpu_fdt.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/cpu_fdt.c diff -u src/sys/arch/arm/fdt/cpu_fdt.c:1.1 src/sys/arch/arm/fdt/cpu_fdt.c:1.2 --- src/sys/arch/arm/fdt/cpu_fdt.c:1.1 Sun May 28 00:40:20 2017 +++ src/sys/arch/arm/fdt/cpu_fdt.c Sun Jun 18 23:20:20 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu_fdt.c,v 1.1 2017/05/28 00:40:20 jmcneill Exp $ */ +/* $NetBSD: cpu_fdt.c,v 1.2 2017/06/18 23:20:20 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared McNeill@@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cpu_fdt.c,v 1.1 2017/05/28 00:40:20 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu_fdt.c,v 1.2 2017/06/18 23:20:20 jmcneill Exp $"); #include #include @@ -68,8 +68,23 @@ cpu_fdt_match(device_t parent, cfdata_t NULL }; struct fdt_attach_args * const faa = aux; + int is_compatible; + bus_addr_t mpidr; + + is_compatible = of_match_compatible(faa->faa_phandle, compatible); + if (!is_compatible) + return 0; + + /* XXX NetBSD requires all CPUs to be in the same cluster */ + if (fdtbus_get_reg(faa->faa_phandle, 0, , NULL) != 0) + return 0; + const uint32_t bp_mpidr = armreg_mpidr_read(); + const u_int bp_clid = __SHIFTOUT(bp_mpidr, CORTEXA9_MPIDR_CLID); + const u_int clid = __SHIFTOUT(mpidr, CORTEXA9_MPIDR_CLID); + if (bp_clid != clid) + return 0; - return of_compatible(faa->faa_phandle, compatible) >= 0; + return is_compatible; } static void @@ -87,5 +102,6 @@ cpu_fdt_attach(device_t parent, device_t return; } - cpu_attach(self, mpidr); + /* Attach the CPU */ + cpu_attach(self, __SHIFTOUT(mpidr, CORTEXA9_MPIDR_CPUID)); }
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Thu Jun 8 21:01:06 UTC 2017 Modified Files: src/sys/arch/arm/fdt: files.fdt Added Files: src/sys/arch/arm/fdt: plrtc_fdt.c Log Message: Add fdt glue for plrtc To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/sys/arch/arm/fdt/files.fdt cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/fdt/plrtc_fdt.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.10 src/sys/arch/arm/fdt/files.fdt:1.11 --- src/sys/arch/arm/fdt/files.fdt:1.10 Thu Jun 8 10:03:59 2017 +++ src/sys/arch/arm/fdt/files.fdt Thu Jun 8 21:01:06 2017 @@ -1,4 +1,4 @@ -# $NetBSD: files.fdt,v 1.10 2017/06/08 10:03:59 jmcneill Exp $ +# $NetBSD: files.fdt,v 1.11 2017/06/08 21:01:06 jmcneill Exp $ include "dev/pckbport/files.pckbport" @@ -35,5 +35,8 @@ file arch/arm/fdt/smsh_fdt.c smsh_fdt attach aaci at fdt with aaci_fdt file arch/arm/fdt/aaci_fdt.c aaci_fdt +attach plrtc at fdt with plrtc_fdt +file arch/arm/fdt/plrtc_fdt.c plrtc_fdt + # Console parameters defparam opt_fdt_arm.hCONSADDR Added files: Index: src/sys/arch/arm/fdt/plrtc_fdt.c diff -u /dev/null src/sys/arch/arm/fdt/plrtc_fdt.c:1.1 --- /dev/null Thu Jun 8 21:01:06 2017 +++ src/sys/arch/arm/fdt/plrtc_fdt.c Thu Jun 8 21:01:06 2017 @@ -0,0 +1,85 @@ +/* $NetBSD: plrtc_fdt.c,v 1.1 2017/06/08 21:01:06 jmcneill Exp $ */ + +/*- + * Copyright (c) 2017 Jared McNeill+ * 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 +__KERNEL_RCSID(0, "$NetBSD: plrtc_fdt.c,v 1.1 2017/06/08 21:01:06 jmcneill Exp $"); + +#include +#include +#include +#include +#include + +#include + +#include + +static int plrtc_fdt_match(device_t, cfdata_t, void *); +static void plrtc_fdt_attach(device_t, device_t, void *); + +static const char * const compatible[] = { + "arm,pl031", + NULL +}; + +CFATTACH_DECL_NEW(plrtc_fdt, sizeof(struct plrtc_softc), + plrtc_fdt_match, plrtc_fdt_attach, NULL, NULL); + +static int +plrtc_fdt_match(device_t parent, cfdata_t cf, void *aux) +{ + struct fdt_attach_args * const faa = aux; + + return of_compatible(faa->faa_phandle, compatible) >= 0; +} + +static void +plrtc_fdt_attach(device_t parent, device_t self, void *aux) +{ + struct plrtc_softc * const sc = device_private(self); + struct fdt_attach_args * const faa = aux; + const int phandle = faa->faa_phandle; + bus_addr_t addr; + bus_size_t size; + + if (fdtbus_get_reg(phandle, 0, , ) != 0) { + aprint_error(": missing 'reg' property\n"); + return; + } + + sc->sc_dev = self; + sc->sc_bst = faa->faa_bst; + if (bus_space_map(faa->faa_bst, addr, size, 0, >sc_bsh)) { + aprint_error(": couldn't map device\n"); + return; + } + + plrtc_attach(sc); + + fdtbus_todr_attach(self, phandle, >sc_todr); +}
CVS commit: src/sys/arch/arm/fdt
Module Name:src Committed By: jmcneill Date: Thu Jun 8 10:03:59 UTC 2017 Modified Files: src/sys/arch/arm/fdt: files.fdt Added Files: src/sys/arch/arm/fdt: aaci_fdt.c Log Message: Add fdt glue for ARM PrimeCell Advanced Audio CODEC interface (PL041). To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/fdt/aaci_fdt.c cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/fdt/files.fdt 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.9 src/sys/arch/arm/fdt/files.fdt:1.10 --- src/sys/arch/arm/fdt/files.fdt:1.9 Sat Jun 3 17:05:23 2017 +++ src/sys/arch/arm/fdt/files.fdt Thu Jun 8 10:03:59 2017 @@ -1,4 +1,4 @@ -# $NetBSD: files.fdt,v 1.9 2017/06/03 17:05:23 jmcneill Exp $ +# $NetBSD: files.fdt,v 1.10 2017/06/08 10:03:59 jmcneill Exp $ include "dev/pckbport/files.pckbport" @@ -32,5 +32,8 @@ file arch/arm/fdt/plmmc_fdt.c plmmc_fdt attach smsh at fdt with smsh_fdt file arch/arm/fdt/smsh_fdt.c smsh_fdt +attach aaci at fdt with aaci_fdt +file arch/arm/fdt/aaci_fdt.c aaci_fdt + # Console parameters defparam opt_fdt_arm.hCONSADDR Added files: Index: src/sys/arch/arm/fdt/aaci_fdt.c diff -u /dev/null src/sys/arch/arm/fdt/aaci_fdt.c:1.1 --- /dev/null Thu Jun 8 10:03:59 2017 +++ src/sys/arch/arm/fdt/aaci_fdt.c Thu Jun 8 10:03:59 2017 @@ -0,0 +1,106 @@ +/* $NetBSD: aaci_fdt.c,v 1.1 2017/06/08 10:03:59 jmcneill Exp $ */ + +/*- + * Copyright (c) 2017 Jared McNeill+ * 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 +__KERNEL_RCSID(0, "$NetBSD: aaci_fdt.c,v 1.1 2017/06/08 10:03:59 jmcneill Exp $"); + +#include +#include +#include +#include +#include + +#include + +#include + +static int aaci_fdt_match(device_t, cfdata_t, void *); +static void aaci_fdt_attach(device_t, device_t, void *); + +static const char * const compatible[] = { + "arm,pl041", + NULL +}; + +CFATTACH_DECL_NEW(aaci_fdt, sizeof(struct aaci_softc), + aaci_fdt_match, aaci_fdt_attach, NULL, NULL); + +static int +aaci_fdt_match(device_t parent, cfdata_t cf, void *aux) +{ + struct fdt_attach_args * const faa = aux; + + return of_compatible(faa->faa_phandle, compatible) >= 0; +} + +static void +aaci_fdt_attach(device_t parent, device_t self, void *aux) +{ + struct aaci_softc * const sc = device_private(self); + struct fdt_attach_args * const faa = aux; + const int phandle = faa->faa_phandle; + char intrstr[128]; + struct clk *clk; + bus_addr_t addr; + bus_size_t size; + void *ih; + + if (fdtbus_get_reg(phandle, 0, , ) != 0) { + aprint_error(": missing 'reg' property\n"); + return; + } + + if (!fdtbus_intr_str(phandle, 0, intrstr, sizeof(intrstr))) { + aprint_error_dev(self, "failed to decode interrupt\n"); + return; + } + + for (int i = 0; (clk = fdtbus_clock_get_index(phandle, i)); i++) + if (clk_enable(clk) != 0) { + aprint_error(": couldn't enable clock #%d\n", i); + return; + } + + sc->sc_dev = self; + sc->sc_bst = faa->faa_bst; + if (bus_space_map(faa->faa_bst, addr, size, 0, >sc_bsh)) { + aprint_error(": couldn't map device\n"); + return; + } + + ih = fdtbus_intr_establish(phandle, 0, IPL_AUDIO, FDT_INTR_MPSAFE, + aaci_intr, sc); + if (ih == NULL) { + aprint_error_dev(self, "couldn't install interrupt handler\n"); + return; + } + + aaci_attach(sc); + + aprint_normal_dev(self, "interrupting on %s\n", intrstr); +}