century_bios.c revision 1.1.6.2 1 1.1.6.2 kent /* $NetBSD: century_bios.c,v 1.1.6.2 2005/04/29 11:28:09 kent Exp $ */
2 1.1.6.2 kent
3 1.1.6.2 kent /*
4 1.1.6.2 kent * Copyright (c) 2004 Shigeyuki Fukushima.
5 1.1.6.2 kent * All rights reserved.
6 1.1.6.2 kent *
7 1.1.6.2 kent * Redistribution and use in source and binary forms, with or without
8 1.1.6.2 kent * modification, are permitted provided that the following conditions
9 1.1.6.2 kent * are met:
10 1.1.6.2 kent * 1. Redistributions of source code must retain the above copyright
11 1.1.6.2 kent * notice, this list of conditions and the following disclaimer.
12 1.1.6.2 kent * 2. Redistributions in binary form must reproduce the above
13 1.1.6.2 kent * copyright notice, this list of conditions and the following
14 1.1.6.2 kent * disclaimer in the documentation and/or other materials provided
15 1.1.6.2 kent * with the distribution.
16 1.1.6.2 kent * 3. The name of the author may not be used to endorse or promote
17 1.1.6.2 kent * products derived from this software without specific prior
18 1.1.6.2 kent * written permission.
19 1.1.6.2 kent *
20 1.1.6.2 kent * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
21 1.1.6.2 kent * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 1.1.6.2 kent * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 1.1.6.2 kent * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
24 1.1.6.2 kent * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 1.1.6.2 kent * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
26 1.1.6.2 kent * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 1.1.6.2 kent * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28 1.1.6.2 kent * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29 1.1.6.2 kent * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30 1.1.6.2 kent * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 1.1.6.2 kent */
32 1.1.6.2 kent
33 1.1.6.2 kent #include <sys/cdefs.h>
34 1.1.6.2 kent __KERNEL_RCSID(0, "$NetBSD: century_bios.c,v 1.1.6.2 2005/04/29 11:28:09 kent Exp $");
35 1.1.6.2 kent
36 1.1.6.2 kent #include <sys/param.h>
37 1.1.6.2 kent #include <sys/systm.h>
38 1.1.6.2 kent
39 1.1.6.2 kent #include <machine/cpu.h>
40 1.1.6.2 kent #include <machine/century_bios.h>
41 1.1.6.2 kent
42 1.1.6.2 kent /*
43 1.1.6.2 kent * OpenBlockS S/R Board configuration structure.
44 1.1.6.2 kent *
45 1.1.6.2 kent * IBM405GP Monitor (Ver. 1.8, REV-01 H/W)
46 1.1.6.2 kent * Century Version (MA-300) (Oct. 30, 2001)
47 1.1.6.2 kent */
48 1.1.6.2 kent struct board_bios_data {
49 1.1.6.2 kent unsigned char mac_address_local[6];
50 1.1.6.2 kent unsigned char boot_mode;
51 1.1.6.2 kent unsigned char mem_size; /* MB */
52 1.1.6.2 kent };
53 1.1.6.2 kent
54 1.1.6.2 kent static struct board_bios_data board_bios;
55 1.1.6.2 kent static unsigned int board_mem_size;
56 1.1.6.2 kent static unsigned int board_cpu_speed;
57 1.1.6.2 kent static unsigned int board_plb_speed;
58 1.1.6.2 kent static unsigned int board_pci_speed;
59 1.1.6.2 kent
60 1.1.6.2 kent void
61 1.1.6.2 kent bios_board_init(void *info_block, u_int sysclk_base)
62 1.1.6.2 kent {
63 1.1.6.2 kent
64 1.1.6.2 kent /* Initialize cache info for memcpy, etc. */
65 1.1.6.2 kent cpu_probe_cache();
66 1.1.6.2 kent
67 1.1.6.2 kent /* Save info block */
68 1.1.6.2 kent memcpy(&board_bios, info_block, sizeof(board_bios));
69 1.1.6.2 kent board_mem_size = board_bios.mem_size * 1024 * 1024;
70 1.1.6.2 kent
71 1.1.6.2 kent board_cpu_speed = 0x0bebc200;
72 1.1.6.2 kent board_plb_speed = 0x05f5e100;
73 1.1.6.2 kent board_pci_speed = 0x01f78a40;
74 1.1.6.2 kent }
75 1.1.6.2 kent
76 1.1.6.2 kent unsigned int
77 1.1.6.2 kent bios_board_memsize_get(void)
78 1.1.6.2 kent {
79 1.1.6.2 kent return board_mem_size;
80 1.1.6.2 kent }
81 1.1.6.2 kent
82 1.1.6.2 kent void
83 1.1.6.2 kent bios_board_info_set(void)
84 1.1.6.2 kent {
85 1.1.6.2 kent
86 1.1.6.2 kent /* Initialize board properties database */
87 1.1.6.2 kent board_info_init();
88 1.1.6.2 kent
89 1.1.6.2 kent if (board_info_set("mem-size",
90 1.1.6.2 kent &board_mem_size,
91 1.1.6.2 kent sizeof(board_mem_size), PROP_CONST, 0))
92 1.1.6.2 kent panic("setting mem-size");
93 1.1.6.2 kent
94 1.1.6.2 kent if (board_info_set("emac0-mac-addr",
95 1.1.6.2 kent &board_bios.mac_address_local,
96 1.1.6.2 kent sizeof(board_bios.mac_address_local), PROP_CONST, 0))
97 1.1.6.2 kent panic("setting emac0-mac-addr");
98 1.1.6.2 kent
99 1.1.6.2 kent if (board_info_set("processor-frequency",
100 1.1.6.2 kent &board_cpu_speed,
101 1.1.6.2 kent sizeof(board_cpu_speed), PROP_CONST, 0))
102 1.1.6.2 kent panic("setting processor-frequency");
103 1.1.6.2 kent
104 1.1.6.2 kent if (board_info_set("plb-frequency",
105 1.1.6.2 kent &board_plb_speed,
106 1.1.6.2 kent sizeof(board_plb_speed), PROP_CONST, 0))
107 1.1.6.2 kent panic("setting plb-frequency");
108 1.1.6.2 kent
109 1.1.6.2 kent if (board_info_set("pci-frequency",
110 1.1.6.2 kent &board_pci_speed,
111 1.1.6.2 kent sizeof(board_pci_speed), PROP_CONST, 0))
112 1.1.6.2 kent panic("setting pci-frequency");
113 1.1.6.2 kent }
114 1.1.6.2 kent
115 1.1.6.2 kent
116 1.1.6.2 kent void
117 1.1.6.2 kent bios_board_print(void)
118 1.1.6.2 kent {
119 1.1.6.2 kent
120 1.1.6.2 kent printf("Board config data:\n");
121 1.1.6.2 kent printf(" mem_size = %u\n", board_mem_size);
122 1.1.6.2 kent printf(" mac_address_local = %02x:%02x:%02x:%02x:%02x:%02x\n",
123 1.1.6.2 kent board_bios.mac_address_local[0], board_bios.mac_address_local[1],
124 1.1.6.2 kent board_bios.mac_address_local[2], board_bios.mac_address_local[3],
125 1.1.6.2 kent board_bios.mac_address_local[4], board_bios.mac_address_local[5]);
126 1.1.6.2 kent printf(" processor_speed = %u\n", board_cpu_speed);
127 1.1.6.2 kent printf(" plb_speed = %u\n", board_plb_speed);
128 1.1.6.2 kent printf(" pci_speed = %u\n", board_pci_speed);
129 1.1.6.2 kent }
130