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