Home | History | Annotate | Line # | Download | only in dev
century_bios.c revision 1.1
      1 /*	$NetBSD: century_bios.c,v 1.1 2005/03/18 15:31:58 shige 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.1 2005/03/18 15:31:58 shige Exp $");
     35 
     36 #include <sys/param.h>
     37 #include <sys/systm.h>
     38 
     39 #include <machine/cpu.h>
     40 #include <machine/century_bios.h>
     41 
     42 /*
     43  * OpenBlockS S/R Board configuration structure.
     44  *
     45  * IBM405GP Monitor (Ver. 1.8, REV-01  H/W)
     46  * Century Version  (MA-300) (Oct. 30, 2001)
     47  */
     48 struct board_bios_data {
     49 	unsigned char	mac_address_local[6];
     50 	unsigned char	boot_mode;
     51 	unsigned char	mem_size;		/* MB */
     52 };
     53 
     54 static struct board_bios_data	board_bios;
     55 static unsigned int		board_mem_size;
     56 static unsigned int		board_cpu_speed;
     57 static unsigned int		board_plb_speed;
     58 static unsigned int		board_pci_speed;
     59 
     60 void
     61 bios_board_init(void *info_block, u_int sysclk_base)
     62 {
     63 
     64         /* Initialize cache info for memcpy, etc. */
     65         cpu_probe_cache();
     66 
     67 	/* Save info block */
     68 	memcpy(&board_bios, info_block, sizeof(board_bios));
     69 	board_mem_size = board_bios.mem_size * 1024 * 1024;
     70 
     71 	board_cpu_speed = 0x0bebc200;
     72 	board_plb_speed = 0x05f5e100;
     73 	board_pci_speed = 0x01f78a40;
     74 }
     75 
     76 unsigned int
     77 bios_board_memsize_get(void)
     78 {
     79 	return board_mem_size;
     80 }
     81 
     82 void
     83 bios_board_info_set(void)
     84 {
     85 
     86 	/* Initialize board properties database */
     87 	board_info_init();
     88 
     89 	if (board_info_set("mem-size",
     90 		&board_mem_size,
     91 		sizeof(board_mem_size), PROP_CONST, 0))
     92 		panic("setting mem-size");
     93 
     94 	if (board_info_set("emac0-mac-addr",
     95 		&board_bios.mac_address_local,
     96 		sizeof(board_bios.mac_address_local), PROP_CONST, 0))
     97 		panic("setting emac0-mac-addr");
     98 
     99 	if (board_info_set("processor-frequency",
    100 		&board_cpu_speed,
    101 		sizeof(board_cpu_speed), PROP_CONST, 0))
    102 		panic("setting processor-frequency");
    103 
    104 	if (board_info_set("plb-frequency",
    105 		&board_plb_speed,
    106 		sizeof(board_plb_speed), PROP_CONST, 0))
    107 		panic("setting plb-frequency");
    108 
    109 	if (board_info_set("pci-frequency",
    110 		&board_pci_speed,
    111 		sizeof(board_pci_speed), PROP_CONST, 0))
    112 		panic("setting pci-frequency");
    113 }
    114 
    115 
    116 void
    117 bios_board_print(void)
    118 {
    119 
    120 	printf("Board config data:\n");
    121 	printf("  mem_size = %u\n", board_mem_size);
    122 	printf("  mac_address_local = %02x:%02x:%02x:%02x:%02x:%02x\n",
    123 	    board_bios.mac_address_local[0], board_bios.mac_address_local[1],
    124 	    board_bios.mac_address_local[2], board_bios.mac_address_local[3],
    125 	    board_bios.mac_address_local[4], board_bios.mac_address_local[5]);
    126 	printf("  processor_speed = %u\n", board_cpu_speed);
    127 	printf("  plb_speed = %u\n", board_plb_speed);
    128 	printf("  pci_speed = %u\n", board_pci_speed);
    129 }
    130