blob: 6ee44d691d9f5e29d15d737e85f52cb5e5c94896 [file] [log] [blame]
wdenkc6097192002-11-03 00:24:07 +00001/*
2 * (C) Copyright 2002
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
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#include <config.h>
25#include <common.h>
26#include <command.h>
27#include <asm/io.h>
28#include <linux/mtd/doc2000.h>
29#include <watchdog.h>
30#include <pci.h>
Ben Warren8ca0b3f2008-08-31 10:45:44 -070031#include <netdev.h>
wdenkc6097192002-11-03 00:24:07 +000032
33#include "hardware.h"
34#include "pcippc2.h"
35#include "sconsole.h"
36#include "fpga_serial.h"
37
Wolfgang Denkd87080b2006-03-31 18:32:53 +020038DECLARE_GLOBAL_DATA_PTR;
39
wdenkc6097192002-11-03 00:24:07 +000040#if defined(CONFIG_WATCHDOG)
41
42static int pcippc2_wdt_init_done = 0;
43
44void pcippc2_wdt_init (void);
45
46#endif
47
48 /* Check board identity
49 */
50int checkboard (void)
51{
52#ifdef CONFIG_PCIPPC2
53 puts ("Board: Gespac PCIPPC-2\n");
54#else
55 puts ("Board: Gespac PCIPPC-6\n");
56#endif
57 return 0;
58}
59
60 /* RAM size is stored in CPC0_RGBAN1
61 */
62u32 pcippc2_sdram_size (void)
63{
64 return in32 (REG (CPC0, RGBAN1));
65}
66
Becky Bruce9973e3c2008-06-09 16:03:40 -050067phys_size_t initdram (int board_type)
wdenkc6097192002-11-03 00:24:07 +000068{
69 return cpc710_ram_init ();
70}
71
wdenk8bde7f72003-06-27 21:31:46 +000072int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
wdenkc6097192002-11-03 00:24:07 +000073{
74 out32 (REG (CPC0, SPOR), 0);
75 iobarrier_rw ();
76 while (1);
wdenk8bde7f72003-06-27 21:31:46 +000077 /* notreached */
78 return (-1);
wdenkc6097192002-11-03 00:24:07 +000079}
80
wdenkc837dcb2004-01-20 23:12:12 +000081int board_early_init_f (void)
wdenkc6097192002-11-03 00:24:07 +000082{
83 out32 (REG (CPC0, RSTR), 0xC0000000);
84 iobarrier_rw ();
85
86 out32 (REG (CPC0, RSTR), 0xF0000000);
87 iobarrier_rw ();
88
89 out32 (REG (CPC0, UCTL), 0x00F80000);
90
91 out32 (REG (CPC0, SIOC0), 0x30000000);
92
93 out32 (REG (CPC0, ABCNTL), 0x00000000);
94
95 out32 (REG (CPC0, SESR), 0x00000000);
96 out32 (REG (CPC0, SEAR), 0x00000000);
97
98 /* Detect IBM Avignon CPC710 Revision */
99 if ((in32 (REG (CPC0, UCTL)) & 0x000000F0) == CPC710_TYPE_100P)
100 out32 (REG (CPC0, PGCHP), 0xA0000040);
101 else
102 out32 (REG (CPC0, PGCHP), 0x80800040);
103
104
105 out32 (REG (CPC0, ATAS), 0x709C2508);
106
107 iobarrier_rw ();
108
109 return 0;
110}
111
112void after_reloc (ulong dest_addr)
113{
wdenkc6097192002-11-03 00:24:07 +0000114 /* Jump to the main U-Boot board init code
115 */
wdenk27b207f2003-07-24 23:38:38 +0000116 board_init_r ((gd_t *)gd, dest_addr);
wdenkc6097192002-11-03 00:24:07 +0000117}
118
119int misc_init_r (void)
120{
121 pcippc2_fpga_init ();
122
wdenke95b61c2002-11-04 16:02:40 +0000123 pcippc2_cpci3264_init ();
124
wdenkc6097192002-11-03 00:24:07 +0000125#if defined(CONFIG_WATCHDOG)
126 pcippc2_wdt_init ();
127#endif
128
129 fpga_serial_init (sconsole_get_baudrate ());
130
131 sconsole_putc = fpga_serial_putc;
132 sconsole_puts = fpga_serial_puts;
133 sconsole_getc = fpga_serial_getc;
134 sconsole_tstc = fpga_serial_tstc;
135 sconsole_setbrg = fpga_serial_setbrg;
136
137 sconsole_flush ();
138 return (0);
139}
140
stroesead10dd92003-02-14 11:21:23 +0000141void pci_init_board (void)
wdenkc6097192002-11-03 00:24:07 +0000142{
143 cpc710_pci_init ();
144
145 /* FPGA requires no retry timeouts to be enabled
146 */
147 cpc710_pci_enable_timeout ();
148}
149
Wolfgang Denk7640f412009-07-19 19:37:24 +0200150#ifdef CONFIG_CMD_DOC
wdenkc6097192002-11-03 00:24:07 +0000151void doc_init (void)
152{
153 doc_probe (pcippc2_fpga1_phys + HW_FPGA1_DOC);
154}
Wolfgang Denk7640f412009-07-19 19:37:24 +0200155#endif
wdenkc6097192002-11-03 00:24:07 +0000156
wdenke95b61c2002-11-04 16:02:40 +0000157void pcippc2_cpci3264_init (void)
158{
159 pci_dev_t bdf = pci_find_device(FPGA_VENDOR_ID, FPGA_DEVICE_ID, 0);
160
161 if (bdf == -1)
162 {
163 puts("Unable to find FPGA !\n");
164 hang();
165 }
166
167 if((in32(pcippc2_fpga0_phys + HW_FPGA0_BOARD) & 0x01000000) == 0x01000000)
168 /* 32-bits Compact PCI bus - LSB bit */
169 {
170 iobarrier_rw();
171 out32(BRIDGE(CPCI, PCIDG), 0x40000000); /* 32-bits bridge, Pipeline */
172 iobarrier_rw();
173 }
174}
175
wdenkc6097192002-11-03 00:24:07 +0000176#if defined(CONFIG_WATCHDOG)
177
178void pcippc2_wdt_init (void)
179{
180 out16r (FPGA (WDT, PROG), 0xffff);
181 out8 (FPGA (WDT, CTRL), 0x1);
182
183 pcippc2_wdt_init_done = 1;
184}
185
186void pcippc2_wdt_done (void)
187{
188 out8 (FPGA (WDT, CTRL), 0x0);
189
190 pcippc2_wdt_init_done = 0;
191}
192
193void pcippc2_wdt_reset (void)
194{
195 if (pcippc2_wdt_init_done == 1)
196 out8 (FPGA (WDT, REFRESH), 0x56);
197}
198
199void watchdog_reset (void)
200{
201 int re_enable = disable_interrupts ();
202
203 pcippc2_wdt_reset ();
204 if (re_enable)
205 enable_interrupts ();
206}
207
Jon Loeliger3fe00102007-07-09 18:38:39 -0500208#if defined(CONFIG_CMD_BSP)
wdenk8bde7f72003-06-27 21:31:46 +0000209int do_wd (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
wdenkc6097192002-11-03 00:24:07 +0000210{
211 switch (argc) {
212 case 1:
213 printf ("Watchdog timer status is %s\n",
214 pcippc2_wdt_init_done == 1 ? "on" : "off");
215
216 return 0;
217 case 2:
218 if (!strcmp(argv[1],"on")) {
219 pcippc2_wdt_init();
220 printf("Watchdog timer now is on\n");
221
222 return 0;
223
224 } else if (!strcmp(argv[1],"off")) {
225 pcippc2_wdt_done();
226 printf("Watchdog timer now is off\n");
227
228 return 0;
229
230 } else
231 break;
232 default:
233 break;
234 }
Peter Tyser62c3ae72009-01-27 18:03:10 -0600235 cmd_usage(cmdtp);
wdenkc6097192002-11-03 00:24:07 +0000236 return 1;
237}
238
wdenk0d498392003-07-01 21:06:45 +0000239U_BOOT_CMD(
240 wd, 2, 1, do_wd,
Peter Tyser2fb26042009-01-27 18:03:12 -0600241 "check and set watchdog",
wdenk8bde7f72003-06-27 21:31:46 +0000242 "on - switch watchDog on\n"
243 "wd off - switch watchdog off\n"
Wolfgang Denka89c33d2009-05-24 17:06:54 +0200244 "wd - print current status"
wdenk8bde7f72003-06-27 21:31:46 +0000245);
246
Jon Loeligerd39b5742007-07-10 10:48:22 -0500247#endif
wdenkc6097192002-11-03 00:24:07 +0000248#endif /* CONFIG_WATCHDOG */
Ben Warren8ca0b3f2008-08-31 10:45:44 -0700249
250int board_eth_init(bd_t *bis)
251{
252 return pci_eth_init(bis);
253}