2002-11-03 00:24:07 +00:00
|
|
|
/*
|
2003-03-20 15:31:19 +00:00
|
|
|
* (C) Copyright 2001-2003
|
2002-11-03 00:24:07 +00:00
|
|
|
* Stefan Roese, esd gmbh germany, stefan.roese@esd-electronics.com
|
|
|
|
*
|
2013-07-08 07:37:19 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0+
|
2002-11-03 00:24:07 +00:00
|
|
|
*/
|
|
|
|
#include <common.h>
|
2015-11-09 06:47:45 +00:00
|
|
|
#include <console.h>
|
2009-01-02 11:18:12 +00:00
|
|
|
#include <libfdt.h>
|
|
|
|
#include <fdt_support.h>
|
2002-11-03 00:24:07 +00:00
|
|
|
#include <asm/processor.h>
|
2007-06-24 15:41:21 +00:00
|
|
|
#include <asm/io.h>
|
2002-11-03 00:24:07 +00:00
|
|
|
#include <command.h>
|
|
|
|
#include <malloc.h>
|
2004-12-16 18:27:05 +00:00
|
|
|
#include <net.h>
|
2007-06-24 15:41:21 +00:00
|
|
|
#include <pci.h>
|
2002-11-03 00:24:07 +00:00
|
|
|
|
2006-03-31 16:32:53 +00:00
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
2009-01-02 11:17:36 +00:00
|
|
|
extern void __ft_board_setup(void *blob, bd_t *bd);
|
|
|
|
|
|
|
|
#undef FPGA_DEBUG
|
2002-11-03 00:24:07 +00:00
|
|
|
|
|
|
|
/* fpga configuration data - generated by bin2cc */
|
|
|
|
const unsigned char fpgadata[] =
|
|
|
|
{
|
2009-01-02 11:17:36 +00:00
|
|
|
#if defined(CONFIG_CPCI405_VER2)
|
2015-01-12 21:47:31 +00:00
|
|
|
# include "fpgadata_cpci4052.c"
|
2002-11-03 00:24:07 +00:00
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* include common fpga code (for esd boards)
|
|
|
|
*/
|
|
|
|
#include "../common/fpga.c"
|
2004-12-16 18:27:05 +00:00
|
|
|
|
2002-11-03 00:24:07 +00:00
|
|
|
/* Prototypes */
|
2003-03-20 15:31:19 +00:00
|
|
|
int cpci405_version(void);
|
2004-12-16 18:27:05 +00:00
|
|
|
void lxt971_no_sleep(void);
|
2002-11-03 00:24:07 +00:00
|
|
|
|
2009-01-02 11:17:36 +00:00
|
|
|
int board_early_init_f(void)
|
2002-11-03 00:24:07 +00:00
|
|
|
{
|
|
|
|
#ifndef CONFIG_CPCI405_VER2
|
|
|
|
int index, len, i;
|
|
|
|
int status;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef FPGA_DEBUG
|
|
|
|
/* set up serial port with default baudrate */
|
2009-01-02 11:17:36 +00:00
|
|
|
(void)get_clocks();
|
2002-11-03 00:24:07 +00:00
|
|
|
gd->baudrate = CONFIG_BAUDRATE;
|
2009-01-02 11:17:36 +00:00
|
|
|
serial_init();
|
2002-11-03 00:24:07 +00:00
|
|
|
console_init_f();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
2009-01-02 11:17:36 +00:00
|
|
|
* First pull fpga-prg pin low,
|
|
|
|
* to disable fpga logic (on version 2 board)
|
2002-11-03 00:24:07 +00:00
|
|
|
*/
|
2009-02-20 09:19:18 +00:00
|
|
|
out_be32((void *)GPIO0_ODR, 0x00000000); /* no open drain pins */
|
|
|
|
out_be32((void *)GPIO0_TCR, CONFIG_SYS_FPGA_PRG); /* setup for output */
|
|
|
|
out_be32((void *)GPIO0_OR, CONFIG_SYS_FPGA_PRG); /* set output pins to high */
|
|
|
|
out_be32((void *)GPIO0_OR, 0); /* pull prg low */
|
2002-11-03 00:24:07 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Boot onboard FPGA
|
|
|
|
*/
|
|
|
|
#ifndef CONFIG_CPCI405_VER2
|
2003-03-20 15:31:19 +00:00
|
|
|
if (cpci405_version() == 1) {
|
2002-11-03 00:24:07 +00:00
|
|
|
status = fpga_boot((unsigned char *)fpgadata, sizeof(fpgadata));
|
|
|
|
if (status != 0) {
|
|
|
|
/* booting FPGA failed */
|
|
|
|
#ifndef FPGA_DEBUG
|
|
|
|
/* set up serial port with default baudrate */
|
2009-01-02 11:17:36 +00:00
|
|
|
(void)get_clocks();
|
2002-11-03 00:24:07 +00:00
|
|
|
gd->baudrate = CONFIG_BAUDRATE;
|
2009-01-02 11:17:36 +00:00
|
|
|
serial_init();
|
2002-11-03 00:24:07 +00:00
|
|
|
console_init_f();
|
|
|
|
#endif
|
|
|
|
printf("\nFPGA: Booting failed ");
|
|
|
|
switch (status) {
|
|
|
|
case ERROR_FPGA_PRG_INIT_LOW:
|
2009-01-02 11:17:36 +00:00
|
|
|
printf("(Timeout: INIT not low after "
|
|
|
|
"asserting PROGRAM*)\n ");
|
2002-11-03 00:24:07 +00:00
|
|
|
break;
|
|
|
|
case ERROR_FPGA_PRG_INIT_HIGH:
|
2009-01-02 11:17:36 +00:00
|
|
|
printf("(Timeout: INIT not high after "
|
|
|
|
"deasserting PROGRAM*)\n ");
|
2002-11-03 00:24:07 +00:00
|
|
|
break;
|
|
|
|
case ERROR_FPGA_PRG_DONE:
|
2009-01-02 11:17:36 +00:00
|
|
|
printf("(Timeout: DONE not high after "
|
|
|
|
"programming FPGA)\n ");
|
2002-11-03 00:24:07 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* display infos on fpgaimage */
|
|
|
|
index = 15;
|
2009-01-02 11:17:36 +00:00
|
|
|
for (i = 0; i < 4; i++) {
|
2002-11-03 00:24:07 +00:00
|
|
|
len = fpgadata[index];
|
2009-01-02 11:17:36 +00:00
|
|
|
printf("FPGA: %s\n", &(fpgadata[index + 1]));
|
|
|
|
index += len + 3;
|
2002-11-03 00:24:07 +00:00
|
|
|
}
|
2009-01-02 11:17:36 +00:00
|
|
|
putc('\n');
|
2002-11-03 00:24:07 +00:00
|
|
|
/* delayed reboot */
|
2009-01-02 11:17:36 +00:00
|
|
|
for (i = 20; i > 0; i--) {
|
2002-11-03 00:24:07 +00:00
|
|
|
printf("Rebooting in %2d seconds \r",i);
|
2009-01-02 11:17:36 +00:00
|
|
|
for (index = 0; index < 1000; index++)
|
2002-11-03 00:24:07 +00:00
|
|
|
udelay(1000);
|
|
|
|
}
|
2009-01-02 11:17:36 +00:00
|
|
|
putc('\n');
|
2002-11-03 00:24:07 +00:00
|
|
|
do_reset(NULL, 0, 0, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif /* !CONFIG_CPCI405_VER2 */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* IRQ 0-15 405GP internally generated; active high; level sensitive
|
|
|
|
* IRQ 16 405GP internally generated; active low; level sensitive
|
|
|
|
* IRQ 17-24 RESERVED
|
|
|
|
* IRQ 25 (EXT IRQ 0) CAN0; active low; level sensitive
|
2009-01-02 11:17:36 +00:00
|
|
|
* IRQ 26 (EXT IRQ 1) CAN1 (+FPGA on CPCI4052); active low; level sens.
|
2002-11-03 00:24:07 +00:00
|
|
|
* IRQ 27 (EXT IRQ 2) PCI SLOT 0; active low; level sensitive
|
|
|
|
* IRQ 28 (EXT IRQ 3) PCI SLOT 1; active low; level sensitive
|
|
|
|
* IRQ 29 (EXT IRQ 4) PCI SLOT 2; active low; level sensitive
|
|
|
|
* IRQ 30 (EXT IRQ 5) PCI SLOT 3; active low; level sensitive
|
|
|
|
* IRQ 31 (EXT IRQ 6) COMPACT FLASH; active high; level sensitive
|
|
|
|
*/
|
2009-09-24 07:55:50 +00:00
|
|
|
mtdcr(UIC0SR, 0xFFFFFFFF); /* clear all ints */
|
|
|
|
mtdcr(UIC0ER, 0x00000000); /* disable all ints */
|
|
|
|
mtdcr(UIC0CR, 0x00000000); /* set all to be non-critical*/
|
2009-01-02 11:17:36 +00:00
|
|
|
#if defined(CONFIG_CPCI405_6U)
|
2003-03-20 15:31:19 +00:00
|
|
|
if (cpci405_version() == 3) {
|
2009-09-24 07:55:50 +00:00
|
|
|
mtdcr(UIC0PR, 0xFFFFFF99); /* set int polarities */
|
2003-03-20 15:31:19 +00:00
|
|
|
} else {
|
2009-09-24 07:55:50 +00:00
|
|
|
mtdcr(UIC0PR, 0xFFFFFF81); /* set int polarities */
|
2003-03-20 15:31:19 +00:00
|
|
|
}
|
2007-06-24 15:41:21 +00:00
|
|
|
#else
|
2009-09-24 07:55:50 +00:00
|
|
|
mtdcr(UIC0PR, 0xFFFFFF81); /* set int polarities */
|
2007-06-24 15:41:21 +00:00
|
|
|
#endif
|
2009-09-24 07:55:50 +00:00
|
|
|
mtdcr(UIC0TR, 0x10000000); /* set int trigger levels */
|
|
|
|
mtdcr(UIC0VCR, 0x00000001); /* set vect base=0,
|
2009-01-02 11:17:36 +00:00
|
|
|
* INT0 highest priority */
|
2009-09-24 07:55:50 +00:00
|
|
|
mtdcr(UIC0SR, 0xFFFFFFFF); /* clear all ints */
|
2002-11-03 00:24:07 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ctermm2(void)
|
|
|
|
{
|
2009-01-02 11:17:36 +00:00
|
|
|
#if defined(CONFIG_CPCI405_VER2)
|
2007-07-09 22:01:28 +00:00
|
|
|
return 0; /* no, board is cpci405 */
|
2002-11-03 00:24:07 +00:00
|
|
|
#else
|
2009-01-02 11:17:36 +00:00
|
|
|
if ((in_8((void*)0xf0000400) == 0x00) &&
|
|
|
|
(in_8((void*)0xf0000401) == 0x01))
|
2007-07-09 22:01:28 +00:00
|
|
|
return 0; /* no, board is cpci405 */
|
2002-11-03 00:24:07 +00:00
|
|
|
else
|
2007-07-09 22:01:28 +00:00
|
|
|
return -1; /* yes, board is cterm-m2 */
|
2002-11-03 00:24:07 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
int cpci405_host(void)
|
|
|
|
{
|
2009-09-09 14:25:29 +00:00
|
|
|
if (mfdcr(CPC0_PSR) & PSR_PCI_ARBIT_EN)
|
2007-07-09 22:01:28 +00:00
|
|
|
return -1; /* yes, board is cpci405 host */
|
2002-11-03 00:24:07 +00:00
|
|
|
else
|
2007-07-09 22:01:28 +00:00
|
|
|
return 0; /* no, board is cpci405 adapter */
|
2002-11-03 00:24:07 +00:00
|
|
|
}
|
|
|
|
|
2003-03-20 15:31:19 +00:00
|
|
|
int cpci405_version(void)
|
2002-11-03 00:24:07 +00:00
|
|
|
{
|
2009-09-09 14:25:29 +00:00
|
|
|
unsigned long CPC0_CR0Reg;
|
2002-11-03 00:24:07 +00:00
|
|
|
unsigned long value;
|
|
|
|
|
|
|
|
/*
|
2003-03-20 15:31:19 +00:00
|
|
|
* Setup GPIO pins (CS2/GPIO11 and CS3/GPIO12 as GPIO)
|
2002-11-03 00:24:07 +00:00
|
|
|
*/
|
2009-09-09 14:25:29 +00:00
|
|
|
CPC0_CR0Reg = mfdcr(CPC0_CR0);
|
|
|
|
mtdcr(CPC0_CR0, CPC0_CR0Reg | 0x03000000);
|
2007-06-24 15:41:21 +00:00
|
|
|
out_be32((void*)GPIO0_ODR, in_be32((void*)GPIO0_ODR) & ~0x00180000);
|
|
|
|
out_be32((void*)GPIO0_TCR, in_be32((void*)GPIO0_TCR) & ~0x00180000);
|
2009-01-02 11:17:36 +00:00
|
|
|
udelay(1000); /* wait some time before reading input */
|
|
|
|
value = in_be32((void*)GPIO0_IR) & 0x00180000; /* get config bits */
|
2002-11-03 00:24:07 +00:00
|
|
|
|
|
|
|
/*
|
2003-03-20 15:31:19 +00:00
|
|
|
* Restore GPIO settings
|
2002-11-03 00:24:07 +00:00
|
|
|
*/
|
2009-09-09 14:25:29 +00:00
|
|
|
mtdcr(CPC0_CR0, CPC0_CR0Reg);
|
2002-11-03 00:24:07 +00:00
|
|
|
|
2003-03-20 15:31:19 +00:00
|
|
|
switch (value) {
|
|
|
|
case 0x00180000:
|
|
|
|
/* CS2==1 && CS3==1 -> version 1 */
|
|
|
|
return 1;
|
|
|
|
case 0x00080000:
|
|
|
|
/* CS2==0 && CS3==1 -> version 2 */
|
|
|
|
return 2;
|
|
|
|
case 0x00100000:
|
2007-06-24 15:41:21 +00:00
|
|
|
/* CS2==1 && CS3==0 -> version 3 or 6U board */
|
2003-03-20 15:31:19 +00:00
|
|
|
return 3;
|
|
|
|
case 0x00000000:
|
|
|
|
/* CS2==0 && CS3==0 -> version 4 */
|
|
|
|
return 4;
|
|
|
|
default:
|
|
|
|
/* should not be reached! */
|
|
|
|
return 2;
|
|
|
|
}
|
2002-11-03 00:24:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int misc_init_r (void)
|
|
|
|
{
|
2009-09-09 14:25:29 +00:00
|
|
|
unsigned long CPC0_CR0Reg;
|
2002-11-03 00:24:07 +00:00
|
|
|
|
2004-12-16 18:27:05 +00:00
|
|
|
/* adjust flash start and offset */
|
|
|
|
gd->bd->bi_flashstart = 0 - gd->bd->bi_flashsize;
|
|
|
|
gd->bd->bi_flashoffset = 0;
|
|
|
|
|
2009-01-02 11:17:36 +00:00
|
|
|
#if defined(CONFIG_CPCI405_VER2)
|
2004-12-16 18:27:05 +00:00
|
|
|
{
|
2002-11-03 00:24:07 +00:00
|
|
|
unsigned char *dst;
|
|
|
|
ulong len = sizeof(fpgadata);
|
|
|
|
int status;
|
|
|
|
int index;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* On CPCI-405 version 2 the environment is saved in eeprom!
|
|
|
|
* FPGA can be gzip compressed (malloc) and booted this late.
|
|
|
|
*/
|
2003-03-20 15:31:19 +00:00
|
|
|
if (cpci405_version() >= 2) {
|
2002-11-03 00:24:07 +00:00
|
|
|
/*
|
|
|
|
* Setup GPIO pins (CS6+CS7 as GPIO)
|
|
|
|
*/
|
2009-09-09 14:25:29 +00:00
|
|
|
CPC0_CR0Reg = mfdcr(CPC0_CR0);
|
|
|
|
mtdcr(CPC0_CR0, CPC0_CR0Reg | 0x00300000);
|
2002-11-03 00:24:07 +00:00
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
dst = malloc(CONFIG_SYS_FPGA_MAX_SIZE);
|
2009-01-02 11:17:36 +00:00
|
|
|
if (gunzip(dst, CONFIG_SYS_FPGA_MAX_SIZE,
|
|
|
|
(uchar *)fpgadata, &len) != 0) {
|
|
|
|
printf("GUNZIP ERROR - must RESET board to recover\n");
|
|
|
|
do_reset(NULL, 0, 0, NULL);
|
2002-11-03 00:24:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
status = fpga_boot(dst, len);
|
|
|
|
if (status != 0) {
|
|
|
|
printf("\nFPGA: Booting failed ");
|
|
|
|
switch (status) {
|
|
|
|
case ERROR_FPGA_PRG_INIT_LOW:
|
2009-01-02 11:17:36 +00:00
|
|
|
printf("(Timeout: INIT not low after "
|
|
|
|
"asserting PROGRAM*)\n ");
|
2002-11-03 00:24:07 +00:00
|
|
|
break;
|
|
|
|
case ERROR_FPGA_PRG_INIT_HIGH:
|
2009-01-02 11:17:36 +00:00
|
|
|
printf("(Timeout: INIT not high after "
|
|
|
|
"deasserting PROGRAM*)\n ");
|
2002-11-03 00:24:07 +00:00
|
|
|
break;
|
|
|
|
case ERROR_FPGA_PRG_DONE:
|
2009-01-02 11:17:36 +00:00
|
|
|
printf("(Timeout: DONE not high after "
|
|
|
|
"programming FPGA)\n ");
|
2002-11-03 00:24:07 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* display infos on fpgaimage */
|
|
|
|
index = 15;
|
2009-01-02 11:17:36 +00:00
|
|
|
for (i = 0; i < 4; i++) {
|
2002-11-03 00:24:07 +00:00
|
|
|
len = dst[index];
|
2009-01-02 11:17:36 +00:00
|
|
|
printf("FPGA: %s\n", &(dst[index + 1]));
|
|
|
|
index += len + 3;
|
2002-11-03 00:24:07 +00:00
|
|
|
}
|
2009-01-02 11:17:36 +00:00
|
|
|
putc('\n');
|
2002-11-03 00:24:07 +00:00
|
|
|
/* delayed reboot */
|
2009-01-02 11:17:36 +00:00
|
|
|
for (i = 20; i > 0; i--) {
|
|
|
|
printf("Rebooting in %2d seconds \r", i);
|
|
|
|
for (index = 0; index < 1000; index++)
|
2002-11-03 00:24:07 +00:00
|
|
|
udelay(1000);
|
|
|
|
}
|
2009-01-02 11:17:36 +00:00
|
|
|
putc('\n');
|
2002-11-03 00:24:07 +00:00
|
|
|
do_reset(NULL, 0, 0, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* restore gpio/cs settings */
|
2009-09-09 14:25:29 +00:00
|
|
|
mtdcr(CPC0_CR0, CPC0_CR0Reg);
|
2002-11-03 00:24:07 +00:00
|
|
|
|
|
|
|
puts("FPGA: ");
|
|
|
|
|
|
|
|
/* display infos on fpgaimage */
|
|
|
|
index = 15;
|
2009-01-02 11:17:36 +00:00
|
|
|
for (i = 0; i < 4; i++) {
|
2002-11-03 00:24:07 +00:00
|
|
|
len = dst[index];
|
2009-01-02 11:17:36 +00:00
|
|
|
printf("%s ", &(dst[index + 1]));
|
|
|
|
index += len + 3;
|
2002-11-03 00:24:07 +00:00
|
|
|
}
|
2009-01-02 11:17:36 +00:00
|
|
|
putc('\n');
|
2002-11-03 00:24:07 +00:00
|
|
|
|
|
|
|
free(dst);
|
2003-03-20 15:31:19 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Reset FPGA via FPGA_DATA pin
|
|
|
|
*/
|
|
|
|
SET_FPGA(FPGA_PRG | FPGA_CLK);
|
|
|
|
udelay(1000); /* wait 1ms */
|
|
|
|
SET_FPGA(FPGA_PRG | FPGA_CLK | FPGA_DATA);
|
|
|
|
udelay(1000); /* wait 1ms */
|
|
|
|
|
2009-01-02 11:17:36 +00:00
|
|
|
#if defined(CONFIG_CPCI405_6U)
|
|
|
|
#error HIER GETH ES WEITER MIT IO ACCESSORS
|
2003-03-20 15:31:19 +00:00
|
|
|
if (cpci405_version() == 3) {
|
|
|
|
/*
|
|
|
|
* Enable outputs in fpga on version 3 board
|
|
|
|
*/
|
2009-01-02 11:17:36 +00:00
|
|
|
out_be16((void*)CONFIG_SYS_FPGA_BASE_ADDR,
|
|
|
|
in_be16((void*)CONFIG_SYS_FPGA_BASE_ADDR) |
|
|
|
|
CONFIG_SYS_FPGA_MODE_ENABLE_OUTPUT);
|
2003-03-20 15:31:19 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Set outputs to 0
|
|
|
|
*/
|
2009-01-02 11:17:36 +00:00
|
|
|
out_8((void*)CONFIG_SYS_LED_ADDR, 0x00);
|
2003-03-20 15:31:19 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Reset external DUART
|
|
|
|
*/
|
2009-01-02 11:17:36 +00:00
|
|
|
out_be16((void*)CONFIG_SYS_FPGA_BASE_ADDR,
|
|
|
|
in_be16((void*)CONFIG_SYS_FPGA_BASE_ADDR) |
|
|
|
|
CONFIG_SYS_FPGA_MODE_DUART_RESET);
|
2003-03-20 15:31:19 +00:00
|
|
|
udelay(100);
|
2009-01-02 11:17:36 +00:00
|
|
|
out_be16((void*)CONFIG_SYS_FPGA_BASE_ADDR,
|
|
|
|
in_be16((void*)CONFIG_SYS_FPGA_BASE_ADDR) &
|
|
|
|
~CONFIG_SYS_FPGA_MODE_DUART_RESET);
|
2003-03-20 15:31:19 +00:00
|
|
|
}
|
2007-06-24 15:41:21 +00:00
|
|
|
#endif
|
2002-11-03 00:24:07 +00:00
|
|
|
}
|
|
|
|
else {
|
2003-03-20 15:31:19 +00:00
|
|
|
puts("\n*** U-Boot Version does not match Board Version!\n");
|
|
|
|
puts("*** CPCI-405 Version 1.x detected!\n");
|
2009-01-02 11:17:36 +00:00
|
|
|
puts("*** Please use correct U-Boot version "
|
|
|
|
"(CPCI405 instead of CPCI4052)!\n\n");
|
2002-11-03 00:24:07 +00:00
|
|
|
}
|
2004-12-16 18:27:05 +00:00
|
|
|
}
|
2002-11-03 00:24:07 +00:00
|
|
|
#else /* CONFIG_CPCI405_VER2 */
|
2003-03-20 15:31:19 +00:00
|
|
|
if (cpci405_version() >= 2) {
|
|
|
|
puts("\n*** U-Boot Version does not match Board Version!\n");
|
|
|
|
puts("*** CPCI-405 Board Version 2.x detected!\n");
|
2009-01-02 11:17:36 +00:00
|
|
|
puts("*** Please use correct U-Boot version "
|
|
|
|
"(CPCI4052 instead of CPCI405)!\n\n");
|
2002-11-03 00:24:07 +00:00
|
|
|
}
|
|
|
|
#endif /* CONFIG_CPCI405_VER2 */
|
|
|
|
|
2003-04-04 16:52:57 +00:00
|
|
|
/*
|
|
|
|
* Select cts (and not dsr) on uart1
|
|
|
|
*/
|
2009-09-09 14:25:29 +00:00
|
|
|
CPC0_CR0Reg = mfdcr(CPC0_CR0);
|
|
|
|
mtdcr(CPC0_CR0, CPC0_CR0Reg | 0x00001000);
|
2003-04-04 16:52:57 +00:00
|
|
|
|
2009-01-02 11:17:36 +00:00
|
|
|
return 0;
|
2002-11-03 00:24:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check Board Identity:
|
|
|
|
*/
|
|
|
|
|
2009-01-02 11:17:36 +00:00
|
|
|
int checkboard(void)
|
2002-11-03 00:24:07 +00:00
|
|
|
{
|
|
|
|
#ifndef CONFIG_CPCI405_VER2
|
|
|
|
int index;
|
|
|
|
int len;
|
|
|
|
#endif
|
2005-10-13 14:45:02 +00:00
|
|
|
char str[64];
|
Rename getenv_r() into getenv_f()
While running from flash, i. e. before relocation, we have only a
limited C runtime environment without writable data segment. In this
phase, some configurations (for example with environment in EEPROM)
must not use the normal getenv(), but a special function. This
function had been called getenv_r(), with the idea that the "_r"
suffix would mean the same as in the _r_eentrant versions of some of
the C library functions (for example getdate vs. getdate_r, getgrent
vs. getgrent_r, etc.).
Unfortunately this was a misleading name, as in U-Boot the "_r"
generally means "running from RAM", i. e. _after_ relocation.
To avoid confusion, rename into getenv_f() [as "running from flash"]
Signed-off-by: Wolfgang Denk <wd@denx.de>
Acked-by: Detlev Zundel <dzu@denx.de>
2010-07-24 19:55:43 +00:00
|
|
|
int i = getenv_f("serial#", str, sizeof(str));
|
2003-03-20 15:31:19 +00:00
|
|
|
unsigned short ver;
|
2002-11-03 00:24:07 +00:00
|
|
|
|
2009-01-02 11:17:36 +00:00
|
|
|
puts("Board: ");
|
2002-11-03 00:24:07 +00:00
|
|
|
|
2009-01-02 11:17:36 +00:00
|
|
|
if (i == -1)
|
|
|
|
puts("### No HW ID - assuming CPCI405");
|
|
|
|
else
|
2002-11-03 00:24:07 +00:00
|
|
|
puts(str);
|
|
|
|
|
2003-03-20 15:31:19 +00:00
|
|
|
ver = cpci405_version();
|
|
|
|
printf(" (Ver %d.x, ", ver);
|
2002-11-03 00:24:07 +00:00
|
|
|
|
|
|
|
if (ctermm2()) {
|
2005-10-13 14:45:02 +00:00
|
|
|
char str[4];
|
2003-09-12 08:44:46 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Read board-id and save in env-variable
|
|
|
|
*/
|
|
|
|
sprintf(str, "%d", *(unsigned char *)0xf0000400);
|
|
|
|
setenv("boardid", str);
|
|
|
|
printf("CTERM-M2 - Id=%s)", str);
|
2002-11-03 00:24:07 +00:00
|
|
|
} else {
|
2009-01-02 11:17:36 +00:00
|
|
|
if (cpci405_host())
|
|
|
|
puts("PCI Host Version)");
|
|
|
|
else
|
|
|
|
puts("PCI Adapter Version)");
|
2002-11-03 00:24:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef CONFIG_CPCI405_VER2
|
2009-01-02 11:17:36 +00:00
|
|
|
puts("\nFPGA: ");
|
2002-11-03 00:24:07 +00:00
|
|
|
|
|
|
|
/* display infos on fpgaimage */
|
|
|
|
index = 15;
|
2009-01-02 11:17:36 +00:00
|
|
|
for (i = 0; i < 4; i++) {
|
2002-11-03 00:24:07 +00:00
|
|
|
len = fpgadata[index];
|
2009-01-02 11:17:36 +00:00
|
|
|
printf("%s ", &(fpgadata[index + 1]));
|
|
|
|
index += len + 3;
|
2002-11-03 00:24:07 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-01-02 11:17:36 +00:00
|
|
|
putc('\n');
|
2002-11-03 00:24:07 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-06-24 15:41:21 +00:00
|
|
|
void reset_phy(void)
|
2002-11-03 00:24:07 +00:00
|
|
|
{
|
2009-01-02 11:17:36 +00:00
|
|
|
#if defined(CONFIG_LXT971_NO_SLEEP)
|
2002-11-03 00:24:07 +00:00
|
|
|
|
2007-06-24 15:41:21 +00:00
|
|
|
/*
|
|
|
|
* Disable sleep mode in LXT971
|
|
|
|
*/
|
|
|
|
lxt971_no_sleep();
|
|
|
|
#endif
|
2002-11-03 00:24:07 +00:00
|
|
|
}
|
|
|
|
|
2009-01-02 11:17:36 +00:00
|
|
|
#if defined(CONFIG_CPCI405_VER2) && defined (CONFIG_IDE_RESET)
|
2002-11-03 00:24:07 +00:00
|
|
|
void ide_set_reset(int on)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Assert or deassert CompactFlash Reset Pin
|
|
|
|
*/
|
2009-01-02 11:17:36 +00:00
|
|
|
if (on) { /* assert RESET */
|
|
|
|
out_be16((void*)CONFIG_SYS_FPGA_BASE_ADDR,
|
|
|
|
in_be16((void*)CONFIG_SYS_FPGA_BASE_ADDR) &
|
|
|
|
~CONFIG_SYS_FPGA_MODE_CF_RESET);
|
|
|
|
} else { /* release RESET */
|
|
|
|
out_be16((void*)CONFIG_SYS_FPGA_BASE_ADDR,
|
|
|
|
in_be16((void*)CONFIG_SYS_FPGA_BASE_ADDR) |
|
|
|
|
CONFIG_SYS_FPGA_MODE_CF_RESET);
|
2002-11-03 00:24:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-02 11:17:36 +00:00
|
|
|
#endif /* CONFIG_IDE_RESET && CONFIG_CPCI405_VER2 */
|
2002-11-03 00:24:07 +00:00
|
|
|
|
2007-06-25 13:57:39 +00:00
|
|
|
#if defined(CONFIG_PCI)
|
2007-06-24 15:41:21 +00:00
|
|
|
void cpci405_pci_fixup_irq(struct pci_controller *hose, pci_dev_t dev)
|
|
|
|
{
|
|
|
|
unsigned char int_line = 0xff;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Write pci interrupt line register (cpci405 specific)
|
|
|
|
*/
|
|
|
|
switch (PCI_DEV(dev) & 0x03) {
|
|
|
|
case 0:
|
|
|
|
int_line = 27 + 2;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
int_line = 27 + 3;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
int_line = 27 + 0;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
int_line = 27 + 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
pci_hose_write_config_byte(hose, dev, PCI_INTERRUPT_LINE, int_line);
|
|
|
|
}
|
|
|
|
|
|
|
|
int pci_pre_init(struct pci_controller *hose)
|
|
|
|
{
|
|
|
|
hose->fixup_irq = cpci405_pci_fixup_irq;
|
|
|
|
return 1;
|
|
|
|
}
|
2007-06-25 13:57:39 +00:00
|
|
|
#endif /* defined(CONFIG_PCI) */
|
2007-06-24 15:41:21 +00:00
|
|
|
|
2009-01-02 11:18:12 +00:00
|
|
|
#if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
|
2014-10-24 00:58:47 +00:00
|
|
|
int ft_board_setup(void *blob, bd_t *bd)
|
2009-01-02 11:18:12 +00:00
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
__ft_board_setup(blob, bd);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Disable PCI in adapter mode.
|
|
|
|
*/
|
|
|
|
if (!cpci405_host()) {
|
|
|
|
rc = fdt_find_and_setprop(blob, "/plb/pci@ec000000", "status",
|
|
|
|
"disabled", sizeof("disabled"), 1);
|
|
|
|
if (rc) {
|
|
|
|
printf("Unable to update property status in PCI node, "
|
|
|
|
"err=%s\n",
|
|
|
|
fdt_strerror(rc));
|
|
|
|
}
|
|
|
|
}
|
2014-10-24 00:58:47 +00:00
|
|
|
|
|
|
|
return 0;
|
2009-01-02 11:18:12 +00:00
|
|
|
}
|
|
|
|
#endif /* defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP) */
|