1 /* $NetBSD: cpu.h,v 1.18 2011/06/18 17:06:52 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/spr.h> 42 #include <powerpc/ibm4xx/spr.h> 43 #include <powerpc/ibm4xx/dcr4xx.h> 44 45 #if defined(_KERNEL) 46 extern char bootpath[]; 47 48 #include <sys/param.h> 49 #include <sys/device.h> 50 #include <prop/proplib.h> 51 52 /* export from ibm4xx/autoconf.c */ 53 extern void (*md_device_register)(device_t dev, void *aux); 54 55 /* export from ibm4xx/machdep.c */ 56 extern void (*md_consinit)(void); 57 extern void (*md_cpu_startup)(void); 58 59 /* export from ibm4xx/ibm40x_machdep.c */ 60 extern void ibm40x_memsize_init(u_int, u_int); 61 62 /* export from ibm4xx/ibm4xx_machdep.c */ 63 extern void ibm4xx_init(void (*)(void)); 64 extern void ibm4xx_cpu_startup(const char *); 65 extern void ibm4xx_dumpsys(void); 66 extern void ibm4xx_install_extint(void (*)(void)); 67 68 /* export from ibm4xx/ibm4xx_autoconf.c */ 69 extern void ibm4xx_device_register(device_t dev, void *aux); 70 71 /* export from ibm4xx/clock.c */ 72 extern void calc_delayconst(void); 73 74 /* export from ibm4xx/4xx_locore.S */ 75 extern void ppc4xx_reset(void) __dead; 76 77 /* 78 * DCR (Device Control Register) access. These have to be 79 * macros because register address is encoded as immediate 80 * operand. 81 */ 82 static inline void 83 mtdcr(int reg, uint32_t val) 84 { 85 __asm volatile("mtdcr %0,%1" : : "K"(reg), "r"(val)); 86 } 87 88 static inline uint32_t 89 mfdcr(int reg) 90 { 91 uint32_t val; 92 93 __asm volatile("mfdcr %0,%1" : "=r"(val) : "K"(reg)); 94 return val; 95 } 96 97 static inline void 98 mtcpr(int reg, uint32_t val) 99 { 100 mtdcr(DCR_CPR0_CFGADDR, reg); 101 mtdcr(DCR_CPR0_CFGDATA, val); 102 } 103 104 static inline uint32_t 105 mfcpr(int reg) 106 { 107 mtdcr(DCR_CPR0_CFGADDR, reg); 108 return mfdcr(DCR_CPR0_CFGDATA); 109 } 110 111 static void inline 112 mtsdr(int reg, uint32_t val) 113 { 114 mtdcr(DCR_SDR0_CFGADDR, reg); 115 mtdcr(DCR_SDR0_CFGDATA, val); 116 } 117 118 static inline uint32_t 119 mfsdr(int reg) 120 { 121 mtdcr(DCR_SDR0_CFGADDR, reg); 122 return mfdcr(DCR_SDR0_CFGDATA); 123 } 124 #endif /* _KERNEL */ 125 126 /* Board info dictionary */ 127 extern prop_dictionary_t board_properties; 128 extern void board_info_init(void); 129 130 /*****************************************************************************/ 131 /* THIS CODE IS OBSOLETE. WILL BE REMOVED */ 132 /* 133 * Board configuration structure from the OpenBIOS. 134 */ 135 struct board_cfg_data { 136 unsigned char usr_config_ver[4]; 137 unsigned char rom_sw_ver[30]; 138 unsigned int mem_size; 139 unsigned char mac_address_local[6]; 140 unsigned char mac_address_pci[6]; 141 unsigned int processor_speed; 142 unsigned int plb_speed; 143 unsigned int pci_speed; 144 }; 145 146 extern struct board_cfg_data board_data; 147 /*****************************************************************************/ 148 149 #endif /* _IBM4XX_CPU_H_ */ 150