blob: 5cc1d0d9d642a580ea2279ef768b235c5edeef44 [file] [log] [blame]
stroese27a0ddc2004-12-16 18:20:14 +00001/*
Matthias Fuchs814f5372008-04-21 14:42:11 +02002 * (C) Copyright 2005-2008
3 * Matthias Fuchs, esd gmbh germany, matthias.fuchs@esd-electronics.com
4 *
stroese27a0ddc2004-12-16 18:20:14 +00005 * (C) Copyright 2001-2003
6 * Stefan Roese, esd gmbh germany, stefan.roese@esd-electronics.com
7 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02008 * SPDX-License-Identifier: GPL-2.0+
stroese27a0ddc2004-12-16 18:20:14 +00009 */
10
11#include <common.h>
12#include <asm/processor.h>
Matthias Fuchs814f5372008-04-21 14:42:11 +020013#include <asm/io.h>
stroese27a0ddc2004-12-16 18:20:14 +000014#include <command.h>
15#include <malloc.h>
Matthias Fuchs814f5372008-04-21 14:42:11 +020016#include <flash.h>
Stefan Roesefb9a7302010-08-31 10:00:10 +020017#include <mtd/cfi_flash.h>
Matthias Fuchs814f5372008-04-21 14:42:11 +020018#include <asm/4xx_pci.h>
19#include <pci.h>
Mateusz Zalegad862f892013-10-04 19:22:26 +020020#include <usb.h>
stroese27a0ddc2004-12-16 18:20:14 +000021
Wolfgang Denk6405a152006-03-31 18:32:53 +020022DECLARE_GLOBAL_DATA_PTR;
stroese27a0ddc2004-12-16 18:20:14 +000023
Matthias Fuchs814f5372008-04-21 14:42:11 +020024#undef FPGA_DEBUG
stroese27a0ddc2004-12-16 18:20:14 +000025
stroese27a0ddc2004-12-16 18:20:14 +000026extern void lxt971_no_sleep(void);
27
28/* fpga configuration data - gzip compressed and generated by bin2c */
29const 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
stroese27a0ddc2004-12-16 18:20:14 +000039#ifdef CONFIG_LCD_USED
40/* logo bitmap data - gzip compressed and generated by bin2c */
41unsigned char logo_bmp[] =
42{
Matthias Fuchs814f5372008-04-21 14:42:11 +020043#include "logo_640_480_24bpp.c"
stroese27a0ddc2004-12-16 18:20:14 +000044};
45
46/*
47 * include common lcd code (for esd boards)
48 */
49#include "../common/lcd.c"
Matthias Fuchs814f5372008-04-21 14:42:11 +020050#include "../common/s1d13505_640_480_16bpp.h"
51#include "../common/s1d13806_640_480_16bpp.h"
stroese27a0ddc2004-12-16 18:20:14 +000052#endif /* CONFIG_LCD_USED */
53
Matthias Fuchs814f5372008-04-21 14:42:11 +020054/*
55 * include common auto-update code (for esd boards)
56 */
57#include "../common/auto_update.h"
58
59au_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
70int N_AU_IMAGES = (sizeof(au_image) / sizeof(au_image[0]));
stroese27a0ddc2004-12-16 18:20:14 +000071
stroese63268872005-04-13 10:06:07 +000072int board_revision(void)
73{
Stefan Roese918010a2009-09-09 16:25:29 +020074 unsigned long CPC0_CR0Reg;
Matthias Fuchsfaac7432009-02-20 10:19:18 +010075 unsigned long value;
stroese63268872005-04-13 10:06:07 +000076
77 /*
78 * Get version of APC405 board from GPIO's
79 */
80
Matthias Fuchs814f5372008-04-21 14:42:11 +020081 /* Setup GPIO pins (CS2/GPIO11, CS3/GPIO12 and CS4/GPIO13 as GPIO) */
Stefan Roese918010a2009-09-09 16:25:29 +020082 CPC0_CR0Reg = mfdcr(CPC0_CR0);
83 mtdcr(CPC0_CR0, CPC0_CR0Reg | 0x03800000);
Matthias Fuchs814f5372008-04-21 14:42:11 +020084 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);
stroese63268872005-04-13 10:06:07 +000089
Matthias Fuchs814f5372008-04-21 14:42:11 +020090 /* get config bits */
91 value = in_be32((void*)GPIO0_IR) & 0x001c0000;
stroese63268872005-04-13 10:06:07 +000092 /*
93 * Restore GPIO settings
94 */
Stefan Roese918010a2009-09-09 16:25:29 +020095 mtdcr(CPC0_CR0, CPC0_CR0Reg);
stroese63268872005-04-13 10:06:07 +000096
97 switch (value) {
Matthias Fuchs814f5372008-04-21 14:42:11 +020098 case 0x001c0000:
99 /* CS2==1 && CS3==1 && CS4==1 -> version <= 1.2 */
stroese63268872005-04-13 10:06:07 +0000100 return 2;
Matthias Fuchs814f5372008-04-21 14:42:11 +0200101 case 0x000c0000:
102 /* CS2==0 && CS3==1 && CS4==1 -> version 1.3 */
stroese63268872005-04-13 10:06:07 +0000103 return 3;
Matthias Fuchs814f5372008-04-21 14:42:11 +0200104 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;
stroese63268872005-04-13 10:06:07 +0000110 default:
111 /* should not be reached! */
112 return 0;
113 }
114}
115
stroese27a0ddc2004-12-16 18:20:14 +0000116int board_early_init_f (void)
117{
118 /*
Matthias Fuchs814f5372008-04-21 14:42:11 +0200119 * First pull fpga-prg pin low, to disable fpga logic
stroese27a0ddc2004-12-16 18:20:14 +0000120 */
Matthias Fuchs814f5372008-04-21 14:42:11 +0200121 out_be32((void*)GPIO0_ODR, 0x00000000); /* no open drain pins */
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200122 out_be32((void*)GPIO0_TCR, CONFIG_SYS_FPGA_PRG); /* setup for output */
Matthias Fuchs814f5372008-04-21 14:42:11 +0200123 out_be32((void*)GPIO0_OR, 0); /* pull prg low */
stroese27a0ddc2004-12-16 18:20:14 +0000124
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 Roese707fd362009-09-24 09:55:50 +0200137 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 */
stroese27a0ddc2004-12-16 18:20:14 +0000144
145 /*
Matthias Fuchs814f5372008-04-21 14:42:11 +0200146 * EBC Configuration Register: set ready timeout to 512 ebc-clks
stroese27a0ddc2004-12-16 18:20:14 +0000147 */
Stefan Roese918010a2009-09-09 16:25:29 +0200148 mtebc(EBC0_CFG, 0xa8400000); /* ebc always driven */
stroese27a0ddc2004-12-16 18:20:14 +0000149
Matthias Fuchs814f5372008-04-21 14:42:11 +0200150 /*
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 Roese918010a2009-09-09 16:25:29 +0200156 mtebc(PB1AP, 0);
157 mtebc(PB1CR, 0);
stroese27a0ddc2004-12-16 18:20:14 +0000158
Matthias Fuchs814f5372008-04-21 14:42:11 +0200159 /* resize CS0 to 32MB */
Stefan Roese918010a2009-09-09 16:25:29 +0200160 mtebc(PB0AP, CONFIG_SYS_EBC_PB0AP_HWREV8);
161 mtebc(PB0CR, CONFIG_SYS_EBC_PB0CR_HWREV8);
Matthias Fuchs814f5372008-04-21 14:42:11 +0200162 }
stroese27a0ddc2004-12-16 18:20:14 +0000163
Matthias Fuchs814f5372008-04-21 14:42:11 +0200164 return 0;
165}
stroese27a0ddc2004-12-16 18:20:14 +0000166
Matthias Fuchs814f5372008-04-21 14:42:11 +0200167int board_early_init_r(void)
stroese27a0ddc2004-12-16 18:20:14 +0000168{
Matthias Fuchs814f5372008-04-21 14:42:11 +0200169 if (gd->board_type >= 8)
Stefan Roesefb9a7302010-08-31 10:00:10 +0200170 cfi_flash_num_flash_banks = 1;
Matthias Fuchs814f5372008-04-21 14:42:11 +0200171
172 return 0;
stroese27a0ddc2004-12-16 18:20:14 +0000173}
174
Matthias Fuchs814f5372008-04-21 14:42:11 +0200175#define FUJI_BASE 0xf0100200
176#define LCDBL_PWM 0xa0
177#define LCDBL_PWMMIN 0xa4
178#define LCDBL_PWMMAX 0xa8
stroese27a0ddc2004-12-16 18:20:14 +0000179
Matthias Fuchs814f5372008-04-21 14:42:11 +0200180int misc_init_r(void)
stroese27a0ddc2004-12-16 18:20:14 +0000181{
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200182 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 Fuchs814f5372008-04-21 14:42:11 +0200184 u8 *duart0_mcr = (u8 *)(DUART0_BA + 4);
185 u8 *duart1_mcr = (u8 *)(DUART1_BA + 4);
stroese27a0ddc2004-12-16 18:20:14 +0000186 unsigned char *dst;
187 ulong len = sizeof(fpgadata);
188 int status;
189 int index;
190 int i;
Stefan Roese918010a2009-09-09 16:25:29 +0200191 unsigned long CPC0_CR0Reg;
Matthias Fuchs814f5372008-04-21 14:42:11 +0200192 char *str;
193 uchar *logo_addr;
194 ulong logo_size;
195 ushort minb, maxb;
196 int result;
stroese27a0ddc2004-12-16 18:20:14 +0000197
198 /*
199 * Setup GPIO pins (CS6+CS7 as GPIO)
200 */
Stefan Roese918010a2009-09-09 16:25:29 +0200201 CPC0_CR0Reg = mfdcr(CPC0_CR0);
202 mtdcr(CPC0_CR0, CPC0_CR0Reg | 0x00300000);
stroese27a0ddc2004-12-16 18:20:14 +0000203
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200204 dst = malloc(CONFIG_SYS_FPGA_MAX_SIZE);
205 if (gunzip(dst, CONFIG_SYS_FPGA_MAX_SIZE, (uchar *)fpgadata, &len) != 0) {
Matthias Fuchs814f5372008-04-21 14:42:11 +0200206 printf("GUNZIP ERROR - must RESET board to recover\n");
207 do_reset(NULL, 0, 0, NULL);
stroese27a0ddc2004-12-16 18:20:14 +0000208 }
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 Fuchs814f5372008-04-21 14:42:11 +0200215 printf("(Timeout: "
216 "INIT not low after asserting PROGRAM*)\n ");
stroese27a0ddc2004-12-16 18:20:14 +0000217 break;
218 case ERROR_FPGA_PRG_INIT_HIGH:
Matthias Fuchs814f5372008-04-21 14:42:11 +0200219 printf("(Timeout: "
220 "INIT not high after deasserting PROGRAM*)\n ");
stroese27a0ddc2004-12-16 18:20:14 +0000221 break;
222 case ERROR_FPGA_PRG_DONE:
Matthias Fuchs814f5372008-04-21 14:42:11 +0200223 printf("(Timeout: "
224 "DONE not high after programming FPGA)\n ");
stroese27a0ddc2004-12-16 18:20:14 +0000225 break;
226 }
227
228 /* display infos on fpgaimage */
229 index = 15;
Matthias Fuchs814f5372008-04-21 14:42:11 +0200230 for (i = 0; i < 4; i++) {
stroese27a0ddc2004-12-16 18:20:14 +0000231 len = dst[index];
232 printf("FPGA: %s\n", &(dst[index+1]));
Matthias Fuchs814f5372008-04-21 14:42:11 +0200233 index += len + 3;
stroese27a0ddc2004-12-16 18:20:14 +0000234 }
Matthias Fuchs814f5372008-04-21 14:42:11 +0200235 putc('\n');
stroese27a0ddc2004-12-16 18:20:14 +0000236 /* delayed reboot */
Matthias Fuchs814f5372008-04-21 14:42:11 +0200237 for (i = 20; i > 0; i--) {
stroese27a0ddc2004-12-16 18:20:14 +0000238 printf("Rebooting in %2d seconds \r",i);
Matthias Fuchs814f5372008-04-21 14:42:11 +0200239 for (index = 0; index < 1000; index++)
stroese27a0ddc2004-12-16 18:20:14 +0000240 udelay(1000);
241 }
Matthias Fuchs814f5372008-04-21 14:42:11 +0200242 putc('\n');
stroese27a0ddc2004-12-16 18:20:14 +0000243 do_reset(NULL, 0, 0, NULL);
244 }
245
246 /* restore gpio/cs settings */
Stefan Roese918010a2009-09-09 16:25:29 +0200247 mtdcr(CPC0_CR0, CPC0_CR0Reg);
stroese27a0ddc2004-12-16 18:20:14 +0000248
249 puts("FPGA: ");
250
251 /* display infos on fpgaimage */
252 index = 15;
Matthias Fuchs814f5372008-04-21 14:42:11 +0200253 for (i = 0; i < 4; i++) {
stroese27a0ddc2004-12-16 18:20:14 +0000254 len = dst[index];
Matthias Fuchs814f5372008-04-21 14:42:11 +0200255 printf("%s ", &(dst[index + 1]));
256 index += len + 3;
stroese27a0ddc2004-12-16 18:20:14 +0000257 }
Matthias Fuchs814f5372008-04-21 14:42:11 +0200258 putc('\n');
stroese27a0ddc2004-12-16 18:20:14 +0000259
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 /*
stroese63268872005-04-13 10:06:07 +0000271 * Write board revision in FPGA
272 */
Matthias Fuchs814f5372008-04-21 14:42:11 +0200273 out_be16(fpga_ctrl2,
274 (in_be16(fpga_ctrl2) & 0xfff0) | (gd->board_type & 0x000f));
stroese63268872005-04-13 10:06:07 +0000275
276 /*
stroese27a0ddc2004-12-16 18:20:14 +0000277 * Enable power on PS/2 interface (with reset)
278 */
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200279 out_be16(fpga_mode, in_be16(fpga_mode) | CONFIG_SYS_FPGA_CTRL_PS2_RESET);
stroese27a0ddc2004-12-16 18:20:14 +0000280 for (i=0;i<100;i++)
281 udelay(1000);
282 udelay(1000);
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200283 out_be16(fpga_mode, in_be16(fpga_mode) & ~CONFIG_SYS_FPGA_CTRL_PS2_RESET);
stroese27a0ddc2004-12-16 18:20:14 +0000284
285 /*
286 * Enable interrupts in exar duart mcr[3]
287 */
Matthias Fuchs814f5372008-04-21 14:42:11 +0200288 out_8(duart0_mcr, 0x08);
289 out_8(duart1_mcr, 0x08);
stroese27a0ddc2004-12-16 18:20:14 +0000290
291 /*
292 * Init lcd interface and display logo
293 */
Matthias Fuchs814f5372008-04-21 14:42:11 +0200294 str = getenv("splashimage");
295 if (str) {
296 logo_addr = (uchar *)simple_strtoul(str, NULL, 16);
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200297 logo_size = CONFIG_SYS_VIDEO_LOGO_MAX_SIZE;
Matthias Fuchs814f5372008-04-21 14:42:11 +0200298 } else {
299 logo_addr = logo_bmp;
300 logo_size = sizeof(logo_bmp);
301 }
302
303 if (gd->board_type >= 6) {
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200304 result = lcd_init((uchar *)CONFIG_SYS_LCD_BIG_REG,
305 (uchar *)CONFIG_SYS_LCD_BIG_MEM,
Matthias Fuchs814f5372008-04-21 14:42:11 +0200306 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-VILLARD03836942008-10-16 15:01:15 +0200314 lcd_init((uchar *)CONFIG_SYS_LCD_BIG_REG,
315 (uchar *)CONFIG_SYS_LCD_BIG_MEM,
Matthias Fuchs814f5372008-04-21 14:42:11 +0200316 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-VILLARD03836942008-10-16 15:01:15 +0200322 result = lcd_init((uchar *)CONFIG_SYS_LCD_BIG_REG,
323 (uchar *)CONFIG_SYS_LCD_BIG_MEM,
Matthias Fuchs814f5372008-04-21 14:42:11 +0200324 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-VILLARD03836942008-10-16 15:01:15 +0200332 lcd_init((uchar *)CONFIG_SYS_LCD_BIG_REG,
333 (uchar *)CONFIG_SYS_LCD_BIG_MEM,
Matthias Fuchs814f5372008-04-21 14:42:11 +0200334 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 }
stroese27a0ddc2004-12-16 18:20:14 +0000340
341 /*
stroese63268872005-04-13 10:06:07 +0000342 * Reset microcontroller and setup backlight PWM controller
stroese27a0ddc2004-12-16 18:20:14 +0000343 */
Matthias Fuchs814f5372008-04-21 14:42:11 +0200344 out_be16(fpga_mode, in_be16(fpga_mode) | 0x0014);
stroese63268872005-04-13 10:06:07 +0000345 for (i=0;i<10;i++)
346 udelay(1000);
Matthias Fuchs814f5372008-04-21 14:42:11 +0200347 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 Fuchs68cea642008-04-25 12:01:39 +0200367 /*
368 * fix environment for field updated units
369 */
370 if (getenv("altbootcmd") == NULL) {
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200371 setenv("usb_load", CONFIG_SYS_USB_LOAD_COMMAND);
372 setenv("usbargs", CONFIG_SYS_USB_ARGS);
Matthias Fuchs814f5372008-04-21 14:42:11 +0200373 setenv("bootcmd", CONFIG_BOOTCOMMAND);
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200374 setenv("usb_self", CONFIG_SYS_USB_SELF_COMMAND);
375 setenv("bootlimit", CONFIG_SYS_BOOTLIMIT);
376 setenv("altbootcmd", CONFIG_SYS_ALT_BOOTCOMMAND);
Matthias Fuchs814f5372008-04-21 14:42:11 +0200377 saveenv();
378 }
stroese27a0ddc2004-12-16 18:20:14 +0000379
380 return (0);
381}
382
stroese27a0ddc2004-12-16 18:20:14 +0000383/*
384 * Check Board Identity:
385 */
stroese27a0ddc2004-12-16 18:20:14 +0000386int checkboard (void)
387{
Matthias Fuchs814f5372008-04-21 14:42:11 +0200388 char str[64];
Wolfgang Denk76af2782010-07-24 21:55:43 +0200389 int i = getenv_f("serial#", str, sizeof(str));
stroese27a0ddc2004-12-16 18:20:14 +0000390
391 puts ("Board: ");
392
393 if (i == -1) {
394 puts ("### No HW ID - assuming APC405");
395 } else {
396 puts(str);
397 }
398
stroese63268872005-04-13 10:06:07 +0000399 gd->board_type = board_revision();
Matthias Fuchs814f5372008-04-21 14:42:11 +0200400 printf(", Rev. 1.%ld\n", gd->board_type);
stroese27a0ddc2004-12-16 18:20:14 +0000401
402 return 0;
403}
404
Matthias Fuchs814f5372008-04-21 14:42:11 +0200405#ifdef CONFIG_IDE_RESET
406void ide_set_reset(int on)
stroese27a0ddc2004-12-16 18:20:14 +0000407{
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200408 u16 *fpga_mode = (u16 *)(CONFIG_SYS_FPGA_BASE_ADDR + CONFIG_SYS_FPGA_CTRL);
stroese27a0ddc2004-12-16 18:20:14 +0000409
Matthias Fuchs814f5372008-04-21 14:42:11 +0200410 /*
411 * Assert or deassert CompactFlash Reset Pin
412 */
413 if (on) {
414 out_be16(fpga_mode,
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200415 in_be16(fpga_mode) & ~CONFIG_SYS_FPGA_CTRL_CF_RESET);
Matthias Fuchs814f5372008-04-21 14:42:11 +0200416 } else {
417 out_be16(fpga_mode,
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200418 in_be16(fpga_mode) | CONFIG_SYS_FPGA_CTRL_CF_RESET);
Matthias Fuchs814f5372008-04-21 14:42:11 +0200419 }
stroese27a0ddc2004-12-16 18:20:14 +0000420}
Matthias Fuchs814f5372008-04-21 14:42:11 +0200421#endif /* CONFIG_IDE_RESET */
stroese27a0ddc2004-12-16 18:20:14 +0000422
Matthias Fuchs814f5372008-04-21 14:42:11 +0200423void reset_phy(void)
424{
425 /*
426 * Disable sleep mode in LXT971
427 */
428 lxt971_no_sleep();
429}
stroese27a0ddc2004-12-16 18:20:14 +0000430
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200431#if defined(CONFIG_USB_OHCI_NEW) && defined(CONFIG_SYS_USB_OHCI_BOARD_INIT)
Troy Kiskyde8ae7b2013-10-10 15:27:55 -0700432int board_usb_init(int index, enum usb_init_type init)
Matthias Fuchs814f5372008-04-21 14:42:11 +0200433{
434 return 0;
435}
stroese27a0ddc2004-12-16 18:20:14 +0000436
Matthias Fuchs814f5372008-04-21 14:42:11 +0200437int usb_board_stop(void)
stroese27a0ddc2004-12-16 18:20:14 +0000438{
Matthias Fuchs814f5372008-04-21 14:42:11 +0200439 unsigned short tmp;
440 int i;
stroese27a0ddc2004-12-16 18:20:14 +0000441
442 /*
Matthias Fuchs814f5372008-04-21 14:42:11 +0200443 * 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.
stroese27a0ddc2004-12-16 18:20:14 +0000446 */
Matthias Fuchs814f5372008-04-21 14:42:11 +0200447 pci_read_config_word(PCIDEVID_405GP, PCIBRDGOPT2, &tmp);
448 pci_write_config_word(PCIDEVID_405GP, PCIBRDGOPT2, (tmp | 0x1000));
stroese27a0ddc2004-12-16 18:20:14 +0000449
Matthias Fuchs814f5372008-04-21 14:42:11 +0200450 for (i = 0; i < 100; i++)
451 udelay(1000);
452
453 pci_write_config_word(PCIDEVID_405GP, PCIBRDGOPT2, tmp);
454 return 0;
455}
stroese27a0ddc2004-12-16 18:20:14 +0000456
Troy Kiskyde8ae7b2013-10-10 15:27:55 -0700457int board_usb_cleanup(int index, enum usb_init_type init)
Matthias Fuchs814f5372008-04-21 14:42:11 +0200458{
Mateusz Zalegad862f892013-10-04 19:22:26 +0200459 return usb_board_stop();
Matthias Fuchs814f5372008-04-21 14:42:11 +0200460}
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200461#endif /* defined(CONFIG_USB_OHCI) && defined(CONFIG_SYS_USB_OHCI_BOARD_INIT) */