blob: 5f12b0dc176854ba54f144dcd92b2cc14c62d8a7 [file] [log] [blame]
wdenk1f4bb372003-07-27 00:21:01 +00001/*
2 * Copyright (c) Orbacom Systems, Inc <www.orbacom.com>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms are freely
6 * permitted provided that the above copyright notice and this
7 * paragraph and the following disclaimer are duplicated in all
8 * such forms.
9 *
10 * This software is provided "AS IS" and without any express or
11 * implied warranties, including, without limitation, the implied
12 * warranties of merchantability and fitness for a particular
13 * purpose.
14 */
15
16#include <common.h>
17#include <asm/processor.h>
18#include <image.h>
19
wdenk1f4bb372003-07-27 00:21:01 +000020#include <lynxkdi.h>
21
Wolfgang Denkd87080b2006-03-31 18:32:53 +020022DECLARE_GLOBAL_DATA_PTR;
23
Stefan Roese846b0dd2005-08-08 12:42:22 +020024#if defined(CONFIG_MPC8260) || defined(CONFIG_440EP) || defined(CONFIG_440GR)
Marian Balakowicz1ee11802008-01-08 18:17:10 +010025void lynxkdi_boot (image_header_t *hdr)
wdenk1f4bb372003-07-27 00:21:01 +000026{
Marian Balakowiczb97a2a02008-01-08 18:14:09 +010027 void (*lynxkdi)(void) = (void(*)(void))image_get_ep (hdr);
wdenk1f4bb372003-07-27 00:21:01 +000028 lynxos_bootparms_t *parms = (lynxos_bootparms_t *)0x0020;
29 bd_t *kbd;
Marian Balakowiczb97a2a02008-01-08 18:14:09 +010030 u32 *psz = (u32 *)(image_get_load (hdr) + 0x0204);
wdenk1f4bb372003-07-27 00:21:01 +000031
Marian Balakowicz1ee11802008-01-08 18:17:10 +010032 memset (parms, 0, sizeof(*parms));
wdenk1f4bb372003-07-27 00:21:01 +000033 kbd = gd->bd;
34 parms->clock_ref = kbd->bi_busfreq;
35 parms->dramsz = kbd->bi_memsize;
Marian Balakowicz1ee11802008-01-08 18:17:10 +010036 memcpy (parms->ethaddr, kbd->bi_enetaddr, 6);
37 mtspr (SPRN_SPRG2, 0x0020);
wdenk1f4bb372003-07-27 00:21:01 +000038
39 /* Do a simple check for Bluecat so we can pass the
40 * kernel command line parameters.
41 */
Marian Balakowicz1ee11802008-01-08 18:17:10 +010042 if (le32_to_cpu (*psz) == image_get_data_size (hdr)) { /* FIXME: NOT SURE HERE ! */
43 char *args;
44 char *cmdline = (char *)(image_get_load (hdr) + 0x020c);
45 int len;
wdenk1f4bb372003-07-27 00:21:01 +000046
Marian Balakowicz1ee11802008-01-08 18:17:10 +010047 printf ("Booting Bluecat KDI ...\n");
48 udelay (200*1000); /* Allow serial port to flush */
49 if ((args = getenv ("bootargs")) == NULL)
50 args = "";
51 /* Prepend the cmdline */
52 len = strlen (args);
53 if (len && (len + strlen (cmdline) + 2 < (0x0400 - 0x020c))) {
54 memmove (cmdline + strlen (args) + 1, cmdline, strlen (cmdline));
55 strcpy (cmdline, args);
56 cmdline[len] = ' ';
57 }
wdenk1f4bb372003-07-27 00:21:01 +000058 }
59 else {
Marian Balakowicz1ee11802008-01-08 18:17:10 +010060 printf ("Booting LynxOS KDI ...\n");
wdenk1f4bb372003-07-27 00:21:01 +000061 }
62
Marian Balakowicz1ee11802008-01-08 18:17:10 +010063 lynxkdi ();
wdenk1f4bb372003-07-27 00:21:01 +000064}
65#else
66#error "Lynx KDI support not implemented for configured CPU"
67#endif