xref: /netbsd-src/sys/arch/emips/stand/common/init_board.c (revision 5f7e80a8347a06224e3d98023e437667ed7b47d5)
1*5f7e80a8Spooka /*	$NetBSD: init_board.c,v 1.1 2011/01/26 01:18:54 pooka Exp $	*/
2*5f7e80a8Spooka 
3*5f7e80a8Spooka /*-
4*5f7e80a8Spooka  * Copyright (c) 2010 The NetBSD Foundation, Inc.
5*5f7e80a8Spooka  * All rights reserved.
6*5f7e80a8Spooka  *
7*5f7e80a8Spooka  * This code was written by Alessandro Forin and Neil Pittman
8*5f7e80a8Spooka  * at Microsoft Research and contributed to The NetBSD Foundation
9*5f7e80a8Spooka  * by Microsoft Corporation.
10*5f7e80a8Spooka  *
11*5f7e80a8Spooka  * Redistribution and use in source and binary forms, with or without
12*5f7e80a8Spooka  * modification, are permitted provided that the following conditions
13*5f7e80a8Spooka  * are met:
14*5f7e80a8Spooka  * 1. Redistributions of source code must retain the above copyright
15*5f7e80a8Spooka  *    notice, this list of conditions and the following disclaimer.
16*5f7e80a8Spooka  * 2. Redistributions in binary form must reproduce the above copyright
17*5f7e80a8Spooka  *    notice, this list of conditions and the following disclaimer in the
18*5f7e80a8Spooka  *    documentation and/or other materials provided with the distribution.
19*5f7e80a8Spooka  *
20*5f7e80a8Spooka  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
21*5f7e80a8Spooka  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22*5f7e80a8Spooka  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23*5f7e80a8Spooka  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
24*5f7e80a8Spooka  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25*5f7e80a8Spooka  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26*5f7e80a8Spooka  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27*5f7e80a8Spooka  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28*5f7e80a8Spooka  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29*5f7e80a8Spooka  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30*5f7e80a8Spooka  * POSSIBILITY OF SUCH DAMAGE.
31*5f7e80a8Spooka  */
32*5f7e80a8Spooka 
33*5f7e80a8Spooka #include <sys/types.h>
34*5f7e80a8Spooka #include <mips/cpuregs.h>
35*5f7e80a8Spooka #include <stand/common/common.h>
36*5f7e80a8Spooka #include <stand/common/prom_iface.h>
37*5f7e80a8Spooka 
38*5f7e80a8Spooka int board_config = 0;
39*5f7e80a8Spooka int mem_config = 0;
40*5f7e80a8Spooka 
41*5f7e80a8Spooka int
init_board(void)42*5f7e80a8Spooka init_board(void)
43*5f7e80a8Spooka {
44*5f7e80a8Spooka     int i = 0;
45*5f7e80a8Spooka     if (init_usart())
46*5f7e80a8Spooka         i |= BOARD_HAS_USART;
47*5f7e80a8Spooka     if ((mem_config = init_memory()) != 0)
48*5f7e80a8Spooka         i |= BOARD_HAS_MEM_OK;
49*5f7e80a8Spooka     if (0 == aceprobe(0))
50*5f7e80a8Spooka         i |= BOARD_HAS_DISK0;
51*5f7e80a8Spooka     if (0 == aceprobe(1))
52*5f7e80a8Spooka         i |= BOARD_HAS_DISK1;
53*5f7e80a8Spooka     if (enic_present(0))
54*5f7e80a8Spooka         i |= BOARD_HAS_NET;
55*5f7e80a8Spooka     board_config = i;
56*5f7e80a8Spooka     return i;
57*5f7e80a8Spooka }
58*5f7e80a8Spooka 
getsysid(void)59*5f7e80a8Spooka int getsysid(void)
60*5f7e80a8Spooka {
61*5f7e80a8Spooka     int systype = XS_ML40x;
62*5f7e80a8Spooka 
63*5f7e80a8Spooka     /* If it looks like a duck..
64*5f7e80a8Spooka      * ML402: 1 SRAM, 1 DRAM, 0 Ether
65*5f7e80a8Spooka      * ML50x: 0 SRAM, 1 DRAM, 1 Ether
66*5f7e80a8Spooka      * BEE3:  0 SRAM, 2 DRAM, 1 Ether
67*5f7e80a8Spooka      * NB:  mem_config  returns (nfl<<16) | (nsr << 8) | (ndr << 0);
68*5f7e80a8Spooka      */
69*5f7e80a8Spooka     if (board_config & BOARD_HAS_NET) {
70*5f7e80a8Spooka         if ((mem_config & 0xffff) == 2)
71*5f7e80a8Spooka             systype = XS_BE3;
72*5f7e80a8Spooka         else
73*5f7e80a8Spooka             systype = XS_ML50x;
74*5f7e80a8Spooka     }
75*5f7e80a8Spooka 
76*5f7e80a8Spooka     return MAKESYSID(1,1,systype,MIPS_eMIPS);
77*5f7e80a8Spooka }
78*5f7e80a8Spooka 
79