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