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