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