Commit 0c32d96ddd7309b86ff92dfc1f3694908f174cf6
1 parent
c12cffc543
Exists in
master
and in
57 other branches
Add support for gth2 board
Patch by Thomas Lange, Aug 11 2005
Showing 17 changed files with 1773 additions and 3 deletions Side-by-side Diff
- CHANGELOG
- CREDITS
- MAINTAINERS
- MAKEALL
- Makefile
- board/gth2/Makefile
- board/gth2/config.mk
- board/gth2/ee_access.c
- board/gth2/ee_access.h
- board/gth2/ee_dev.h
- board/gth2/flash.c
- board/gth2/gth2.c
- board/gth2/lowlevel_init.S
- board/gth2/u-boot.lds
- common/cmd_ide.c
- include/asm-mips/au1x00.h
- include/configs/gth2.h
CHANGELOG
| ... | ... | @@ -2,6 +2,9 @@ |
| 2 | 2 | Changes since U-Boot 1.1.4: |
| 3 | 3 | ====================================================================== |
| 4 | 4 | |
| 5 | +* Add support for gth2 board | |
| 6 | + Patch by Thomas Lange, Aug 11 2005 | |
| 7 | + | |
| 5 | 8 | * Add support for CONFIG_SERIAL_MULTI on MPC5xxx |
| 6 | 9 | Patch by Martin Krause, 8 Jun 2006 |
| 7 | 10 |
CREDITS
MAINTAINERS
MAKEALL
Makefile
| ... | ... | @@ -1652,6 +1652,11 @@ |
| 1652 | 1652 | cm41xx_config : unconfig |
| 1653 | 1653 | @./mkconfig $(@:_config=) arm arm920t cm41xx NULL ks8695 |
| 1654 | 1654 | |
| 1655 | +gth2_config : unconfig | |
| 1656 | + @ >include/config.h | |
| 1657 | + @echo "#define CONFIG_GTH2 1" >>include/config.h | |
| 1658 | + @./mkconfig -a gth2 mips mips gth2 | |
| 1659 | + | |
| 1655 | 1660 | ######################################################################### |
| 1656 | 1661 | ## S3C44B0 Systems |
| 1657 | 1662 | ######################################################################### |
board/gth2/Makefile
| 1 | +# | |
| 2 | +# (C) Copyright 2005 | |
| 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 | |
| 15 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 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 | +include $(TOPDIR)/config.mk | |
| 25 | + | |
| 26 | +LIB = lib$(BOARD).a | |
| 27 | + | |
| 28 | +OBJS = $(BOARD).o flash.o ee_access.o | |
| 29 | +SOBJS = lowlevel_init.o | |
| 30 | + | |
| 31 | +$(LIB): .depend $(OBJS) $(SOBJS) | |
| 32 | + $(AR) crv $@ $(OBJS) $(SOBJS) | |
| 33 | + | |
| 34 | +######################################################################### | |
| 35 | + | |
| 36 | +.depend: Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c) | |
| 37 | + $(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@ | |
| 38 | + | |
| 39 | +sinclude .depend | |
| 40 | + | |
| 41 | +######################################################################### |
board/gth2/config.mk
| 1 | +# | |
| 2 | +# (C) Copyright 2004-2005 | |
| 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 | |
| 15 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 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 | +# | |
| 25 | +# AMD Alchemy AU1000, MIPS32 core | |
| 26 | +# | |
| 27 | + | |
| 28 | +ifeq ($(TBASE),0) | |
| 29 | +TEXT_BASE = 0 | |
| 30 | +else | |
| 31 | +ifeq ($(TBASE),1) | |
| 32 | +TEXT_BASE = 0xbfc10070 | |
| 33 | +else | |
| 34 | +ifeq ($(TBASE),2) | |
| 35 | +TEXT_BASE = 0xbfc30070 | |
| 36 | +else | |
| 37 | +## Only to make ordinary make work | |
| 38 | +TEXT_BASE = 0x90000000 | |
| 39 | +endif | |
| 40 | +endif | |
| 41 | +endif |
board/gth2/ee_access.c
| 1 | +/* Module for handling DALLAS DS2438, smart battery monitor | |
| 2 | + Chip can store up to 40 bytes of user data in EEPROM, | |
| 3 | + perform temp, voltage and current measurements. | |
| 4 | + Chip also contains a unique serial number. | |
| 5 | + | |
| 6 | + Always read/write LSb first | |
| 7 | + | |
| 8 | + For documentaion, see data sheet for DS2438, 2438.pdf | |
| 9 | + | |
| 10 | + By Thomas.Lange@corelatus.com 001025 | |
| 11 | + | |
| 12 | + Copyright (C) 2000-2005 Corelatus AB */ | |
| 13 | + | |
| 14 | +/* This program is free software; you can redistribute it and/or | |
| 15 | + * modify it under the terms of the GNU General Public License as | |
| 16 | + * published by the Free Software Foundation; either version 2 of | |
| 17 | + * the License, or (at your option) any later version. | |
| 18 | + * | |
| 19 | + * This program is distributed in the hope that it will be useful, | |
| 20 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 21 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 22 | + * GNU General Public License for more details. | |
| 23 | + * | |
| 24 | + * You should have received a copy of the GNU General Public License | |
| 25 | + * along with this program; if not, write to the Free Software | |
| 26 | + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, | |
| 27 | + * MA 02111-1307 USA | |
| 28 | + */ | |
| 29 | + | |
| 30 | +#include <common.h> | |
| 31 | +#include <command.h> | |
| 32 | +#include <asm/au1x00.h> | |
| 33 | +#include <asm/io.h> | |
| 34 | +#include "ee_dev.h" | |
| 35 | +#include "ee_access.h" | |
| 36 | + | |
| 37 | +/* static int Debug = 1; */ | |
| 38 | +#undef E_DEBUG | |
| 39 | +#define E_DEBUG(fmt,args...) /* */ | |
| 40 | +/* #define E_DEBUG(fmt,args...) printk("EEA:"fmt,##args); */ | |
| 41 | + | |
| 42 | +/* We dont have kernel functions */ | |
| 43 | +#define printk printf | |
| 44 | +#define KERN_DEBUG | |
| 45 | +#define KERN_ERR | |
| 46 | +#define EIO 1 | |
| 47 | + | |
| 48 | +#ifndef TRUE | |
| 49 | +#define TRUE 1 | |
| 50 | +#endif | |
| 51 | +#ifndef FALSE | |
| 52 | +#define FALSE 0 | |
| 53 | +#endif | |
| 54 | + | |
| 55 | +/* lookup table ripped from DS app note 17, understanding and using cyclic redundancy checks... */ | |
| 56 | + | |
| 57 | +static u8 crc_lookup[256] = { | |
| 58 | + 0, 94, 188, 226, 97, 63, 221, 131, | |
| 59 | + 194, 156, 126, 32, 163, 253, 31, 65, | |
| 60 | + 157, 195, 33, 127, 252, 162, 64, 30, | |
| 61 | + 95, 1, 227, 189, 62, 96, 130, 220, | |
| 62 | + 35, 125, 159, 193, 66, 28, 254, 160, | |
| 63 | + 225, 191, 93, 3, 128, 222, 60, 98, | |
| 64 | + 190, 224, 2, 92, 223, 129, 99, 61, | |
| 65 | + 124, 34, 192, 158, 29, 67, 161, 255, | |
| 66 | + 70, 24, 250, 164, 39, 121, 155, 197, | |
| 67 | + 132, 218, 56, 102, 229, 187, 89, 7, | |
| 68 | + 219, 133, 103, 57, 186, 228, 6, 88, | |
| 69 | + 25, 71, 165, 251, 120, 38, 196, 154, | |
| 70 | + 101, 59, 217, 135, 4, 90, 184, 230, | |
| 71 | + 167, 249, 27, 69, 198, 152, 122, 36, | |
| 72 | + 248, 166, 68, 26, 153, 199, 37, 123, | |
| 73 | + 58, 100, 134, 216, 91, 5, 231, 185, | |
| 74 | + 140, 210, 48, 110, 237, 179, 81, 15, | |
| 75 | + 78, 16, 242, 172, 47, 113, 147, 205, | |
| 76 | + 17, 79, 173, 243, 112, 46, 204, 146, | |
| 77 | + 211, 141, 111, 49, 178, 236, 14, 80, | |
| 78 | + 175, 241, 19, 77, 206, 144, 114, 44, | |
| 79 | + 109, 51, 209, 143, 12, 82, 176, 238, | |
| 80 | + 50, 108, 142, 208, 83, 13, 239, 177, | |
| 81 | + 240, 174, 76, 18, 145, 207, 45, 115, | |
| 82 | + 202, 148, 118, 40, 171, 245, 23, 73, | |
| 83 | + 8, 86, 180, 234, 105, 55, 213, 139, | |
| 84 | + 87, 9, 235, 181, 54, 104, 138, 212, | |
| 85 | + 149, 203, 41, 119, 244, 170, 72, 22, | |
| 86 | + 233, 183, 85, 11, 136, 214, 52, 106, | |
| 87 | + 43, 117, 151, 201, 74, 20, 246, 168, | |
| 88 | + 116, 42, 200, 150, 21, 75, 169, 247, | |
| 89 | + 182, 232, 10, 84, 215, 137, 107, 53 | |
| 90 | +}; | |
| 91 | + | |
| 92 | +static void | |
| 93 | +write_gpio_data(int value ){ | |
| 94 | + if(value){ | |
| 95 | + /* Tristate */ | |
| 96 | + gpio_tristate(GPIO_EEDQ); | |
| 97 | + } | |
| 98 | + else{ | |
| 99 | + /* Drive 0 */ | |
| 100 | + gpio_clear(GPIO_EEDQ); | |
| 101 | + } | |
| 102 | +} | |
| 103 | + | |
| 104 | +static u8 make_new_crc( u8 Old_crc, u8 New_value ){ | |
| 105 | + /* Compute a new checksum with new byte, using previous checksum as input | |
| 106 | + See DS app note 17, understanding and using cyclic redundancy checks... | |
| 107 | + Also see DS2438, page 11 */ | |
| 108 | + return( crc_lookup[Old_crc ^ New_value ]); | |
| 109 | +} | |
| 110 | + | |
| 111 | +int ee_crc_ok( u8 *Buffer, int Len, u8 Crc ){ | |
| 112 | + /* Check if the checksum for this buffer is correct */ | |
| 113 | + u8 Curr_crc=0; | |
| 114 | + int i; | |
| 115 | + u8 *Curr_byte = Buffer; | |
| 116 | + | |
| 117 | + for(i=0;i<Len;i++){ | |
| 118 | + Curr_crc = make_new_crc( Curr_crc, *Curr_byte); | |
| 119 | + Curr_byte++; | |
| 120 | + } | |
| 121 | + E_DEBUG("Calculated CRC = 0x%x, read = 0x%x\n", Curr_crc, Crc); | |
| 122 | + | |
| 123 | + if(Curr_crc == Crc){ | |
| 124 | + /* Good */ | |
| 125 | + return(TRUE); | |
| 126 | + } | |
| 127 | + printk(KERN_ERR"EE checksum error, Calculated CRC = 0x%x, read = 0x%x\n", Curr_crc, Crc); | |
| 128 | + return(FALSE); | |
| 129 | +} | |
| 130 | + | |
| 131 | +static void | |
| 132 | +set_idle(void){ | |
| 133 | + /* Send idle and keep start time | |
| 134 | + Continous 1 is idle */ | |
| 135 | + WRITE_PORT(1); | |
| 136 | +} | |
| 137 | + | |
| 138 | + | |
| 139 | +static int | |
| 140 | +do_cpu_reset(void){ | |
| 141 | + /* Release reset and verify that chip responds with presence pulse */ | |
| 142 | + int Retries=0; | |
| 143 | + while(Retries<15){ | |
| 144 | + udelay(RESET_LOW_TIME); | |
| 145 | + | |
| 146 | + /* Send reset */ | |
| 147 | + WRITE_PORT(0); | |
| 148 | + udelay(RESET_LOW_TIME); | |
| 149 | + | |
| 150 | + /* Release reset */ | |
| 151 | + WRITE_PORT(1); | |
| 152 | + | |
| 153 | + /* Wait for EEPROM to drive output */ | |
| 154 | + udelay(PRESENCE_TIMEOUT); | |
| 155 | + if(!READ_PORT){ | |
| 156 | + /* Ok, EEPROM is driving a 0 */ | |
| 157 | + E_DEBUG("Presence detected\n"); | |
| 158 | + if(Retries){ | |
| 159 | + E_DEBUG("Retries %d\n",Retries); | |
| 160 | + } | |
| 161 | + /* Make sure chip releases pin */ | |
| 162 | + udelay(PRESENCE_LOW_TIME); | |
| 163 | + return 0; | |
| 164 | + } | |
| 165 | + Retries++; | |
| 166 | + } | |
| 167 | + | |
| 168 | + printk(KERN_ERR"eeprom did not respond when releasing reset\n"); | |
| 169 | + | |
| 170 | + /* Make sure chip releases pin */ | |
| 171 | + udelay(PRESENCE_LOW_TIME); | |
| 172 | + | |
| 173 | + /* Set to idle again */ | |
| 174 | + set_idle(); | |
| 175 | + | |
| 176 | + return(-EIO); | |
| 177 | +} | |
| 178 | + | |
| 179 | +static u8 | |
| 180 | +read_cpu_byte(void){ | |
| 181 | + /* Read a single byte from EEPROM | |
| 182 | + Read LSb first */ | |
| 183 | + int i; | |
| 184 | + int Value; | |
| 185 | + u8 Result=0; | |
| 186 | + u32 Flags; | |
| 187 | + | |
| 188 | + E_DEBUG("Reading byte\n"); | |
| 189 | + | |
| 190 | + for(i=0;i<8;i++){ | |
| 191 | + /* Small delay between pulses */ | |
| 192 | + udelay(1); | |
| 193 | + | |
| 194 | +#ifdef __KERNEL__ | |
| 195 | + /* Disable irq */ | |
| 196 | + save_flags(Flags); | |
| 197 | + cli(); | |
| 198 | +#endif | |
| 199 | + | |
| 200 | + /* Pull down pin short time to start read | |
| 201 | + See page 26 in data sheet */ | |
| 202 | + | |
| 203 | + WRITE_PORT(0); | |
| 204 | + udelay(READ_LOW); | |
| 205 | + WRITE_PORT(1); | |
| 206 | + | |
| 207 | + /* Wait for chip to drive pin */ | |
| 208 | + udelay(READ_TIMEOUT); | |
| 209 | + | |
| 210 | + Value = READ_PORT; | |
| 211 | + if(Value) | |
| 212 | + Value=1; | |
| 213 | + | |
| 214 | +#ifdef __KERNEL__ | |
| 215 | + /* Enable irq */ | |
| 216 | + restore_flags(Flags); | |
| 217 | +#endif | |
| 218 | + | |
| 219 | + /* Wait for chip to release pin */ | |
| 220 | + udelay(TOTAL_READ_LOW-READ_TIMEOUT); | |
| 221 | + | |
| 222 | + /* LSb first */ | |
| 223 | + Result|=Value<<i; | |
| 224 | + /* E_DEBUG("Read %d\n",Value); */ | |
| 225 | + | |
| 226 | + } | |
| 227 | + | |
| 228 | + E_DEBUG("Read byte 0x%x\n",Result); | |
| 229 | + | |
| 230 | + return(Result); | |
| 231 | +} | |
| 232 | + | |
| 233 | +static void | |
| 234 | +write_cpu_byte(u8 Byte){ | |
| 235 | + /* Write a single byte to EEPROM | |
| 236 | + Write LSb first */ | |
| 237 | + int i; | |
| 238 | + int Value; | |
| 239 | + u32 Flags; | |
| 240 | + | |
| 241 | + E_DEBUG("Writing byte 0x%x\n",Byte); | |
| 242 | + | |
| 243 | + for(i=0;i<8;i++){ | |
| 244 | + /* Small delay between pulses */ | |
| 245 | + udelay(1); | |
| 246 | + Value = Byte&1; | |
| 247 | + | |
| 248 | +#ifdef __KERNEL__ | |
| 249 | + /* Disable irq */ | |
| 250 | + save_flags(Flags); | |
| 251 | + cli(); | |
| 252 | +#endif | |
| 253 | + | |
| 254 | + /* Pull down pin short time for a 1, long time for a 0 | |
| 255 | + See page 26 in data sheet */ | |
| 256 | + | |
| 257 | + WRITE_PORT(0); | |
| 258 | + if(Value){ | |
| 259 | + /* Write a 1 */ | |
| 260 | + udelay(WRITE_1_LOW); | |
| 261 | + } | |
| 262 | + else{ | |
| 263 | + /* Write a 0 */ | |
| 264 | + udelay(WRITE_0_LOW); | |
| 265 | + } | |
| 266 | + | |
| 267 | + WRITE_PORT(1); | |
| 268 | + | |
| 269 | +#ifdef __KERNEL__ | |
| 270 | + /* Enable irq */ | |
| 271 | + restore_flags(Flags); | |
| 272 | +#endif | |
| 273 | + | |
| 274 | + if(Value) | |
| 275 | + /* Wait for chip to read the 1 */ | |
| 276 | + udelay(TOTAL_WRITE_LOW-WRITE_1_LOW); | |
| 277 | + | |
| 278 | + /* E_DEBUG("Wrote %d\n",Value); */ | |
| 279 | + Byte>>=1; | |
| 280 | + } | |
| 281 | +} | |
| 282 | + | |
| 283 | +int ee_do_cpu_command( u8 *Tx, int Tx_len, u8 *Rx, int Rx_len, int Send_skip ){ | |
| 284 | + /* Execute this command string, including | |
| 285 | + giving reset and setting to idle after command | |
| 286 | + if Rx_len is set, we read out data from EEPROM */ | |
| 287 | + int i; | |
| 288 | + | |
| 289 | + E_DEBUG("Command, Tx_len %d, Rx_len %d\n", Tx_len, Rx_len ); | |
| 290 | + | |
| 291 | + if(do_cpu_reset()){ | |
| 292 | + /* Failed! */ | |
| 293 | + return(-EIO); | |
| 294 | + } | |
| 295 | + | |
| 296 | + if(Send_skip) | |
| 297 | + /* Always send SKIP_ROM first to tell chip we are sending a command, | |
| 298 | + except when we read out rom data for chip */ | |
| 299 | + write_cpu_byte(SKIP_ROM); | |
| 300 | + | |
| 301 | + /* Always have Tx data */ | |
| 302 | + for(i=0;i<Tx_len;i++){ | |
| 303 | + write_cpu_byte(Tx[i]); | |
| 304 | + } | |
| 305 | + | |
| 306 | + if(Rx_len){ | |
| 307 | + for(i=0;i<Rx_len;i++){ | |
| 308 | + Rx[i]=read_cpu_byte(); | |
| 309 | + } | |
| 310 | + } | |
| 311 | + | |
| 312 | + set_idle(); | |
| 313 | + | |
| 314 | + E_DEBUG("Command done\n"); | |
| 315 | + | |
| 316 | + return(0); | |
| 317 | +} | |
| 318 | + | |
| 319 | +int ee_init_cpu_data(void){ | |
| 320 | + int i; | |
| 321 | + u8 Tx[10]; | |
| 322 | + | |
| 323 | + /* Leave it floting since altera is driving the same pin */ | |
| 324 | + set_idle(); | |
| 325 | + | |
| 326 | + /* Copy all User EEPROM data to scratchpad */ | |
| 327 | + for(i=0;i<USER_PAGES;i++){ | |
| 328 | + Tx[0]=RECALL_MEMORY; | |
| 329 | + Tx[1]=EE_USER_PAGE_0+i; | |
| 330 | + if(ee_do_cpu_command(Tx,2,NULL,0,TRUE)) return(-EIO); | |
| 331 | + } | |
| 332 | + | |
| 333 | + /* Make sure chip doesnt store measurements in NVRAM */ | |
| 334 | + Tx[0]=WRITE_SCRATCHPAD; | |
| 335 | + Tx[1]=0; /* Page */ | |
| 336 | + Tx[2]=9; | |
| 337 | + if(ee_do_cpu_command(Tx,3,NULL,0,TRUE)) return(-EIO); | |
| 338 | + | |
| 339 | + Tx[0]=COPY_SCRATCHPAD; | |
| 340 | + if(ee_do_cpu_command(Tx,2,NULL,0,TRUE)) return(-EIO); | |
| 341 | + | |
| 342 | + for(i=0;i<10;i++){ | |
| 343 | + udelay(1000); | |
| 344 | + } | |
| 345 | + | |
| 346 | + return(0); | |
| 347 | +} |
board/gth2/ee_access.h
| 1 | +/* By Thomas.Lange@Corelatus.com 001025 */ | |
| 2 | + | |
| 3 | +/* Definitions for EEPROM/VOLT METER DS2438 */ | |
| 4 | +/* Copyright (C) 2000-2005 Corelatus AB */ | |
| 5 | + | |
| 6 | +#ifndef INCeeaccessh | |
| 7 | +#define INCeeaccessh | |
| 8 | + | |
| 9 | +#include <asm/types.h> | |
| 10 | +#include "ee_dev.h" | |
| 11 | + | |
| 12 | +int ee_do_cpu_command( u8 *Tx, int Tx_len, u8 *Rx, int Rx_len, int Send_skip ); | |
| 13 | +int ee_init_cpu_data(void); | |
| 14 | + | |
| 15 | +int ee_crc_ok( u8 *Buffer, int Len, u8 Crc ); | |
| 16 | + | |
| 17 | +/* Defs for altera reg */ | |
| 18 | +#define EE_WRITE_SHIFT 8 /* bits to shift left */ | |
| 19 | +#define EE_READ_SHIFT 16 /* bits to shift left */ | |
| 20 | +#define EE_DONE 0x80000000 | |
| 21 | +#define EE_BUSY 0x40000000 | |
| 22 | +#define EE_ERROR 0x20000000 | |
| 23 | + | |
| 24 | +/* Commands */ | |
| 25 | +#define EE_CMD_NOP 0 | |
| 26 | +#define EE_CMD_INIT_RES 1 | |
| 27 | +#define EE_CMD_WR_BYTE 2 | |
| 28 | +#define EE_CMD_RD_BYTE 3 | |
| 29 | + | |
| 30 | +#endif /* INCeeaccessh */ |
board/gth2/ee_dev.h
| 1 | +/* By Thomas.Lange@Corelatus.com 001025 */ | |
| 2 | +/* Definitions for EEPROM/VOLT METER DS2438 */ | |
| 3 | +/* Copyright (C) 2000-2005 Corelatus AB */ | |
| 4 | + | |
| 5 | +/* This program is free software; you can redistribute it and/or | |
| 6 | + * modify it under the terms of the GNU General Public License as | |
| 7 | + * published by the Free Software Foundation; either version 2 of | |
| 8 | + * the License, or (at your option) any later version. | |
| 9 | + * | |
| 10 | + * This program is distributed in the hope that it will be useful, | |
| 11 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 13 | + * GNU General Public License for more details. | |
| 14 | + * | |
| 15 | + * You should have received a copy of the GNU General Public License | |
| 16 | + * along with this program; if not, write to the Free Software | |
| 17 | + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, | |
| 18 | + * MA 02111-1307 USA | |
| 19 | + */ | |
| 20 | + | |
| 21 | +#ifndef INCeedevh | |
| 22 | +#define INCeedevh | |
| 23 | + | |
| 24 | +#define E_DEBUG(fmt,args...) if( Debug ) printk(KERN_DEBUG"EE: " fmt, ##args) | |
| 25 | + | |
| 26 | +/* MIPS */ | |
| 27 | +#define WRITE_PORT(Value) write_gpio_data(Value) | |
| 28 | + | |
| 29 | +#define READ_PORT (gpio_read()&GPIO_EEDQ) | |
| 30 | + | |
| 31 | +/* 64 bytes chip */ | |
| 32 | +#define EE_CHIP_SIZE 64 | |
| 33 | + | |
| 34 | +/* Board with new current resistor */ | |
| 35 | +#define EE_GTH_0304 1 | |
| 36 | + | |
| 37 | +/* new dsp and 64 MB SDRAM */ | |
| 38 | +#define EE_DSP_64 0x10 | |
| 39 | + | |
| 40 | +/* microsecs */ | |
| 41 | +/* Pull line down at least this long for reset pulse */ | |
| 42 | +#define RESET_LOW_TIME 490 | |
| 43 | + | |
| 44 | +/* Read presence pulse after we release reset pulse */ | |
| 45 | +#define PRESENCE_TIMEOUT 100 | |
| 46 | +#define PRESENCE_LOW_TIME 200 | |
| 47 | + | |
| 48 | +#define WRITE_0_LOW 60 | |
| 49 | +#define WRITE_1_LOW 1 | |
| 50 | +#define TOTAL_WRITE_LOW 60 | |
| 51 | + | |
| 52 | +#define READ_LOW 1 | |
| 53 | +#define READ_TIMEOUT 10 | |
| 54 | +#define TOTAL_READ_LOW 70 | |
| 55 | + | |
| 56 | +/* Rom function commands */ | |
| 57 | +#define READ_ROM 0x33 | |
| 58 | +#define MATCH_ROM 0x55 | |
| 59 | +#define SKIP_ROM 0xCC | |
| 60 | +#define SEARCH_ROM 0xF0 | |
| 61 | + | |
| 62 | + | |
| 63 | +/* Memory_command_function */ | |
| 64 | +#define WRITE_SCRATCHPAD 0x4E | |
| 65 | +#define READ_SCRATCHPAD 0xBE | |
| 66 | +#define COPY_SCRATCHPAD 0x48 | |
| 67 | +#define RECALL_MEMORY 0xB8 | |
| 68 | +#define CONVERT_TEMP 0x44 | |
| 69 | +#define CONVERT_VOLTAGE 0xB4 | |
| 70 | + | |
| 71 | +/* Chip is divided in 8 pages, 8 bytes each */ | |
| 72 | + | |
| 73 | +#define EE_PAGE_SIZE 8 | |
| 74 | + | |
| 75 | +/* All chip data we want are in page 0 */ | |
| 76 | + | |
| 77 | +/* Bytes in page 0 */ | |
| 78 | +#define EE_P0_STATUS 0 | |
| 79 | +#define EE_P0_TEMP_LSB 1 | |
| 80 | +#define EE_P0_TEMP_MSB 2 | |
| 81 | +#define EE_P0_VOLT_LSB 3 | |
| 82 | +#define EE_P0_VOLT_MSB 4 | |
| 83 | +#define EE_P0_CURRENT_LSB 5 | |
| 84 | +#define EE_P0_CURRENT_MSB 6 | |
| 85 | + | |
| 86 | + | |
| 87 | +/* 40 byte user data is located at page 3-7 */ | |
| 88 | +#define EE_USER_PAGE_0 3 | |
| 89 | +#define USER_PAGES 5 | |
| 90 | + | |
| 91 | +/* Layout of gth user pages usage */ | |
| 92 | +/* Bytes 0-16 ethernet addr in ascii ( len 17 ) */ | |
| 93 | + | |
| 94 | +#define EE_ETHERNET_OFFSET 0 | |
| 95 | + | |
| 96 | +#endif /* INCeedevh */ |
board/gth2/flash.c
| 1 | +/* | |
| 2 | + * (C) Copyright 2005 | |
| 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 | |
| 15 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 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 | +#include <common.h> | |
| 25 | + | |
| 26 | +flash_info_t flash_info[CFG_MAX_FLASH_BANKS]; /* info for FLASH chips */ | |
| 27 | + | |
| 28 | +/*----------------------------------------------------------------------- | |
| 29 | + * flash_init() | |
| 30 | + * | |
| 31 | + * sets up flash_info and returns size of FLASH (bytes) | |
| 32 | + */ | |
| 33 | +unsigned long flash_init (void) | |
| 34 | +{ | |
| 35 | + printf ("Skipping flash_init\n"); | |
| 36 | + return (0); | |
| 37 | +} | |
| 38 | + | |
| 39 | +int write_buff (flash_info_t * info, uchar * src, ulong addr, ulong cnt) | |
| 40 | +{ | |
| 41 | + printf ("write_buff not implemented\n"); | |
| 42 | + return (-1); | |
| 43 | +} |
board/gth2/gth2.c
| 1 | +/* | |
| 2 | + * (C) Copyright 2005 | |
| 3 | + * Thomas.Lange@corelatus.se | |
| 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 | |
| 15 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 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 | +#include <common.h> | |
| 25 | +#include <command.h> | |
| 26 | +#include <asm/au1x00.h> | |
| 27 | +#include <asm/addrspace.h> | |
| 28 | +#include <asm/mipsregs.h> | |
| 29 | +#include <watchdog.h> | |
| 30 | + | |
| 31 | +#include "ee_access.h" | |
| 32 | + | |
| 33 | +static int wdi_status = 0; | |
| 34 | + | |
| 35 | +unsigned long mips_io_port_base = 0; | |
| 36 | + | |
| 37 | +#define SDRAM_SIZE ((64*1024*1024)-(12*4096)) | |
| 38 | + | |
| 39 | + | |
| 40 | +#define SERIAL_LOG_BUFFER KSEG1ADDR(SDRAM_SIZE + (8*4096)) | |
| 41 | + | |
| 42 | +void inline log_serial_char(char c){ | |
| 43 | + char *serial_log_buffer = (char*)SERIAL_LOG_BUFFER; | |
| 44 | + int serial_log_offset; | |
| 45 | + u32 *serial_log_offsetp = (u32*)SERIAL_LOG_BUFFER; | |
| 46 | + | |
| 47 | + serial_log_offset = *serial_log_offsetp; | |
| 48 | + | |
| 49 | + *(serial_log_buffer + serial_log_offset) = c; | |
| 50 | + | |
| 51 | + serial_log_offset++; | |
| 52 | + | |
| 53 | + if(serial_log_offset >= 4096){ | |
| 54 | + serial_log_offset = 4; | |
| 55 | + } | |
| 56 | + *serial_log_offsetp = serial_log_offset; | |
| 57 | +} | |
| 58 | + | |
| 59 | +void init_log_serial(void){ | |
| 60 | + char *serial_log_buffer = (char*)SERIAL_LOG_BUFFER; | |
| 61 | + u32 *serial_log_offsetp = (u32*)SERIAL_LOG_BUFFER; | |
| 62 | + | |
| 63 | + /* Copy buffer from last run */ | |
| 64 | + memcpy(serial_log_buffer + 4096, | |
| 65 | + serial_log_buffer, | |
| 66 | + 4096); | |
| 67 | + | |
| 68 | + memset(serial_log_buffer, 0, 4096); | |
| 69 | + | |
| 70 | + *serial_log_offsetp = 4; | |
| 71 | +} | |
| 72 | + | |
| 73 | + | |
| 74 | +void hw_watchdog_reset(void){ | |
| 75 | + volatile u32 *sys_outputset = (volatile u32*)SYS_OUTPUTSET; | |
| 76 | + volatile u32 *sys_outputclear = (volatile u32*)SYS_OUTPUTCLR; | |
| 77 | + if(wdi_status){ | |
| 78 | + *sys_outputset = GPIO_CPU_LED|GPIO_WDI; | |
| 79 | + wdi_status = 0; | |
| 80 | + } | |
| 81 | + else{ | |
| 82 | + *sys_outputclear = GPIO_CPU_LED|GPIO_WDI; | |
| 83 | + wdi_status = 1; | |
| 84 | + } | |
| 85 | +} | |
| 86 | + | |
| 87 | +long int initdram(int board_type) | |
| 88 | +{ | |
| 89 | + /* Sdram is setup by assembler code */ | |
| 90 | + /* If memory could be changed, we should return the true value here */ | |
| 91 | + | |
| 92 | + WATCHDOG_RESET(); | |
| 93 | + | |
| 94 | + return (SDRAM_SIZE); | |
| 95 | +} | |
| 96 | + | |
| 97 | +/* In cpu/mips/cpu.c */ | |
| 98 | +void write_one_tlb( int index, u32 pagemask, u32 hi, u32 low0, u32 low1 ); | |
| 99 | + | |
| 100 | +void set_ledcard(u32 value){ | |
| 101 | + /* Clock 24 bits to led card */ | |
| 102 | + int i; | |
| 103 | + volatile u32 *sys_outputset = (volatile u32*)SYS_OUTPUTSET; | |
| 104 | + volatile u32 *sys_outputclr = (volatile u32*)SYS_OUTPUTCLR; | |
| 105 | + | |
| 106 | + /* Start with known values */ | |
| 107 | + *sys_outputclr = GPIO_LEDCLK|GPIO_LEDD; | |
| 108 | + | |
| 109 | + for(i=0;i<24;i++){ | |
| 110 | + if(value&0x00800000){ | |
| 111 | + *sys_outputset = GPIO_LEDD; | |
| 112 | + } | |
| 113 | + else{ | |
| 114 | + *sys_outputclr = GPIO_LEDD; | |
| 115 | + } | |
| 116 | + udelay(1); | |
| 117 | + *sys_outputset = GPIO_LEDCLK; | |
| 118 | + udelay(1); | |
| 119 | + *sys_outputclr = GPIO_LEDCLK; | |
| 120 | + udelay(1); | |
| 121 | + | |
| 122 | + value<<=1; | |
| 123 | + } | |
| 124 | + /* Data is enable output */ | |
| 125 | + *sys_outputset = GPIO_LEDD; | |
| 126 | +} | |
| 127 | + | |
| 128 | +int checkboard (void) | |
| 129 | +{ | |
| 130 | + volatile u32 *sys_counter = (volatile u32*)SYS_COUNTER_CNTRL; | |
| 131 | + volatile u32 *sys_outputset = (volatile u32*)SYS_OUTPUTSET; | |
| 132 | + volatile u32 *sys_outputclr = (volatile u32*)SYS_OUTPUTCLR; | |
| 133 | + u32 proc_id; | |
| 134 | + | |
| 135 | + WATCHDOG_RESET(); | |
| 136 | + | |
| 137 | + *sys_counter = 0x100; /* Enable 32 kHz oscillator for RTC/TOY */ | |
| 138 | + | |
| 139 | + proc_id = read_32bit_cp0_register(CP0_PRID); | |
| 140 | + | |
| 141 | + switch (proc_id >> 24) { | |
| 142 | + case 0: | |
| 143 | + puts ("Board: GTH2\n"); | |
| 144 | + printf ("CPU: Au1000 500 MHz, id: 0x%02x, rev: 0x%02x\n", | |
| 145 | + (proc_id >> 8) & 0xFF, proc_id & 0xFF); | |
| 146 | + break; | |
| 147 | + default: | |
| 148 | + printf ("Unsupported cpu %d, proc_id=0x%x\n", proc_id >> 24, proc_id); | |
| 149 | + } | |
| 150 | +#ifdef CONFIG_IDE_PCMCIA | |
| 151 | + /* PCMCIA is on a 36 bit physical address. | |
| 152 | + We need to map it into a 32 bit addresses */ | |
| 153 | + write_one_tlb(20, /* index */ | |
| 154 | + 0x01ffe000, /* Pagemask, 16 MB pages */ | |
| 155 | + CFG_PCMCIA_IO_BASE, /* Hi */ | |
| 156 | + 0x3C000017, /* Lo0 */ | |
| 157 | + 0x3C200017); /* Lo1 */ | |
| 158 | + | |
| 159 | + write_one_tlb(21, /* index */ | |
| 160 | + 0x01ffe000, /* Pagemask, 16 MB pages */ | |
| 161 | + CFG_PCMCIA_ATTR_BASE, /* Hi */ | |
| 162 | + 0x3D000017, /* Lo0 */ | |
| 163 | + 0x3D200017); /* Lo1 */ | |
| 164 | + | |
| 165 | + write_one_tlb(22, /* index */ | |
| 166 | + 0x01ffe000, /* Pagemask, 16 MB pages */ | |
| 167 | + CFG_PCMCIA_MEM_ADDR, /* Hi */ | |
| 168 | + 0x3E000017, /* Lo0 */ | |
| 169 | + 0x3E200017); /* Lo1 */ | |
| 170 | + | |
| 171 | +#endif /* CONFIG_IDE_PCMCIA */ | |
| 172 | + | |
| 173 | + /* Wait for GPIO ports to become stable */ | |
| 174 | + udelay(5000); /* FIXME */ | |
| 175 | + | |
| 176 | + /* Release reset of ethernet PHY chips */ | |
| 177 | + /* Always do this, because linux does not know about it */ | |
| 178 | + *sys_outputset = GPIO_ERESET; | |
| 179 | + | |
| 180 | + /* Kill FPGA:s */ | |
| 181 | + *sys_outputclr = GPIO_CACONFIG|GPIO_DPACONFIG; | |
| 182 | + udelay(2); | |
| 183 | + *sys_outputset = GPIO_CACONFIG|GPIO_DPACONFIG; | |
| 184 | + | |
| 185 | + /* Turn front led yellow */ | |
| 186 | + set_ledcard(0x00100000); | |
| 187 | + | |
| 188 | + return 0; | |
| 189 | +} | |
| 190 | + | |
| 191 | +#define POWER_OFFSET 0xF0000 | |
| 192 | +#define SW_WATCHDOG_REASON 13 | |
| 193 | + | |
| 194 | +#define BOOTDATA_OFFSET 0xF8000 | |
| 195 | +#define MAX_ATTEMPTS 5 | |
| 196 | + | |
| 197 | +#define FAILSAFE_BOOT 1 | |
| 198 | +#define SYSTEM_BOOT 2 | |
| 199 | +#define SYSTEM2_BOOT 3 | |
| 200 | + | |
| 201 | +#define WRITE_FLASH16(a, d) \ | |
| 202 | +do \ | |
| 203 | +{ \ | |
| 204 | + *((volatile u16 *) (a)) = (d);\ | |
| 205 | + } while(0) | |
| 206 | + | |
| 207 | +static void write_bootdata (volatile u16 * addr, u8 System, u8 Count) | |
| 208 | +{ | |
| 209 | + u16 data; | |
| 210 | + volatile u16 *flash = (u16 *) (CFG_FLASH_BASE); | |
| 211 | + | |
| 212 | + switch(System){ | |
| 213 | + case FAILSAFE_BOOT: | |
| 214 | + printf ("Setting failsafe boot in flash\n"); | |
| 215 | + break; | |
| 216 | + case SYSTEM_BOOT: | |
| 217 | + printf ("Setting system boot in flash\n"); | |
| 218 | + break; | |
| 219 | + case SYSTEM2_BOOT: | |
| 220 | + printf ("Setting system2 boot in flash\n"); | |
| 221 | + break; | |
| 222 | + default: | |
| 223 | + printf ("Invalid system data %u, setting failsafe\n", System); | |
| 224 | + System = FAILSAFE_BOOT; | |
| 225 | + } | |
| 226 | + | |
| 227 | + if ((Count < 1) | (Count > MAX_ATTEMPTS)) { | |
| 228 | + printf ("Invalid boot count %u, setting 1\n", Count); | |
| 229 | + Count = 1; | |
| 230 | + } | |
| 231 | + | |
| 232 | + printf ("Boot attempt %d\n", Count); | |
| 233 | + | |
| 234 | + data = (System << 8) | Count; | |
| 235 | + /* AMD 16 bit */ | |
| 236 | + WRITE_FLASH16 (&flash[0x555], 0xAAAA); | |
| 237 | + WRITE_FLASH16 (&flash[0x2AA], 0x5555); | |
| 238 | + WRITE_FLASH16 (&flash[0x555], 0xA0A0); | |
| 239 | + | |
| 240 | + WRITE_FLASH16 (addr, data); | |
| 241 | +} | |
| 242 | + | |
| 243 | +static int random_system(void){ | |
| 244 | + /* EEPROM read failed. Just try to choose one | |
| 245 | + system release and hope it works */ | |
| 246 | + | |
| 247 | + /* FIXME */ | |
| 248 | + return(SYSTEM_BOOT); | |
| 249 | +} | |
| 250 | + | |
| 251 | +static int switch_system(int old_system){ | |
| 252 | + u8 Rx[10]; | |
| 253 | + u8 Tx[5]; | |
| 254 | + int valid_release; | |
| 255 | + | |
| 256 | + if(old_system==FAILSAFE_BOOT){ | |
| 257 | + /* Find out which system release to use */ | |
| 258 | + | |
| 259 | + /* Copy from nvram to scratchpad */ | |
| 260 | + Tx[0] = RECALL_MEMORY; | |
| 261 | + Tx[1] = 7; /* Page */ | |
| 262 | + if (ee_do_cpu_command (Tx, 2, NULL, 0, 1)) { | |
| 263 | + printf ("EE user page 7 recall failed\n"); | |
| 264 | + return (random_system()); | |
| 265 | + } | |
| 266 | + | |
| 267 | + Tx[0] = READ_SCRATCHPAD; | |
| 268 | + if (ee_do_cpu_command (Tx, 2, Rx, 9, 1)) { | |
| 269 | + printf ("EE user page 7 read failed\n"); | |
| 270 | + return (random_system()); | |
| 271 | + } | |
| 272 | + /* Crc in 9:th byte */ | |
| 273 | + if (!ee_crc_ok (Rx, 8, *(Rx + 8))) { | |
| 274 | + printf ("EE read failed, page 7. CRC error\n"); | |
| 275 | + return (random_system()); | |
| 276 | + } | |
| 277 | + | |
| 278 | + valid_release = Rx[7]; | |
| 279 | + if((valid_release==0xFF)| | |
| 280 | + ((valid_release&1) == 0)){ | |
| 281 | + return(SYSTEM_BOOT); | |
| 282 | + } | |
| 283 | + else{ | |
| 284 | + return(SYSTEM2_BOOT); | |
| 285 | + } | |
| 286 | + } | |
| 287 | + else{ | |
| 288 | + return(FAILSAFE_BOOT); | |
| 289 | + } | |
| 290 | +} | |
| 291 | + | |
| 292 | +static void check_boot_tries (void) | |
| 293 | +{ | |
| 294 | + /* Count the number of boot attemps | |
| 295 | + switch system if too many */ | |
| 296 | + | |
| 297 | + int i; | |
| 298 | + volatile u16 *addr; | |
| 299 | + volatile u16 data; | |
| 300 | + u8 system = FAILSAFE_BOOT; | |
| 301 | + u8 count; | |
| 302 | + | |
| 303 | + addr = (u16 *) (CFG_FLASH_BASE + BOOTDATA_OFFSET); | |
| 304 | + | |
| 305 | + if (*addr == 0xFFFF) { | |
| 306 | + printf ("*** No bootdata exists. ***\n"); | |
| 307 | + write_bootdata (addr, FAILSAFE_BOOT, 1); | |
| 308 | + } else { | |
| 309 | + /* Search for latest written bootdata */ | |
| 310 | + i = 0; | |
| 311 | + while ((*(addr + 1) != 0xFFFF) & (i < 8000)) { | |
| 312 | + addr++; | |
| 313 | + i++; | |
| 314 | + } | |
| 315 | + if (i >= 8000) { | |
| 316 | + /* Whoa, dont write any more */ | |
| 317 | + printf ("*** No bootdata found. Not updating flash***\n"); | |
| 318 | + } else { | |
| 319 | + /* See how many times we have tried to boot real system */ | |
| 320 | + data = *addr; | |
| 321 | + system = data >> 8; | |
| 322 | + count = data & 0xFF; | |
| 323 | + if ((system != SYSTEM_BOOT) & | |
| 324 | + (system != SYSTEM2_BOOT) & | |
| 325 | + (system != FAILSAFE_BOOT)) { | |
| 326 | + printf ("*** Wrong system %d\n", system); | |
| 327 | + system = FAILSAFE_BOOT; | |
| 328 | + count = 1; | |
| 329 | + } else { | |
| 330 | + switch (count) { | |
| 331 | + case 0: | |
| 332 | + case 1: | |
| 333 | + case 2: | |
| 334 | + case 3: | |
| 335 | + case 4: | |
| 336 | + /* Try same system again if needed */ | |
| 337 | + count++; | |
| 338 | + break; | |
| 339 | + | |
| 340 | + case 5: | |
| 341 | + /* Switch system and reset tries */ | |
| 342 | + count = 1; | |
| 343 | + system = switch_system(system); | |
| 344 | + printf ("***Too many boot attempts, switching system***\n"); | |
| 345 | + break; | |
| 346 | + default: | |
| 347 | + /* Switch system, start over and hope it works */ | |
| 348 | + printf ("***Unexpected data on addr 0x%x, %u***\n", | |
| 349 | + (u32) addr, data); | |
| 350 | + count = 1; | |
| 351 | + system = switch_system(system); | |
| 352 | + } | |
| 353 | + } | |
| 354 | + write_bootdata (addr + 1, system, count); | |
| 355 | + } | |
| 356 | + } | |
| 357 | + switch(system){ | |
| 358 | + case FAILSAFE_BOOT: | |
| 359 | + printf ("Booting failsafe system\n"); | |
| 360 | + setenv ("bootargs", "panic=1 root=/dev/hda7"); | |
| 361 | + setenv ("bootcmd", "ide reset;disk 0x81000000 0:5;run addmisc;bootm"); | |
| 362 | + break; | |
| 363 | + | |
| 364 | + case SYSTEM_BOOT: | |
| 365 | + printf ("Using normal system\n"); | |
| 366 | + setenv ("bootargs", "panic=1 root=/dev/hda4"); | |
| 367 | + setenv ("bootcmd", "ide reset;disk 0x81000000 0:2;run addmisc;bootm"); | |
| 368 | + break; | |
| 369 | + | |
| 370 | + case SYSTEM2_BOOT: | |
| 371 | + printf ("Using normal system2\n"); | |
| 372 | + setenv ("bootargs", "panic=1 root=/dev/hda9"); | |
| 373 | + setenv ("bootcmd", "ide reset;disk 0x81000000 0:8;run addmisc;bootm"); | |
| 374 | + break; | |
| 375 | + default: | |
| 376 | + printf ("Invalid system %d\n", system); | |
| 377 | + printf ("Hanging\n"); | |
| 378 | + while(1); | |
| 379 | + } | |
| 380 | +} | |
| 381 | + | |
| 382 | +int misc_init_r(void){ | |
| 383 | + u8 Rx[80]; | |
| 384 | + u8 Tx[5]; | |
| 385 | + int page; | |
| 386 | + int read = 0; | |
| 387 | + | |
| 388 | + WATCHDOG_RESET(); | |
| 389 | + | |
| 390 | + if (ee_init_cpu_data ()) { | |
| 391 | + printf ("EEPROM init failed\n"); | |
| 392 | + return (0); | |
| 393 | + } | |
| 394 | + | |
| 395 | + /* Check which release to boot */ | |
| 396 | + check_boot_tries (); | |
| 397 | + | |
| 398 | + /* Read the pages where ethernet address is stored */ | |
| 399 | + | |
| 400 | + for (page = EE_USER_PAGE_0; page <= EE_USER_PAGE_0 + 2; page++) { | |
| 401 | + /* Copy from nvram to scratchpad */ | |
| 402 | + Tx[0] = RECALL_MEMORY; | |
| 403 | + Tx[1] = page; | |
| 404 | + if (ee_do_cpu_command (Tx, 2, NULL, 0, 1)) { | |
| 405 | + printf ("EE user page %d recall failed\n", page); | |
| 406 | + return (0); | |
| 407 | + } | |
| 408 | + | |
| 409 | + Tx[0] = READ_SCRATCHPAD; | |
| 410 | + if (ee_do_cpu_command (Tx, 2, Rx + read, 9, 1)) { | |
| 411 | + printf ("EE user page %d read failed\n", page); | |
| 412 | + return (0); | |
| 413 | + } | |
| 414 | + /* Crc in 9:th byte */ | |
| 415 | + if (!ee_crc_ok (Rx + read, 8, *(Rx + read + 8))) { | |
| 416 | + printf ("EE read failed, page %d. CRC error\n", page); | |
| 417 | + return (0); | |
| 418 | + } | |
| 419 | + read += 8; | |
| 420 | + } | |
| 421 | + | |
| 422 | + /* Add eos after eth addr */ | |
| 423 | + Rx[17] = 0; | |
| 424 | + | |
| 425 | + printf ("Ethernet addr read from eeprom: %s\n\n", Rx); | |
| 426 | + | |
| 427 | + if ((Rx[2] != ':') | | |
| 428 | + (Rx[5] != ':') | | |
| 429 | + (Rx[8] != ':') | (Rx[11] != ':') | (Rx[14] != ':')) { | |
| 430 | + printf ("*** ethernet addr invalid, using default ***\n"); | |
| 431 | + } else { | |
| 432 | + setenv ("ethaddr", Rx); | |
| 433 | + } | |
| 434 | + return (0); | |
| 435 | +} |
board/gth2/lowlevel_init.S
| 1 | +/* Memory sub-system initialization code */ | |
| 2 | + | |
| 3 | +#include <config.h> | |
| 4 | +#include <version.h> | |
| 5 | +#include <asm/regdef.h> | |
| 6 | +#include <asm/au1x00.h> | |
| 7 | +#include <asm/mipsregs.h> | |
| 8 | + | |
| 9 | +#define CP0_Config0 $16 | |
| 10 | +#define MEM_1MS ((CFG_MHZ) * 1000) | |
| 11 | +#define GPIO_RJ1LY (1<<22) | |
| 12 | +#define GPIO_CFRESET (1<<10) | |
| 13 | + | |
| 14 | + .text | |
| 15 | + .set noreorder | |
| 16 | + .set mips32 | |
| 17 | + | |
| 18 | + .globl lowlevel_init | |
| 19 | +lowlevel_init: | |
| 20 | + /* | |
| 21 | + * Step 2) Establish Status Register | |
| 22 | + * (set BEV, clear ERL, clear EXL, clear IE) | |
| 23 | + */ | |
| 24 | + li t1, 0x00400000 | |
| 25 | + mtc0 t1, CP0_STATUS | |
| 26 | + | |
| 27 | + /* | |
| 28 | + * Step 3) Establish CP0 Config0 | |
| 29 | + * (set OD, set K0=3) | |
| 30 | + */ | |
| 31 | + li t1, 0x00080003 | |
| 32 | + mtc0 t1, CP0_CONFIG | |
| 33 | + | |
| 34 | + /* | |
| 35 | + * Step 4) Disable Watchpoint facilities | |
| 36 | + */ | |
| 37 | + li t1, 0x00000000 | |
| 38 | + mtc0 t1, CP0_WATCHLO | |
| 39 | + mtc0 t1, CP0_IWATCHLO | |
| 40 | + /* | |
| 41 | + * Step 5) Disable the performance counters | |
| 42 | + */ | |
| 43 | + mtc0 zero, CP0_PERFORMANCE | |
| 44 | + nop | |
| 45 | + | |
| 46 | + /* | |
| 47 | + * Step 6) Establish EJTAG Debug register | |
| 48 | + */ | |
| 49 | + mtc0 zero, CP0_DEBUG | |
| 50 | + nop | |
| 51 | + | |
| 52 | + /* | |
| 53 | + * Step 7) Establish Cause | |
| 54 | + * (set IV bit) | |
| 55 | + */ | |
| 56 | + li t1, 0x00800000 | |
| 57 | + mtc0 t1, CP0_CAUSE | |
| 58 | + | |
| 59 | + /* Establish Wired (and Random) */ | |
| 60 | + mtc0 zero, CP0_WIRED | |
| 61 | + nop | |
| 62 | + | |
| 63 | + /* No workaround if running from ram */ | |
| 64 | + lui t0, 0xffc0 | |
| 65 | + lui t3, 0xbfc0 | |
| 66 | + and t1, ra, t0 | |
| 67 | + bne t1, t3, noCacheJump | |
| 68 | + nop | |
| 69 | + | |
| 70 | + /*** From AMD YAMON ***/ | |
| 71 | + /* | |
| 72 | + * Step 8) Initialize the caches | |
| 73 | + */ | |
| 74 | + li t0, (16*1024) | |
| 75 | + li t1, 32 | |
| 76 | + li t2, 0x80000000 | |
| 77 | + addu t3, t0, t2 | |
| 78 | +cacheloop: | |
| 79 | + cache 0, 0(t2) | |
| 80 | + cache 1, 0(t2) | |
| 81 | + addu t2, t1 | |
| 82 | + bne t2, t3, cacheloop | |
| 83 | + nop | |
| 84 | + | |
| 85 | + /* Save return address */ | |
| 86 | + move t3, ra | |
| 87 | + | |
| 88 | + /* Run from cacheable space now */ | |
| 89 | + bal cachehere | |
| 90 | + nop | |
| 91 | +cachehere: | |
| 92 | + li t1, ~0x20000000 /* convert to KSEG0 */ | |
| 93 | + and t0, ra, t1 | |
| 94 | + addi t0, 5*4 /* 5 insns beyond cachehere */ | |
| 95 | + jr t0 | |
| 96 | + nop | |
| 97 | + | |
| 98 | + /* Restore return address */ | |
| 99 | + move ra, t3 | |
| 100 | + | |
| 101 | + /* | |
| 102 | + * Step 9) Initialize the TLB | |
| 103 | + */ | |
| 104 | + li t0, 0 # index value | |
| 105 | + li t1, 0x00000000 # entryhi value | |
| 106 | + li t2, 32 # 32 entries | |
| 107 | + | |
| 108 | +tlbloop: | |
| 109 | + /* Probe TLB for matching EntryHi */ | |
| 110 | + mtc0 t1, CP0_ENTRYHI | |
| 111 | + tlbp | |
| 112 | + nop | |
| 113 | + | |
| 114 | + /* Examine Index[P], 1=no matching entry */ | |
| 115 | + mfc0 t3, CP0_INDEX | |
| 116 | + li t4, 0x80000000 | |
| 117 | + and t3, t4, t3 | |
| 118 | + addiu t1, t1, 1 # increment t1 (asid) | |
| 119 | + beq zero, t3, tlbloop | |
| 120 | + nop | |
| 121 | + | |
| 122 | + /* Initialize the TLB entry */ | |
| 123 | + mtc0 t0, CP0_INDEX | |
| 124 | + mtc0 zero, CP0_ENTRYLO0 | |
| 125 | + mtc0 zero, CP0_ENTRYLO1 | |
| 126 | + mtc0 zero, CP0_PAGEMASK | |
| 127 | + tlbwi | |
| 128 | + | |
| 129 | + /* Do it again */ | |
| 130 | + addiu t0, t0, 1 | |
| 131 | + bne t0, t2, tlbloop | |
| 132 | + nop | |
| 133 | + | |
| 134 | + /* First setup pll:s to make serial work ok */ | |
| 135 | + /* We have a 12.5 MHz crystal */ | |
| 136 | + li t0, SYS_CPUPLL | |
| 137 | + li t1, 0x28 /* CPU clock, 500 MHz */ | |
| 138 | + sw t1, 0(t0) | |
| 139 | + sync | |
| 140 | + nop | |
| 141 | + nop | |
| 142 | + | |
| 143 | + /* wait 1mS for clocks to settle */ | |
| 144 | + li t1, MEM_1MS | |
| 145 | +1: add t1, -1 | |
| 146 | + bne t1, zero, 1b | |
| 147 | + nop | |
| 148 | + /* Setup AUX PLL */ | |
| 149 | + li t0, SYS_AUXPLL | |
| 150 | + li t1, 0 | |
| 151 | + sw t1, 0(t0) /* aux pll */ | |
| 152 | + sync | |
| 153 | + | |
| 154 | + /* Static memory controller */ | |
| 155 | + /* RCE0 - can not change while fetching, do so from icache */ | |
| 156 | + move t2, ra /* Store return address */ | |
| 157 | + bal getAddr | |
| 158 | + nop | |
| 159 | + | |
| 160 | +getAddr: | |
| 161 | + move t1, ra | |
| 162 | + move ra, t2 /* Move return addess back */ | |
| 163 | + | |
| 164 | + cache 0x14,0(t1) | |
| 165 | + cache 0x14,32(t1) | |
| 166 | + /*** /From YAMON ***/ | |
| 167 | + | |
| 168 | +noCacheJump: | |
| 169 | + | |
| 170 | + /* Static memory controller */ | |
| 171 | + | |
| 172 | + /* RCE0 AMD 29LV800 Flash */ | |
| 173 | + li t0, MEM_STCFG0 | |
| 174 | + li t1, 0x00000243 | |
| 175 | + sw t1, 0(t0) | |
| 176 | + | |
| 177 | + li t0, MEM_STTIME0 | |
| 178 | + li t1, 0x040181D7 /* FIXME */ | |
| 179 | + sw t1, 0(t0) | |
| 180 | + | |
| 181 | + li t0, MEM_STADDR0 | |
| 182 | + li t1, 0x11E03F80 | |
| 183 | + sw t1, 0(t0) | |
| 184 | + | |
| 185 | + /* RCE1 PCMCIA 250ns */ | |
| 186 | + li t0, MEM_STCFG1 | |
| 187 | + li t1, 0x00000002 | |
| 188 | + sw t1, 0(t0) | |
| 189 | + | |
| 190 | + li t0, MEM_STTIME1 | |
| 191 | + li t1, 0x280E3E07 | |
| 192 | + sw t1, 0(t0) | |
| 193 | + | |
| 194 | + li t0, MEM_STADDR1 | |
| 195 | + li t1, 0x10000000 | |
| 196 | + sw t1, 0(t0) | |
| 197 | + | |
| 198 | + /* RCE2 CP Altera */ | |
| 199 | + li t0, MEM_STCFG2 | |
| 200 | + li t1, 0x00000280 /* BE, EW */ | |
| 201 | + sw t1, 0(t0) | |
| 202 | + | |
| 203 | + li t0, MEM_STTIME2 | |
| 204 | + li t1, 0x0303000c | |
| 205 | + sw t1, 0(t0) | |
| 206 | + | |
| 207 | + li t0, MEM_STADDR2 | |
| 208 | + li t1, 0x10c03f80 /* 1 MB */ | |
| 209 | + sw t1, 0(t0) | |
| 210 | + | |
| 211 | + /* RCE3 DP Altera */ | |
| 212 | + li t0, MEM_STCFG3 | |
| 213 | + li t1, 0x00000280 /* BE, EW */ | |
| 214 | + sw t1, 0(t0) | |
| 215 | + | |
| 216 | + li t0, MEM_STTIME3 | |
| 217 | + li t1, 0x0303000c | |
| 218 | + sw t1, 0(t0) | |
| 219 | + | |
| 220 | + li t0, MEM_STADDR3 | |
| 221 | + li t1, 0x10e03f80 /* 1 MB */ | |
| 222 | + sw t1, 0(t0) | |
| 223 | + | |
| 224 | + sync | |
| 225 | + | |
| 226 | + /* Set peripherals to a known state */ | |
| 227 | + li t0, IC0_CFG0CLR | |
| 228 | + li t1, 0xFFFFFFFF | |
| 229 | + sw t1, 0(t0) | |
| 230 | + | |
| 231 | + li t0, IC0_CFG0CLR | |
| 232 | + sw t1, 0(t0) | |
| 233 | + | |
| 234 | + li t0, IC0_CFG1CLR | |
| 235 | + sw t1, 0(t0) | |
| 236 | + | |
| 237 | + li t0, IC0_CFG2CLR | |
| 238 | + sw t1, 0(t0) | |
| 239 | + | |
| 240 | + li t0, IC0_SRCSET | |
| 241 | + sw t1, 0(t0) | |
| 242 | + | |
| 243 | + li t0, IC0_ASSIGNSET | |
| 244 | + sw t1, 0(t0) | |
| 245 | + | |
| 246 | + li t0, IC0_WAKECLR | |
| 247 | + sw t1, 0(t0) | |
| 248 | + | |
| 249 | + li t0, IC0_RISINGCLR | |
| 250 | + sw t1, 0(t0) | |
| 251 | + | |
| 252 | + li t0, IC0_FALLINGCLR | |
| 253 | + sw t1, 0(t0) | |
| 254 | + | |
| 255 | + li t0, IC0_TESTBIT | |
| 256 | + li t1, 0x00000000 | |
| 257 | + sw t1, 0(t0) | |
| 258 | + sync | |
| 259 | + | |
| 260 | + li t0, IC1_CFG0CLR | |
| 261 | + li t1, 0xFFFFFFFF | |
| 262 | + sw t1, 0(t0) | |
| 263 | + | |
| 264 | + li t0, IC1_CFG0CLR | |
| 265 | + sw t1, 0(t0) | |
| 266 | + | |
| 267 | + li t0, IC1_CFG1CLR | |
| 268 | + sw t1, 0(t0) | |
| 269 | + | |
| 270 | + li t0, IC1_CFG2CLR | |
| 271 | + sw t1, 0(t0) | |
| 272 | + | |
| 273 | + li t0, IC1_SRCSET | |
| 274 | + sw t1, 0(t0) | |
| 275 | + | |
| 276 | + li t0, IC1_ASSIGNSET | |
| 277 | + sw t1, 0(t0) | |
| 278 | + | |
| 279 | + li t0, IC1_WAKECLR | |
| 280 | + sw t1, 0(t0) | |
| 281 | + | |
| 282 | + li t0, IC1_RISINGCLR | |
| 283 | + sw t1, 0(t0) | |
| 284 | + | |
| 285 | + li t0, IC1_FALLINGCLR | |
| 286 | + sw t1, 0(t0) | |
| 287 | + | |
| 288 | + li t0, IC1_TESTBIT | |
| 289 | + li t1, 0x00000000 | |
| 290 | + sw t1, 0(t0) | |
| 291 | + sync | |
| 292 | + | |
| 293 | + li t0, SYS_FREQCTRL0 | |
| 294 | + li t1, 0x00000000 | |
| 295 | + sw t1, 0(t0) | |
| 296 | + | |
| 297 | + li t0, SYS_FREQCTRL1 | |
| 298 | + li t1, 0x00000000 | |
| 299 | + sw t1, 0(t0) | |
| 300 | + | |
| 301 | + li t0, SYS_CLKSRC | |
| 302 | + li t1, 0x00000000 | |
| 303 | + sw t1, 0(t0) | |
| 304 | + | |
| 305 | + li t0, SYS_PININPUTEN | |
| 306 | + li t1, 0x00000000 | |
| 307 | + sw t1, 0(t0) | |
| 308 | + sync | |
| 309 | + | |
| 310 | + li t0, 0xB1100100 | |
| 311 | + li t1, 0x00000000 | |
| 312 | + sw t1, 0(t0) | |
| 313 | + | |
| 314 | + li t0, 0xB1400100 | |
| 315 | + li t1, 0x00000000 | |
| 316 | + sw t1, 0(t0) | |
| 317 | + | |
| 318 | + | |
| 319 | + li t0, SYS_WAKEMSK | |
| 320 | + li t1, 0x00000000 | |
| 321 | + sw t1, 0(t0) | |
| 322 | + | |
| 323 | + li t0, SYS_WAKESRC | |
| 324 | + li t1, 0x00000000 | |
| 325 | + sw t1, 0(t0) | |
| 326 | + | |
| 327 | + /* wait 1mS before setup */ | |
| 328 | + li t1, MEM_1MS | |
| 329 | +1: add t1, -1 | |
| 330 | + bne t1, zero, 1b | |
| 331 | + nop | |
| 332 | + | |
| 333 | + | |
| 334 | +/* SDCS 0 SDRAM */ | |
| 335 | + li t0, MEM_SDMODE0 | |
| 336 | + li t1, 0x592CD1 | |
| 337 | + sw t1, 0(t0) | |
| 338 | + | |
| 339 | + li t0, MEM_SDMODE1 | |
| 340 | + li t1, 0x00000000 | |
| 341 | + sw t1, 0(t0) | |
| 342 | + | |
| 343 | + li t0, MEM_SDMODE2 | |
| 344 | + li t1, 0x00000000 | |
| 345 | + sw t1, 0(t0) | |
| 346 | + | |
| 347 | +/* 64 MB SDRAM at addr 0 */ | |
| 348 | + li t0, MEM_SDADDR0 | |
| 349 | + li t1, 0x001003F0 | |
| 350 | + sw t1, 0(t0) | |
| 351 | + | |
| 352 | + | |
| 353 | + li t0, MEM_SDADDR1 | |
| 354 | + li t1, 0x00000000 | |
| 355 | + sw t1, 0(t0) | |
| 356 | + | |
| 357 | + li t0, MEM_SDADDR2 | |
| 358 | + li t1, 0x00000000 | |
| 359 | + sw t1, 0(t0) | |
| 360 | + | |
| 361 | + sync | |
| 362 | + | |
| 363 | + li t0, MEM_SDREFCFG | |
| 364 | + li t1, 0x880007A1 /* Disable */ | |
| 365 | + sw t1, 0(t0) | |
| 366 | + sync | |
| 367 | + | |
| 368 | + li t0, MEM_SDPRECMD | |
| 369 | + sw zero, 0(t0) | |
| 370 | + sync | |
| 371 | + | |
| 372 | + li t0, MEM_SDAUTOREF | |
| 373 | + sw zero, 0(t0) | |
| 374 | + sync | |
| 375 | + sw zero, 0(t0) | |
| 376 | + sync | |
| 377 | + | |
| 378 | + li t0, MEM_SDREFCFG | |
| 379 | + li t1, 0x8A0007A1 /* Enable */ | |
| 380 | + sw t1, 0(t0) | |
| 381 | + sync | |
| 382 | + | |
| 383 | + li t0, MEM_SDWRMD0 | |
| 384 | + li t1, 0x00000023 | |
| 385 | + sw t1, 0(t0) | |
| 386 | + sync | |
| 387 | + | |
| 388 | + /* wait 1mS after setup */ | |
| 389 | + li t1, MEM_1MS | |
| 390 | +1: add t1, -1 | |
| 391 | + bne t1, zero, 1b | |
| 392 | + nop | |
| 393 | + | |
| 394 | + /* Setup GPIO pins */ | |
| 395 | + | |
| 396 | + li t0, SYS_PINFUNC | |
| 397 | + li t1, 0x00007025 /* 0x8080 */ | |
| 398 | + sw t1, 0(t0) | |
| 399 | + | |
| 400 | + li t0, SYS_TRIOUTCLR | |
| 401 | + li t1, 0xFFFFFFFF /* 0x1FFF */ | |
| 402 | + sw t1, 0(t0) | |
| 403 | + | |
| 404 | + /* Turn yellow front led on */ | |
| 405 | + /* Release reset on CF */ | |
| 406 | + li t0, SYS_OUTPUTCLR | |
| 407 | + li t1, GPIO_RJ1LG | |
| 408 | + sw t1, 0(t0) | |
| 409 | + li t0, SYS_OUTPUTSET | |
| 410 | + li t1, GPIO_RJ1LY|GPIO_CFRESET | |
| 411 | + sw t1, 0(t0) | |
| 412 | + sync | |
| 413 | + j clearmem | |
| 414 | + nop | |
| 415 | + | |
| 416 | + .globl memtest | |
| 417 | +memtest: | |
| 418 | + /* Fill memory with address */ | |
| 419 | + li t0, 0x80000000 | |
| 420 | + li t1, 0xFFF000 /* 64 MB */ | |
| 421 | +mt0: sw t0, 0(t0) | |
| 422 | + add t1, -1 | |
| 423 | + add t0, 4 | |
| 424 | + bne t1, zero, mt0 | |
| 425 | + nop | |
| 426 | + nop | |
| 427 | + /* Verify addr */ | |
| 428 | + li t0, 0x80000000 | |
| 429 | + li t1, 0xFFF000 /* 64 MB */ | |
| 430 | +mt1: lw t2, 0(t0) | |
| 431 | + bne t0, t2, memhang | |
| 432 | + add t1, -1 | |
| 433 | + add t0, 4 | |
| 434 | + bne t1, zero, mt1 | |
| 435 | + nop | |
| 436 | + nop | |
| 437 | + .globl clearmem | |
| 438 | +clearmem: | |
| 439 | + /* Clear memory */ | |
| 440 | + li t0, 0x80000000 | |
| 441 | + li t1, 0xFFF000 /* 64 MB */ | |
| 442 | +mtc: sw zero, 0(t0) | |
| 443 | + add t1, -1 | |
| 444 | + add t0, 4 | |
| 445 | + bne t1, zero, mtc | |
| 446 | + nop | |
| 447 | + nop | |
| 448 | +memtestend: | |
| 449 | + j ra | |
| 450 | + nop | |
| 451 | + | |
| 452 | +memhang: | |
| 453 | + b memhang | |
| 454 | + nop |
board/gth2/u-boot.lds
| 1 | +/* | |
| 2 | + * (C) Copyright 2003-2005 | |
| 3 | + * Wolfgang Denk 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 | |
| 15 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 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 | +/* | |
| 25 | +OUTPUT_FORMAT("elf32-bigmips", "elf32-bigmips", "elf32-bigmips") | |
| 26 | +*/ | |
| 27 | +OUTPUT_FORMAT("elf32-tradbigmips", "elf32-tradbigmips", "elf32-tradbigmips") | |
| 28 | +OUTPUT_ARCH(mips) | |
| 29 | +ENTRY(_start) | |
| 30 | +SECTIONS | |
| 31 | +{ | |
| 32 | + . = 0x00000000; | |
| 33 | + | |
| 34 | + . = ALIGN(4); | |
| 35 | + .text : | |
| 36 | + { | |
| 37 | + *(.text) | |
| 38 | + } | |
| 39 | + | |
| 40 | + . = ALIGN(4); | |
| 41 | + .rodata : { *(.rodata) } | |
| 42 | + | |
| 43 | + . = ALIGN(4); | |
| 44 | + .data : { *(.data) } | |
| 45 | + | |
| 46 | + . = ALIGN(4); | |
| 47 | + .sdata : { *(.sdata) } | |
| 48 | + | |
| 49 | + _gp = ALIGN(16); | |
| 50 | + | |
| 51 | + __got_start = .; | |
| 52 | + .got : { *(.got) } | |
| 53 | + __got_end = .; | |
| 54 | + | |
| 55 | + .sdata : { *(.sdata) } | |
| 56 | + | |
| 57 | + __u_boot_cmd_start = .; | |
| 58 | + .u_boot_cmd : { *(.u_boot_cmd) } | |
| 59 | + __u_boot_cmd_end = .; | |
| 60 | + | |
| 61 | + uboot_end_data = .; | |
| 62 | + num_got_entries = (__got_end - __got_start) >> 2; | |
| 63 | + | |
| 64 | + . = ALIGN(4); | |
| 65 | + .sbss : { *(.sbss) } | |
| 66 | + .bss : { *(.bss) } | |
| 67 | + uboot_end = .; | |
| 68 | +} |
common/cmd_ide.c
| ... | ... | @@ -855,7 +855,7 @@ |
| 855 | 855 | |
| 856 | 856 | /* We only need to swap data if we are running on a big endian cpu. */ |
| 857 | 857 | /* But Au1x00 cpu:s already swaps data in big endian mode! */ |
| 858 | -#if defined(__LITTLE_ENDIAN) || defined(CONFIG_AU1X00) | |
| 858 | +#if defined(__LITTLE_ENDIAN) || ( defined(CONFIG_AU1X00) && !defined(CONFIG_GTH2) ) | |
| 859 | 859 | #define input_swap_data(x,y,z) input_data(x,y,z) |
| 860 | 860 | #else |
| 861 | 861 | static void |
| 862 | 862 | |
| ... | ... | @@ -881,8 +881,13 @@ |
| 881 | 881 | debug("in input swap data base for read is %lx\n", (unsigned long) pbuf); |
| 882 | 882 | |
| 883 | 883 | while (words--) { |
| 884 | +#ifdef __MIPS__ | |
| 885 | + *dbuf++ = swab16p((u16*)pbuf); | |
| 886 | + *dbuf++ = swab16p((u16*)pbuf); | |
| 887 | +#else | |
| 884 | 888 | *dbuf++ = ld_le16(pbuf); |
| 885 | 889 | *dbuf++ = ld_le16(pbuf); |
| 890 | +#endif /* !MIPS */ | |
| 886 | 891 | } |
| 887 | 892 | #endif |
| 888 | 893 | } |
include/asm-mips/au1x00.h
| ... | ... | @@ -119,6 +119,11 @@ |
| 119 | 119 | return __ilog2(x & -x) + 1; |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | +#define gpio_set(Value) outl(Value, SYS_OUTPUTSET) | |
| 123 | +#define gpio_clear(Value) outl(Value, SYS_OUTPUTCLR) | |
| 124 | +#define gpio_read() inl(SYS_PINSTATERD) | |
| 125 | +#define gpio_tristate(Value) outl(Value, SYS_TRIOUTCLR) | |
| 126 | + | |
| 122 | 127 | #endif /* !ASSEMBLY */ |
| 123 | 128 | |
| 124 | 129 | #ifdef CONFIG_PM |
include/configs/gth2.h
| 1 | +/* | |
| 2 | + * (C) Copyright 2005 | |
| 3 | + * Thomas.Lange@corelatus.se | |
| 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 | |
| 15 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 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 | +/* | |
| 25 | + * This file contains the configuration parameters for the gth2 board. | |
| 26 | + */ | |
| 27 | + | |
| 28 | +#ifndef __CONFIG_H | |
| 29 | +#define __CONFIG_H | |
| 30 | + | |
| 31 | +#define CONFIG_MIPS32 1 /* MIPS32 CPU core */ | |
| 32 | +#define CONFIG_GTH2 1 | |
| 33 | +#define CONFIG_AU1X00 1 /* alchemy series cpu */ | |
| 34 | + | |
| 35 | +#define CONFIG_AU1000 1 | |
| 36 | + | |
| 37 | +#define CONFIG_MISC_INIT_R 1 | |
| 38 | + | |
| 39 | +#define CONFIG_ETHADDR DE:AD:BE:EF:01:02 /* Ethernet address */ | |
| 40 | + | |
| 41 | +#define CONFIG_BOOTDELAY 1 /* autoboot after 1 seconds */ | |
| 42 | + | |
| 43 | +#define CONFIG_ENV_OVERWRITE 1 /* Allow change of ethernet address */ | |
| 44 | + | |
| 45 | +#define CONFIG_BOOT_RETRY_TIME 5 /* Retry boot in 5 secs */ | |
| 46 | + | |
| 47 | +#define CONFIG_RESET_TO_RETRY 1 /* If timeout waiting for command, perform a reset */ | |
| 48 | + | |
| 49 | +#define CONFIG_BAUDRATE 115200 | |
| 50 | + | |
| 51 | +/* valid baudrates */ | |
| 52 | +#define CFG_BAUDRATE_TABLE { 115200 } | |
| 53 | + | |
| 54 | +/* Only interrupt boot if space is pressed */ | |
| 55 | +/* If a long serial cable is connected but */ | |
| 56 | +/* other end is dead, garbage will be read */ | |
| 57 | +#define CONFIG_AUTOBOOT_KEYED 1 | |
| 58 | +#define CONFIG_AUTOBOOT_PROMPT "Press space to abort autoboot in %d second\n" | |
| 59 | +#define CONFIG_AUTOBOOT_DELAY_STR "d" | |
| 60 | +#define CONFIG_AUTOBOOT_STOP_STR " " | |
| 61 | + | |
| 62 | +#define CONFIG_TIMESTAMP /* Print image info with timestamp */ | |
| 63 | +#define CONFIG_BOOTARGS "panic=1" | |
| 64 | + | |
| 65 | +#define CONFIG_EXTRA_ENV_SETTINGS \ | |
| 66 | + "addmisc=setenv bootargs $(bootargs) " \ | |
| 67 | + "ethaddr=$(ethaddr) \0" \ | |
| 68 | + "netboot=bootp;run addmisc;bootm\0" \ | |
| 69 | + "" | |
| 70 | + | |
| 71 | +/* Boot from Compact flash partition 2 as default */ | |
| 72 | +#define CONFIG_BOOTCOMMAND "ide reset;disk 0x81000000 0:2;run addmisc;bootm" | |
| 73 | + | |
| 74 | +#define CONFIG_COMMANDS ((CONFIG_CMD_DFL | CFG_CMD_IDE | CFG_CMD_DHCP ) & \ | |
| 75 | + ~(CFG_CMD_ENV | CFG_CMD_FAT | CFG_CMD_FLASH | CFG_CMD_FPGA | \ | |
| 76 | + CFG_CMD_MII | CFG_CMD_LOADS | CFG_CMD_LOADB | CFG_CMD_ELF | \ | |
| 77 | + CFG_CMD_BDI | CFG_CMD_BEDBUG | CFG_CMD_NFS | CFG_CMD_AUTOSCRIPT )) | |
| 78 | + | |
| 79 | +#include <cmd_confdefs.h> | |
| 80 | + | |
| 81 | +/* | |
| 82 | + * Miscellaneous configurable options | |
| 83 | + */ | |
| 84 | +#define CFG_LONGHELP /* undef to save memory */ | |
| 85 | +#define CFG_PROMPT "GTH2 # " /* Monitor Command Prompt */ | |
| 86 | +#define CFG_CBSIZE 256 /* Console I/O Buffer Size */ | |
| 87 | +#define CFG_PBSIZE (CFG_CBSIZE+sizeof(CFG_PROMPT)+16) /* Print Buffer Size */ | |
| 88 | +#define CFG_MAXARGS 16 /* max number of command args*/ | |
| 89 | + | |
| 90 | +#define CFG_MALLOC_LEN 128*1024 | |
| 91 | + | |
| 92 | +#define CFG_BOOTPARAMS_LEN 128*1024 | |
| 93 | + | |
| 94 | +#define CFG_MHZ 500 | |
| 95 | + | |
| 96 | +#define CFG_HZ (CFG_MHZ * 1000000) /* FIXME causes overflow in net.c */ | |
| 97 | + | |
| 98 | +#define CFG_SDRAM_BASE 0x80000000 /* Cached addr */ | |
| 99 | + | |
| 100 | +#define CFG_LOAD_ADDR 0x81000000 /* default load address */ | |
| 101 | + | |
| 102 | +#define CFG_MEMTEST_START 0x80100000 | |
| 103 | +#define CFG_MEMTEST_END 0x83000000 | |
| 104 | + | |
| 105 | +#define CONFIG_HW_WATCHDOG 1 | |
| 106 | + | |
| 107 | +/*----------------------------------------------------------------------- | |
| 108 | + * FLASH and environment organization | |
| 109 | + */ | |
| 110 | +#define CFG_MAX_FLASH_BANKS 2 /* max number of memory banks */ | |
| 111 | +#define CFG_MAX_FLASH_SECT (128) /* max number of sectors on one chip */ | |
| 112 | + | |
| 113 | +#define PHYS_FLASH 0xbfc00000 /* Flash Bank #1 */ | |
| 114 | + | |
| 115 | +/* The following #defines are needed to get flash environment right */ | |
| 116 | +#define CFG_MONITOR_BASE TEXT_BASE | |
| 117 | +#define CFG_MONITOR_LEN (192 << 10) | |
| 118 | + | |
| 119 | +#define CFG_INIT_SP_OFFSET 0x400000 | |
| 120 | + | |
| 121 | +/* We boot from this flash, selected with dip switch */ | |
| 122 | +#define CFG_FLASH_BASE PHYS_FLASH | |
| 123 | + | |
| 124 | +/* timeout values are in ticks */ | |
| 125 | +#define CFG_FLASH_ERASE_TOUT (2 * CFG_HZ) /* Timeout for Flash Erase */ | |
| 126 | +#define CFG_FLASH_WRITE_TOUT (2 * CFG_HZ) /* Timeout for Flash Write */ | |
| 127 | + | |
| 128 | +#define CFG_ENV_IS_NOWHERE 1 | |
| 129 | + | |
| 130 | +/* Address and size of Primary Environment Sector */ | |
| 131 | +#define CFG_ENV_ADDR 0xB0030000 | |
| 132 | +#define CFG_ENV_SIZE 0x10000 | |
| 133 | + | |
| 134 | +#define CONFIG_FLASH_16BIT | |
| 135 | + | |
| 136 | +#define CONFIG_NR_DRAM_BANKS 2 | |
| 137 | + | |
| 138 | +#define CONFIG_NET_MULTI | |
| 139 | + | |
| 140 | +#define CONFIG_MEMSIZE_IN_BYTES | |
| 141 | + | |
| 142 | +/*---ATA PCMCIA ------------------------------------*/ | |
| 143 | +#define CFG_PCMCIA_MEM_SIZE 0x4000000 /* Offset to slot 1 FIXME!!! */ | |
| 144 | + | |
| 145 | +#define CFG_PCMCIA_MEM_ADDR 0x20000000 | |
| 146 | +#define CFG_PCMCIA_IO_BASE 0x28000000 | |
| 147 | +#define CFG_PCMCIA_ATTR_BASE 0x30000000 | |
| 148 | + | |
| 149 | +#define CONFIG_PCMCIA_SLOT_A | |
| 150 | + | |
| 151 | +#define CONFIG_ATAPI 1 | |
| 152 | +#define CONFIG_MAC_PARTITION 1 | |
| 153 | + | |
| 154 | +/* We run CF in "true ide" mode or a harddrive via pcmcia */ | |
| 155 | +#define CONFIG_IDE_PCMCIA 1 | |
| 156 | + | |
| 157 | +/* We only support one slot for now */ | |
| 158 | +#define CFG_IDE_MAXBUS 1 /* max. 1 IDE bus */ | |
| 159 | +#define CFG_IDE_MAXDEVICE 1 /* max. 1 drive per IDE bus */ | |
| 160 | + | |
| 161 | +#undef CONFIG_IDE_LED /* LED for ide not supported */ | |
| 162 | +#undef CONFIG_IDE_RESET /* reset for ide not supported */ | |
| 163 | + | |
| 164 | +#define CFG_ATA_IDE0_OFFSET 0 | |
| 165 | + | |
| 166 | +#define CFG_ATA_BASE_ADDR CFG_PCMCIA_IO_BASE | |
| 167 | + | |
| 168 | +/* Offset for data I/O */ | |
| 169 | +#define CFG_ATA_DATA_OFFSET 0 | |
| 170 | + | |
| 171 | +/* Offset for normal register accesses */ | |
| 172 | +#define CFG_ATA_REG_OFFSET 0 | |
| 173 | + | |
| 174 | +/* Offset for alternate registers */ | |
| 175 | +#define CFG_ATA_ALT_OFFSET 0x0200 | |
| 176 | + | |
| 177 | +/*----------------------------------------------------------------------- | |
| 178 | + * Cache Configuration | |
| 179 | + */ | |
| 180 | +#define CFG_DCACHE_SIZE 16384 | |
| 181 | +#define CFG_ICACHE_SIZE 16384 | |
| 182 | +#define CFG_CACHELINE_SIZE 32 | |
| 183 | + | |
| 184 | +#define GPIO_CACONFIG (1<<0) | |
| 185 | +#define GPIO_DPACONFIG (1<<6) | |
| 186 | +#define GPIO_ERESET (1<<11) | |
| 187 | +#define GPIO_EEDQ (1<<17) | |
| 188 | +#define GPIO_WDI (1<<18) | |
| 189 | +#define GPIO_RJ1LY (1<<22) | |
| 190 | +#define GPIO_RJ1LG (1<<23) | |
| 191 | +#define GPIO_LEDCLK (1<<29) | |
| 192 | +#define GPIO_LEDD (1<<30) | |
| 193 | +#define GPIO_CPU_LED (1<<31) | |
| 194 | + | |
| 195 | +#endif /* __CONFIG_H */ |