2 //==========================================================================
6 // OMAP1510DC EVM [platform] specific RedBoot commands
8 //==========================================================================
9 //####ECOSGPLCOPYRIGHTBEGIN####
10 // -------------------------------------------
11 // This file is part of eCos, the Embedded Configurable Operating System.
12 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
14 // eCos is free software; you can redistribute it and/or modify it under
15 // the terms of the GNU General Public License as published by the Free
16 // Software Foundation; either version 2 or (at your option) any later version.
18 // eCos is distributed in the hope that it will be useful, but WITHOUT ANY
19 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
23 // You should have received a copy of the GNU General Public License along
24 // with eCos; if not, write to the Free Software Foundation, Inc.,
25 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
27 // As a special exception, if other files instantiate templates or use macros
28 // or inline functions from this file, or you compile this file and link it
29 // with other works to produce a work based on this file, this file does not
30 // by itself cause the resulting work to be covered by the GNU General Public
31 // License. However the source code for this file must still be made available
32 // in accordance with section (3) of the GNU General Public License.
34 // This exception does not invalidate any other reasons why a work based on
35 // this file might be covered by the GNU General Public License.
37 // Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
38 // at http://sources.redhat.com/ecos/ecos-license/
39 // -------------------------------------------
40 //####ECOSGPLCOPYRIGHTEND####
41 //==========================================================================
42 //#####DESCRIPTIONBEGIN####
44 // Author(s): Patrick Doyle <wpd@delcomsys.com>
45 // Contributors: Patrick Doyle <wpd@delcomsys.com>
50 // This code is part of RedBoot (tm). It was modified from "redboot_cmds"
51 // for the iPaq by wpd in order to add some platform specific commands to
52 // the OMAP1510DC EVM platform.
54 //####DESCRIPTIONEND####
56 //==========================================================================
60 #include <cyg/hal/hal_intr.h>
61 #include <cyg/hal/hal_cache.h>
62 #include <cyg/hal/hal_io.h>
63 #include <cyg/hal/hal_diag.h>
64 #include <cyg/hal/innovator.h>
66 static void do_mem(int argc, char *argv[]);
67 static void do_try_reset(int argc, char *argv[]);
68 static void do_testsdram(int argc, char *argv[]);
69 static void do_delay(int argc, char *argv[]);
72 "Set a memory location",
73 "[-h|-b] [-n] [-a <address>] <data>",
77 RedBoot_cmd("try_reset",
78 "try to reset the platform",
84 RedBoot_cmd("testsdram",
85 "test SDRAM (very simply)",
91 "delay specified number of usecs",
101 struct option_info opts[4];
102 bool mem_half_word, mem_byte;
103 bool no_verify = false;
104 static int address = 0x00000000;
106 init_opts(&opts[0], 'b', false, OPTION_ARG_TYPE_FLG,
107 (void**)&mem_byte, 0, "write a byte");
108 init_opts(&opts[1], 'h', false, OPTION_ARG_TYPE_FLG,
109 (void**)&mem_half_word, 0, "write a half-word");
110 init_opts(&opts[2], 'a', true, OPTION_ARG_TYPE_NUM,
111 (void**)&address, NULL, "address to write at");
112 init_opts(&opts[3], 'n', false, OPTION_ARG_TYPE_FLG,
113 (void**)&no_verify, 0, "noverify");
115 if (!scan_opts(argc, argv,
117 opts, sizeof(opts) / sizeof(opts[0]),
118 (void*)&value, OPTION_ARG_TYPE_NUM, "address to set")) {
122 if ( mem_byte && mem_half_word ) {
123 diag_printf("*ERR: Should not specify both byte and half-word access\n");
124 } else if ( mem_byte ) {
125 *(cyg_uint8*)address = (cyg_uint8)(value & 255);
127 diag_printf(" Set 0x%08X to 0x%02X\n",
128 address, value & 255);
130 diag_printf(" Set 0x%08X to 0x%02X (result 0x%02X)\n",
131 address, value & 255, (int)*(cyg_uint8*)address );
133 } else if ( mem_half_word ) {
135 diag_printf( "*ERR: Badly aligned address 0x%08X for half-word store\n",
138 *(cyg_uint16*)address = (cyg_uint16)(value & 0xffff);
140 diag_printf(" Set 0x%08X to 0x%04X\n",
141 address, value & 0xffff);
143 diag_printf(" Set 0x%08X to 0x%04X (result 0x%04X)\n",
144 address, value & 0xffff, (int)*(cyg_uint16*)address );
149 diag_printf( "*ERR: Badly aligned address 0x%08X for word store\n",
152 *(cyg_uint32*)address = (cyg_uint32)value;
154 diag_printf(" Set 0x%08X to 0x%08X\n",
157 diag_printf(" Set 0x%08X to 0x%08X (result 0x%08X)\n",
158 address, value, (int)*(cyg_uint32*)address );
165 do_try_reset(int argc,
168 struct option_info opts[4];
176 init_opts(&opts[0], '1', false, OPTION_ARG_TYPE_FLG,
177 (void**)&flag_1, 0, "only try phase 1");
178 init_opts(&opts[1], '2', false, OPTION_ARG_TYPE_FLG,
179 (void**)&flag_2, 0, "try phase 1 & phase 2");
180 init_opts(&opts[2], '3', false, OPTION_ARG_TYPE_FLG,
181 (void**)&flag_3, 0, "try phase 1 through phase 3");
182 init_opts(&opts[3], '4', false, OPTION_ARG_TYPE_FLG,
183 (void**)&flag_4, 0, "try phase 1 through phase 4");
185 if (!scan_opts(argc, argv,
187 opts, sizeof(opts) / sizeof(opts[0]),
191 diag_printf("flag_4 = %d, flag_3 = %d, flag_2 = %d, flag_1 = %d\n",
192 flag_4, flag_3, flag_2, flag_1);
194 flag_3 = flag_2 = flag_1 = true;
196 flag_2 = flag_1 = true;
200 diag_printf("flag_4 = %d, flag_3 = %d, flag_2 = %d, flag_1 = %d\n",
201 flag_4, flag_3, flag_2, flag_1);
204 HAL_READ_UINT16(CLKM_ARM_IDLECT2, tmp);
205 diag_printf("tmp = %04X\n", tmp);
210 diag_printf("Writing %04X to %08X\n", tmp, CLKM_ARM_IDLECT2);
211 HAL_WRITE_UINT16(CLKM_ARM_IDLECT2, tmp | 1);
215 diag_printf("Writing %04X to %08X\n", 0x80F5, WATCHDOG_TIMER_MODE);
216 HAL_WRITE_UINT16(WATCHDOG_TIMER_MODE, 0x80F5); \
220 diag_printf("Writing %04X to %08X\n", 0x80F5, WATCHDOG_TIMER_MODE);
221 HAL_WRITE_UINT16(WATCHDOG_TIMER_MODE, 0x80F5); \
224 diag_printf("try_reset: done\n");
227 #define SDRAM_BASE 0x10000000
228 #define SDRAM_LEN (32*1024*1024) /* 32 Mbytes */
230 do_testsdram(int argc,
233 cyg_uint32 *mem_addr = (cyg_uint32 *)SDRAM_BASE;
238 struct option_info opts[1];
240 init_opts(&opts[0], 'l', true, OPTION_ARG_TYPE_NUM,
241 (void**)&len, &len_set, "length");
243 if (!scan_opts(argc, argv,
253 diag_printf("Length = 0x%08X\n", len);
255 diag_printf("Writing data-equals-address pattern to SDRAM\n");
256 for (i = 0; i < len; i++) {
257 mem_addr[i] = ~(cyg_uint32)(mem_addr + i);
259 diag_printf("Reading back pattern\n");
260 for (i = 0; i < len; i++) {
261 if (mem_addr[i] != ~(cyg_uint32)(mem_addr + i)) {
262 diag_printf("Error: mismatch at address %p, read back 0x%08x\n",
268 diag_printf("Done\n");
275 struct option_info opts[1];
276 int count = 0x00000000;
281 init_opts(&opts[0], 'c', true, OPTION_ARG_TYPE_NUM,
282 (void**)&count, &count_set, "Number of times to delay");
284 if (!scan_opts(argc, argv,
286 opts, sizeof(opts) / sizeof(opts[0]),
287 (void*)&value, OPTION_ARG_TYPE_NUM, "amount of time to delay (usec)")) {
294 for (i = 0; i < count; i++) {
295 diag_printf("Delaying %d useconds...", value);
297 diag_printf("Done\n");