Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/evbarm/marvell Add support Marvell Sheevaplug.



details:   https://anonhg.NetBSD.org/src/rev/f342f61bbc73
branches:  trunk
changeset: 757914:f342f61bbc73
user:      kiyohara <kiyohara%NetBSD.org@localhost>
date:      Sun Oct 03 06:03:10 2010 +0000

description:
Add support Marvell Sheevaplug.
Add some NAS on Marvell SoC.

diffstat:

 sys/arch/evbarm/marvell/marvell_machdep.c |  1001 +++++++++++++++++++++++++++++
 sys/arch/evbarm/marvell/marvell_start.S   |   206 +++++
 sys/arch/evbarm/marvell/marvellreg.h      |    42 +
 sys/arch/evbarm/marvell/marvellvar.h      |    40 +
 4 files changed, 1289 insertions(+), 0 deletions(-)

diffs (truncated from 1305 to 300 lines):

diff -r bb46ea00e595 -r f342f61bbc73 sys/arch/evbarm/marvell/marvell_machdep.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/evbarm/marvell/marvell_machdep.c Sun Oct 03 06:03:10 2010 +0000
@@ -0,0 +1,1001 @@
+/*     $NetBSD: marvell_machdep.c,v 1.1 2010/10/03 06:03:10 kiyohara 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.1 2010/10/03 06:03:10 kiyohara Exp $");
+
+#include "opt_evbarm_boardtype.h"
+#include "opt_ddb.h"
+#include "opt_pci.h"
+#include "opt_mvsoc.h"
+#include "com.h"
+#include "gtpci.h"
+#include "mvpex.h"
+
+#include <sys/param.h>
+#include <sys/kernel.h>
+#include <sys/reboot.h>
+#include <sys/systm.h>
+#include <sys/termios.h>
+
+#include <prop/proplib.h>
+
+#include <dev/cons.h>
+#include <dev/md.h>
+
+#include <dev/marvell/marvellreg.h>
+#include <dev/marvell/marvellvar.h>
+#include <dev/pci/pcireg.h>
+#include <dev/pci/pcivar.h>
+
+#include <machine/autoconf.h>
+#include <machine/bootconfig.h>
+#include <machine/pci_machdep.h>
+
+#include <uvm/uvm_extern.h>
+
+#include <arm/db_machdep.h>
+#include <arm/undefined.h>
+#include <arm/arm32/machdep.h>
+
+#include <arm/marvell/mvsocreg.h>
+#include <arm/marvell/mvsocvar.h>
+#include <arm/marvell/orionreg.h>
+#include <arm/marvell/kirkwoodreg.h>
+#include <arm/marvell/mvsocgppvar.h>
+
+#include <evbarm/marvell/marvellreg.h>
+#include <evbarm/marvell/marvellvar.h>
+
+#include <ddb/db_extern.h>
+#include <ddb/db_sym.h>
+
+#include "ksyms.h"
+
+
+/* Kernel text starts 2MB in from the bottom of the kernel address space. */
+#define KERNEL_TEXT_BASE       (KERNEL_BASE + 0x00000000)
+#define KERNEL_VM_BASE         (KERNEL_BASE + 0x01000000)
+
+/*
+ * The range 0xc1000000 - 0xccffffff is available for kernel VM space
+ * Core-logic registers and I/O mappings occupy 0xfd000000 - 0xffffffff
+ */
+#define KERNEL_VM_SIZE         0x0c000000
+
+/*
+ * Address to call from cpu_reset() to reset the machine.
+ * This is machine architecture dependant as it varies depending
+ * on where the ROM appears when you turn the MMU off.
+ */
+
+u_int cpu_reset_address = 0xffff0000;
+
+/* Define various stack sizes in pages */
+#define IRQ_STACK_SIZE 1
+#define ABT_STACK_SIZE 1
+#ifdef IPKDB
+#define UND_STACK_SIZE 2
+#else
+#define UND_STACK_SIZE 1
+#endif
+
+BootConfig bootconfig;         /* Boot config storage */
+char *boot_args = NULL;
+
+vm_offset_t physical_start;
+vm_offset_t physical_freestart;
+vm_offset_t physical_freeend;
+vm_offset_t physical_end;
+u_int free_pages;
+int physmem = 0;
+
+/* Physical and virtual addresses for some global pages */
+pv_addr_t systempage;
+pv_addr_t irqstack;
+pv_addr_t undstack;
+pv_addr_t abtstack;
+pv_addr_t kernelstack;
+
+vm_offset_t msgbufphys;
+
+extern u_int data_abort_handler_address;
+extern u_int prefetch_abort_handler_address;
+extern u_int undefined_handler_address;
+
+extern char _end[];
+
+#define KERNEL_PT_SYS          0   /* Page table for mapping proc0 zero page */
+#define KERNEL_PT_KERNEL       1       /* Page table for mapping kernel */
+#define KERNEL_PT_KERNEL_NUM   4
+#define KERNEL_PT_VMDATA       (KERNEL_PT_KERNEL + KERNEL_PT_KERNEL_NUM)
+/* Page tables for mapping kernel VM */
+#define KERNEL_PT_VMDATA_NUM   4       /* start with 16MB of KVM */
+#define NUM_KERNEL_PTS         (KERNEL_PT_VMDATA + KERNEL_PT_VMDATA_NUM)
+
+pv_addr_t kernel_pt_table[NUM_KERNEL_PTS];
+
+/*
+ * 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
+#define KERN_VTOPHYS(va) \
+       ((paddr_t)((vaddr_t)va - KERNEL_BASE + KERNEL_BASE_PHYS))
+#define KERN_PHYSTOV(pa) \
+       ((vaddr_t)((paddr_t)pa - KERNEL_BASE_PHYS + KERNEL_BASE))
+
+
+#include "com.h"
+#if NCOM > 0
+#include <dev/ic/comreg.h>
+#include <dev/ic/comvar.h>
+#endif
+
+#ifndef CONSPEED
+#define CONSPEED       B115200 /* It's a setting of the default of u-boot */
+#endif
+#ifndef CONMODE
+#define CONMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */
+
+int comcnspeed = CONSPEED;
+int comcnmode = CONMODE;
+#endif
+
+#include "opt_kgdb.h"
+#ifdef KGDB
+#include <sys/kgdb.h>
+#endif
+
+static void marvell_device_register(device_t, void *);
+#if NGTPCI > 0 || NMVPEX > 0
+static void marvell_startend_by_tag(int, uint64_t *, uint64_t *);
+#endif
+
+
+void
+cpu_reboot(int howto, char *bootstr)
+{
+
+       /*
+        * If we are still cold then hit the air brakes
+        * and crash to earth fast
+        */
+       if (cold) {
+               doshutdownhooks();
+               printf("The operating system has halted.\r\n");
+               printf("Please press any key to reboot.\r\n");
+               cngetc();
+               printf("rebooting...\r\n");
+               cpu_reset();
+       }
+
+       /*
+        * If RB_NOSYNC was not specified sync the discs.
+        * Note: Unless cold is set to 1 here, syslogd will die during the
+        * unmount.  It looks like syslogd is getting woken up only to find
+        * that it cannot page part of the binary in as the filesystem has
+        * been unmounted.
+        */
+       if (!(howto & RB_NOSYNC))
+               bootsync();
+
+       /* Say NO to interrupts */
+       splhigh();
+
+       /* Do a dump if requested. */
+       if ((howto & (RB_DUMP | RB_HALT)) == RB_DUMP)
+               dumpsys();
+
+       /* Run any shutdown hooks */
+       doshutdownhooks();
+
+       /* Make sure IRQ's are disabled */
+       IRQdisable;
+
+       if (howto & RB_HALT) {
+               printf("The operating system has halted.\r\n");
+               printf("Please press any key to reboot.\r\n");
+               cngetc();
+       }
+
+       printf("rebooting...\r\n");
+       cpu_reset();
+
+       /*NOTREACHED*/
+}
+
+static inline
+pd_entry_t *
+read_ttb(void)
+{
+       long ttb;
+
+       __asm volatile("mrc     p15, 0, %0, c2, c0, 0" : "=r" (ttb));
+
+       return (pd_entry_t *)(ttb & ~((1<<14)-1));
+}
+
+/*
+ * 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.
+ */
+#define _A(a)  ((a) & ~L1_S_OFFSET)
+#define _S(s)  (((s) + L1_S_SIZE - 1) & ~(L1_S_SIZE-1))
+
+static const struct pmap_devmap marvell_devmap[] = {
+       {
+               MARVELL_INTERREGS_VBASE,
+               _A(MARVELL_INTERREGS_PBASE),
+               _S(MARVELL_INTERREGS_SIZE),
+               VM_PROT_READ|VM_PROT_WRITE,
+               PTE_NOCACHE,
+       },
+
+       { 0, 0, 0, 0, 0 }
+};
+
+#undef  _A
+#undef  _S
+
+
+/*
+ * u_int 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
+ */
+u_int
+initarm(void *arg)
+{
+       uint32_t target, attr, base, size;
+       u_int l1pagetable;
+       int loop, pt_index, cs, memtag = 0, iotag = 0, window;
+
+       /* map some peripheral registers */
+       pmap_devmap_bootstrap((vaddr_t)read_ttb(), marvell_devmap);



Home | Main Index | Thread Index | Old Index