blob: 7210512bfbcb686e369d3ba88b32f1291e118922 [file] [log] [blame]
Jon Loeligerd68e2ba2006-05-30 17:47:00 -05001/*
2 * Copyright 2006 Freescale Semiconductor
3 * Jeff Brown
4 * Srikanth Srinivasan (srikanth.srinivasan@freescale.com)
5 *
6 * See file CREDITS for list of people who contributed to this
7 * project.
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of
12 * the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
22 * MA 02111-1307 USA
23 */
24
25#include <common.h>
Jon Loeligerd68e2ba2006-05-30 17:47:00 -050026#include <command.h>
Haiying Wang57b6e9c2007-01-22 12:37:30 -060027#include <watchdog.h>
Liew Tsi Chung-r5aahp78a1db42007-09-13 16:04:05 -070028#include <asm/cache.h>
Andy Flemingdb2b5bd2008-08-31 16:33:30 -050029#include <asm/io.h>
Jon Loeliger4eab6232008-01-15 13:42:41 -060030
Jon Loeligerd68e2ba2006-05-30 17:47:00 -050031#include "pixis.h"
32
33
Haiying Wang57b6e9c2007-01-22 12:37:30 -060034static ulong strfractoint(uchar *strptr);
35
36
37/*
38 * Simple board reset.
39 */
40void pixis_reset(void)
41{
Kumar Gala146c4b22009-07-22 10:12:39 -050042 u8 *pixis_base = (u8 *)PIXIS_BASE;
43 out_8(pixis_base + PIXIS_RST, 0);
Haiying Wang57b6e9c2007-01-22 12:37:30 -060044}
45
46
Jon Loeligerd68e2ba2006-05-30 17:47:00 -050047/*
48 * Per table 27, page 58 of MPC8641HPCN spec.
49 */
50int set_px_sysclk(ulong sysclk)
51{
52 u8 sysclk_s, sysclk_r, sysclk_v, vclkh, vclkl, sysclk_aux;
Kumar Gala146c4b22009-07-22 10:12:39 -050053 u8 *pixis_base = (u8 *)PIXIS_BASE;
Jon Loeligerd68e2ba2006-05-30 17:47:00 -050054
55 switch (sysclk) {
56 case 33:
57 sysclk_s = 0x04;
58 sysclk_r = 0x04;
59 sysclk_v = 0x07;
60 sysclk_aux = 0x00;
61 break;
62 case 40:
63 sysclk_s = 0x01;
64 sysclk_r = 0x1F;
65 sysclk_v = 0x20;
66 sysclk_aux = 0x01;
67 break;
68 case 50:
69 sysclk_s = 0x01;
70 sysclk_r = 0x1F;
71 sysclk_v = 0x2A;
72 sysclk_aux = 0x02;
73 break;
74 case 66:
75 sysclk_s = 0x01;
76 sysclk_r = 0x04;
77 sysclk_v = 0x04;
78 sysclk_aux = 0x03;
79 break;
80 case 83:
81 sysclk_s = 0x01;
82 sysclk_r = 0x1F;
83 sysclk_v = 0x4B;
84 sysclk_aux = 0x04;
85 break;
86 case 100:
87 sysclk_s = 0x01;
88 sysclk_r = 0x1F;
89 sysclk_v = 0x5C;
90 sysclk_aux = 0x05;
91 break;
92 case 134:
93 sysclk_s = 0x06;
94 sysclk_r = 0x1F;
95 sysclk_v = 0x3B;
96 sysclk_aux = 0x06;
97 break;
98 case 166:
99 sysclk_s = 0x06;
100 sysclk_r = 0x1F;
101 sysclk_v = 0x4B;
102 sysclk_aux = 0x07;
103 break;
104 default:
105 printf("Unsupported SYSCLK frequency.\n");
106 return 0;
107 }
108
Jon Loeliger4fbb09c2006-08-22 12:25:27 -0500109 vclkh = (sysclk_s << 5) | sysclk_r;
Jon Loeligerd68e2ba2006-05-30 17:47:00 -0500110 vclkl = sysclk_v;
111
Kumar Gala146c4b22009-07-22 10:12:39 -0500112 out_8(pixis_base + PIXIS_VCLKH, vclkh);
113 out_8(pixis_base + PIXIS_VCLKL, vclkl);
Jon Loeligerd68e2ba2006-05-30 17:47:00 -0500114
Kumar Gala146c4b22009-07-22 10:12:39 -0500115 out_8(pixis_base + PIXIS_AUX, sysclk_aux);
Jon Loeligerd68e2ba2006-05-30 17:47:00 -0500116
117 return 1;
118}
119
120
121int set_px_mpxpll(ulong mpxpll)
122{
123 u8 tmp;
124 u8 val;
Kumar Gala146c4b22009-07-22 10:12:39 -0500125 u8 *pixis_base = (u8 *)PIXIS_BASE;
Jon Loeligerd68e2ba2006-05-30 17:47:00 -0500126
127 switch (mpxpll) {
128 case 2:
129 case 4:
130 case 6:
131 case 8:
132 case 10:
133 case 12:
134 case 14:
135 case 16:
Jon Loeliger4fbb09c2006-08-22 12:25:27 -0500136 val = (u8) mpxpll;
Jon Loeligerd68e2ba2006-05-30 17:47:00 -0500137 break;
138 default:
139 printf("Unsupported MPXPLL ratio.\n");
140 return 0;
141 }
142
Kumar Gala146c4b22009-07-22 10:12:39 -0500143 tmp = in_8(pixis_base + PIXIS_VSPEED1);
Jon Loeligerd68e2ba2006-05-30 17:47:00 -0500144 tmp = (tmp & 0xF0) | (val & 0x0F);
Kumar Gala146c4b22009-07-22 10:12:39 -0500145 out_8(pixis_base + PIXIS_VSPEED1, tmp);
Jon Loeligerd68e2ba2006-05-30 17:47:00 -0500146
147 return 1;
148}
149
150
151int set_px_corepll(ulong corepll)
152{
153 u8 tmp;
154 u8 val;
Kumar Gala146c4b22009-07-22 10:12:39 -0500155 u8 *pixis_base = (u8 *)PIXIS_BASE;
Jon Loeligerd68e2ba2006-05-30 17:47:00 -0500156
157 switch ((int)corepll) {
158 case 20:
159 val = 0x08;
160 break;
161 case 25:
162 val = 0x0C;
163 break;
164 case 30:
165 val = 0x10;
166 break;
167 case 35:
168 val = 0x1C;
169 break;
170 case 40:
171 val = 0x14;
172 break;
173 case 45:
174 val = 0x0E;
175 break;
176 default:
177 printf("Unsupported COREPLL ratio.\n");
178 return 0;
179 }
180
Kumar Gala146c4b22009-07-22 10:12:39 -0500181 tmp = in_8(pixis_base + PIXIS_VSPEED0);
Jon Loeligerd68e2ba2006-05-30 17:47:00 -0500182 tmp = (tmp & 0xE0) | (val & 0x1F);
Kumar Gala146c4b22009-07-22 10:12:39 -0500183 out_8(pixis_base + PIXIS_VSPEED0, tmp);
Jon Loeligerd68e2ba2006-05-30 17:47:00 -0500184
185 return 1;
186}
187
188
189void read_from_px_regs(int set)
190{
Kumar Gala146c4b22009-07-22 10:12:39 -0500191 u8 *pixis_base = (u8 *)PIXIS_BASE;
James Yang61f17812008-01-16 11:58:08 -0600192 u8 mask = 0x1C; /* COREPLL, MPXPLL, SYSCLK controlled by PIXIS */
Kumar Gala146c4b22009-07-22 10:12:39 -0500193 u8 tmp = in_8(pixis_base + PIXIS_VCFGEN0);
Jon Loeligerd68e2ba2006-05-30 17:47:00 -0500194
195 if (set)
196 tmp = tmp | mask;
197 else
198 tmp = tmp & ~mask;
Kumar Gala146c4b22009-07-22 10:12:39 -0500199 out_8(pixis_base + PIXIS_VCFGEN0, tmp);
Jon Loeligerd68e2ba2006-05-30 17:47:00 -0500200}
201
202
203void read_from_px_regs_altbank(int set)
204{
Kumar Gala146c4b22009-07-22 10:12:39 -0500205 u8 *pixis_base = (u8 *)PIXIS_BASE;
James Yang61f17812008-01-16 11:58:08 -0600206 u8 mask = 0x04; /* FLASHBANK and FLASHMAP controlled by PIXIS */
Kumar Gala146c4b22009-07-22 10:12:39 -0500207 u8 tmp = in_8(pixis_base + PIXIS_VCFGEN1);
Jon Loeligerd68e2ba2006-05-30 17:47:00 -0500208
209 if (set)
210 tmp = tmp | mask;
211 else
212 tmp = tmp & ~mask;
Kumar Gala146c4b22009-07-22 10:12:39 -0500213 out_8(pixis_base + PIXIS_VCFGEN1, tmp);
Jon Loeligerd68e2ba2006-05-30 17:47:00 -0500214}
215
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200216#ifndef CONFIG_SYS_PIXIS_VBOOT_MASK
217#define CONFIG_SYS_PIXIS_VBOOT_MASK (0x40)
Jason Jinf08899a2007-10-29 19:26:21 +0800218#endif
Jon Loeligerd68e2ba2006-05-30 17:47:00 -0500219
James Yang61f17812008-01-16 11:58:08 -0600220void clear_altbank(void)
221{
222 u8 tmp;
Kumar Gala146c4b22009-07-22 10:12:39 -0500223 u8 *pixis_base = (u8 *)PIXIS_BASE;
James Yang61f17812008-01-16 11:58:08 -0600224
Kumar Gala146c4b22009-07-22 10:12:39 -0500225 tmp = in_8(pixis_base + PIXIS_VBOOT);
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200226 tmp &= ~CONFIG_SYS_PIXIS_VBOOT_MASK;
James Yang61f17812008-01-16 11:58:08 -0600227
Kumar Gala146c4b22009-07-22 10:12:39 -0500228 out_8(pixis_base + PIXIS_VBOOT, tmp);
James Yang61f17812008-01-16 11:58:08 -0600229}
230
231
Jon Loeligerd68e2ba2006-05-30 17:47:00 -0500232void set_altbank(void)
233{
234 u8 tmp;
Kumar Gala146c4b22009-07-22 10:12:39 -0500235 u8 *pixis_base = (u8 *)PIXIS_BASE;
Jon Loeligerd68e2ba2006-05-30 17:47:00 -0500236
Kumar Gala146c4b22009-07-22 10:12:39 -0500237 tmp = in_8(pixis_base + PIXIS_VBOOT);
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200238 tmp |= CONFIG_SYS_PIXIS_VBOOT_MASK;
Jon Loeligerd68e2ba2006-05-30 17:47:00 -0500239
Kumar Gala146c4b22009-07-22 10:12:39 -0500240 out_8(pixis_base + PIXIS_VBOOT, tmp);
Jon Loeligerd68e2ba2006-05-30 17:47:00 -0500241}
242
243
244void set_px_go(void)
245{
246 u8 tmp;
Kumar Gala146c4b22009-07-22 10:12:39 -0500247 u8 *pixis_base = (u8 *)PIXIS_BASE;
Jon Loeligerd68e2ba2006-05-30 17:47:00 -0500248
Kumar Gala146c4b22009-07-22 10:12:39 -0500249 tmp = in_8(pixis_base + PIXIS_VCTL);
James Yang61f17812008-01-16 11:58:08 -0600250 tmp = tmp & 0x1E; /* clear GO bit */
Kumar Gala146c4b22009-07-22 10:12:39 -0500251 out_8(pixis_base + PIXIS_VCTL, tmp);
Jon Loeligerd68e2ba2006-05-30 17:47:00 -0500252
Kumar Gala146c4b22009-07-22 10:12:39 -0500253 tmp = in_8(pixis_base + PIXIS_VCTL);
James Yang61f17812008-01-16 11:58:08 -0600254 tmp = tmp | 0x01; /* set GO bit - start reset sequencer */
Kumar Gala146c4b22009-07-22 10:12:39 -0500255 out_8(pixis_base + PIXIS_VCTL, tmp);
Jon Loeligerd68e2ba2006-05-30 17:47:00 -0500256}
257
258
259void set_px_go_with_watchdog(void)
260{
261 u8 tmp;
Kumar Gala146c4b22009-07-22 10:12:39 -0500262 u8 *pixis_base = (u8 *)PIXIS_BASE;
Jon Loeligerd68e2ba2006-05-30 17:47:00 -0500263
Kumar Gala146c4b22009-07-22 10:12:39 -0500264 tmp = in_8(pixis_base + PIXIS_VCTL);
Jon Loeligerd68e2ba2006-05-30 17:47:00 -0500265 tmp = tmp & 0x1E;
Kumar Gala146c4b22009-07-22 10:12:39 -0500266 out_8(pixis_base + PIXIS_VCTL, tmp);
Jon Loeligerd68e2ba2006-05-30 17:47:00 -0500267
Kumar Gala146c4b22009-07-22 10:12:39 -0500268 tmp = in_8(pixis_base + PIXIS_VCTL);
Jon Loeligerd68e2ba2006-05-30 17:47:00 -0500269 tmp = tmp | 0x09;
Kumar Gala146c4b22009-07-22 10:12:39 -0500270 out_8(pixis_base + PIXIS_VCTL, tmp);
Jon Loeligerd68e2ba2006-05-30 17:47:00 -0500271}
272
273
Haiying Wang57b6e9c2007-01-22 12:37:30 -0600274int pixis_disable_watchdog_cmd(cmd_tbl_t *cmdtp,
275 int flag, int argc, char *argv[])
Jon Loeligerd68e2ba2006-05-30 17:47:00 -0500276{
277 u8 tmp;
Kumar Gala146c4b22009-07-22 10:12:39 -0500278 u8 *pixis_base = (u8 *)PIXIS_BASE;
Jon Loeligerd68e2ba2006-05-30 17:47:00 -0500279
Kumar Gala146c4b22009-07-22 10:12:39 -0500280 tmp = in_8(pixis_base + PIXIS_VCTL);
Jon Loeligerd68e2ba2006-05-30 17:47:00 -0500281 tmp = tmp & 0x1E;
Kumar Gala146c4b22009-07-22 10:12:39 -0500282 out_8(pixis_base + PIXIS_VCTL, tmp);
Jon Loeligerd68e2ba2006-05-30 17:47:00 -0500283
284 /* setting VCTL[WDEN] to 0 to disable watch dog */
Kumar Gala146c4b22009-07-22 10:12:39 -0500285 tmp = in_8(pixis_base + PIXIS_VCTL);
Jon Loeliger4fbb09c2006-08-22 12:25:27 -0500286 tmp &= ~0x08;
Kumar Gala146c4b22009-07-22 10:12:39 -0500287 out_8(pixis_base + PIXIS_VCTL, tmp);
Jon Loeligerd68e2ba2006-05-30 17:47:00 -0500288
289 return 0;
290}
291
Jon Loeligerd68e2ba2006-05-30 17:47:00 -0500292U_BOOT_CMD(
Wolfgang Denkc54781c2009-05-24 17:06:54 +0200293 diswd, 1, 0, pixis_disable_watchdog_cmd,
294 "Disable watchdog timer",
295 ""
296);
Jon Loeligerd68e2ba2006-05-30 17:47:00 -0500297
Liu Yu46269062008-10-10 11:40:58 +0800298#ifdef CONFIG_PIXIS_SGMII_CMD
Andy Flemingdb2b5bd2008-08-31 16:33:30 -0500299int pixis_set_sgmii(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
300{
301 int which_tsec = -1;
Kumar Gala146c4b22009-07-22 10:12:39 -0500302 u8 *pixis_base = (u8 *)PIXIS_BASE;
Andy Flemingdb2b5bd2008-08-31 16:33:30 -0500303 uchar mask;
304 uchar switch_mask;
305
306 if (argc > 2)
307 if (strcmp(argv[1], "all") != 0)
308 which_tsec = simple_strtoul(argv[1], NULL, 0);
309
310 switch (which_tsec) {
Liu Yu46269062008-10-10 11:40:58 +0800311#ifdef CONFIG_TSEC1
Andy Flemingdb2b5bd2008-08-31 16:33:30 -0500312 case 1:
313 mask = PIXIS_VSPEED2_TSEC1SER;
314 switch_mask = PIXIS_VCFGEN1_TSEC1SER;
315 break;
Liu Yu46269062008-10-10 11:40:58 +0800316#endif
317#ifdef CONFIG_TSEC2
318 case 2:
319 mask = PIXIS_VSPEED2_TSEC2SER;
320 switch_mask = PIXIS_VCFGEN1_TSEC2SER;
321 break;
322#endif
323#ifdef CONFIG_TSEC3
Andy Flemingdb2b5bd2008-08-31 16:33:30 -0500324 case 3:
325 mask = PIXIS_VSPEED2_TSEC3SER;
326 switch_mask = PIXIS_VCFGEN1_TSEC3SER;
327 break;
Liu Yu46269062008-10-10 11:40:58 +0800328#endif
329#ifdef CONFIG_TSEC4
330 case 4:
331 mask = PIXIS_VSPEED2_TSEC4SER;
332 switch_mask = PIXIS_VCFGEN1_TSEC4SER;
333 break;
334#endif
Andy Flemingdb2b5bd2008-08-31 16:33:30 -0500335 default:
Liu Yu46269062008-10-10 11:40:58 +0800336 mask = PIXIS_VSPEED2_MASK;
337 switch_mask = PIXIS_VCFGEN1_MASK;
Andy Flemingdb2b5bd2008-08-31 16:33:30 -0500338 break;
339 }
340
341 /* Toggle whether the switches or FPGA control the settings */
342 if (!strcmp(argv[argc - 1], "switch"))
Kumar Gala146c4b22009-07-22 10:12:39 -0500343 clrbits_8(pixis_base + PIXIS_VCFGEN1, switch_mask);
Andy Flemingdb2b5bd2008-08-31 16:33:30 -0500344 else
Kumar Gala146c4b22009-07-22 10:12:39 -0500345 setbits_8(pixis_base + PIXIS_VCFGEN1, switch_mask);
Andy Flemingdb2b5bd2008-08-31 16:33:30 -0500346
347 /* If it's not the switches, enable or disable SGMII, as specified */
348 if (!strcmp(argv[argc - 1], "on"))
Kumar Gala146c4b22009-07-22 10:12:39 -0500349 clrbits_8(pixis_base + PIXIS_VSPEED2, mask);
Andy Flemingdb2b5bd2008-08-31 16:33:30 -0500350 else if (!strcmp(argv[argc - 1], "off"))
Kumar Gala146c4b22009-07-22 10:12:39 -0500351 setbits_8(pixis_base + PIXIS_VSPEED2, mask);
Andy Flemingdb2b5bd2008-08-31 16:33:30 -0500352
353 return 0;
354}
355
356U_BOOT_CMD(
Wolfgang Denkc54781c2009-05-24 17:06:54 +0200357 pixis_set_sgmii, CONFIG_SYS_MAXARGS, 1, pixis_set_sgmii,
358 "pixis_set_sgmii"
359 " - Enable or disable SGMII mode for a given TSEC \n",
360 "\npixis_set_sgmii [TSEC num] <on|off|switch>\n"
361 " TSEC num: 1,2,3,4 or 'all'. 'all' is default.\n"
362 " on - enables SGMII\n"
363 " off - disables SGMII\n"
364 " switch - use switch settings"
365);
Andy Flemingdb2b5bd2008-08-31 16:33:30 -0500366#endif
367
Jon Loeligerd68e2ba2006-05-30 17:47:00 -0500368/*
369 * This function takes the non-integral cpu:mpx pll ratio
370 * and converts it to an integer that can be used to assign
371 * FPGA register values.
372 * input: strptr i.e. argv[2]
373 */
374
Haiying Wang57b6e9c2007-01-22 12:37:30 -0600375static ulong strfractoint(uchar *strptr)
Jon Loeligerd68e2ba2006-05-30 17:47:00 -0500376{
377 int i, j, retval;
378 int mulconst;
379 int intarr_len = 0, decarr_len = 0, no_dec = 0;
380 ulong intval = 0, decval = 0;
381 uchar intarr[3], decarr[3];
382
383 /* Assign the integer part to intarr[]
384 * If there is no decimal point i.e.
385 * if the ratio is an integral value
386 * simply create the intarr.
387 */
388 i = 0;
James Yang61f17812008-01-16 11:58:08 -0600389 while (strptr[i] != '.') {
Jon Loeligerd68e2ba2006-05-30 17:47:00 -0500390 if (strptr[i] == 0) {
391 no_dec = 1;
392 break;
393 }
394 intarr[i] = strptr[i];
395 i++;
396 }
397
398 /* Assign length of integer part to intarr_len. */
399 intarr_len = i;
400 intarr[i] = '\0';
401
402 if (no_dec) {
403 /* Currently needed only for single digit corepll ratios */
Jon Loeliger4fbb09c2006-08-22 12:25:27 -0500404 mulconst = 10;
Jon Loeligerd68e2ba2006-05-30 17:47:00 -0500405 decval = 0;
406 } else {
407 j = 0;
Jon Loeliger4fbb09c2006-08-22 12:25:27 -0500408 i++; /* Skipping the decimal point */
James Yang61f17812008-01-16 11:58:08 -0600409 while ((strptr[i] >= '0') && (strptr[i] <= '9')) {
Jon Loeligerd68e2ba2006-05-30 17:47:00 -0500410 decarr[j] = strptr[i];
411 i++;
412 j++;
413 }
414
415 decarr_len = j;
416 decarr[j] = '\0';
417
418 mulconst = 1;
419 for (i = 0; i < decarr_len; i++)
420 mulconst *= 10;
Wolfgang Denk4d5a8e32007-08-02 00:48:45 +0200421 decval = simple_strtoul((char *)decarr, NULL, 10);
Jon Loeligerd68e2ba2006-05-30 17:47:00 -0500422 }
423
Wolfgang Denk4d5a8e32007-08-02 00:48:45 +0200424 intval = simple_strtoul((char *)intarr, NULL, 10);
Jon Loeligerd68e2ba2006-05-30 17:47:00 -0500425 intval = intval * mulconst;
426
427 retval = intval + decval;
428
429 return retval;
430}
Haiying Wang57b6e9c2007-01-22 12:37:30 -0600431
432
433int
434pixis_reset_cmd(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
435{
James Yang61f17812008-01-16 11:58:08 -0600436 unsigned int i;
437 char *p_cf = NULL;
438 char *p_cf_sysclk = NULL;
439 char *p_cf_corepll = NULL;
440 char *p_cf_mpxpll = NULL;
441 char *p_altbank = NULL;
442 char *p_wd = NULL;
443 unsigned int unknown_param = 0;
Haiying Wang57b6e9c2007-01-22 12:37:30 -0600444
445 /*
446 * No args is a simple reset request.
447 */
448 if (argc <= 1) {
449 pixis_reset();
450 /* not reached */
451 }
452
James Yang61f17812008-01-16 11:58:08 -0600453 for (i = 1; i < argc; i++) {
454 if (strcmp(argv[i], "cf") == 0) {
455 p_cf = argv[i];
456 if (i + 3 >= argc) {
457 break;
458 }
459 p_cf_sysclk = argv[i+1];
460 p_cf_corepll = argv[i+2];
461 p_cf_mpxpll = argv[i+3];
462 i += 3;
463 continue;
Haiying Wang57b6e9c2007-01-22 12:37:30 -0600464 }
465
James Yang61f17812008-01-16 11:58:08 -0600466 if (strcmp(argv[i], "altbank") == 0) {
467 p_altbank = argv[i];
468 continue;
469 }
Haiying Wang57b6e9c2007-01-22 12:37:30 -0600470
James Yang61f17812008-01-16 11:58:08 -0600471 if (strcmp(argv[i], "wd") == 0) {
472 p_wd = argv[i];
473 continue;
Haiying Wang57b6e9c2007-01-22 12:37:30 -0600474 }
475
James Yang61f17812008-01-16 11:58:08 -0600476 unknown_param = 1;
477 }
Haiying Wang57b6e9c2007-01-22 12:37:30 -0600478
James Yang61f17812008-01-16 11:58:08 -0600479 /*
480 * Check that cf has all required parms
481 */
482 if ((p_cf && !(p_cf_sysclk && p_cf_corepll && p_cf_mpxpll))
Wolfgang Denka1be4762008-05-20 16:00:29 +0200483 || unknown_param) {
Ed Swarthout06c70d62008-10-08 23:38:01 -0500484#ifdef CONFIG_SYS_LONGHELP
James Yang61f17812008-01-16 11:58:08 -0600485 puts(cmdtp->help);
Ed Swarthout06c70d62008-10-08 23:38:01 -0500486#endif
James Yang61f17812008-01-16 11:58:08 -0600487 return 1;
488 }
Haiying Wang57b6e9c2007-01-22 12:37:30 -0600489
James Yang61f17812008-01-16 11:58:08 -0600490 /*
491 * PIXIS seems to be sensitive to the ordering of
492 * the registers that are touched.
493 */
494 read_from_px_regs(0);
Haiying Wang57b6e9c2007-01-22 12:37:30 -0600495
James Yang61f17812008-01-16 11:58:08 -0600496 if (p_altbank) {
497 read_from_px_regs_altbank(0);
498 }
499 clear_altbank();
Haiying Wang57b6e9c2007-01-22 12:37:30 -0600500
James Yang61f17812008-01-16 11:58:08 -0600501 /*
502 * Clock configuration specified.
503 */
504 if (p_cf) {
505 unsigned long sysclk;
506 unsigned long corepll;
507 unsigned long mpxpll;
Haiying Wang57b6e9c2007-01-22 12:37:30 -0600508
James Yang61f17812008-01-16 11:58:08 -0600509 sysclk = simple_strtoul(p_cf_sysclk, NULL, 10);
510 corepll = strfractoint((uchar *) p_cf_corepll);
511 mpxpll = simple_strtoul(p_cf_mpxpll, NULL, 10);
Haiying Wang57b6e9c2007-01-22 12:37:30 -0600512
James Yang61f17812008-01-16 11:58:08 -0600513 if (!(set_px_sysclk(sysclk)
514 && set_px_corepll(corepll)
515 && set_px_mpxpll(mpxpll))) {
Ed Swarthout06c70d62008-10-08 23:38:01 -0500516#ifdef CONFIG_SYS_LONGHELP
James Yang61f17812008-01-16 11:58:08 -0600517 puts(cmdtp->help);
Ed Swarthout06c70d62008-10-08 23:38:01 -0500518#endif
Haiying Wang57b6e9c2007-01-22 12:37:30 -0600519 return 1;
520 }
James Yang61f17812008-01-16 11:58:08 -0600521 read_from_px_regs(1);
522 }
Haiying Wang57b6e9c2007-01-22 12:37:30 -0600523
James Yang61f17812008-01-16 11:58:08 -0600524 /*
525 * Altbank specified
526 *
527 * NOTE CHANGE IN BEHAVIOR: previous code would default
528 * to enabling watchdog if altbank is specified.
529 * Now the watchdog must be enabled explicitly using 'wd'.
530 */
531 if (p_altbank) {
532 set_altbank();
533 read_from_px_regs_altbank(1);
534 }
535
536 /*
537 * Reset with watchdog specified.
538 */
539 if (p_wd) {
540 set_px_go_with_watchdog();
Haiying Wang57b6e9c2007-01-22 12:37:30 -0600541 } else {
James Yang61f17812008-01-16 11:58:08 -0600542 set_px_go();
Haiying Wang57b6e9c2007-01-22 12:37:30 -0600543 }
544
James Yang61f17812008-01-16 11:58:08 -0600545 /*
546 * Shouldn't be reached.
547 */
Haiying Wang57b6e9c2007-01-22 12:37:30 -0600548 return 0;
549}
550
551
552U_BOOT_CMD(
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200553 pixis_reset, CONFIG_SYS_MAXARGS, 1, pixis_reset_cmd,
Peter Tyserdfb72b82009-01-27 18:03:12 -0600554 "Reset the board using the FPGA sequencer",
Haiying Wang57b6e9c2007-01-22 12:37:30 -0600555 " pixis_reset\n"
556 " pixis_reset [altbank]\n"
557 " pixis_reset altbank wd\n"
558 " pixis_reset altbank cf <SYSCLK freq> <COREPLL ratio> <MPXPLL ratio>\n"
Wolfgang Denkc54781c2009-05-24 17:06:54 +0200559 " pixis_reset cf <SYSCLK freq> <COREPLL ratio> <MPXPLL ratio>"
560);