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