Home | History | Annotate | Line # | Download | only in emips
      1 /* $NetBSD: xs_bee3.c,v 1.5 2016/07/11 16:18:56 matt Exp $ */
      2 
      3 /*-
      4  * Copyright (c) 2010 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code was written by Alessandro Forin and Neil Pittman
      8  * at Microsoft Research and contributed to The NetBSD Foundation
      9  * by Microsoft Corporation.
     10  *
     11  * Redistribution and use in source and binary forms, with or without
     12  * modification, are permitted provided that the following conditions
     13  * are met:
     14  * 1. Redistributions of source code must retain the above copyright
     15  *    notice, this list of conditions and the following disclaimer.
     16  * 2. Redistributions in binary form must reproduce the above copyright
     17  *    notice, this list of conditions and the following disclaimer in the
     18  *    documentation and/or other materials provided with the distribution.
     19  *
     20  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     21  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     22  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     23  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     24  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     25  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     26  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     27  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     28  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     29  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     30  * POSSIBILITY OF SUCH DAMAGE.
     31  */
     32 
     33 #include <sys/cdefs.h>
     34 __KERNEL_RCSID(0, "$NetBSD: xs_bee3.c,v 1.5 2016/07/11 16:18:56 matt Exp $");
     35 
     36 #define __INTR_PRIVATE
     37 
     38 #include <sys/param.h>
     39 #include <sys/systm.h>
     40 #include <sys/device.h>
     41 #include <sys/cpu.h>
     42 #include <sys/intr.h>
     43 
     44 #include <uvm/uvm_extern.h>
     45 
     46 #include <machine/sysconf.h>
     47 #include <machine/locore.h>
     48 
     49 #include <emips/emips/machdep.h>
     50 #include <emips/emips/cons.h>
     51 #include <machine/emipsreg.h>
     52 
     53 
     54 void		xs_bee3_init (void);
     55 static void	xs_bee3_cons_init (void);
     56 
     57 #if 0
     58 #define NOINTS (MIPS_INT_MASK_5|MIPS_SOFT_INT_MASK_0|MIPS_SOFT_INT_MASK_1)
     59 #else
     60 #define NOINTS MIPS_INT_MASK
     61 #endif
     62 
     63 /* BUGBUG Rewrite this to go off to the interrupt controller masks */
     64 #if 0
     65 	splvec.splbio = MIPS_SPL0; // 0x700
     66 	splvec.splnet = MIPS_SPL_0_1; // 0xf00
     67 	splvec.spltty = MIPS_SPL_0_1_2; // 0x1f00
     68 	splvec.splvm = MIPS_SPLHIGH; // 0xff00
     69 	splvec.splclock = MIPS_SPL_0_1_2_3; //0x3f00
     70 	splvec.splstatclock = MIPS_SPL_0_1_2_3; //0x3f00
     71 #endif
     72 
     73 static const struct ipl_sr_map xs_bee3_ipl_sr_map = {
     74     .sr_bits = {
     75 	[IPL_NONE] = 0,
     76 	[IPL_SOFTCLOCK] = MIPS_SOFT_INT_MASK_0,
     77 	[IPL_SOFTBIO] = MIPS_SOFT_INT_MASK_0,
     78 	[IPL_SOFTNET] = MIPS_SOFT_INT_MASK,
     79 	[IPL_SOFTSERIAL] = MIPS_SOFT_INT_MASK,
     80 	[IPL_VM] = NOINTS,
     81 	[IPL_SCHED] = NOINTS,
     82 	[IPL_DDB] = NOINTS,
     83 	[IPL_HIGH] = NOINTS,
     84     },
     85 };
     86 
     87 void
     88 xs_bee3_init(void)
     89 {
     90 	platform.iobus = "baseboard";
     91 	platform.bus_reset = noop;
     92 	platform.cons_init = xs_bee3_cons_init;
     93 	platform.iointr = emips_aic_intr;
     94 	platform.intr_establish = emips_intr_establish;
     95 	platform.memsize = memsize_pmt;
     96 	/* no high resolution timer available (actually we do?) */
     97 
     98 	/* calibrate cpu_mhz value */
     99 	//cpu_mhz = 10;
    100 	cpuspeed  = 8; /* xxx */
    101 	cpu_setmodel("BeSquare BEE3 (eMIPS)");
    102 
    103 	ipl_sr_map = xs_bee3_ipl_sr_map;
    104 }
    105 
    106 static void
    107 xs_bee3_cons_init(void)
    108 {
    109 
    110 	/*
    111 	 * Map the USART 1:1, we just turned on the TLB.
    112 	 * NB: This must be a wired TLB entry lest we lose it before autoconf().
    113 	 */
    114 #if 0
    115 	pmap_kenter_pa(USART_DEFAULT_ADDRESS,
    116 	    USART_DEFAULT_ADDRESS,VM_PROT_WRITE|VM_PROT_READ);
    117 #else
    118 	struct tlbmask tlb;
    119 
    120 	tlb.tlb_hi = USART_DEFAULT_ADDRESS;
    121 	tlb.tlb_lo0 = USART_DEFAULT_ADDRESS | 0xf02;
    122 	tlb_write_entry(3, &tlb);
    123 #endif
    124 
    125 	dz_ebus_cnsetup(USART_DEFAULT_ADDRESS);
    126 }
    127