/* $NetBSD: marvell_machdep.c,v 1.38 2023/04/20 08:28:05 skrll Exp $ */
/*
* Copyright (c) 2007, 2008, 2010 KIYOHARA Takashi
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: marvell_machdep.c,v 1.38 2023/04/20 08:28:05 skrll Exp $");
extern int KERNEL_BASE_phys[];
extern char _end[];
/*
* Macros to translate between physical and virtual for a subset of the
* kernel address space. *Not* for general use.
*/
#define KERNEL_BASE_PHYS physical_start
/*
* Static device mappings. These peripheral registers are mapped at
* fixed virtual addresses very early in initarm() so that we can use
* them while booting the kernel, and stay at the same address
* throughout whole kernel's life time.
*
* We use this table twice; once with bootstrap page table, and once
* with kernel's page table which we build up in initarm().
*
* Since we map these registers into the bootstrap page table using
* pmap_devmap_bootstrap() which calls pmap_map_chunk(), we map
* registers segment-aligned and segment-rounded in order to avoid
* using the 2nd page tables.
*/
/*
* vaddr_t initarm(...)
*
* Initial entry point on startup. This gets called before main() is
* entered.
* It should be responsible for setting up everything that must be
* in place when main is called.
* This includes
* Taking a copy of the boot configuration structure.
* Initialising the physical console so characters can be printed.
* Setting up page tables for the kernel
* Relocating the kernel to the bottom of physical memory
*/
vaddr_t
initarm(void *arg)
{
int cs, cs_end, memtag = 0, iotag = 0;
mvsoc_bootstrap(MARVELL_INTERREGS_VBASE);
/*
* Heads up ... Setup the CPU / MMU / TLB functions
*/
if (set_cpufuncs())
panic("cpu not recognized!");
/* map some peripheral registers */
pmap_devmap_bootstrap((vaddr_t)read_ttb(), marvell_devmap);
/*
* U-Boot doesn't use the virtual memory.
*
* Physical Address Range Description
* ----------------------- ----------------------------------
* 0x00000000 - 0x0fffffff SDRAM Bank 0 (max 256MB)
* 0x10000000 - 0x1fffffff SDRAM Bank 1 (max 256MB)
* 0x20000000 - 0x2fffffff SDRAM Bank 2 (max 256MB)
* 0x30000000 - 0x3fffffff SDRAM Bank 3 (max 256MB)
* 0xf1000000 - 0xf10fffff SoC Internal Registers
*/
/* Get ready for splfoo() */
switch (mvsoc_model()) {
#ifdef ORION
case MARVELL_ORION_1_88F1181:
case MARVELL_ORION_1_88F5082:
case MARVELL_ORION_1_88F5180N:
case MARVELL_ORION_1_88F5181:
case MARVELL_ORION_1_88F5182:
case MARVELL_ORION_1_88F6082:
case MARVELL_ORION_1_88F6183:
case MARVELL_ORION_1_88W8660:
case MARVELL_ORION_2_88F1281:
case MARVELL_ORION_2_88F5281:
cpu_reset_address = marvell_system_reset;
#ifdef KIRKWOOD
case MARVELL_KIRKWOOD_88F6180:
case MARVELL_KIRKWOOD_88F6192:
case MARVELL_KIRKWOOD_88F6281:
case MARVELL_KIRKWOOD_88F6282:
cpu_reset_address = marvell_system_reset;
marvell_fixup_mbus(memtag, iotag);
break;
#endif /* DOVE */
#ifdef ARMADAXP
case MARVELL_ARMADAXP_MV78130:
case MARVELL_ARMADAXP_MV78160:
case MARVELL_ARMADAXP_MV78230:
case MARVELL_ARMADAXP_MV78260:
case MARVELL_ARMADAXP_MV78460:
case MARVELL_ARMADA370_MV6707:
case MARVELL_ARMADA370_MV6710:
case MARVELL_ARMADA370_MV6W11:
cpu_reset_address = armadaxp_system_reset;
default:
/* We can't output console here yet... */
panic("unknown model...\n");
/* NOTREACHED */
}
consinit();
/* Talk to the user */
#ifndef EVBARM_BOARDTYPE
#define EVBARM_BOARDTYPE Marvell
#endif
#define BDSTR(s) _BDSTR(s)
#define _BDSTR(s) #s
printf("\nNetBSD/evbarm (" BDSTR(EVBARM_BOARDTYPE) ") booting ...\n");
/* copy command line U-Boot gave us, if args is valid. */
if (u_boot_args[3] != 0) /* XXXXX: need more check?? */
strncpy(bootargs, (char *)u_boot_args[3], sizeof(bootargs));
#ifdef VERBOSE_INIT_ARM
printf("initarm: Configuring system ...\n");
#endif
/* Setup the hint for interrupt-pin. */
#define BDSTR(s) _BDSTR(s)
#define _BDSTR(s) #s
#define THIS_BOARD(str) (strcmp(str, BDSTR(EVBARM_BOARDTYPE)) == 0)
for (i = 0; hints[i].boardtype != NULL; i++)
if (THIS_BOARD(hints[i].boardtype))
break;
if (hints[i].boardtype == NULL)
return;
#ifdef ARMADAXP
case MARVELL_ARMADAXP_MV78130:
case MARVELL_ARMADAXP_MV78160:
case MARVELL_ARMADAXP_MV78230:
case MARVELL_ARMADAXP_MV78260:
case MARVELL_ARMADAXP_MV78460:
case MARVELL_ARMADA370_MV6707:
case MARVELL_ARMADA370_MV6710:
case MARVELL_ARMADA370_MV6W11:
{
extern struct arm32_pci_chipset
arm32_mvpex2_chipset, arm32_mvpex3_chipset,
arm32_mvpex4_chipset, arm32_mvpex5_chipset;
const struct {
bus_size_t offset;
struct bus_space *io_bs_tag;
struct bus_space *mem_bs_tag;
struct arm32_pci_chipset *chipset;
int iotag;
int memtag;
} mvpex_tags[] = {
{ MVSOC_PEX_BASE,
&armadaxp_pex00_io_bs_tag,
&armadaxp_pex00_mem_bs_tag,
&arm32_mvpex0_chipset,
ARMADAXP_TAG_PEX00_IO,
ARMADAXP_TAG_PEX00_MEM },