1 /* $NetBSD: wrap030_machdep.c,v 1.1 2026/08/06 14:41:09 thorpej Exp $ */ 2 3 /*- 4 * Copyright (c) 2026 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by Jason R. Thorpe. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32 #include <sys/cdefs.h> 33 __KERNEL_RCSID(0, "$NetBSD: wrap030_machdep.c,v 1.1 2026/08/06 14:41:09 thorpej Exp $"); 34 35 #include <sys/param.h> 36 #include <sys/bus.h> 37 #include <sys/device.h> 38 39 #include <dev/fdt/fdtvar.h> 40 #include <dev/fdt/fdt_platform.h> 41 42 #include <uvm/uvm_extern.h> 43 44 #include <m68k/mmu_30.h> 45 46 /* 47 * plat_bootstrap -- 48 * Early bootstrap routine, mainly for the purpose of providing 49 * data necessary to configure the MMU. 50 */ 51 static paddr_t 52 wrap030_plat_bootstrap(paddr_t nextpa, vaddr_t reloff) 53 { 54 /* 55 * We're going to use TT0 to map all of the device address space, 56 * which is located >= 0x80000000. We have to: 57 * 58 * - Initialize the TT register data. 59 * and 60 * - Tell pmap_bootstrap1() about the TT-mapped region. 61 */ 62 uint32_t *tt = (uint32_t *)PMAP_BOOTSTRAP_RELOC_GLOB(mmu_tt30); 63 tt[MMU_TTREG_TT0] = 64 0x80000000 | 65 __SHIFTIN(0x7f,TT30_LAM) | 66 TT30_E | TT30_CI | TT30_RWM | 67 TT30_SUPERD; 68 69 struct pmap_bootmap *pmbm = 70 (struct pmap_bootmap *)PMAP_BOOTSTRAP_RELOC_GLOB(machine_bootmap); 71 pmbm[0].pmbm_vaddr = 0x80000000; 72 pmbm[0].pmbm_size = 0x80000000; 73 pmbm[0].pmbm_flags = PMBM_F_KEEPOUT; 74 75 return nextpa; 76 } 77 78 /* 79 * plat_uart_freq -- 80 * Return the console UART clock frequency in Hz. This is 81 * called if the information is not available in the device 82 * tree. 83 */ 84 static u_int 85 wrap030_plat_uart_freq(void) 86 { 87 return 1843200; 88 } 89 90 static const struct fdt_platform wrap030_platform = { 91 .fp_bootstrap = wrap030_plat_bootstrap, 92 .fp_uart_freq = wrap030_plat_uart_freq, 93 }; 94 FDT_PLATFORM(wrap030, "techav,wrap030", &wrap030_platform); 95