blob: 16dc96886506da08d5f1df732c52808910e1eb01 [file] [log] [blame]
wdenke58b0dc2003-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
20#if defined(CONFIG_LYNXKDI)
21#include <lynxkdi.h>
22
Wolfgang Denk6405a152006-03-31 18:32:53 +020023DECLARE_GLOBAL_DATA_PTR;
24
Stefan Roeseb30f2a12005-08-08 12:42:22 +020025#if defined(CONFIG_MPC8260) || defined(CONFIG_440EP) || defined(CONFIG_440GR)
wdenke58b0dc2003-07-27 00:21:01 +000026void lynxkdi_boot ( image_header_t *hdr )
27{
Marian Balakowicz41d71ed2008-01-08 18:14:09 +010028 void (*lynxkdi)(void) = (void(*)(void))image_get_ep (hdr);
wdenke58b0dc2003-07-27 00:21:01 +000029 lynxos_bootparms_t *parms = (lynxos_bootparms_t *)0x0020;
30 bd_t *kbd;
Marian Balakowicz41d71ed2008-01-08 18:14:09 +010031 u32 *psz = (u32 *)(image_get_load (hdr) + 0x0204);
wdenke58b0dc2003-07-27 00:21:01 +000032
33 memset( parms, 0, sizeof(*parms));
34 kbd = gd->bd;
35 parms->clock_ref = kbd->bi_busfreq;
36 parms->dramsz = kbd->bi_memsize;
37 memcpy(parms->ethaddr, kbd->bi_enetaddr, 6);
38 mtspr(SPRN_SPRG2, 0x0020);
39
40 /* Do a simple check for Bluecat so we can pass the
41 * kernel command line parameters.
42 */
Marian Balakowicz41d71ed2008-01-08 18:14:09 +010043 if( le32_to_cpu(*psz) == image_get_data_size (hdr) ){ /* FIXME: NOT SURE HERE ! */
wdenke58b0dc2003-07-27 00:21:01 +000044 char *args;
Marian Balakowicz41d71ed2008-01-08 18:14:09 +010045 char *cmdline = (char *)(image_get_load (hdr) + 0x020c);
wdenke58b0dc2003-07-27 00:21:01 +000046 int len;
47
48 printf("Booting Bluecat KDI ...\n");
49 udelay(200*1000); /* Allow serial port to flush */
50 if ((args = getenv("bootargs")) == NULL)
51 args = "";
52 /* Prepend the cmdline */
53 len = strlen(args);
54 if( len && (len + strlen(cmdline) + 2 < (0x0400 - 0x020c))) {
55 memmove( cmdline + strlen(args) + 1, cmdline, strlen(cmdline) );
56 strcpy( cmdline, args );
57 cmdline[len] = ' ';
58 }
59 }
60 else {
61 printf("Booting LynxOS KDI ...\n");
62 }
63
64 lynxkdi();
65}
66#else
67#error "Lynx KDI support not implemented for configured CPU"
68#endif
69
70#endif /* CONFIG_LYNXKDI */