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