stroese | 1bc0f14 | 2004-12-16 18:20:14 +0000 | [diff] [blame] | 1 | /* |
Matthias Fuchs | 0b98725 | 2008-04-21 14:42:11 +0200 | [diff] [blame] | 2 | * (C) Copyright 2005-2008 |
| 3 | * Matthias Fuchs, esd gmbh germany, matthias.fuchs@esd-electronics.com |
| 4 | * |
stroese | 1bc0f14 | 2004-12-16 18:20:14 +0000 | [diff] [blame] | 5 | * (C) Copyright 2001-2003 |
| 6 | * Stefan Roese, esd gmbh germany, stefan.roese@esd-electronics.com |
| 7 | * |
| 8 | * See file CREDITS for list of people who contributed to this |
| 9 | * project. |
| 10 | * |
| 11 | * This program is free software; you can redistribute it and/or |
| 12 | * modify it under the terms of the GNU General Public License as |
| 13 | * published by the Free Software Foundation; either version 2 of |
| 14 | * the License, or (at your option) any later version. |
| 15 | * |
| 16 | * This program is distributed in the hope that it will be useful, |
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 | * GNU General Public License for more details. |
| 20 | * |
| 21 | * You should have received a copy of the GNU General Public License |
| 22 | * along with this program; if not, write to the Free Software |
| 23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 24 | * MA 02111-1307 USA |
| 25 | */ |
| 26 | |
| 27 | #include <common.h> |
| 28 | #include <asm/processor.h> |
Matthias Fuchs | 0b98725 | 2008-04-21 14:42:11 +0200 | [diff] [blame] | 29 | #include <asm/io.h> |
stroese | 1bc0f14 | 2004-12-16 18:20:14 +0000 | [diff] [blame] | 30 | #include <command.h> |
| 31 | #include <malloc.h> |
Matthias Fuchs | 0b98725 | 2008-04-21 14:42:11 +0200 | [diff] [blame] | 32 | #include <flash.h> |
| 33 | #include <asm/4xx_pci.h> |
| 34 | #include <pci.h> |
stroese | 1bc0f14 | 2004-12-16 18:20:14 +0000 | [diff] [blame] | 35 | |
Wolfgang Denk | d87080b | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 36 | DECLARE_GLOBAL_DATA_PTR; |
stroese | 1bc0f14 | 2004-12-16 18:20:14 +0000 | [diff] [blame] | 37 | |
Matthias Fuchs | 0b98725 | 2008-04-21 14:42:11 +0200 | [diff] [blame] | 38 | #undef FPGA_DEBUG |
stroese | 1bc0f14 | 2004-12-16 18:20:14 +0000 | [diff] [blame] | 39 | |
| 40 | extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]); |
| 41 | extern void lxt971_no_sleep(void); |
Matthias Fuchs | 0b98725 | 2008-04-21 14:42:11 +0200 | [diff] [blame] | 42 | extern ulong flash_get_size (ulong base, int banknum); |
| 43 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 44 | int flash_banks = CONFIG_SYS_MAX_FLASH_BANKS_DETECT; |
stroese | 1bc0f14 | 2004-12-16 18:20:14 +0000 | [diff] [blame] | 45 | |
| 46 | /* fpga configuration data - gzip compressed and generated by bin2c */ |
| 47 | const unsigned char fpgadata[] = |
| 48 | { |
| 49 | #include "fpgadata.c" |
| 50 | }; |
| 51 | |
| 52 | /* |
| 53 | * include common fpga code (for esd boards) |
| 54 | */ |
| 55 | #include "../common/fpga.c" |
| 56 | |
stroese | 1bc0f14 | 2004-12-16 18:20:14 +0000 | [diff] [blame] | 57 | #ifdef CONFIG_LCD_USED |
| 58 | /* logo bitmap data - gzip compressed and generated by bin2c */ |
| 59 | unsigned char logo_bmp[] = |
| 60 | { |
Matthias Fuchs | 0b98725 | 2008-04-21 14:42:11 +0200 | [diff] [blame] | 61 | #include "logo_640_480_24bpp.c" |
stroese | 1bc0f14 | 2004-12-16 18:20:14 +0000 | [diff] [blame] | 62 | }; |
| 63 | |
| 64 | /* |
| 65 | * include common lcd code (for esd boards) |
| 66 | */ |
| 67 | #include "../common/lcd.c" |
Matthias Fuchs | 0b98725 | 2008-04-21 14:42:11 +0200 | [diff] [blame] | 68 | #include "../common/s1d13505_640_480_16bpp.h" |
| 69 | #include "../common/s1d13806_640_480_16bpp.h" |
stroese | 1bc0f14 | 2004-12-16 18:20:14 +0000 | [diff] [blame] | 70 | #endif /* CONFIG_LCD_USED */ |
| 71 | |
Matthias Fuchs | 0b98725 | 2008-04-21 14:42:11 +0200 | [diff] [blame] | 72 | /* |
| 73 | * include common auto-update code (for esd boards) |
| 74 | */ |
| 75 | #include "../common/auto_update.h" |
| 76 | |
| 77 | au_image_t au_image[] = { |
| 78 | {"preinst.img", 0, -1, AU_SCRIPT}, |
| 79 | {"u-boot.img", 0xfff80000, 0x00080000, AU_FIRMWARE | AU_PROTECT}, |
| 80 | {"pImage", 0xfe000000, 0x00100000, AU_NOR | AU_PROTECT}, |
| 81 | {"pImage.initrd", 0xfe100000, 0x00400000, AU_NOR | AU_PROTECT}, |
| 82 | {"work.img", 0xfe500000, 0x01400000, AU_NOR}, |
| 83 | {"data.img", 0xff900000, 0x00580000, AU_NOR}, |
| 84 | {"logo.img", 0xffe80000, 0x00100000, AU_NOR | AU_PROTECT}, |
| 85 | {"postinst.img", 0, 0, AU_SCRIPT}, |
| 86 | }; |
| 87 | |
| 88 | int N_AU_IMAGES = (sizeof(au_image) / sizeof(au_image[0])); |
stroese | 1bc0f14 | 2004-12-16 18:20:14 +0000 | [diff] [blame] | 89 | |
stroese | 04e93ec | 2005-04-13 10:06:07 +0000 | [diff] [blame] | 90 | int board_revision(void) |
| 91 | { |
Stefan Roese | d1c3b27 | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 92 | unsigned long CPC0_CR0Reg; |
Matthias Fuchs | 049216f | 2009-02-20 10:19:18 +0100 | [diff] [blame] | 93 | unsigned long value; |
stroese | 04e93ec | 2005-04-13 10:06:07 +0000 | [diff] [blame] | 94 | |
| 95 | /* |
| 96 | * Get version of APC405 board from GPIO's |
| 97 | */ |
| 98 | |
Matthias Fuchs | 0b98725 | 2008-04-21 14:42:11 +0200 | [diff] [blame] | 99 | /* Setup GPIO pins (CS2/GPIO11, CS3/GPIO12 and CS4/GPIO13 as GPIO) */ |
Stefan Roese | d1c3b27 | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 100 | CPC0_CR0Reg = mfdcr(CPC0_CR0); |
| 101 | mtdcr(CPC0_CR0, CPC0_CR0Reg | 0x03800000); |
Matthias Fuchs | 0b98725 | 2008-04-21 14:42:11 +0200 | [diff] [blame] | 102 | out_be32((void*)GPIO0_ODR, in_be32((void*)GPIO0_ODR) & ~0x001c0000); |
| 103 | out_be32((void*)GPIO0_TCR, in_be32((void*)GPIO0_TCR) & ~0x001c0000); |
stroese | 04e93ec | 2005-04-13 10:06:07 +0000 | [diff] [blame] | 104 | |
Matthias Fuchs | 0b98725 | 2008-04-21 14:42:11 +0200 | [diff] [blame] | 105 | /* wait some time before reading input */ |
| 106 | udelay(1000); |
| 107 | |
| 108 | /* get config bits */ |
| 109 | value = in_be32((void*)GPIO0_IR) & 0x001c0000; |
stroese | 04e93ec | 2005-04-13 10:06:07 +0000 | [diff] [blame] | 110 | /* |
| 111 | * Restore GPIO settings |
| 112 | */ |
Stefan Roese | d1c3b27 | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 113 | mtdcr(CPC0_CR0, CPC0_CR0Reg); |
stroese | 04e93ec | 2005-04-13 10:06:07 +0000 | [diff] [blame] | 114 | |
| 115 | switch (value) { |
Matthias Fuchs | 0b98725 | 2008-04-21 14:42:11 +0200 | [diff] [blame] | 116 | case 0x001c0000: |
| 117 | /* CS2==1 && CS3==1 && CS4==1 -> version <= 1.2 */ |
stroese | 04e93ec | 2005-04-13 10:06:07 +0000 | [diff] [blame] | 118 | return 2; |
Matthias Fuchs | 0b98725 | 2008-04-21 14:42:11 +0200 | [diff] [blame] | 119 | case 0x000c0000: |
| 120 | /* CS2==0 && CS3==1 && CS4==1 -> version 1.3 */ |
stroese | 04e93ec | 2005-04-13 10:06:07 +0000 | [diff] [blame] | 121 | return 3; |
Matthias Fuchs | 0b98725 | 2008-04-21 14:42:11 +0200 | [diff] [blame] | 122 | case 0x00180000: |
| 123 | /* CS2==1 && CS3==1 && CS4==0 -> version 1.6 */ |
| 124 | return 6; |
| 125 | case 0x00140000: |
| 126 | /* CS2==1 && CS3==0 && CS4==1 -> version 1.8 */ |
| 127 | return 8; |
stroese | 04e93ec | 2005-04-13 10:06:07 +0000 | [diff] [blame] | 128 | default: |
| 129 | /* should not be reached! */ |
| 130 | return 0; |
| 131 | } |
| 132 | } |
| 133 | |
stroese | 1bc0f14 | 2004-12-16 18:20:14 +0000 | [diff] [blame] | 134 | int board_early_init_f (void) |
| 135 | { |
| 136 | /* |
Matthias Fuchs | 0b98725 | 2008-04-21 14:42:11 +0200 | [diff] [blame] | 137 | * First pull fpga-prg pin low, to disable fpga logic |
stroese | 1bc0f14 | 2004-12-16 18:20:14 +0000 | [diff] [blame] | 138 | */ |
Matthias Fuchs | 0b98725 | 2008-04-21 14:42:11 +0200 | [diff] [blame] | 139 | out_be32((void*)GPIO0_ODR, 0x00000000); /* no open drain pins */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 140 | out_be32((void*)GPIO0_TCR, CONFIG_SYS_FPGA_PRG); /* setup for output */ |
Matthias Fuchs | 0b98725 | 2008-04-21 14:42:11 +0200 | [diff] [blame] | 141 | out_be32((void*)GPIO0_OR, 0); /* pull prg low */ |
stroese | 1bc0f14 | 2004-12-16 18:20:14 +0000 | [diff] [blame] | 142 | |
| 143 | /* |
| 144 | * IRQ 0-15 405GP internally generated; active high; level sensitive |
| 145 | * IRQ 16 405GP internally generated; active low; level sensitive |
| 146 | * IRQ 17-24 RESERVED |
| 147 | * IRQ 25 (EXT IRQ 0) CAN0; active low; level sensitive |
| 148 | * IRQ 26 (EXT IRQ 1) SER0 ; active low; level sensitive |
| 149 | * IRQ 27 (EXT IRQ 2) SER1; active low; level sensitive |
| 150 | * IRQ 28 (EXT IRQ 3) FPGA 0; active low; level sensitive |
| 151 | * IRQ 29 (EXT IRQ 4) FPGA 1; active low; level sensitive |
| 152 | * IRQ 30 (EXT IRQ 5) PCI INTA; active low; level sensitive |
| 153 | * IRQ 31 (EXT IRQ 6) COMPACT FLASH; active high; level sensitive |
| 154 | */ |
Stefan Roese | 952e776 | 2009-09-24 09:55:50 +0200 | [diff] [blame] | 155 | mtdcr(UIC0SR, 0xFFFFFFFF); /* clear all ints */ |
| 156 | mtdcr(UIC0ER, 0x00000000); /* disable all ints */ |
| 157 | mtdcr(UIC0CR, 0x00000000); /* set all to be non-critical*/ |
| 158 | mtdcr(UIC0PR, 0xFFFFFF81); /* set int polarities */ |
| 159 | mtdcr(UIC0TR, 0x10000000); /* set int trigger levels */ |
| 160 | mtdcr(UIC0VCR, 0x00000001); /* set vect base=0 */ |
| 161 | mtdcr(UIC0SR, 0xFFFFFFFF); /* clear all ints */ |
stroese | 1bc0f14 | 2004-12-16 18:20:14 +0000 | [diff] [blame] | 162 | |
| 163 | /* |
Matthias Fuchs | 0b98725 | 2008-04-21 14:42:11 +0200 | [diff] [blame] | 164 | * EBC Configuration Register: set ready timeout to 512 ebc-clks |
stroese | 1bc0f14 | 2004-12-16 18:20:14 +0000 | [diff] [blame] | 165 | */ |
Stefan Roese | d1c3b27 | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 166 | mtebc(EBC0_CFG, 0xa8400000); /* ebc always driven */ |
Matthias Fuchs | 0b98725 | 2008-04-21 14:42:11 +0200 | [diff] [blame] | 167 | |
| 168 | /* |
| 169 | * New boards have a single 32MB flash connected to CS0 |
| 170 | * instead of two 16MB flashes on CS0+1. |
| 171 | */ |
| 172 | if (board_revision() >= 8) { |
| 173 | /* disable CS1 */ |
Stefan Roese | d1c3b27 | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 174 | mtebc(PB1AP, 0); |
| 175 | mtebc(PB1CR, 0); |
Matthias Fuchs | 0b98725 | 2008-04-21 14:42:11 +0200 | [diff] [blame] | 176 | |
| 177 | /* resize CS0 to 32MB */ |
Stefan Roese | d1c3b27 | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 178 | mtebc(PB0AP, CONFIG_SYS_EBC_PB0AP_HWREV8); |
| 179 | mtebc(PB0CR, CONFIG_SYS_EBC_PB0CR_HWREV8); |
Matthias Fuchs | 0b98725 | 2008-04-21 14:42:11 +0200 | [diff] [blame] | 180 | } |
stroese | 1bc0f14 | 2004-12-16 18:20:14 +0000 | [diff] [blame] | 181 | |
| 182 | return 0; |
| 183 | } |
| 184 | |
Matthias Fuchs | 0b98725 | 2008-04-21 14:42:11 +0200 | [diff] [blame] | 185 | int board_early_init_r(void) |
stroese | 1bc0f14 | 2004-12-16 18:20:14 +0000 | [diff] [blame] | 186 | { |
Matthias Fuchs | 0b98725 | 2008-04-21 14:42:11 +0200 | [diff] [blame] | 187 | if (gd->board_type >= 8) |
| 188 | flash_banks = 1; |
| 189 | |
| 190 | return 0; |
stroese | 1bc0f14 | 2004-12-16 18:20:14 +0000 | [diff] [blame] | 191 | } |
| 192 | |
Matthias Fuchs | 0b98725 | 2008-04-21 14:42:11 +0200 | [diff] [blame] | 193 | #define FUJI_BASE 0xf0100200 |
| 194 | #define LCDBL_PWM 0xa0 |
| 195 | #define LCDBL_PWMMIN 0xa4 |
| 196 | #define LCDBL_PWMMAX 0xa8 |
stroese | 1bc0f14 | 2004-12-16 18:20:14 +0000 | [diff] [blame] | 197 | |
Matthias Fuchs | 0b98725 | 2008-04-21 14:42:11 +0200 | [diff] [blame] | 198 | int misc_init_r(void) |
stroese | 1bc0f14 | 2004-12-16 18:20:14 +0000 | [diff] [blame] | 199 | { |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 200 | u16 *fpga_mode = (u16 *)(CONFIG_SYS_FPGA_BASE_ADDR + CONFIG_SYS_FPGA_CTRL); |
| 201 | u16 *fpga_ctrl2 =(u16 *)(CONFIG_SYS_FPGA_BASE_ADDR + CONFIG_SYS_FPGA_CTRL2); |
Matthias Fuchs | 0b98725 | 2008-04-21 14:42:11 +0200 | [diff] [blame] | 202 | u8 *duart0_mcr = (u8 *)(DUART0_BA + 4); |
| 203 | u8 *duart1_mcr = (u8 *)(DUART1_BA + 4); |
stroese | 1bc0f14 | 2004-12-16 18:20:14 +0000 | [diff] [blame] | 204 | unsigned char *dst; |
| 205 | ulong len = sizeof(fpgadata); |
| 206 | int status; |
| 207 | int index; |
| 208 | int i; |
Stefan Roese | d1c3b27 | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 209 | unsigned long CPC0_CR0Reg; |
Matthias Fuchs | 0b98725 | 2008-04-21 14:42:11 +0200 | [diff] [blame] | 210 | char *str; |
| 211 | uchar *logo_addr; |
| 212 | ulong logo_size; |
| 213 | ushort minb, maxb; |
| 214 | int result; |
stroese | 1bc0f14 | 2004-12-16 18:20:14 +0000 | [diff] [blame] | 215 | |
| 216 | /* |
| 217 | * Setup GPIO pins (CS6+CS7 as GPIO) |
| 218 | */ |
Stefan Roese | d1c3b27 | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 219 | CPC0_CR0Reg = mfdcr(CPC0_CR0); |
| 220 | mtdcr(CPC0_CR0, CPC0_CR0Reg | 0x00300000); |
stroese | 1bc0f14 | 2004-12-16 18:20:14 +0000 | [diff] [blame] | 221 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 222 | dst = malloc(CONFIG_SYS_FPGA_MAX_SIZE); |
| 223 | if (gunzip(dst, CONFIG_SYS_FPGA_MAX_SIZE, (uchar *)fpgadata, &len) != 0) { |
Matthias Fuchs | 0b98725 | 2008-04-21 14:42:11 +0200 | [diff] [blame] | 224 | printf("GUNZIP ERROR - must RESET board to recover\n"); |
| 225 | do_reset(NULL, 0, 0, NULL); |
stroese | 1bc0f14 | 2004-12-16 18:20:14 +0000 | [diff] [blame] | 226 | } |
| 227 | |
| 228 | status = fpga_boot(dst, len); |
| 229 | if (status != 0) { |
| 230 | printf("\nFPGA: Booting failed "); |
| 231 | switch (status) { |
| 232 | case ERROR_FPGA_PRG_INIT_LOW: |
Matthias Fuchs | 0b98725 | 2008-04-21 14:42:11 +0200 | [diff] [blame] | 233 | printf("(Timeout: " |
| 234 | "INIT not low after asserting PROGRAM*)\n "); |
stroese | 1bc0f14 | 2004-12-16 18:20:14 +0000 | [diff] [blame] | 235 | break; |
| 236 | case ERROR_FPGA_PRG_INIT_HIGH: |
Matthias Fuchs | 0b98725 | 2008-04-21 14:42:11 +0200 | [diff] [blame] | 237 | printf("(Timeout: " |
| 238 | "INIT not high after deasserting PROGRAM*)\n "); |
stroese | 1bc0f14 | 2004-12-16 18:20:14 +0000 | [diff] [blame] | 239 | break; |
| 240 | case ERROR_FPGA_PRG_DONE: |
Matthias Fuchs | 0b98725 | 2008-04-21 14:42:11 +0200 | [diff] [blame] | 241 | printf("(Timeout: " |
| 242 | "DONE not high after programming FPGA)\n "); |
stroese | 1bc0f14 | 2004-12-16 18:20:14 +0000 | [diff] [blame] | 243 | break; |
| 244 | } |
| 245 | |
| 246 | /* display infos on fpgaimage */ |
| 247 | index = 15; |
Matthias Fuchs | 0b98725 | 2008-04-21 14:42:11 +0200 | [diff] [blame] | 248 | for (i = 0; i < 4; i++) { |
stroese | 1bc0f14 | 2004-12-16 18:20:14 +0000 | [diff] [blame] | 249 | len = dst[index]; |
| 250 | printf("FPGA: %s\n", &(dst[index+1])); |
Matthias Fuchs | 0b98725 | 2008-04-21 14:42:11 +0200 | [diff] [blame] | 251 | index += len + 3; |
stroese | 1bc0f14 | 2004-12-16 18:20:14 +0000 | [diff] [blame] | 252 | } |
Matthias Fuchs | 0b98725 | 2008-04-21 14:42:11 +0200 | [diff] [blame] | 253 | putc('\n'); |
stroese | 1bc0f14 | 2004-12-16 18:20:14 +0000 | [diff] [blame] | 254 | /* delayed reboot */ |
Matthias Fuchs | 0b98725 | 2008-04-21 14:42:11 +0200 | [diff] [blame] | 255 | for (i = 20; i > 0; i--) { |
stroese | 1bc0f14 | 2004-12-16 18:20:14 +0000 | [diff] [blame] | 256 | printf("Rebooting in %2d seconds \r",i); |
Matthias Fuchs | 0b98725 | 2008-04-21 14:42:11 +0200 | [diff] [blame] | 257 | for (index = 0; index < 1000; index++) |
stroese | 1bc0f14 | 2004-12-16 18:20:14 +0000 | [diff] [blame] | 258 | udelay(1000); |
| 259 | } |
Matthias Fuchs | 0b98725 | 2008-04-21 14:42:11 +0200 | [diff] [blame] | 260 | putc('\n'); |
stroese | 1bc0f14 | 2004-12-16 18:20:14 +0000 | [diff] [blame] | 261 | do_reset(NULL, 0, 0, NULL); |
| 262 | } |
| 263 | |
| 264 | /* restore gpio/cs settings */ |
Stefan Roese | d1c3b27 | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 265 | mtdcr(CPC0_CR0, CPC0_CR0Reg); |
stroese | 1bc0f14 | 2004-12-16 18:20:14 +0000 | [diff] [blame] | 266 | |
| 267 | puts("FPGA: "); |
| 268 | |
| 269 | /* display infos on fpgaimage */ |
| 270 | index = 15; |
Matthias Fuchs | 0b98725 | 2008-04-21 14:42:11 +0200 | [diff] [blame] | 271 | for (i = 0; i < 4; i++) { |
stroese | 1bc0f14 | 2004-12-16 18:20:14 +0000 | [diff] [blame] | 272 | len = dst[index]; |
Matthias Fuchs | 0b98725 | 2008-04-21 14:42:11 +0200 | [diff] [blame] | 273 | printf("%s ", &(dst[index + 1])); |
| 274 | index += len + 3; |
stroese | 1bc0f14 | 2004-12-16 18:20:14 +0000 | [diff] [blame] | 275 | } |
Matthias Fuchs | 0b98725 | 2008-04-21 14:42:11 +0200 | [diff] [blame] | 276 | putc('\n'); |
stroese | 1bc0f14 | 2004-12-16 18:20:14 +0000 | [diff] [blame] | 277 | |
| 278 | free(dst); |
| 279 | |
| 280 | /* |
| 281 | * Reset FPGA via FPGA_DATA pin |
| 282 | */ |
| 283 | SET_FPGA(FPGA_PRG | FPGA_CLK); |
| 284 | udelay(1000); /* wait 1ms */ |
| 285 | SET_FPGA(FPGA_PRG | FPGA_CLK | FPGA_DATA); |
| 286 | udelay(1000); /* wait 1ms */ |
| 287 | |
| 288 | /* |
stroese | 04e93ec | 2005-04-13 10:06:07 +0000 | [diff] [blame] | 289 | * Write board revision in FPGA |
| 290 | */ |
Matthias Fuchs | 0b98725 | 2008-04-21 14:42:11 +0200 | [diff] [blame] | 291 | out_be16(fpga_ctrl2, |
| 292 | (in_be16(fpga_ctrl2) & 0xfff0) | (gd->board_type & 0x000f)); |
stroese | 04e93ec | 2005-04-13 10:06:07 +0000 | [diff] [blame] | 293 | |
| 294 | /* |
stroese | 1bc0f14 | 2004-12-16 18:20:14 +0000 | [diff] [blame] | 295 | * Enable power on PS/2 interface (with reset) |
| 296 | */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 297 | out_be16(fpga_mode, in_be16(fpga_mode) | CONFIG_SYS_FPGA_CTRL_PS2_RESET); |
stroese | 1bc0f14 | 2004-12-16 18:20:14 +0000 | [diff] [blame] | 298 | for (i=0;i<100;i++) |
| 299 | udelay(1000); |
| 300 | udelay(1000); |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 301 | out_be16(fpga_mode, in_be16(fpga_mode) & ~CONFIG_SYS_FPGA_CTRL_PS2_RESET); |
stroese | 1bc0f14 | 2004-12-16 18:20:14 +0000 | [diff] [blame] | 302 | |
| 303 | /* |
| 304 | * Enable interrupts in exar duart mcr[3] |
| 305 | */ |
Matthias Fuchs | 0b98725 | 2008-04-21 14:42:11 +0200 | [diff] [blame] | 306 | out_8(duart0_mcr, 0x08); |
| 307 | out_8(duart1_mcr, 0x08); |
stroese | 1bc0f14 | 2004-12-16 18:20:14 +0000 | [diff] [blame] | 308 | |
| 309 | /* |
| 310 | * Init lcd interface and display logo |
| 311 | */ |
Matthias Fuchs | 0b98725 | 2008-04-21 14:42:11 +0200 | [diff] [blame] | 312 | str = getenv("splashimage"); |
| 313 | if (str) { |
| 314 | logo_addr = (uchar *)simple_strtoul(str, NULL, 16); |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 315 | logo_size = CONFIG_SYS_VIDEO_LOGO_MAX_SIZE; |
Matthias Fuchs | 0b98725 | 2008-04-21 14:42:11 +0200 | [diff] [blame] | 316 | } else { |
| 317 | logo_addr = logo_bmp; |
| 318 | logo_size = sizeof(logo_bmp); |
| 319 | } |
| 320 | |
| 321 | if (gd->board_type >= 6) { |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 322 | result = lcd_init((uchar *)CONFIG_SYS_LCD_BIG_REG, |
| 323 | (uchar *)CONFIG_SYS_LCD_BIG_MEM, |
Matthias Fuchs | 0b98725 | 2008-04-21 14:42:11 +0200 | [diff] [blame] | 324 | regs_13505_640_480_16bpp, |
| 325 | sizeof(regs_13505_640_480_16bpp) / |
| 326 | sizeof(regs_13505_640_480_16bpp[0]), |
| 327 | logo_addr, logo_size); |
| 328 | if (result && str) { |
| 329 | /* retry with internal image */ |
| 330 | logo_addr = logo_bmp; |
| 331 | logo_size = sizeof(logo_bmp); |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 332 | lcd_init((uchar *)CONFIG_SYS_LCD_BIG_REG, |
| 333 | (uchar *)CONFIG_SYS_LCD_BIG_MEM, |
Matthias Fuchs | 0b98725 | 2008-04-21 14:42:11 +0200 | [diff] [blame] | 334 | regs_13505_640_480_16bpp, |
| 335 | sizeof(regs_13505_640_480_16bpp) / |
| 336 | sizeof(regs_13505_640_480_16bpp[0]), |
| 337 | logo_addr, logo_size); |
| 338 | } |
| 339 | } else { |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 340 | result = lcd_init((uchar *)CONFIG_SYS_LCD_BIG_REG, |
| 341 | (uchar *)CONFIG_SYS_LCD_BIG_MEM, |
Matthias Fuchs | 0b98725 | 2008-04-21 14:42:11 +0200 | [diff] [blame] | 342 | regs_13806_640_480_16bpp, |
| 343 | sizeof(regs_13806_640_480_16bpp) / |
| 344 | sizeof(regs_13806_640_480_16bpp[0]), |
| 345 | logo_addr, logo_size); |
| 346 | if (result && str) { |
| 347 | /* retry with internal image */ |
| 348 | logo_addr = logo_bmp; |
| 349 | logo_size = sizeof(logo_bmp); |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 350 | lcd_init((uchar *)CONFIG_SYS_LCD_BIG_REG, |
| 351 | (uchar *)CONFIG_SYS_LCD_BIG_MEM, |
Matthias Fuchs | 0b98725 | 2008-04-21 14:42:11 +0200 | [diff] [blame] | 352 | regs_13806_640_480_16bpp, |
| 353 | sizeof(regs_13806_640_480_16bpp) / |
| 354 | sizeof(regs_13806_640_480_16bpp[0]), |
| 355 | logo_addr, logo_size); |
| 356 | } |
| 357 | } |
stroese | 1bc0f14 | 2004-12-16 18:20:14 +0000 | [diff] [blame] | 358 | |
| 359 | /* |
stroese | 04e93ec | 2005-04-13 10:06:07 +0000 | [diff] [blame] | 360 | * Reset microcontroller and setup backlight PWM controller |
stroese | 1bc0f14 | 2004-12-16 18:20:14 +0000 | [diff] [blame] | 361 | */ |
Matthias Fuchs | 0b98725 | 2008-04-21 14:42:11 +0200 | [diff] [blame] | 362 | out_be16(fpga_mode, in_be16(fpga_mode) | 0x0014); |
stroese | 04e93ec | 2005-04-13 10:06:07 +0000 | [diff] [blame] | 363 | for (i=0;i<10;i++) |
| 364 | udelay(1000); |
Matthias Fuchs | 0b98725 | 2008-04-21 14:42:11 +0200 | [diff] [blame] | 365 | out_be16(fpga_mode, in_be16(fpga_mode) | 0x001c); |
| 366 | |
| 367 | minb = 0; |
| 368 | maxb = 0xff; |
| 369 | str = getenv("lcdbl"); |
| 370 | if (str) { |
| 371 | minb = (ushort)simple_strtoul(str, &str, 16) & 0x00ff; |
| 372 | if (str && (*str=',')) { |
| 373 | str++; |
| 374 | maxb = (ushort)simple_strtoul(str, NULL, 16) & 0x00ff; |
| 375 | } else |
| 376 | minb = 0; |
| 377 | |
| 378 | out_be16((u16 *)(FUJI_BASE + LCDBL_PWMMIN), minb); |
| 379 | out_be16((u16 *)(FUJI_BASE + LCDBL_PWMMAX), maxb); |
| 380 | |
| 381 | printf("LCDBL: min=0x%02x, max=0x%02x\n", minb, maxb); |
| 382 | } |
| 383 | out_be16((u16 *)(FUJI_BASE + LCDBL_PWM), 0xff); |
| 384 | |
Matthias Fuchs | 8e048c4 | 2008-04-25 12:01:39 +0200 | [diff] [blame] | 385 | /* |
| 386 | * fix environment for field updated units |
| 387 | */ |
| 388 | if (getenv("altbootcmd") == NULL) { |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 389 | setenv("usb_load", CONFIG_SYS_USB_LOAD_COMMAND); |
| 390 | setenv("usbargs", CONFIG_SYS_USB_ARGS); |
Matthias Fuchs | 0b98725 | 2008-04-21 14:42:11 +0200 | [diff] [blame] | 391 | setenv("bootcmd", CONFIG_BOOTCOMMAND); |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 392 | setenv("usb_self", CONFIG_SYS_USB_SELF_COMMAND); |
| 393 | setenv("bootlimit", CONFIG_SYS_BOOTLIMIT); |
| 394 | setenv("altbootcmd", CONFIG_SYS_ALT_BOOTCOMMAND); |
Matthias Fuchs | 0b98725 | 2008-04-21 14:42:11 +0200 | [diff] [blame] | 395 | saveenv(); |
| 396 | } |
stroese | 1bc0f14 | 2004-12-16 18:20:14 +0000 | [diff] [blame] | 397 | |
| 398 | return (0); |
| 399 | } |
| 400 | |
stroese | 1bc0f14 | 2004-12-16 18:20:14 +0000 | [diff] [blame] | 401 | /* |
| 402 | * Check Board Identity: |
| 403 | */ |
stroese | 1bc0f14 | 2004-12-16 18:20:14 +0000 | [diff] [blame] | 404 | int checkboard (void) |
| 405 | { |
Matthias Fuchs | 0b98725 | 2008-04-21 14:42:11 +0200 | [diff] [blame] | 406 | char str[64]; |
stroese | 1bc0f14 | 2004-12-16 18:20:14 +0000 | [diff] [blame] | 407 | int i = getenv_r ("serial#", str, sizeof(str)); |
| 408 | |
| 409 | puts ("Board: "); |
| 410 | |
| 411 | if (i == -1) { |
| 412 | puts ("### No HW ID - assuming APC405"); |
| 413 | } else { |
| 414 | puts(str); |
| 415 | } |
| 416 | |
stroese | 04e93ec | 2005-04-13 10:06:07 +0000 | [diff] [blame] | 417 | gd->board_type = board_revision(); |
Matthias Fuchs | 0b98725 | 2008-04-21 14:42:11 +0200 | [diff] [blame] | 418 | printf(", Rev. 1.%ld\n", gd->board_type); |
stroese | 1bc0f14 | 2004-12-16 18:20:14 +0000 | [diff] [blame] | 419 | |
| 420 | return 0; |
| 421 | } |
| 422 | |
stroese | 1bc0f14 | 2004-12-16 18:20:14 +0000 | [diff] [blame] | 423 | #ifdef CONFIG_IDE_RESET |
stroese | 1bc0f14 | 2004-12-16 18:20:14 +0000 | [diff] [blame] | 424 | void ide_set_reset(int on) |
| 425 | { |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 426 | u16 *fpga_mode = (u16 *)(CONFIG_SYS_FPGA_BASE_ADDR + CONFIG_SYS_FPGA_CTRL); |
stroese | 1bc0f14 | 2004-12-16 18:20:14 +0000 | [diff] [blame] | 427 | |
| 428 | /* |
| 429 | * Assert or deassert CompactFlash Reset Pin |
| 430 | */ |
Matthias Fuchs | 0b98725 | 2008-04-21 14:42:11 +0200 | [diff] [blame] | 431 | if (on) { |
| 432 | out_be16(fpga_mode, |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 433 | in_be16(fpga_mode) & ~CONFIG_SYS_FPGA_CTRL_CF_RESET); |
Matthias Fuchs | 0b98725 | 2008-04-21 14:42:11 +0200 | [diff] [blame] | 434 | } else { |
| 435 | out_be16(fpga_mode, |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 436 | in_be16(fpga_mode) | CONFIG_SYS_FPGA_CTRL_CF_RESET); |
stroese | 1bc0f14 | 2004-12-16 18:20:14 +0000 | [diff] [blame] | 437 | } |
| 438 | } |
stroese | 1bc0f14 | 2004-12-16 18:20:14 +0000 | [diff] [blame] | 439 | #endif /* CONFIG_IDE_RESET */ |
| 440 | |
Matthias Fuchs | 0b98725 | 2008-04-21 14:42:11 +0200 | [diff] [blame] | 441 | void reset_phy(void) |
| 442 | { |
| 443 | /* |
| 444 | * Disable sleep mode in LXT971 |
| 445 | */ |
| 446 | lxt971_no_sleep(); |
| 447 | } |
| 448 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 449 | #if defined(CONFIG_USB_OHCI_NEW) && defined(CONFIG_SYS_USB_OHCI_BOARD_INIT) |
Matthias Fuchs | 0b98725 | 2008-04-21 14:42:11 +0200 | [diff] [blame] | 450 | int usb_board_init(void) |
| 451 | { |
| 452 | return 0; |
| 453 | } |
| 454 | |
| 455 | int usb_board_stop(void) |
| 456 | { |
| 457 | unsigned short tmp; |
| 458 | int i; |
| 459 | |
| 460 | /* |
| 461 | * reset PCI bus |
| 462 | * This is required to make some very old Linux OHCI driver |
| 463 | * work after U-Boot has used the OHCI controller. |
| 464 | */ |
| 465 | pci_read_config_word(PCIDEVID_405GP, PCIBRDGOPT2, &tmp); |
| 466 | pci_write_config_word(PCIDEVID_405GP, PCIBRDGOPT2, (tmp | 0x1000)); |
| 467 | |
| 468 | for (i = 0; i < 100; i++) |
| 469 | udelay(1000); |
| 470 | |
| 471 | pci_write_config_word(PCIDEVID_405GP, PCIBRDGOPT2, tmp); |
| 472 | return 0; |
| 473 | } |
| 474 | |
| 475 | int usb_board_init_fail(void) |
| 476 | { |
| 477 | usb_board_stop(); |
| 478 | return 0; |
| 479 | } |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 480 | #endif /* defined(CONFIG_USB_OHCI) && defined(CONFIG_SYS_USB_OHCI_BOARD_INIT) */ |