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