Home | History | Annotate | Line # | Download | only in ibm4xx
cpu.h revision 1.19
      1 /*	$NetBSD: cpu.h,v 1.19 2011/06/20 06:24:30 matt Exp $	*/
      2 
      3 /*
      4  * Copyright 2002 Wasabi Systems, Inc.
      5  * All rights reserved.
      6  *
      7  * Written by Eduardo Horvath for Wasabi Systems, Inc.
      8  *
      9  * Redistribution and use in source and binary forms, with or without
     10  * modification, are permitted provided that the following conditions
     11  * are met:
     12  * 1. Redistributions of source code must retain the above copyright
     13  *    notice, this list of conditions and the following disclaimer.
     14  * 2. Redistributions in binary form must reproduce the above copyright
     15  *    notice, this list of conditions and the following disclaimer in the
     16  *    documentation and/or other materials provided with the distribution.
     17  * 3. All advertising materials mentioning features or use of this software
     18  *    must display the following acknowledgement:
     19  *      This product includes software developed for the NetBSD Project by
     20  *      Wasabi Systems, Inc.
     21  * 4. The name of Wasabi Systems, Inc. may not be used to endorse
     22  *    or promote products derived from this software without specific prior
     23  *    written permission.
     24  *
     25  * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
     26  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     27  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     28  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
     29  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     31  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     32  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     33  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     34  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     35  * POSSIBILITY OF SUCH DAMAGE.
     36  */
     37 
     38 #ifndef	_IBM4XX_CPU_H_
     39 #define	_IBM4XX_CPU_H_
     40 
     41 #include <powerpc/psl.h>
     42 #include <powerpc/spr.h>
     43 #include <powerpc/ibm4xx/spr.h>
     44 #include <powerpc/ibm4xx/dcr4xx.h>
     45 
     46 #if defined(_KERNEL)
     47 extern char bootpath[];
     48 
     49 #include <sys/param.h>
     50 #include <sys/device.h>
     51 #include <prop/proplib.h>
     52 
     53 /* export from ibm4xx/autoconf.c */
     54 extern void (*md_device_register)(device_t dev, void *aux);
     55 
     56 /* export from ibm4xx/machdep.c */
     57 extern void (*md_consinit)(void);
     58 extern void (*md_cpu_startup)(void);
     59 
     60 /* export from ibm4xx/ibm40x_machdep.c */
     61 extern void ibm40x_memsize_init(u_int, u_int);
     62 
     63 /* export from ibm4xx/ibm4xx_machdep.c */
     64 extern void ibm4xx_init(void (*)(void));
     65 extern void ibm4xx_cpu_startup(const char *);
     66 extern void ibm4xx_dumpsys(void);
     67 extern void ibm4xx_install_extint(void (*)(void));
     68 
     69 /* export from ibm4xx/ibm4xx_autoconf.c */
     70 extern void ibm4xx_device_register(device_t dev, void *aux);
     71 
     72 /* export from ibm4xx/clock.c */
     73 extern void calc_delayconst(void);
     74 
     75 /* export from ibm4xx/4xx_locore.S */
     76 extern void ppc4xx_reset(void) __dead;
     77 
     78 /*
     79  * DCR (Device Control Register) access. These have to be
     80  * macros because register address is encoded as immediate
     81  * operand.
     82  */
     83 static inline void
     84 mtdcr(int reg, uint32_t val)
     85 {
     86 	__asm volatile("mtdcr %0,%1" : : "K"(reg), "r"(val));
     87 }
     88 
     89 static inline uint32_t
     90 mfdcr(int reg)
     91 {
     92 	uint32_t val;
     93 
     94 	__asm volatile("mfdcr %0,%1" : "=r"(val) : "K"(reg));
     95 	return val;
     96 }
     97 
     98 static inline void
     99 mtcpr(int reg, uint32_t val)
    100 {
    101 	mtdcr(DCR_CPR0_CFGADDR, reg);
    102 	mtdcr(DCR_CPR0_CFGDATA, val);
    103 }
    104 
    105 static inline uint32_t
    106 mfcpr(int reg)
    107 {
    108 	mtdcr(DCR_CPR0_CFGADDR, reg);
    109 	return mfdcr(DCR_CPR0_CFGDATA);
    110 }
    111 
    112 static void inline
    113 mtsdr(int reg, uint32_t val)
    114 {
    115 	mtdcr(DCR_SDR0_CFGADDR, reg);
    116 	mtdcr(DCR_SDR0_CFGDATA, val);
    117 }
    118 
    119 static inline uint32_t
    120 mfsdr(int reg)
    121 {
    122 	mtdcr(DCR_SDR0_CFGADDR, reg);
    123 	return mfdcr(DCR_SDR0_CFGDATA);
    124 }
    125 #endif /* _KERNEL */
    126 
    127 /* Board info dictionary */
    128 extern prop_dictionary_t board_properties;
    129 extern void board_info_init(void);
    130 
    131 /*****************************************************************************/
    132 /* THIS CODE IS OBSOLETE. WILL BE REMOVED */
    133 /*
    134  * Board configuration structure from the OpenBIOS.
    135  */
    136 struct board_cfg_data {
    137 	unsigned char	usr_config_ver[4];
    138 	unsigned char	rom_sw_ver[30];
    139 	unsigned int	mem_size;
    140 	unsigned char	mac_address_local[6];
    141 	unsigned char	mac_address_pci[6];
    142 	unsigned int	processor_speed;
    143 	unsigned int	plb_speed;
    144 	unsigned int	pci_speed;
    145 };
    146 
    147 extern struct board_cfg_data board_data;
    148 /*****************************************************************************/
    149 
    150 #endif	/* _IBM4XX_CPU_H_ */
    151