wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 1 | /* |
wdenk | 1ebf41e | 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 | ad276f2 | 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 | ad276f2 | 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 | ad276f2 | 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 | 1ebf41e | 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 | a7556b2 | 2004-06-06 21:35:06 +0000 | [diff] [blame] | 51 | # define CONFIG_MPC866_FAMILY 1 |
wdenk | ad276f2 | 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 | a7556b2 | 2004-06-06 21:35:06 +0000 | [diff] [blame] | 56 | # define CONFIG_MPC885_FAMILY 1 |
wdenk | ad276f2 | 2004-01-04 16:28:35 +0000 | [diff] [blame] | 57 | #endif |
| 58 | #if defined(CONFIG_MPC860) \ |
| 59 | || defined(CONFIG_MPC860T) \ |
wdenk | a7556b2 | 2004-06-06 21:35:06 +0000 | [diff] [blame] | 60 | || defined(CONFIG_MPC866_FAMILY) \ |
| 61 | || defined(CONFIG_MPC885_FAMILY) |
wdenk | ad276f2 | 2004-01-04 16:28:35 +0000 | [diff] [blame] | 62 | # define CONFIG_MPC86x 1 |
wdenk | 2bb1105 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 63 | #endif |
wdenk | 359733b | 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 | 3902d70 | 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 | 9c53f40 | 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 | b00ec16 | 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 | 88e72a3 | 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 | 88e72a3 | 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 | 87249ba | 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 | 87249ba | 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 | 7a428cc | 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 | 1ebf41e | 2004-01-02 14:00:00 +0000 | [diff] [blame] | 116 | defined(CONFIG_TQM862M) || defined(CONFIG_TQM866M) |
wdenk | 7a428cc | 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 | 6bd1489 | 2003-04-10 11:18:18 +0000 | [diff] [blame] | 122 | defined(CONFIG_TQM855L) || defined(CONFIG_TQM860L) || \ |
wdenk | 7a428cc | 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 | |
wdenk | 7ac1610 | 2004-08-01 22:48:16 +0000 | [diff] [blame] | 129 | #ifndef CONFIG_SERIAL_MULTI |
| 130 | |
| 131 | #if defined(CONFIG_8xx_CONS_SMC1) || defined(CONFIG_8xx_CONS_SMC2) \ |
| 132 | || defined(CONFIG_8xx_CONS_SCC1) || defined(CONFIG_8xx_CONS_SCC2) \ |
| 133 | || defined(CONFIG_8xx_CONS_SCC3) || defined(CONFIG_8xx_CONS_SCC4) |
| 134 | |
| 135 | #define CONFIG_SERIAL_MULTI 1 |
| 136 | |
| 137 | #endif |
| 138 | |
| 139 | #endif /* CONFIG_SERIAL_MULTI */ |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 140 | |
| 141 | /* |
wdenk | 452cfd6 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 142 | * General Purpose Utilities |
| 143 | */ |
| 144 | #define min(X, Y) \ |
| 145 | ({ typeof (X) __x = (X), __y = (Y); \ |
| 146 | (__x < __y) ? __x : __y; }) |
| 147 | |
| 148 | #define max(X, Y) \ |
| 149 | ({ typeof (X) __x = (X), __y = (Y); \ |
| 150 | (__x > __y) ? __x : __y; }) |
| 151 | |
| 152 | |
| 153 | /* |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 154 | * Function Prototypes |
| 155 | */ |
| 156 | |
wdenk | c35ba4e | 2004-03-14 22:25:36 +0000 | [diff] [blame] | 157 | #ifdef CONFIG_SERIAL_SOFTWARE_FIFO |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 158 | void serial_buffered_init (void); |
| 159 | void serial_buffered_putc (const char); |
| 160 | void serial_buffered_puts (const char *); |
| 161 | int serial_buffered_getc (void); |
| 162 | int serial_buffered_tstc (void); |
| 163 | #endif /* CONFIG_SERIAL_SOFTWARE_FIFO */ |
| 164 | |
wdenk | 87249ba | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 165 | void hang (void) __attribute__ ((noreturn)); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 166 | |
| 167 | /* */ |
| 168 | long int initdram (int); |
wdenk | 87249ba | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 169 | int display_options (void); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 170 | void print_size (ulong, const char *); |
| 171 | |
| 172 | /* common/main.c */ |
| 173 | void main_loop (void); |
| 174 | int run_command (const char *cmd, int flag); |
| 175 | int readline (const char *const prompt); |
wdenk | b00ec16 | 2003-06-19 23:40:20 +0000 | [diff] [blame] | 176 | void init_cmd_timeout(void); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 177 | void reset_cmd_timeout(void); |
| 178 | |
wdenk | 9f83793 | 2003-10-09 19:00:25 +0000 | [diff] [blame] | 179 | /* lib_$(ARCH)/board.c */ |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 180 | void board_init_f (ulong); |
| 181 | void board_init_r (gd_t *, ulong); |
| 182 | int checkboard (void); |
| 183 | int checkflash (void); |
| 184 | int checkdram (void); |
| 185 | char * strmhz(char *buf, long hz); |
| 186 | int last_stage_init(void); |
wdenk | b9a83a9 | 2003-05-30 12:48:29 +0000 | [diff] [blame] | 187 | extern ulong monitor_flash_len; |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 188 | |
| 189 | /* common/flash.c */ |
| 190 | void flash_perror (int); |
| 191 | |
wdenk | f12e396 | 2003-06-29 21:03:46 +0000 | [diff] [blame] | 192 | /* common/cmd_autoscript.c */ |
| 193 | int autoscript (ulong addr); |
| 194 | |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 195 | /* common/cmd_bootm.c */ |
wdenk | f12e396 | 2003-06-29 21:03:46 +0000 | [diff] [blame] | 196 | void print_image_hdr (image_header_t *hdr); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 197 | |
wdenk | 87249ba | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 198 | extern ulong load_addr; /* Default Load Address */ |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 199 | |
| 200 | /* common/cmd_nvedit.c */ |
| 201 | int env_init (void); |
| 202 | void env_relocate (void); |
wdenk | 87249ba | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 203 | char *getenv (uchar *); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 204 | int getenv_r (uchar *name, uchar *buf, unsigned len); |
wdenk | 87249ba | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 205 | int saveenv (void); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 206 | #ifdef CONFIG_PPC /* ARM version to be fixed! */ |
| 207 | void inline setenv (char *, char *); |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 208 | #else |
wdenk | 87249ba | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 209 | void setenv (char *, char *); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 210 | #endif /* CONFIG_PPC */ |
| 211 | #ifdef CONFIG_ARM |
wdenk | bc01dd5 | 2004-01-02 16:05:07 +0000 | [diff] [blame] | 212 | # include <asm/setup.h> |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 213 | # include <asm/u-boot-arm.h> /* ARM version to be fixed! */ |
| 214 | #endif /* CONFIG_ARM */ |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 215 | #ifdef CONFIG_I386 /* x86 version to be fixed! */ |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 216 | # include <asm/u-boot-i386.h> |
wdenk | 591dda5 | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 217 | #endif /* CONFIG_I386 */ |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 218 | |
wdenk | 3902d70 | 2004-04-15 18:22:41 +0000 | [diff] [blame] | 219 | #ifdef CONFIG_AUTO_COMPLETE |
| 220 | int env_complete(char *var, int maxv, char *cmdv[], int maxsz, char *buf); |
| 221 | #endif |
| 222 | |
wdenk | 87249ba | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 223 | void pci_init (void); |
| 224 | void pci_init_board(void); |
| 225 | void pciinfo (int, int); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 226 | |
| 227 | #if defined(CONFIG_PCI) && defined(CONFIG_440) |
| 228 | # if defined(CFG_PCI_PRE_INIT) |
wdenk | 87249ba | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 229 | int pci_pre_init (struct pci_controller * ); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 230 | # endif |
| 231 | # if defined(CFG_PCI_TARGET_INIT) |
wdenk | 87249ba | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 232 | void pci_target_init (struct pci_controller *); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 233 | # endif |
| 234 | # if defined(CFG_PCI_MASTER_INIT) |
wdenk | 87249ba | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 235 | void pci_master_init (struct pci_controller *); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 236 | # endif |
wdenk | 87249ba | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 237 | int is_pci_host (struct pci_controller *); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 238 | #endif |
| 239 | |
| 240 | int misc_init_f (void); |
| 241 | int misc_init_r (void); |
| 242 | |
wdenk | 874ac26 | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 243 | /* common/exports.c */ |
| 244 | void jumptable_init(void); |
| 245 | |
wdenk | 87249ba | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 246 | /* common/memsize.c */ |
| 247 | int get_ram_size (volatile long *, long); |
| 248 | |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 249 | /* $(BOARD)/$(BOARD).c */ |
| 250 | void reset_phy (void); |
wdenk | 87249ba | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 251 | void fdc_hw_init (void); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 252 | |
| 253 | /* $(BOARD)/eeprom.c */ |
| 254 | void eeprom_init (void); |
wdenk | b00ec16 | 2003-06-19 23:40:20 +0000 | [diff] [blame] | 255 | #ifndef CONFIG_SPI |
| 256 | int eeprom_probe (unsigned dev_addr, unsigned offset); |
| 257 | #endif |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 258 | int eeprom_read (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt); |
| 259 | int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt); |
| 260 | #ifdef CONFIG_LWMON |
| 261 | extern uchar pic_read (uchar reg); |
| 262 | extern void pic_write (uchar reg, uchar val); |
| 263 | #endif |
| 264 | |
| 265 | /* |
| 266 | * Set this up regardless of board |
| 267 | * type, to prevent errors. |
| 268 | */ |
| 269 | #if defined(CONFIG_SPI) || !defined(CFG_I2C_EEPROM_ADDR) |
| 270 | # define CFG_DEF_EEPROM_ADDR 0 |
| 271 | #else |
| 272 | # define CFG_DEF_EEPROM_ADDR CFG_I2C_EEPROM_ADDR |
| 273 | #endif /* CONFIG_SPI || !defined(CFG_I2C_EEPROM_ADDR) */ |
| 274 | |
wdenk | 0a65855 | 2003-08-05 17:43:17 +0000 | [diff] [blame] | 275 | #if defined(CONFIG_SPI) |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 276 | extern void spi_init_f (void); |
| 277 | extern void spi_init_r (void); |
wdenk | 87249ba | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 278 | extern ssize_t spi_read (uchar *, int, uchar *, int); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 279 | extern ssize_t spi_write (uchar *, int, uchar *, int); |
| 280 | #endif |
| 281 | |
| 282 | #ifdef CONFIG_RPXCLASSIC |
| 283 | void rpxclassic_init (void); |
| 284 | #endif |
| 285 | |
wdenk | ec43274 | 2004-06-09 21:04:48 +0000 | [diff] [blame] | 286 | void rpxlite_init (void); |
| 287 | |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 288 | #ifdef CONFIG_MBX |
| 289 | /* $(BOARD)/mbx8xx.c */ |
| 290 | void mbx_init (void); |
| 291 | void board_serial_init (void); |
| 292 | void board_ether_init (void); |
| 293 | #endif |
| 294 | |
wdenk | 544e973 | 2004-02-06 23:19:44 +0000 | [diff] [blame] | 295 | #if defined(CONFIG_RPXCLASSIC) || defined(CONFIG_MBX) || \ |
| 296 | defined(CONFIG_IAD210) || defined(CONFIG_XPEDITE1K) |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 297 | void board_get_enetaddr (uchar *addr); |
| 298 | #endif |
| 299 | |
| 300 | #ifdef CONFIG_HERMES |
| 301 | /* $(BOARD)/hermes.c */ |
| 302 | void hermes_start_lxt980 (int speed); |
| 303 | #endif |
| 304 | |
| 305 | #ifdef CONFIG_EVB64260 |
| 306 | void evb64260_init(void); |
| 307 | void debug_led(int, int); |
| 308 | void display_mem_map(void); |
| 309 | void perform_soft_reset(void); |
| 310 | #endif |
| 311 | |
| 312 | void load_sernum_ethaddr (void); |
| 313 | |
| 314 | /* $(BOARD)/$(BOARD).c */ |
wdenk | da55c6e | 2004-01-20 23:12:12 +0000 | [diff] [blame] | 315 | int board_early_init_f (void); |
| 316 | int board_late_init (void); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 317 | int board_postclk_init (void); /* after clocks/timebase, before env/serial */ |
wdenk | da55c6e | 2004-01-20 23:12:12 +0000 | [diff] [blame] | 318 | int board_early_init_r (void); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 319 | void board_poweroff (void); |
| 320 | |
| 321 | #if defined(CFG_DRAM_TEST) |
| 322 | int testdram(void); |
| 323 | #endif /* CFG_DRAM_TEST */ |
| 324 | |
| 325 | /* $(CPU)/start.S */ |
wdenk | 87249ba | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 326 | #if defined(CONFIG_5xx) || \ |
wdenk | 359733b | 2003-03-31 17:27:09 +0000 | [diff] [blame] | 327 | defined(CONFIG_8xx) |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 328 | uint get_immr (uint); |
| 329 | #endif |
wdenk | 87249ba | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 330 | uint get_pir (void); |
wdenk | 2d64482 | 2004-06-09 17:45:32 +0000 | [diff] [blame] | 331 | #if defined(CONFIG_MPC5xxx) |
| 332 | uint get_svr (void); |
| 333 | #endif |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 334 | uint get_pvr (void); |
wdenk | cc24599 | 2004-06-09 00:51:50 +0000 | [diff] [blame] | 335 | uint get_svr (void); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 336 | uint rd_ic_cst (void); |
| 337 | void wr_ic_cst (uint); |
| 338 | void wr_ic_adr (uint); |
| 339 | uint rd_dc_cst (void); |
| 340 | void wr_dc_cst (uint); |
| 341 | void wr_dc_adr (uint); |
| 342 | int icache_status (void); |
| 343 | void icache_enable (void); |
| 344 | void icache_disable(void); |
| 345 | int dcache_status (void); |
| 346 | void dcache_enable (void); |
| 347 | void dcache_disable(void); |
| 348 | void relocate_code (ulong, gd_t *, ulong); |
| 349 | ulong get_endaddr (void); |
| 350 | void trap_init (ulong); |
| 351 | #if defined (CONFIG_4xx) || \ |
wdenk | aea86e4 | 2004-03-23 22:53:55 +0000 | [diff] [blame] | 352 | defined (CONFIG_MPC5xxx) || \ |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 353 | defined (CONFIG_74xx_7xx) || \ |
| 354 | defined (CONFIG_74x) || \ |
| 355 | defined (CONFIG_75x) || \ |
wdenk | 13eb221 | 2004-07-09 23:27:13 +0000 | [diff] [blame] | 356 | defined (CONFIG_74xx) || \ |
| 357 | defined(CONFIG_MPC85xx) |
wdenk | 87249ba | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 358 | unsigned char in8(unsigned int); |
| 359 | void out8(unsigned int, unsigned char); |
| 360 | unsigned short in16(unsigned int); |
| 361 | unsigned short in16r(unsigned int); |
| 362 | void out16(unsigned int, unsigned short value); |
| 363 | void out16r(unsigned int, unsigned short value); |
| 364 | unsigned long in32(unsigned int); |
| 365 | unsigned long in32r(unsigned int); |
| 366 | void out32(unsigned int, unsigned long value); |
| 367 | void out32r(unsigned int, unsigned long value); |
| 368 | void ppcDcbf(unsigned long value); |
| 369 | void ppcDcbi(unsigned long value); |
| 370 | void ppcSync(void); |
wdenk | 13eb221 | 2004-07-09 23:27:13 +0000 | [diff] [blame] | 371 | void ppcDcbz(unsigned long value); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 372 | #endif |
| 373 | |
| 374 | /* $(CPU)/cpu.c */ |
| 375 | int checkcpu (void); |
| 376 | int checkicache (void); |
| 377 | int checkdcache (void); |
| 378 | void upmconfig (unsigned int, unsigned int *, unsigned int); |
| 379 | ulong get_tbclk (void); |
| 380 | |
| 381 | /* $(CPU)/serial.c */ |
| 382 | int serial_init (void); |
| 383 | void serial_setbrg (void); |
| 384 | void serial_putc (const char); |
| 385 | void serial_puts (const char *); |
| 386 | void serial_addr (unsigned int); |
| 387 | int serial_getc (void); |
| 388 | int serial_tstc (void); |
| 389 | |
| 390 | /* $(CPU)/speed.c */ |
| 391 | int get_clocks (void); |
wdenk | b50cde5 | 2004-01-24 20:25:54 +0000 | [diff] [blame] | 392 | int get_clocks_866 (void); |
| 393 | int sdram_adjust_866 (void); |
wdenk | c78bf13 | 2004-04-24 23:23:30 +0000 | [diff] [blame] | 394 | int adjust_sdram_tbs_8xx (void); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 395 | #if defined(CONFIG_8260) |
| 396 | int prt_8260_clks (void); |
| 397 | #endif |
wdenk | be9c1cb | 2004-02-24 02:00:03 +0000 | [diff] [blame] | 398 | #if defined(CONFIG_MPC5xxx) |
wdenk | 21136db | 2003-07-16 21:53:01 +0000 | [diff] [blame] | 399 | int prt_mpc5xxx_clks (void); |
| 400 | #endif |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 401 | #ifdef CONFIG_4xx |
| 402 | ulong get_OPB_freq (void); |
| 403 | ulong get_PCI_freq (void); |
| 404 | #endif |
wdenk | 3c71176 | 2004-06-09 13:37:52 +0000 | [diff] [blame] | 405 | #if defined(CONFIG_S3C2400) || defined(CONFIG_S3C2410) || defined(CONFIG_LH7A40X) |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 406 | ulong get_FCLK (void); |
| 407 | ulong get_HCLK (void); |
| 408 | ulong get_PCLK (void); |
| 409 | ulong get_UCLK (void); |
| 410 | #endif |
wdenk | 3c71176 | 2004-06-09 13:37:52 +0000 | [diff] [blame] | 411 | #if defined(CONFIG_LH7A40X) |
| 412 | ulong get_PLLCLK (void); |
| 413 | #endif |
wdenk | 67f1336 | 2003-12-27 19:24:54 +0000 | [diff] [blame] | 414 | #if defined CONFIG_INCA_IP |
wdenk | 87249ba | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 415 | uint incaip_get_cpuclk (void); |
wdenk | 67f1336 | 2003-12-27 19:24:54 +0000 | [diff] [blame] | 416 | #endif |
wdenk | 7ac1610 | 2004-08-01 22:48:16 +0000 | [diff] [blame] | 417 | #if defined(CONFIG_IMX) |
| 418 | ulong get_systemPLLCLK(void); |
| 419 | ulong get_FCLK(void); |
| 420 | ulong get_HCLK(void); |
| 421 | ulong get_BCLK(void); |
| 422 | ulong get_PERCLK1(void); |
| 423 | ulong get_PERCLK2(void); |
| 424 | ulong get_PERCLK3(void); |
| 425 | #endif |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 426 | ulong get_bus_freq (ulong); |
| 427 | |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 428 | #if defined(CONFIG_MPC85xx) |
| 429 | typedef MPC85xx_SYS_INFO sys_info_t; |
wdenk | 87249ba | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 430 | void get_sys_info ( sys_info_t * ); |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 431 | #endif |
| 432 | |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 433 | #if defined(CONFIG_4xx) || defined(CONFIG_IOP480) |
| 434 | # if defined(CONFIG_440) |
| 435 | typedef PPC440_SYS_INFO sys_info_t; |
| 436 | # else |
| 437 | typedef PPC405_SYS_INFO sys_info_t; |
| 438 | # endif |
wdenk | 87249ba | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 439 | void get_sys_info ( sys_info_t * ); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 440 | #endif |
| 441 | |
| 442 | /* $(CPU)/cpu_init.c */ |
| 443 | #if defined(CONFIG_8xx) || defined(CONFIG_8260) |
| 444 | void cpu_init_f (volatile immap_t *immr); |
| 445 | #endif |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 446 | #if defined(CONFIG_4xx) || defined(CONFIG_MPC85xx) || defined(CONFIG_MCF52x2) |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 447 | void cpu_init_f (void); |
| 448 | #endif |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 449 | |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 450 | int cpu_init_r (void); |
| 451 | #if defined(CONFIG_8260) |
| 452 | int prt_8260_rsr (void); |
| 453 | #endif |
| 454 | |
| 455 | /* $(CPU)/interrupts.c */ |
wdenk | 87249ba | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 456 | int interrupt_init (void); |
| 457 | void timer_interrupt (struct pt_regs *); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 458 | void external_interrupt (struct pt_regs *); |
| 459 | void irq_install_handler(int, interrupt_handler_t *, void *); |
| 460 | void irq_free_handler (int); |
| 461 | void reset_timer (void); |
| 462 | ulong get_timer (ulong base); |
| 463 | void set_timer (ulong t); |
| 464 | void enable_interrupts (void); |
| 465 | int disable_interrupts (void); |
| 466 | |
| 467 | /* $(CPU)/.../commproc.c */ |
| 468 | int dpram_init (void); |
| 469 | uint dpram_base(void); |
| 470 | uint dpram_base_align(uint align); |
| 471 | uint dpram_alloc(uint size); |
| 472 | uint dpram_alloc_align(uint size,uint align); |
| 473 | void post_word_store (ulong); |
| 474 | ulong post_word_load (void); |
wdenk | 0a65855 | 2003-08-05 17:43:17 +0000 | [diff] [blame] | 475 | void bootcount_store (ulong); |
| 476 | ulong bootcount_load (void); |
| 477 | #define BOOTCOUNT_MAGIC 0xB001C041 |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 478 | |
| 479 | /* $(CPU)/.../<eth> */ |
| 480 | void mii_init (void); |
| 481 | |
| 482 | /* $(CPU)/.../lcd.c */ |
| 483 | ulong lcd_setmem (ulong); |
| 484 | |
| 485 | /* $(CPU)/.../vfd.c */ |
| 486 | ulong vfd_setmem (ulong); |
| 487 | |
| 488 | /* $(CPU)/.../video.c */ |
| 489 | ulong video_setmem (ulong); |
| 490 | |
wdenk | b5bb139 | 2004-07-10 23:11:10 +0000 | [diff] [blame] | 491 | /* lib_$(ARCH)/cache.c */ |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 492 | void flush_cache (unsigned long, unsigned long); |
| 493 | |
wdenk | 359733b | 2003-03-31 17:27:09 +0000 | [diff] [blame] | 494 | |
wdenk | 9f83793 | 2003-10-09 19:00:25 +0000 | [diff] [blame] | 495 | /* lib_$(ARCH)/ticks.S */ |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 496 | unsigned long long get_ticks(void); |
| 497 | void wait_ticks (unsigned long); |
| 498 | |
wdenk | 9f83793 | 2003-10-09 19:00:25 +0000 | [diff] [blame] | 499 | /* lib_$(ARCH)/time.c */ |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 500 | void udelay (unsigned long); |
| 501 | ulong usec2ticks (unsigned long usec); |
| 502 | ulong ticks2usec (unsigned long ticks); |
| 503 | int init_timebase (void); |
| 504 | |
wdenk | 9f83793 | 2003-10-09 19:00:25 +0000 | [diff] [blame] | 505 | /* lib_generic/vsprintf.c */ |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 506 | ulong simple_strtoul(const char *cp,char **endp,unsigned int base); |
wdenk | c35ba4e | 2004-03-14 22:25:36 +0000 | [diff] [blame] | 507 | #ifdef CFG_64BIT_VSPRINTF |
wdenk | f602aa0 | 2004-03-13 23:29:43 +0000 | [diff] [blame] | 508 | unsigned long long simple_strtoull(const char *cp,char **endp,unsigned int base); |
| 509 | #endif |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 510 | long simple_strtol(const char *cp,char **endp,unsigned int base); |
| 511 | void panic(const char *fmt, ...); |
| 512 | int sprintf(char * buf, const char *fmt, ...); |
wdenk | 87249ba | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 513 | int vsprintf(char *buf, const char *fmt, va_list args); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 514 | |
wdenk | 9f83793 | 2003-10-09 19:00:25 +0000 | [diff] [blame] | 515 | /* lib_generic/crc32.c */ |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 516 | ulong crc32 (ulong, const unsigned char *, uint); |
| 517 | ulong crc32_no_comp (ulong, const unsigned char *, uint); |
| 518 | |
| 519 | /* common/console.c */ |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 520 | int console_init_f(void); /* Before relocation; uses the serial stuff */ |
| 521 | int console_init_r(void); /* After relocation; uses the console stuff */ |
| 522 | int console_assign (int file, char *devname); /* Assign the console */ |
| 523 | int ctrlc (void); |
| 524 | int had_ctrlc (void); /* have we had a Control-C since last clear? */ |
| 525 | void clear_ctrlc (void); /* clear the Control-C condition */ |
| 526 | int disable_ctrlc (int); /* 1 to disable, 0 to enable Control-C detect */ |
| 527 | |
| 528 | /* |
| 529 | * STDIO based functions (can always be used) |
| 530 | */ |
| 531 | |
| 532 | /* serial stuff */ |
| 533 | void serial_printf (const char *fmt, ...); |
| 534 | |
| 535 | /* stdin */ |
| 536 | int getc(void); |
| 537 | int tstc(void); |
| 538 | |
| 539 | /* stdout */ |
| 540 | void putc(const char c); |
| 541 | void puts(const char *s); |
| 542 | void printf(const char *fmt, ...); |
wdenk | b00ec16 | 2003-06-19 23:40:20 +0000 | [diff] [blame] | 543 | void vprintf(const char *fmt, va_list args); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 544 | |
| 545 | /* stderr */ |
| 546 | #define eputc(c) fputc(stderr, c) |
| 547 | #define eputs(s) fputs(stderr, s) |
| 548 | #define eprintf(fmt,args...) fprintf(stderr,fmt ,##args) |
| 549 | |
| 550 | /* |
| 551 | * FILE based functions (can only be used AFTER relocation!) |
| 552 | */ |
| 553 | |
| 554 | #define stdin 0 |
| 555 | #define stdout 1 |
| 556 | #define stderr 2 |
| 557 | #define MAX_FILES 3 |
| 558 | |
| 559 | void fprintf(int file, const char *fmt, ...); |
| 560 | void fputs(int file, const char *s); |
| 561 | void fputc(int file, const char c); |
| 562 | int ftstc(int file); |
| 563 | int fgetc(int file); |
| 564 | |
| 565 | int pcmcia_init (void); |
| 566 | |
| 567 | #ifdef CONFIG_SHOW_BOOT_PROGRESS |
| 568 | void show_boot_progress (int status); |
| 569 | #endif |
| 570 | |
| 571 | #endif /* __COMMON_H_ */ |