wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 1 | /* |
wdenk | d4ca31c | 2004-01-02 14:00:00 +0000 | [diff] [blame] | 2 | * (C) Copyright 2000-2004 |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 4 | * |
| 5 | * See file CREDITS for list of people who contributed to this |
| 6 | * project. |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU General Public License as |
| 10 | * published by the Free Software Foundation; either version 2 of |
| 11 | * the License, or (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
wdenk | 180d3f7 | 2004-01-04 16:28:35 +0000 | [diff] [blame] | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 21 | * MA 02111-1307 USA |
| 22 | */ |
| 23 | |
| 24 | #ifndef __COMMON_H_ |
| 25 | #define __COMMON_H_ 1 |
| 26 | |
| 27 | #undef _LINUX_CONFIG_H |
| 28 | #define _LINUX_CONFIG_H 1 /* avoid reading Linux autoconf.h file */ |
| 29 | |
| 30 | typedef unsigned char uchar; |
| 31 | typedef volatile unsigned long vu_long; |
wdenk | 180d3f7 | 2004-01-04 16:28:35 +0000 | [diff] [blame] | 32 | typedef volatile unsigned short vu_short; |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 33 | typedef volatile unsigned char vu_char; |
| 34 | |
| 35 | #include <config.h> |
| 36 | #include <linux/bitops.h> |
| 37 | #include <linux/types.h> |
| 38 | #include <linux/string.h> |
| 39 | #include <asm/ptrace.h> |
| 40 | #include <stdarg.h> |
| 41 | #if defined(CONFIG_PCI) && defined(CONFIG_440) |
| 42 | #include <pci.h> |
| 43 | #endif |
wdenk | 180d3f7 | 2004-01-04 16:28:35 +0000 | [diff] [blame] | 44 | #if defined(CONFIG_8xx) |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 45 | #include <asm/8xx_immap.h> |
wdenk | d4ca31c | 2004-01-02 14:00:00 +0000 | [diff] [blame] | 46 | #if defined(CONFIG_MPC852) || defined(CONFIG_MPC852T) || \ |
| 47 | defined(CONFIG_MPC859) || defined(CONFIG_MPC859T) || \ |
| 48 | defined(CONFIG_MPC859DSL) || \ |
| 49 | defined(CONFIG_MPC866) || defined(CONFIG_MPC866T) || \ |
| 50 | defined(CONFIG_MPC866P) |
wdenk | 1114257 | 2004-06-06 21:35:06 +0000 | [diff] [blame] | 51 | # define CONFIG_MPC866_FAMILY 1 |
wdenk | 180d3f7 | 2004-01-04 16:28:35 +0000 | [diff] [blame] | 52 | #elif defined(CONFIG_MPC870) \ |
| 53 | || defined(CONFIG_MPC875) \ |
| 54 | || defined(CONFIG_MPC880) \ |
| 55 | || defined(CONFIG_MPC885) |
wdenk | 1114257 | 2004-06-06 21:35:06 +0000 | [diff] [blame] | 56 | # define CONFIG_MPC885_FAMILY 1 |
wdenk | 180d3f7 | 2004-01-04 16:28:35 +0000 | [diff] [blame] | 57 | #endif |
| 58 | #if defined(CONFIG_MPC860) \ |
| 59 | || defined(CONFIG_MPC860T) \ |
wdenk | 1114257 | 2004-06-06 21:35:06 +0000 | [diff] [blame] | 60 | || defined(CONFIG_MPC866_FAMILY) \ |
| 61 | || defined(CONFIG_MPC885_FAMILY) |
wdenk | 180d3f7 | 2004-01-04 16:28:35 +0000 | [diff] [blame] | 62 | # define CONFIG_MPC86x 1 |
wdenk | 2535d60 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 63 | #endif |
wdenk | 0db5bca | 2003-03-31 17:27:09 +0000 | [diff] [blame] | 64 | #elif defined(CONFIG_5xx) |
| 65 | #include <asm/5xx_immap.h> |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 66 | #elif defined(CONFIG_8260) |
wdenk | 04a85b3 | 2004-04-15 18:22:41 +0000 | [diff] [blame] | 67 | #if defined(CONFIG_MPC8247) \ |
| 68 | || defined(CONFIG_MPC8248) \ |
| 69 | || defined(CONFIG_MPC8271) \ |
| 70 | || defined(CONFIG_MPC8272) |
| 71 | #define CONFIG_MPC8272_FAMILY 1 |
| 72 | #endif |
| 73 | #if defined(CONFIG_MPC8272_FAMILY) |
| 74 | #define CONFIG_MPC8260 1 |
| 75 | #endif |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 76 | #include <asm/immap_8260.h> |
| 77 | #endif |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 78 | #ifdef CONFIG_MPC85xx |
| 79 | #include <mpc85xx.h> |
| 80 | #include <asm/immap_85xx.h> |
| 81 | #endif |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 82 | #ifdef CONFIG_4xx |
| 83 | #include <ppc4xx.h> |
| 84 | #endif |
| 85 | #ifdef CONFIG_HYMOD |
wdenk | 6dd652f | 2003-06-19 23:40:20 +0000 | [diff] [blame] | 86 | #include <board/hymod/hymod.h> |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 87 | #endif |
| 88 | #ifdef CONFIG_ARM |
| 89 | #define asmlinkage /* nothing */ |
| 90 | #endif |
| 91 | |
| 92 | #include <part.h> |
| 93 | #include <flash.h> |
| 94 | #include <image.h> |
| 95 | |
| 96 | #ifdef DEBUG |
| 97 | #define debug(fmt,args...) printf (fmt ,##args) |
wdenk | 52f52c1 | 2003-06-19 23:04:19 +0000 | [diff] [blame] | 98 | #define debugX(level,fmt,args...) if (DEBUG>=level) printf(fmt,##args); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 99 | #else |
| 100 | #define debug(fmt,args...) |
wdenk | 52f52c1 | 2003-06-19 23:04:19 +0000 | [diff] [blame] | 101 | #define debugX(level,fmt,args...) |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 102 | #endif /* DEBUG */ |
| 103 | |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 104 | typedef void (interrupt_handler_t)(void *); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 105 | |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 106 | #include <asm/u-boot.h> /* boot information for Linux kernel */ |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 107 | #include <asm/global_data.h> /* global data used for startup functions */ |
| 108 | |
wdenk | 71f9511 | 2003-06-15 22:40:42 +0000 | [diff] [blame] | 109 | /* |
| 110 | * enable common handling for all TQM8xxL/M boards: |
| 111 | * - CONFIG_TQM8xxM will be defined for all TQM8xxM boards |
| 112 | * - CONFIG_TQM8xxL will be defined for all TQM8xxL _and_ TQM8xxM boards |
| 113 | */ |
| 114 | #if defined(CONFIG_TQM823M) || defined(CONFIG_TQM850M) || \ |
| 115 | defined(CONFIG_TQM855M) || defined(CONFIG_TQM860M) || \ |
wdenk | d4ca31c | 2004-01-02 14:00:00 +0000 | [diff] [blame] | 116 | defined(CONFIG_TQM862M) || defined(CONFIG_TQM866M) |
wdenk | 71f9511 | 2003-06-15 22:40:42 +0000 | [diff] [blame] | 117 | # ifndef CONFIG_TQM8xxM |
| 118 | # define CONFIG_TQM8xxM |
| 119 | # endif |
| 120 | #endif |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 121 | #if defined(CONFIG_TQM823L) || defined(CONFIG_TQM850L) || \ |
wdenk | d126bfb | 2003-04-10 11:18:18 +0000 | [diff] [blame] | 122 | defined(CONFIG_TQM855L) || defined(CONFIG_TQM860L) || \ |
wdenk | 71f9511 | 2003-06-15 22:40:42 +0000 | [diff] [blame] | 123 | defined(CONFIG_TQM862L) || defined(CONFIG_TQM8xxM) |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 124 | # ifndef CONFIG_TQM8xxL |
| 125 | # define CONFIG_TQM8xxL |
| 126 | # endif |
| 127 | #endif |
| 128 | |
| 129 | |
| 130 | /* |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 131 | * General Purpose Utilities |
| 132 | */ |
| 133 | #define min(X, Y) \ |
| 134 | ({ typeof (X) __x = (X), __y = (Y); \ |
| 135 | (__x < __y) ? __x : __y; }) |
| 136 | |
| 137 | #define max(X, Y) \ |
| 138 | ({ typeof (X) __x = (X), __y = (Y); \ |
| 139 | (__x > __y) ? __x : __y; }) |
| 140 | |
| 141 | |
| 142 | /* |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 143 | * Function Prototypes |
| 144 | */ |
| 145 | |
wdenk | 42dfe7a | 2004-03-14 22:25:36 +0000 | [diff] [blame] | 146 | #ifdef CONFIG_SERIAL_SOFTWARE_FIFO |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 147 | void serial_buffered_init (void); |
| 148 | void serial_buffered_putc (const char); |
| 149 | void serial_buffered_puts (const char *); |
| 150 | int serial_buffered_getc (void); |
| 151 | int serial_buffered_tstc (void); |
| 152 | #endif /* CONFIG_SERIAL_SOFTWARE_FIFO */ |
| 153 | |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 154 | void hang (void) __attribute__ ((noreturn)); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 155 | |
| 156 | /* */ |
| 157 | long int initdram (int); |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 158 | int display_options (void); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 159 | void print_size (ulong, const char *); |
| 160 | |
| 161 | /* common/main.c */ |
| 162 | void main_loop (void); |
| 163 | int run_command (const char *cmd, int flag); |
| 164 | int readline (const char *const prompt); |
wdenk | 6dd652f | 2003-06-19 23:40:20 +0000 | [diff] [blame] | 165 | void init_cmd_timeout(void); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 166 | void reset_cmd_timeout(void); |
| 167 | |
wdenk | 15647dc | 2003-10-09 19:00:25 +0000 | [diff] [blame] | 168 | /* lib_$(ARCH)/board.c */ |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 169 | void board_init_f (ulong); |
| 170 | void board_init_r (gd_t *, ulong); |
| 171 | int checkboard (void); |
| 172 | int checkflash (void); |
| 173 | int checkdram (void); |
| 174 | char * strmhz(char *buf, long hz); |
| 175 | int last_stage_init(void); |
wdenk | 3b57fe0 | 2003-05-30 12:48:29 +0000 | [diff] [blame] | 176 | extern ulong monitor_flash_len; |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 177 | |
| 178 | /* common/flash.c */ |
| 179 | void flash_perror (int); |
| 180 | |
wdenk | b0fce99 | 2003-06-29 21:03:46 +0000 | [diff] [blame] | 181 | /* common/cmd_autoscript.c */ |
| 182 | int autoscript (ulong addr); |
| 183 | |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 184 | /* common/cmd_bootm.c */ |
wdenk | b0fce99 | 2003-06-29 21:03:46 +0000 | [diff] [blame] | 185 | void print_image_hdr (image_header_t *hdr); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 186 | |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 187 | extern ulong load_addr; /* Default Load Address */ |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 188 | |
| 189 | /* common/cmd_nvedit.c */ |
| 190 | int env_init (void); |
| 191 | void env_relocate (void); |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 192 | char *getenv (uchar *); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 193 | int getenv_r (uchar *name, uchar *buf, unsigned len); |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 194 | int saveenv (void); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 195 | #ifdef CONFIG_PPC /* ARM version to be fixed! */ |
| 196 | void inline setenv (char *, char *); |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 197 | #else |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 198 | void setenv (char *, char *); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 199 | #endif /* CONFIG_PPC */ |
| 200 | #ifdef CONFIG_ARM |
wdenk | b6e4c40 | 2004-01-02 16:05:07 +0000 | [diff] [blame] | 201 | # include <asm/setup.h> |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 202 | # include <asm/u-boot-arm.h> /* ARM version to be fixed! */ |
| 203 | #endif /* CONFIG_ARM */ |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 204 | #ifdef CONFIG_I386 /* x86 version to be fixed! */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 205 | # include <asm/u-boot-i386.h> |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 206 | #endif /* CONFIG_I386 */ |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 207 | |
wdenk | 04a85b3 | 2004-04-15 18:22:41 +0000 | [diff] [blame] | 208 | #ifdef CONFIG_AUTO_COMPLETE |
| 209 | int env_complete(char *var, int maxv, char *cmdv[], int maxsz, char *buf); |
| 210 | #endif |
| 211 | |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 212 | void pci_init (void); |
| 213 | void pci_init_board(void); |
| 214 | void pciinfo (int, int); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 215 | |
| 216 | #if defined(CONFIG_PCI) && defined(CONFIG_440) |
| 217 | # if defined(CFG_PCI_PRE_INIT) |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 218 | int pci_pre_init (struct pci_controller * ); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 219 | # endif |
| 220 | # if defined(CFG_PCI_TARGET_INIT) |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 221 | void pci_target_init (struct pci_controller *); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 222 | # endif |
| 223 | # if defined(CFG_PCI_MASTER_INIT) |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 224 | void pci_master_init (struct pci_controller *); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 225 | # endif |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 226 | int is_pci_host (struct pci_controller *); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 227 | #endif |
| 228 | |
| 229 | int misc_init_f (void); |
| 230 | int misc_init_r (void); |
| 231 | |
wdenk | 27b207f | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 232 | /* common/exports.c */ |
| 233 | void jumptable_init(void); |
| 234 | |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 235 | /* common/memsize.c */ |
| 236 | int get_ram_size (volatile long *, long); |
| 237 | |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 238 | /* $(BOARD)/$(BOARD).c */ |
| 239 | void reset_phy (void); |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 240 | void fdc_hw_init (void); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 241 | |
| 242 | /* $(BOARD)/eeprom.c */ |
| 243 | void eeprom_init (void); |
wdenk | 6dd652f | 2003-06-19 23:40:20 +0000 | [diff] [blame] | 244 | #ifndef CONFIG_SPI |
| 245 | int eeprom_probe (unsigned dev_addr, unsigned offset); |
| 246 | #endif |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 247 | int eeprom_read (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt); |
| 248 | int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt); |
| 249 | #ifdef CONFIG_LWMON |
| 250 | extern uchar pic_read (uchar reg); |
| 251 | extern void pic_write (uchar reg, uchar val); |
| 252 | #endif |
| 253 | |
| 254 | /* |
| 255 | * Set this up regardless of board |
| 256 | * type, to prevent errors. |
| 257 | */ |
| 258 | #if defined(CONFIG_SPI) || !defined(CFG_I2C_EEPROM_ADDR) |
| 259 | # define CFG_DEF_EEPROM_ADDR 0 |
| 260 | #else |
| 261 | # define CFG_DEF_EEPROM_ADDR CFG_I2C_EEPROM_ADDR |
| 262 | #endif /* CONFIG_SPI || !defined(CFG_I2C_EEPROM_ADDR) */ |
| 263 | |
wdenk | bdccc4f | 2003-08-05 17:43:17 +0000 | [diff] [blame] | 264 | #if defined(CONFIG_SPI) |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 265 | extern void spi_init_f (void); |
| 266 | extern void spi_init_r (void); |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 267 | extern ssize_t spi_read (uchar *, int, uchar *, int); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 268 | extern ssize_t spi_write (uchar *, int, uchar *, int); |
| 269 | #endif |
| 270 | |
| 271 | #ifdef CONFIG_RPXCLASSIC |
| 272 | void rpxclassic_init (void); |
| 273 | #endif |
| 274 | |
wdenk | e63c8ee | 2004-06-09 21:04:48 +0000 | [diff] [blame] | 275 | void rpxlite_init (void); |
| 276 | |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 277 | #ifdef CONFIG_MBX |
| 278 | /* $(BOARD)/mbx8xx.c */ |
| 279 | void mbx_init (void); |
| 280 | void board_serial_init (void); |
| 281 | void board_ether_init (void); |
| 282 | #endif |
| 283 | |
wdenk | ba56f62 | 2004-02-06 23:19:44 +0000 | [diff] [blame] | 284 | #if defined(CONFIG_RPXCLASSIC) || defined(CONFIG_MBX) || \ |
| 285 | defined(CONFIG_IAD210) || defined(CONFIG_XPEDITE1K) |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 286 | void board_get_enetaddr (uchar *addr); |
| 287 | #endif |
| 288 | |
| 289 | #ifdef CONFIG_HERMES |
| 290 | /* $(BOARD)/hermes.c */ |
| 291 | void hermes_start_lxt980 (int speed); |
| 292 | #endif |
| 293 | |
| 294 | #ifdef CONFIG_EVB64260 |
| 295 | void evb64260_init(void); |
| 296 | void debug_led(int, int); |
| 297 | void display_mem_map(void); |
| 298 | void perform_soft_reset(void); |
| 299 | #endif |
| 300 | |
| 301 | void load_sernum_ethaddr (void); |
| 302 | |
| 303 | /* $(BOARD)/$(BOARD).c */ |
wdenk | c837dcb | 2004-01-20 23:12:12 +0000 | [diff] [blame] | 304 | int board_early_init_f (void); |
| 305 | int board_late_init (void); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 306 | int board_postclk_init (void); /* after clocks/timebase, before env/serial */ |
wdenk | c837dcb | 2004-01-20 23:12:12 +0000 | [diff] [blame] | 307 | int board_early_init_r (void); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 308 | void board_poweroff (void); |
| 309 | |
| 310 | #if defined(CFG_DRAM_TEST) |
| 311 | int testdram(void); |
| 312 | #endif /* CFG_DRAM_TEST */ |
| 313 | |
| 314 | /* $(CPU)/start.S */ |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 315 | #if defined(CONFIG_5xx) || \ |
wdenk | 0db5bca | 2003-03-31 17:27:09 +0000 | [diff] [blame] | 316 | defined(CONFIG_8xx) |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 317 | uint get_immr (uint); |
| 318 | #endif |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 319 | uint get_pir (void); |
wdenk | 36c7287 | 2004-06-09 17:45:32 +0000 | [diff] [blame] | 320 | #if defined(CONFIG_MPC5xxx) |
| 321 | uint get_svr (void); |
| 322 | #endif |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 323 | uint get_pvr (void); |
wdenk | 547b4cb | 2004-06-09 00:51:50 +0000 | [diff] [blame] | 324 | uint get_svr (void); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 325 | uint rd_ic_cst (void); |
| 326 | void wr_ic_cst (uint); |
| 327 | void wr_ic_adr (uint); |
| 328 | uint rd_dc_cst (void); |
| 329 | void wr_dc_cst (uint); |
| 330 | void wr_dc_adr (uint); |
| 331 | int icache_status (void); |
| 332 | void icache_enable (void); |
| 333 | void icache_disable(void); |
| 334 | int dcache_status (void); |
| 335 | void dcache_enable (void); |
| 336 | void dcache_disable(void); |
| 337 | void relocate_code (ulong, gd_t *, ulong); |
| 338 | ulong get_endaddr (void); |
| 339 | void trap_init (ulong); |
| 340 | #if defined (CONFIG_4xx) || \ |
wdenk | eeb1b77 | 2004-03-23 22:53:55 +0000 | [diff] [blame] | 341 | defined (CONFIG_MPC5xxx) || \ |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 342 | defined (CONFIG_74xx_7xx) || \ |
| 343 | defined (CONFIG_74x) || \ |
| 344 | defined (CONFIG_75x) || \ |
wdenk | 0ac6f8b | 2004-07-09 23:27:13 +0000 | [diff] [blame] | 345 | defined (CONFIG_74xx) || \ |
| 346 | defined(CONFIG_MPC85xx) |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 347 | unsigned char in8(unsigned int); |
| 348 | void out8(unsigned int, unsigned char); |
| 349 | unsigned short in16(unsigned int); |
| 350 | unsigned short in16r(unsigned int); |
| 351 | void out16(unsigned int, unsigned short value); |
| 352 | void out16r(unsigned int, unsigned short value); |
| 353 | unsigned long in32(unsigned int); |
| 354 | unsigned long in32r(unsigned int); |
| 355 | void out32(unsigned int, unsigned long value); |
| 356 | void out32r(unsigned int, unsigned long value); |
| 357 | void ppcDcbf(unsigned long value); |
| 358 | void ppcDcbi(unsigned long value); |
| 359 | void ppcSync(void); |
wdenk | 0ac6f8b | 2004-07-09 23:27:13 +0000 | [diff] [blame] | 360 | void ppcDcbz(unsigned long value); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 361 | #endif |
| 362 | |
| 363 | /* $(CPU)/cpu.c */ |
| 364 | int checkcpu (void); |
| 365 | int checkicache (void); |
| 366 | int checkdcache (void); |
| 367 | void upmconfig (unsigned int, unsigned int *, unsigned int); |
| 368 | ulong get_tbclk (void); |
| 369 | |
| 370 | /* $(CPU)/serial.c */ |
| 371 | int serial_init (void); |
| 372 | void serial_setbrg (void); |
| 373 | void serial_putc (const char); |
| 374 | void serial_puts (const char *); |
| 375 | void serial_addr (unsigned int); |
| 376 | int serial_getc (void); |
| 377 | int serial_tstc (void); |
| 378 | |
| 379 | /* $(CPU)/speed.c */ |
| 380 | int get_clocks (void); |
wdenk | c178d3d | 2004-01-24 20:25:54 +0000 | [diff] [blame] | 381 | int get_clocks_866 (void); |
| 382 | int sdram_adjust_866 (void); |
wdenk | e9132ea | 2004-04-24 23:23:30 +0000 | [diff] [blame] | 383 | int adjust_sdram_tbs_8xx (void); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 384 | #if defined(CONFIG_8260) |
| 385 | int prt_8260_clks (void); |
| 386 | #endif |
wdenk | cbd8a35 | 2004-02-24 02:00:03 +0000 | [diff] [blame] | 387 | #if defined(CONFIG_MPC5xxx) |
wdenk | 945af8d | 2003-07-16 21:53:01 +0000 | [diff] [blame] | 388 | int prt_mpc5xxx_clks (void); |
| 389 | #endif |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 390 | #ifdef CONFIG_4xx |
| 391 | ulong get_OPB_freq (void); |
| 392 | ulong get_PCI_freq (void); |
| 393 | #endif |
wdenk | f39748a | 2004-06-09 13:37:52 +0000 | [diff] [blame] | 394 | #if defined(CONFIG_S3C2400) || defined(CONFIG_S3C2410) || defined(CONFIG_LH7A40X) |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 395 | ulong get_FCLK (void); |
| 396 | ulong get_HCLK (void); |
| 397 | ulong get_PCLK (void); |
| 398 | ulong get_UCLK (void); |
| 399 | #endif |
wdenk | f39748a | 2004-06-09 13:37:52 +0000 | [diff] [blame] | 400 | #if defined(CONFIG_LH7A40X) |
| 401 | ulong get_PLLCLK (void); |
| 402 | #endif |
wdenk | 7cb22f9 | 2003-12-27 19:24:54 +0000 | [diff] [blame] | 403 | #if defined CONFIG_INCA_IP |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 404 | uint incaip_get_cpuclk (void); |
wdenk | 7cb22f9 | 2003-12-27 19:24:54 +0000 | [diff] [blame] | 405 | #endif |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 406 | ulong get_bus_freq (ulong); |
| 407 | |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 408 | #if defined(CONFIG_MPC85xx) |
| 409 | typedef MPC85xx_SYS_INFO sys_info_t; |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 410 | void get_sys_info ( sys_info_t * ); |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 411 | #endif |
| 412 | |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 413 | #if defined(CONFIG_4xx) || defined(CONFIG_IOP480) |
| 414 | # if defined(CONFIG_440) |
| 415 | typedef PPC440_SYS_INFO sys_info_t; |
| 416 | # else |
| 417 | typedef PPC405_SYS_INFO sys_info_t; |
| 418 | # endif |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 419 | void get_sys_info ( sys_info_t * ); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 420 | #endif |
| 421 | |
| 422 | /* $(CPU)/cpu_init.c */ |
| 423 | #if defined(CONFIG_8xx) || defined(CONFIG_8260) |
| 424 | void cpu_init_f (volatile immap_t *immr); |
| 425 | #endif |
wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 426 | #if defined(CONFIG_4xx) || defined(CONFIG_MPC85xx) || defined(CONFIG_MCF52x2) |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 427 | void cpu_init_f (void); |
| 428 | #endif |
wdenk | bf9e3b3 | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 429 | |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 430 | int cpu_init_r (void); |
| 431 | #if defined(CONFIG_8260) |
| 432 | int prt_8260_rsr (void); |
| 433 | #endif |
| 434 | |
| 435 | /* $(CPU)/interrupts.c */ |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 436 | int interrupt_init (void); |
| 437 | void timer_interrupt (struct pt_regs *); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 438 | void external_interrupt (struct pt_regs *); |
| 439 | void irq_install_handler(int, interrupt_handler_t *, void *); |
| 440 | void irq_free_handler (int); |
| 441 | void reset_timer (void); |
| 442 | ulong get_timer (ulong base); |
| 443 | void set_timer (ulong t); |
| 444 | void enable_interrupts (void); |
| 445 | int disable_interrupts (void); |
| 446 | |
| 447 | /* $(CPU)/.../commproc.c */ |
| 448 | int dpram_init (void); |
| 449 | uint dpram_base(void); |
| 450 | uint dpram_base_align(uint align); |
| 451 | uint dpram_alloc(uint size); |
| 452 | uint dpram_alloc_align(uint size,uint align); |
| 453 | void post_word_store (ulong); |
| 454 | ulong post_word_load (void); |
wdenk | bdccc4f | 2003-08-05 17:43:17 +0000 | [diff] [blame] | 455 | void bootcount_store (ulong); |
| 456 | ulong bootcount_load (void); |
| 457 | #define BOOTCOUNT_MAGIC 0xB001C041 |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 458 | |
| 459 | /* $(CPU)/.../<eth> */ |
| 460 | void mii_init (void); |
| 461 | |
| 462 | /* $(CPU)/.../lcd.c */ |
| 463 | ulong lcd_setmem (ulong); |
| 464 | |
| 465 | /* $(CPU)/.../vfd.c */ |
| 466 | ulong vfd_setmem (ulong); |
| 467 | |
| 468 | /* $(CPU)/.../video.c */ |
| 469 | ulong video_setmem (ulong); |
| 470 | |
wdenk | fabd46a | 2004-07-10 23:11:10 +0000 | [diff] [blame] | 471 | /* lib_$(ARCH)/cache.c */ |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 472 | void flush_cache (unsigned long, unsigned long); |
| 473 | |
wdenk | 0db5bca | 2003-03-31 17:27:09 +0000 | [diff] [blame] | 474 | |
wdenk | 15647dc | 2003-10-09 19:00:25 +0000 | [diff] [blame] | 475 | /* lib_$(ARCH)/ticks.S */ |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 476 | unsigned long long get_ticks(void); |
| 477 | void wait_ticks (unsigned long); |
| 478 | |
wdenk | 15647dc | 2003-10-09 19:00:25 +0000 | [diff] [blame] | 479 | /* lib_$(ARCH)/time.c */ |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 480 | void udelay (unsigned long); |
| 481 | ulong usec2ticks (unsigned long usec); |
| 482 | ulong ticks2usec (unsigned long ticks); |
| 483 | int init_timebase (void); |
| 484 | |
wdenk | 15647dc | 2003-10-09 19:00:25 +0000 | [diff] [blame] | 485 | /* lib_generic/vsprintf.c */ |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 486 | ulong simple_strtoul(const char *cp,char **endp,unsigned int base); |
wdenk | 42dfe7a | 2004-03-14 22:25:36 +0000 | [diff] [blame] | 487 | #ifdef CFG_64BIT_VSPRINTF |
wdenk | c40b295 | 2004-03-13 23:29:43 +0000 | [diff] [blame] | 488 | unsigned long long simple_strtoull(const char *cp,char **endp,unsigned int base); |
| 489 | #endif |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 490 | long simple_strtol(const char *cp,char **endp,unsigned int base); |
| 491 | void panic(const char *fmt, ...); |
| 492 | int sprintf(char * buf, const char *fmt, ...); |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 493 | int vsprintf(char *buf, const char *fmt, va_list args); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 494 | |
wdenk | 15647dc | 2003-10-09 19:00:25 +0000 | [diff] [blame] | 495 | /* lib_generic/crc32.c */ |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 496 | ulong crc32 (ulong, const unsigned char *, uint); |
| 497 | ulong crc32_no_comp (ulong, const unsigned char *, uint); |
| 498 | |
| 499 | /* common/console.c */ |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 500 | int console_init_f(void); /* Before relocation; uses the serial stuff */ |
| 501 | int console_init_r(void); /* After relocation; uses the console stuff */ |
| 502 | int console_assign (int file, char *devname); /* Assign the console */ |
| 503 | int ctrlc (void); |
| 504 | int had_ctrlc (void); /* have we had a Control-C since last clear? */ |
| 505 | void clear_ctrlc (void); /* clear the Control-C condition */ |
| 506 | int disable_ctrlc (int); /* 1 to disable, 0 to enable Control-C detect */ |
| 507 | |
| 508 | /* |
| 509 | * STDIO based functions (can always be used) |
| 510 | */ |
| 511 | |
| 512 | /* serial stuff */ |
| 513 | void serial_printf (const char *fmt, ...); |
| 514 | |
| 515 | /* stdin */ |
| 516 | int getc(void); |
| 517 | int tstc(void); |
| 518 | |
| 519 | /* stdout */ |
| 520 | void putc(const char c); |
| 521 | void puts(const char *s); |
| 522 | void printf(const char *fmt, ...); |
wdenk | 6dd652f | 2003-06-19 23:40:20 +0000 | [diff] [blame] | 523 | void vprintf(const char *fmt, va_list args); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 524 | |
| 525 | /* stderr */ |
| 526 | #define eputc(c) fputc(stderr, c) |
| 527 | #define eputs(s) fputs(stderr, s) |
| 528 | #define eprintf(fmt,args...) fprintf(stderr,fmt ,##args) |
| 529 | |
| 530 | /* |
| 531 | * FILE based functions (can only be used AFTER relocation!) |
| 532 | */ |
| 533 | |
| 534 | #define stdin 0 |
| 535 | #define stdout 1 |
| 536 | #define stderr 2 |
| 537 | #define MAX_FILES 3 |
| 538 | |
| 539 | void fprintf(int file, const char *fmt, ...); |
| 540 | void fputs(int file, const char *s); |
| 541 | void fputc(int file, const char c); |
| 542 | int ftstc(int file); |
| 543 | int fgetc(int file); |
| 544 | |
| 545 | int pcmcia_init (void); |
| 546 | |
| 547 | #ifdef CONFIG_SHOW_BOOT_PROGRESS |
| 548 | void show_boot_progress (int status); |
| 549 | #endif |
| 550 | |
| 551 | #endif /* __COMMON_H_ */ |