2002-08-17 09:36:01 +00:00
|
|
|
/*
|
|
|
|
* (C) Copyright 2001
|
|
|
|
* Stefan Roese, esd gmbh germany, stefan.roese@esd-electronics.com
|
|
|
|
*
|
|
|
|
* See file CREDITS for list of people who contributed to this
|
|
|
|
* project.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2 of
|
|
|
|
* the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
* MA 02111-1307 USA
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <command.h>
|
|
|
|
#include <pci.h>
|
2009-02-20 09:19:18 +00:00
|
|
|
#include <asm/io.h>
|
2002-08-17 09:36:01 +00:00
|
|
|
|
|
|
|
#define OK 0
|
|
|
|
#define ERROR (-1)
|
|
|
|
|
|
|
|
#define TRUE 1
|
|
|
|
#define FALSE 0
|
|
|
|
|
|
|
|
|
|
|
|
extern u_long pci9054_iobase;
|
|
|
|
|
|
|
|
|
|
|
|
/***************************************************************************
|
|
|
|
*
|
|
|
|
* Routines for PLX PCI9054 eeprom access
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2003-06-27 21:31:46 +00:00
|
|
|
static unsigned int PciEepromReadLongVPD (int offs)
|
2002-08-17 09:36:01 +00:00
|
|
|
{
|
2003-06-27 21:31:46 +00:00
|
|
|
unsigned int value;
|
|
|
|
unsigned int ret;
|
|
|
|
int count;
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
pci_write_config_dword (CONFIG_SYS_PCI9054_DEV_FN, 0x4c,
|
2003-06-27 21:31:46 +00:00
|
|
|
(offs << 16) | 0x0003);
|
|
|
|
count = 0;
|
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
udelay (10 * 1000);
|
2008-10-16 13:01:15 +00:00
|
|
|
pci_read_config_dword (CONFIG_SYS_PCI9054_DEV_FN, 0x4c, &ret);
|
2003-06-27 21:31:46 +00:00
|
|
|
if ((ret & 0x80000000) != 0) {
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
count++;
|
|
|
|
if (count > 10) {
|
|
|
|
printf ("\nTimeout: ret=%08x - Please try again!\n", ret);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
pci_read_config_dword (CONFIG_SYS_PCI9054_DEV_FN, 0x50, &value);
|
2003-06-27 21:31:46 +00:00
|
|
|
|
|
|
|
return value;
|
2002-08-17 09:36:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-06-27 21:31:46 +00:00
|
|
|
static int PciEepromWriteLongVPD (int offs, unsigned int value)
|
2002-08-17 09:36:01 +00:00
|
|
|
{
|
2003-06-27 21:31:46 +00:00
|
|
|
unsigned int ret;
|
|
|
|
int count;
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
pci_write_config_dword (CONFIG_SYS_PCI9054_DEV_FN, 0x50, value);
|
|
|
|
pci_write_config_dword (CONFIG_SYS_PCI9054_DEV_FN, 0x4c,
|
2003-06-27 21:31:46 +00:00
|
|
|
(offs << 16) | 0x80000003);
|
|
|
|
count = 0;
|
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
udelay (10 * 1000);
|
2008-10-16 13:01:15 +00:00
|
|
|
pci_read_config_dword (CONFIG_SYS_PCI9054_DEV_FN, 0x4c, &ret);
|
2003-06-27 21:31:46 +00:00
|
|
|
if ((ret & 0x80000000) == 0) {
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
count++;
|
|
|
|
if (count > 10) {
|
|
|
|
printf ("\nTimeout: ret=%08x - Please try again!\n", ret);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
2002-08-17 09:36:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-06-27 21:31:46 +00:00
|
|
|
static void showPci9054 (void)
|
2002-08-17 09:36:01 +00:00
|
|
|
{
|
2003-06-27 21:31:46 +00:00
|
|
|
int val;
|
|
|
|
int l, i;
|
|
|
|
|
|
|
|
/* read 9054-values */
|
|
|
|
for (l = 0; l < 6; l++) {
|
|
|
|
printf ("%02x: ", l * 0x10);
|
|
|
|
for (i = 0; i < 4; i++) {
|
2008-10-16 13:01:15 +00:00
|
|
|
pci_read_config_dword (CONFIG_SYS_PCI9054_DEV_FN,
|
2003-06-27 21:31:46 +00:00
|
|
|
l * 16 + i * 4,
|
2005-10-13 14:45:02 +00:00
|
|
|
(unsigned int *)&val);
|
2003-06-27 21:31:46 +00:00
|
|
|
printf ("%08x ", val);
|
|
|
|
}
|
|
|
|
printf ("\n");
|
|
|
|
}
|
|
|
|
printf ("\n");
|
|
|
|
|
|
|
|
for (l = 0; l < 7; l++) {
|
|
|
|
printf ("%02x: ", l * 0x10);
|
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
printf ("%08x ",
|
|
|
|
PciEepromReadLongVPD ((i + l * 4) * 4));
|
|
|
|
printf ("\n");
|
|
|
|
}
|
|
|
|
printf ("\n");
|
2002-08-17 09:36:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-06-27 21:31:46 +00:00
|
|
|
static void updatePci9054 (void)
|
2002-08-17 09:36:01 +00:00
|
|
|
{
|
2003-06-27 21:31:46 +00:00
|
|
|
/*
|
|
|
|
* Set EEPROM write-protect register to 0
|
|
|
|
*/
|
2009-02-20 09:19:18 +00:00
|
|
|
out_be32 ((void *)(pci9054_iobase + 0x0c),
|
|
|
|
in_be32 ((void *)(pci9054_iobase + 0x0c)) & 0xffff00ff);
|
2002-08-17 09:36:01 +00:00
|
|
|
|
2003-06-27 21:31:46 +00:00
|
|
|
/* Long Serial EEPROM Load Registers... */
|
2011-11-15 08:03:20 +00:00
|
|
|
PciEepromWriteLongVPD (0x00, 0x905410b5);
|
|
|
|
PciEepromWriteLongVPD (0x04, 0x09800001); /* other input controller */
|
|
|
|
PciEepromWriteLongVPD (0x08, 0x28140100);
|
2002-08-17 09:36:01 +00:00
|
|
|
|
2011-11-15 08:03:20 +00:00
|
|
|
PciEepromWriteLongVPD (0x0c, 0x00000000); /* MBOX0... */
|
|
|
|
PciEepromWriteLongVPD (0x10, 0x00000000);
|
2002-08-17 09:36:01 +00:00
|
|
|
|
2003-06-27 21:31:46 +00:00
|
|
|
/* las0: fpga access (0x0000.0000 ... 0x0003.ffff) */
|
2011-11-15 08:03:20 +00:00
|
|
|
PciEepromWriteLongVPD (0x14, 0xfffc0000); /* LAS0RR... */
|
|
|
|
PciEepromWriteLongVPD (0x18, 0x00000001); /* LAS0BA */
|
2002-08-17 09:36:01 +00:00
|
|
|
|
2011-11-15 08:03:20 +00:00
|
|
|
PciEepromWriteLongVPD (0x1c, 0x00200000); /* MARBR... */
|
|
|
|
PciEepromWriteLongVPD (0x20, 0x00300500); /* LMISC/BIGEND */
|
2002-08-17 09:36:01 +00:00
|
|
|
|
2011-11-15 08:03:20 +00:00
|
|
|
PciEepromWriteLongVPD (0x24, 0x00000000); /* EROMRR... */
|
|
|
|
PciEepromWriteLongVPD (0x28, 0x00000000); /* EROMBA */
|
2002-08-17 09:36:01 +00:00
|
|
|
|
2011-11-15 08:03:20 +00:00
|
|
|
PciEepromWriteLongVPD (0x2c, 0x43030000); /* LBRD0... */
|
2002-08-17 09:36:01 +00:00
|
|
|
|
2011-11-15 08:03:20 +00:00
|
|
|
PciEepromWriteLongVPD (0x30, 0x00000000); /* DMRR... */
|
|
|
|
PciEepromWriteLongVPD (0x34, 0x00000000);
|
|
|
|
PciEepromWriteLongVPD (0x38, 0x00000000);
|
2002-08-17 09:36:01 +00:00
|
|
|
|
2011-11-15 08:03:20 +00:00
|
|
|
PciEepromWriteLongVPD (0x3c, 0x00000000); /* DMPBAM... */
|
|
|
|
PciEepromWriteLongVPD (0x40, 0x00000000);
|
2002-08-17 09:36:01 +00:00
|
|
|
|
2003-06-27 21:31:46 +00:00
|
|
|
/* Extra Long Serial EEPROM Load Registers... */
|
2011-11-15 08:03:20 +00:00
|
|
|
PciEepromWriteLongVPD (0x44, 0x010212fe); /* PCISID... */
|
2002-08-17 09:36:01 +00:00
|
|
|
|
2003-06-27 21:31:46 +00:00
|
|
|
/* las1: 505-sram access (0x0004.0000 ... 0x001f.ffff) */
|
|
|
|
/* Offset to LAS1: Group 1: 0x00040000 */
|
|
|
|
/* Group 2: 0x00080000 */
|
|
|
|
/* Group 3: 0x000c0000 */
|
2011-11-15 08:03:20 +00:00
|
|
|
PciEepromWriteLongVPD (0x48, 0xffe00000); /* LAS1RR */
|
|
|
|
PciEepromWriteLongVPD (0x4c, 0x00040001); /* LAS1BA */
|
|
|
|
PciEepromWriteLongVPD (0x50, 0x00000208); /* LBRD1 */ /* so wars bisher */
|
2002-08-17 09:36:01 +00:00
|
|
|
|
2011-11-15 08:03:20 +00:00
|
|
|
PciEepromWriteLongVPD (0x54, 0x00004c06); /* HotSwap... */
|
2002-08-17 09:36:01 +00:00
|
|
|
|
2003-06-27 21:31:46 +00:00
|
|
|
printf ("Finished writing defaults into PLX PCI9054 EEPROM!\n");
|
2002-08-17 09:36:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-06-27 21:31:46 +00:00
|
|
|
static void clearPci9054 (void)
|
2002-08-17 09:36:01 +00:00
|
|
|
{
|
2003-06-27 21:31:46 +00:00
|
|
|
/*
|
|
|
|
* Set EEPROM write-protect register to 0
|
|
|
|
*/
|
2009-02-20 09:19:18 +00:00
|
|
|
out_be32 ((void *)(pci9054_iobase + 0x0c),
|
|
|
|
in_be32 ((void *)(pci9054_iobase + 0x0c)) & 0xffff00ff);
|
2002-08-17 09:36:01 +00:00
|
|
|
|
2003-06-27 21:31:46 +00:00
|
|
|
/* Long Serial EEPROM Load Registers... */
|
2011-11-15 08:03:20 +00:00
|
|
|
PciEepromWriteLongVPD (0x00, 0xffffffff);
|
|
|
|
PciEepromWriteLongVPD (0x04, 0xffffffff); /* other input controller */
|
2002-08-17 09:36:01 +00:00
|
|
|
|
2003-06-27 21:31:46 +00:00
|
|
|
printf ("Finished clearing PLX PCI9054 EEPROM!\n");
|
2002-08-17 09:36:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------- */
|
2003-06-27 21:31:46 +00:00
|
|
|
int do_pci9054 (cmd_tbl_t * cmdtp, int flag, int argc,
|
2010-06-28 20:00:46 +00:00
|
|
|
char * const argv[])
|
2002-08-17 09:36:01 +00:00
|
|
|
{
|
2003-06-27 21:31:46 +00:00
|
|
|
if (strcmp (argv[1], "info") == 0) {
|
|
|
|
showPci9054 ();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strcmp (argv[1], "update") == 0) {
|
|
|
|
updatePci9054 ();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strcmp (argv[1], "clear") == 0) {
|
|
|
|
clearPci9054 ();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-07-16 23:06:04 +00:00
|
|
|
return cmd_usage(cmdtp);
|
2002-08-17 09:36:01 +00:00
|
|
|
}
|
|
|
|
|
2003-07-01 21:06:45 +00:00
|
|
|
U_BOOT_CMD(
|
|
|
|
pci9054, 3, 1, do_pci9054,
|
2009-01-28 00:03:12 +00:00
|
|
|
"PLX PCI9054 EEPROM access",
|
2003-06-27 21:31:46 +00:00
|
|
|
"pci9054 info - print EEPROM values\n"
|
2009-05-24 15:06:54 +00:00
|
|
|
"pci9054 update - updates EEPROM with default values"
|
2003-06-27 21:31:46 +00:00
|
|
|
);
|
|
|
|
|
2002-08-17 09:36:01 +00:00
|
|
|
/* ------------------------------------------------------------------------- */
|