blob: ccea7152c2b06193f28c0074f1309f01bdecc440 [file] [log] [blame]
wdenkaffae2b2002-08-17 09:36:01 +00001/*
2 * (C) Copyright 2001
3 * Stefan Roese, esd gmbh germany, stefan.roese@esd-electronics.com
4 *
5 * See file CREDITS for list of people who contributed to this
6 * project.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 * MA 02111-1307 USA
22 *
23 */
24
25#include <common.h>
26#include <command.h>
27#include <pci.h>
Matthias Fuchsfaac7432009-02-20 10:19:18 +010028#include <asm/io.h>
wdenkaffae2b2002-08-17 09:36:01 +000029
30#define OK 0
31#define ERROR (-1)
32
wdenkaffae2b2002-08-17 09:36:01 +000033extern u_long pci9054_iobase;
34
35
36/***************************************************************************
37 *
38 * Routines for PLX PCI9054 eeprom access
39 *
40 */
41
wdenk57b2d802003-06-27 21:31:46 +000042static unsigned int PciEepromReadLongVPD (int offs)
wdenkaffae2b2002-08-17 09:36:01 +000043{
wdenk57b2d802003-06-27 21:31:46 +000044 unsigned int value;
45 unsigned int ret;
46 int count;
wdenkaffae2b2002-08-17 09:36:01 +000047
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020048 pci_write_config_dword (CONFIG_SYS_PCI9054_DEV_FN, 0x4c,
wdenk57b2d802003-06-27 21:31:46 +000049 (offs << 16) | 0x0003);
50 count = 0;
wdenkaffae2b2002-08-17 09:36:01 +000051
wdenk57b2d802003-06-27 21:31:46 +000052 for (;;) {
53 udelay (10 * 1000);
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020054 pci_read_config_dword (CONFIG_SYS_PCI9054_DEV_FN, 0x4c, &ret);
wdenk57b2d802003-06-27 21:31:46 +000055 if ((ret & 0x80000000) != 0) {
56 break;
57 } else {
58 count++;
59 if (count > 10) {
60 printf ("\nTimeout: ret=%08x - Please try again!\n", ret);
61 break;
62 }
63 }
64 }
wdenkaffae2b2002-08-17 09:36:01 +000065
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020066 pci_read_config_dword (CONFIG_SYS_PCI9054_DEV_FN, 0x50, &value);
wdenkaffae2b2002-08-17 09:36:01 +000067
wdenk57b2d802003-06-27 21:31:46 +000068 return value;
wdenkaffae2b2002-08-17 09:36:01 +000069}
70
71
wdenk57b2d802003-06-27 21:31:46 +000072static int PciEepromWriteLongVPD (int offs, unsigned int value)
wdenkaffae2b2002-08-17 09:36:01 +000073{
wdenk57b2d802003-06-27 21:31:46 +000074 unsigned int ret;
75 int count;
wdenkaffae2b2002-08-17 09:36:01 +000076
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020077 pci_write_config_dword (CONFIG_SYS_PCI9054_DEV_FN, 0x50, value);
78 pci_write_config_dword (CONFIG_SYS_PCI9054_DEV_FN, 0x4c,
wdenk57b2d802003-06-27 21:31:46 +000079 (offs << 16) | 0x80000003);
80 count = 0;
wdenkaffae2b2002-08-17 09:36:01 +000081
wdenk57b2d802003-06-27 21:31:46 +000082 for (;;) {
83 udelay (10 * 1000);
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020084 pci_read_config_dword (CONFIG_SYS_PCI9054_DEV_FN, 0x4c, &ret);
wdenk57b2d802003-06-27 21:31:46 +000085 if ((ret & 0x80000000) == 0) {
86 break;
87 } else {
88 count++;
89 if (count > 10) {
90 printf ("\nTimeout: ret=%08x - Please try again!\n", ret);
91 break;
92 }
93 }
94 }
wdenkaffae2b2002-08-17 09:36:01 +000095
York Sun4a598092013-04-01 11:29:11 -070096 return true;
wdenkaffae2b2002-08-17 09:36:01 +000097}
98
99
wdenk57b2d802003-06-27 21:31:46 +0000100static void showPci9054 (void)
wdenkaffae2b2002-08-17 09:36:01 +0000101{
wdenk57b2d802003-06-27 21:31:46 +0000102 int val;
103 int l, i;
wdenkaffae2b2002-08-17 09:36:01 +0000104
wdenk57b2d802003-06-27 21:31:46 +0000105 /* read 9054-values */
106 for (l = 0; l < 6; l++) {
107 printf ("%02x: ", l * 0x10);
108 for (i = 0; i < 4; i++) {
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200109 pci_read_config_dword (CONFIG_SYS_PCI9054_DEV_FN,
wdenk57b2d802003-06-27 21:31:46 +0000110 l * 16 + i * 4,
Wolfgang Denk7fb52662005-10-13 16:45:02 +0200111 (unsigned int *)&val);
wdenk57b2d802003-06-27 21:31:46 +0000112 printf ("%08x ", val);
113 }
114 printf ("\n");
115 }
116 printf ("\n");
wdenkaffae2b2002-08-17 09:36:01 +0000117
wdenk57b2d802003-06-27 21:31:46 +0000118 for (l = 0; l < 7; l++) {
119 printf ("%02x: ", l * 0x10);
120 for (i = 0; i < 4; i++)
121 printf ("%08x ",
122 PciEepromReadLongVPD ((i + l * 4) * 4));
123 printf ("\n");
124 }
125 printf ("\n");
wdenkaffae2b2002-08-17 09:36:01 +0000126}
127
128
wdenk57b2d802003-06-27 21:31:46 +0000129static void updatePci9054 (void)
wdenkaffae2b2002-08-17 09:36:01 +0000130{
wdenk57b2d802003-06-27 21:31:46 +0000131 /*
132 * Set EEPROM write-protect register to 0
133 */
Matthias Fuchsfaac7432009-02-20 10:19:18 +0100134 out_be32 ((void *)(pci9054_iobase + 0x0c),
135 in_be32 ((void *)(pci9054_iobase + 0x0c)) & 0xffff00ff);
wdenkaffae2b2002-08-17 09:36:01 +0000136
wdenk57b2d802003-06-27 21:31:46 +0000137 /* Long Serial EEPROM Load Registers... */
Stefan Roese697c0602011-11-15 08:03:20 +0000138 PciEepromWriteLongVPD (0x00, 0x905410b5);
139 PciEepromWriteLongVPD (0x04, 0x09800001); /* other input controller */
140 PciEepromWriteLongVPD (0x08, 0x28140100);
wdenkaffae2b2002-08-17 09:36:01 +0000141
Stefan Roese697c0602011-11-15 08:03:20 +0000142 PciEepromWriteLongVPD (0x0c, 0x00000000); /* MBOX0... */
143 PciEepromWriteLongVPD (0x10, 0x00000000);
wdenkaffae2b2002-08-17 09:36:01 +0000144
wdenk57b2d802003-06-27 21:31:46 +0000145 /* las0: fpga access (0x0000.0000 ... 0x0003.ffff) */
Stefan Roese697c0602011-11-15 08:03:20 +0000146 PciEepromWriteLongVPD (0x14, 0xfffc0000); /* LAS0RR... */
147 PciEepromWriteLongVPD (0x18, 0x00000001); /* LAS0BA */
wdenkaffae2b2002-08-17 09:36:01 +0000148
Stefan Roese697c0602011-11-15 08:03:20 +0000149 PciEepromWriteLongVPD (0x1c, 0x00200000); /* MARBR... */
150 PciEepromWriteLongVPD (0x20, 0x00300500); /* LMISC/BIGEND */
wdenkaffae2b2002-08-17 09:36:01 +0000151
Stefan Roese697c0602011-11-15 08:03:20 +0000152 PciEepromWriteLongVPD (0x24, 0x00000000); /* EROMRR... */
153 PciEepromWriteLongVPD (0x28, 0x00000000); /* EROMBA */
wdenkaffae2b2002-08-17 09:36:01 +0000154
Stefan Roese697c0602011-11-15 08:03:20 +0000155 PciEepromWriteLongVPD (0x2c, 0x43030000); /* LBRD0... */
wdenkaffae2b2002-08-17 09:36:01 +0000156
Stefan Roese697c0602011-11-15 08:03:20 +0000157 PciEepromWriteLongVPD (0x30, 0x00000000); /* DMRR... */
158 PciEepromWriteLongVPD (0x34, 0x00000000);
159 PciEepromWriteLongVPD (0x38, 0x00000000);
wdenkaffae2b2002-08-17 09:36:01 +0000160
Stefan Roese697c0602011-11-15 08:03:20 +0000161 PciEepromWriteLongVPD (0x3c, 0x00000000); /* DMPBAM... */
162 PciEepromWriteLongVPD (0x40, 0x00000000);
wdenkaffae2b2002-08-17 09:36:01 +0000163
wdenk57b2d802003-06-27 21:31:46 +0000164 /* Extra Long Serial EEPROM Load Registers... */
Stefan Roese697c0602011-11-15 08:03:20 +0000165 PciEepromWriteLongVPD (0x44, 0x010212fe); /* PCISID... */
wdenkaffae2b2002-08-17 09:36:01 +0000166
wdenk57b2d802003-06-27 21:31:46 +0000167 /* las1: 505-sram access (0x0004.0000 ... 0x001f.ffff) */
168 /* Offset to LAS1: Group 1: 0x00040000 */
169 /* Group 2: 0x00080000 */
170 /* Group 3: 0x000c0000 */
Stefan Roese697c0602011-11-15 08:03:20 +0000171 PciEepromWriteLongVPD (0x48, 0xffe00000); /* LAS1RR */
172 PciEepromWriteLongVPD (0x4c, 0x00040001); /* LAS1BA */
173 PciEepromWriteLongVPD (0x50, 0x00000208); /* LBRD1 */ /* so wars bisher */
wdenkaffae2b2002-08-17 09:36:01 +0000174
Stefan Roese697c0602011-11-15 08:03:20 +0000175 PciEepromWriteLongVPD (0x54, 0x00004c06); /* HotSwap... */
wdenkaffae2b2002-08-17 09:36:01 +0000176
wdenk57b2d802003-06-27 21:31:46 +0000177 printf ("Finished writing defaults into PLX PCI9054 EEPROM!\n");
wdenkaffae2b2002-08-17 09:36:01 +0000178}
179
180
wdenk57b2d802003-06-27 21:31:46 +0000181static void clearPci9054 (void)
wdenkaffae2b2002-08-17 09:36:01 +0000182{
wdenk57b2d802003-06-27 21:31:46 +0000183 /*
184 * Set EEPROM write-protect register to 0
185 */
Matthias Fuchsfaac7432009-02-20 10:19:18 +0100186 out_be32 ((void *)(pci9054_iobase + 0x0c),
187 in_be32 ((void *)(pci9054_iobase + 0x0c)) & 0xffff00ff);
wdenkaffae2b2002-08-17 09:36:01 +0000188
wdenk57b2d802003-06-27 21:31:46 +0000189 /* Long Serial EEPROM Load Registers... */
Stefan Roese697c0602011-11-15 08:03:20 +0000190 PciEepromWriteLongVPD (0x00, 0xffffffff);
191 PciEepromWriteLongVPD (0x04, 0xffffffff); /* other input controller */
wdenkaffae2b2002-08-17 09:36:01 +0000192
wdenk57b2d802003-06-27 21:31:46 +0000193 printf ("Finished clearing PLX PCI9054 EEPROM!\n");
wdenkaffae2b2002-08-17 09:36:01 +0000194}
195
196
197/* ------------------------------------------------------------------------- */
wdenk57b2d802003-06-27 21:31:46 +0000198int do_pci9054 (cmd_tbl_t * cmdtp, int flag, int argc,
Wolfgang Denk6262d0212010-06-28 22:00:46 +0200199 char * const argv[])
wdenkaffae2b2002-08-17 09:36:01 +0000200{
wdenk57b2d802003-06-27 21:31:46 +0000201 if (strcmp (argv[1], "info") == 0) {
202 showPci9054 ();
203 return 0;
204 }
wdenkaffae2b2002-08-17 09:36:01 +0000205
wdenk57b2d802003-06-27 21:31:46 +0000206 if (strcmp (argv[1], "update") == 0) {
207 updatePci9054 ();
208 return 0;
209 }
wdenkaffae2b2002-08-17 09:36:01 +0000210
wdenk57b2d802003-06-27 21:31:46 +0000211 if (strcmp (argv[1], "clear") == 0) {
212 clearPci9054 ();
213 return 0;
214 }
wdenkaffae2b2002-08-17 09:36:01 +0000215
Wolfgang Denk3b683112010-07-17 01:06:04 +0200216 return cmd_usage(cmdtp);
wdenkaffae2b2002-08-17 09:36:01 +0000217}
218
wdenkf287a242003-07-01 21:06:45 +0000219U_BOOT_CMD(
220 pci9054, 3, 1, do_pci9054,
Peter Tyserdfb72b82009-01-27 18:03:12 -0600221 "PLX PCI9054 EEPROM access",
wdenk57b2d802003-06-27 21:31:46 +0000222 "pci9054 info - print EEPROM values\n"
Wolfgang Denkc54781c2009-05-24 17:06:54 +0200223 "pci9054 update - updates EEPROM with default values"
wdenk57b2d802003-06-27 21:31:46 +0000224);
225
wdenkaffae2b2002-08-17 09:36:01 +0000226/* ------------------------------------------------------------------------- */