diff --git a/sys/arm/annapurna/alpine/alpine_machdep.c b/sys/arm/annapurna/alpine/alpine_machdep.c index a4e51d339354..89d21bf9fcae 100644 --- a/sys/arm/annapurna/alpine/alpine_machdep.c +++ b/sys/arm/annapurna/alpine/alpine_machdep.c @@ -1,158 +1,159 @@ /*- * Copyright (c) 2013 Ruslan Bukin * Copyright (c) 2015 Semihalf * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * */ #include "opt_ddb.h" #include "opt_platform.h" #include #include #include +#include #include #include #include #include #include #include #include #include #include "platform_if.h" #define WDTLOAD 0x000 #define LOAD_MIN 0x00000001 #define LOAD_MAX 0xFFFFFFFF #define WDTVALUE 0x004 #define WDTCONTROL 0x008 /* control register masks */ #define INT_ENABLE (1 << 0) #define RESET_ENABLE (1 << 1) #define WDTLOCK 0xC00 #define UNLOCK 0x1ACCE551 #define LOCK 0x00000001 bus_addr_t al_devmap_pa; bus_addr_t al_devmap_size; static int alpine_get_devmap_base(bus_addr_t *pa, bus_addr_t *size) { phandle_t node; if ((node = OF_finddevice("/")) == -1) return (ENXIO); if ((node = fdt_find_compatible(node, "simple-bus", 1)) == 0) return (ENXIO); return fdt_get_range(node, 0, pa, size); } static int alpine_get_wdt_base(uint32_t *pbase, uint32_t *psize) { phandle_t node; u_long base = 0; u_long size = 0; if (pbase == NULL || psize == NULL) return (EINVAL); if ((node = OF_finddevice("/")) == -1) return (EFAULT); if ((node = fdt_find_compatible(node, "simple-bus", 1)) == 0) return (EFAULT); if ((node = fdt_find_compatible(node, "arm,sp805", 1)) == 0) return (EFAULT); if (fdt_regsize(node, &base, &size)) return (EFAULT); *pbase = base; *psize = size; return (0); } /* * Construct devmap table with DT-derived config data. */ static int alpine_devmap_init(platform_t plat) { alpine_get_devmap_base(&al_devmap_pa, &al_devmap_size); devmap_add_entry(al_devmap_pa, al_devmap_size); return (0); } static void alpine_cpu_reset(platform_t plat) { uint32_t wdbase, wdsize; bus_addr_t wdbaddr; int ret; ret = alpine_get_wdt_base(&wdbase, &wdsize); if (ret) { printf("Unable to get WDT base, do power down manually..."); goto infinite; } ret = bus_space_map(fdtbus_bs_tag, al_devmap_pa + wdbase, wdsize, 0, &wdbaddr); if (ret) { printf("Unable to map WDT base, do power down manually..."); goto infinite; } bus_space_write_4(fdtbus_bs_tag, wdbaddr, WDTLOCK, UNLOCK); bus_space_write_4(fdtbus_bs_tag, wdbaddr, WDTLOAD, LOAD_MIN); bus_space_write_4(fdtbus_bs_tag, wdbaddr, WDTCONTROL, INT_ENABLE | RESET_ENABLE); infinite: while (1) {} } static platform_method_t alpine_methods[] = { PLATFORMMETHOD(platform_devmap_init, alpine_devmap_init), PLATFORMMETHOD(platform_cpu_reset, alpine_cpu_reset), #ifdef SMP PLATFORMMETHOD(platform_mp_start_ap, alpine_mp_start_ap), PLATFORMMETHOD(platform_mp_setmaxid, alpine_mp_setmaxid), #endif PLATFORMMETHOD_END, }; FDT_PLATFORM_DEF(alpine, "alpine", 0, "annapurna,alpine", 200); diff --git a/sys/arm/freescale/vybrid/vf_machdep.c b/sys/arm/freescale/vybrid/vf_machdep.c index fe36558b7ece..2ab14f5154eb 100644 --- a/sys/arm/freescale/vybrid/vf_machdep.c +++ b/sys/arm/freescale/vybrid/vf_machdep.c @@ -1,84 +1,85 @@ /*- * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2013 Ruslan Bukin * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include "opt_platform.h" #include #include +#include #include #include #include #include #include #include #include #include "platform_if.h" static int vf_devmap_init(platform_t plat) { devmap_add_entry(0x40000000, 0x100000); return (0); } static void vf_cpu_reset(platform_t plat) { phandle_t src; uint32_t paddr; bus_addr_t vaddr; if (src_swreset() == 0) goto end; src = OF_finddevice("src"); if ((src != -1) && (OF_getencprop(src, "reg", &paddr, sizeof(paddr))) > 0) { if (bus_space_map(fdtbus_bs_tag, paddr, 0x10, 0, &vaddr) == 0) { bus_space_write_4(fdtbus_bs_tag, vaddr, 0x00, SW_RST); } } end: while (1); } static platform_method_t vf_methods[] = { PLATFORMMETHOD(platform_devmap_init, vf_devmap_init), PLATFORMMETHOD(platform_cpu_reset, vf_cpu_reset), PLATFORMMETHOD_END, }; FDT_PLATFORM_DEF(vf, "vybrid", 0, "freescale,vybrid", 200); diff --git a/sys/arm/qualcomm/ipq4018_machdep.c b/sys/arm/qualcomm/ipq4018_machdep.c index c0131d08dee6..49dd2ff0193a 100644 --- a/sys/arm/qualcomm/ipq4018_machdep.c +++ b/sys/arm/qualcomm/ipq4018_machdep.c @@ -1,232 +1,233 @@ /*- * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2021 Adrian Chadd * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include "opt_platform.h" #include #include #include #include +#include #include #include #include #include #include #include #include #include #include #include #include #include #include "platform_if.h" static int ipq4018_attach(platform_t plat) { return (0); } static void ipq4018_late_init(platform_t plat) { /* * XXX FIXME This is needed because we're not parsing * the fdt reserved memory regions in a consistent way * between arm/arm64. Once the reserved region parsing * is fixed up this will become unnecessary. * * These cover the SRAM/TZ regions that are not fully * accessible from the OS. They're in the ipq4018.dtsi * tree. * * Without these, the system fails to boot because we * aren't parsing the regions correctly. * * These will be unnecessary once the parser and setup * code is fixed. */ physmem_exclude_region(IPQ4018_MEM_SMEM_START, IPQ4018_MEM_SMEM_SIZE, EXFLAG_NODUMP | EXFLAG_NOALLOC); physmem_exclude_region(IPQ4018_MEM_TZ_START, IPQ4018_MEM_TZ_SIZE, EXFLAG_NODUMP | EXFLAG_NOALLOC); } static int ipq4018_devmap_init(platform_t plat) { /* * This covers the boot UART. Without it we can't boot successfully: * there's a mutex uninit panic in subr_vmem.c that occurs when doing * a call to pmap_mapdev() when the bus space code is doing its thing. */ devmap_add_entry(IPQ4018_MEM_UART1_START, IPQ4018_MEM_UART1_SIZE); /* * This covers a bunch of the reset block, which includes the PS-HOLD * register for dropping power. */ devmap_add_entry(IPQ4018_MEM_PSHOLD_START, IPQ4018_MEM_PSHOLD_SIZE); return (0); } /* * This toggles the PS-HOLD register which on most IPQ devices will toggle * the power control block and reset the SoC. * * However, there are apparently some units out there where this is not * appropriate and instead the watchdog needs to be used. * * For now since there's only going to be one or two initial supported boards * this will be fine. But if this doesn't reboot cleanly, now you know. */ static void ipq4018_cpu_reset_pshold(void) { bus_space_handle_t pshold; printf("%s: called\n", __func__); bus_space_map(fdtbus_bs_tag, IPQ4018_MEM_PSHOLD_START, IPQ4018_MEM_PSHOLD_SIZE, 0, &pshold); bus_space_write_4(fdtbus_bs_tag, pshold, 0, 0); bus_space_barrier(fdtbus_bs_tag, pshold, 0, 0x4, BUS_SPACE_BARRIER_WRITE); } static void ipq4018_cpu_reset(platform_t plat) { spinlock_enter(); dsb(); ipq4018_cpu_reset_pshold(); /* Spin */ printf("%s: spinning\n", __func__); while(1) ; } /* * Early putc routine for EARLY_PRINTF support. To use, add to kernel config: * option SOCDEV_PA=0x07800000 * option SOCDEV_VA=0x07800000 * option EARLY_PRINTF * Resist the temptation to change the #if 0 to #ifdef EARLY_PRINTF here. It * makes sense now, but if multiple SOCs do that it will make early_putc another * duplicate symbol to be eliminated on the path to a generic kernel. */ #if 0 void qca_msm_early_putc(int c) { static int is_init = 0; int limit; /* * This must match what's put into SOCDEV_VA. You have to change them * both together. * * XXX TODO I should really go and just make UART_BASE here depend upon * SOCDEV_VA so they move together. */ #define UART_BASE IPQ4018_MEM_UART1_START volatile uint32_t * UART_DM_TF0 = (uint32_t *)(UART_BASE + 0x70); volatile uint32_t * UART_DM_SR = (uint32_t *)(UART_BASE + 0x08); #define UART_DM_SR_TXEMT (1 << 3) #define UART_DM_SR_TXRDY (1 << 2) volatile uint32_t * UART_DM_ISR = (uint32_t *)(UART_BASE + 0x14); volatile uint32_t * UART_DM_CR = (uint32_t *)(UART_BASE + 0x10); #define UART_DM_TX_READY (1 << 7) #define UART_DM_CLEAR_TX_READY 0x300 volatile uint32_t * UART_DM_NO_CHARS_FOR_TX = (uint32_t *)(UART_BASE + 0x40); volatile uint32_t * UART_DM_TFWR = (uint32_t *)(UART_BASE + 0x1c); #define UART_DM_TFW_VALUE 0 volatile uint32_t * UART_DM_IPR = (uint32_t *)(UART_BASE + 0x18); #define UART_DM_STALE_TIMEOUT_LSB 0xf if (is_init == 0) { is_init = 1; *UART_DM_TFWR = UART_DM_TFW_VALUE; wmb(); *UART_DM_IPR = UART_DM_STALE_TIMEOUT_LSB; wmb(); } /* Wait until TXFIFO is empty via ISR */ limit = 100000; if ((*UART_DM_SR & UART_DM_SR_TXEMT) == 0) { while (((*UART_DM_ISR & UART_DM_TX_READY) == 0) && --limit) { /* Note - can't use DELAY here yet, too early */ rmb(); } *UART_DM_CR = UART_DM_CLEAR_TX_READY; wmb(); } /* FIFO is ready. Say we're going to write one byte */ *UART_DM_NO_CHARS_FOR_TX = 1; wmb(); limit = 100000; while (((*UART_DM_SR & UART_DM_SR_TXRDY) == 0) && --limit) { /* Note - can't use DELAY here yet, too early */ rmb(); } /* Put character in first fifo slot */ *UART_DM_TF0 = c; wmb(); } early_putc_t *early_putc = qca_msm_early_putc; #endif static platform_method_t ipq4018_methods[] = { PLATFORMMETHOD(platform_attach, ipq4018_attach), PLATFORMMETHOD(platform_devmap_init, ipq4018_devmap_init), PLATFORMMETHOD(platform_late_init, ipq4018_late_init), PLATFORMMETHOD(platform_cpu_reset, ipq4018_cpu_reset), #ifdef SMP PLATFORMMETHOD(platform_mp_start_ap, ipq4018_mp_start_ap), PLATFORMMETHOD(platform_mp_setmaxid, ipq4018_mp_setmaxid), #endif PLATFORMMETHOD_END, }; FDT_PLATFORM_DEF2(ipq4018, ipq4018_ac58u, "ASUS RT-AC58U", 0, "asus,rt-ac58u", 80); diff --git a/sys/arm/ti/ti_machdep.c b/sys/arm/ti/ti_machdep.c index ee4f416eeded..29afcb7d9b59 100644 --- a/sys/arm/ti/ti_machdep.c +++ b/sys/arm/ti/ti_machdep.c @@ -1,115 +1,116 @@ /*- * SPDX-License-Identifier: BSD-4-Clause * * Copyright (c) 1994-1998 Mark Brinicombe. * Copyright (c) 1994 Brini. * All rights reserved. * * This code is derived from software written for Brini by Mark Brinicombe * * 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by Brini. * 4. The name of the company nor the name of the author may be used to * endorse or promote products derived from this software without specific * prior written permission. * * THIS SOFTWARE IS PROVIDED BY BRINI ``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 BRINI OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * from: FreeBSD: //depot/projects/arm/src/sys/arm/at91/kb920x_machdep.c, rev 45 */ #include "opt_platform.h" #include #include #include +#include #include #include #include #include #include #include #include "platform_if.h" #if defined(SOC_TI_AM335X) static platform_attach_t ti_am335x_attach; static platform_devmap_init_t ti_am335x_devmap_init; #endif static platform_cpu_reset_t ti_plat_cpu_reset; void (*ti_cpu_reset)(void) = NULL; int _ti_chip = -1; #if defined(SOC_TI_AM335X) static int ti_am335x_attach(platform_t plat) { _ti_chip = CHIP_AM335X; return (0); } #endif /* * Construct static devmap entries to map out the most frequently used * peripherals using 1mb section mappings. */ #if defined(SOC_TI_AM335X) static int ti_am335x_devmap_init(platform_t plat) { devmap_add_entry(0x44C00000, 0x00400000); /* 4mb L4_WKUP devices*/ devmap_add_entry(0x47400000, 0x00100000); /* 1mb USB */ devmap_add_entry(0x47800000, 0x00100000); /* 1mb mmchs2 */ devmap_add_entry(0x48000000, 0x01000000); /*16mb L4_PER devices */ devmap_add_entry(0x49000000, 0x00100000); /* 1mb edma3 */ devmap_add_entry(0x49800000, 0x00300000); /* 3mb edma3 */ devmap_add_entry(0x4A000000, 0x01000000); /*16mb L4_FAST devices*/ return (0); } #endif static void ti_plat_cpu_reset(platform_t plat) { if (ti_cpu_reset) (*ti_cpu_reset)(); else printf("no cpu_reset implementation\n"); } #if defined(SOC_TI_AM335X) static platform_method_t am335x_methods[] = { PLATFORMMETHOD(platform_attach, ti_am335x_attach), PLATFORMMETHOD(platform_devmap_init, ti_am335x_devmap_init), PLATFORMMETHOD(platform_cpu_reset, ti_plat_cpu_reset), PLATFORMMETHOD_END, }; FDT_PLATFORM_DEF(am335x, "am335x", 0, "ti,am33xx", 200); #endif