blob: 98560159fe34694c02435153a8c2df4d2ca43da9 [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>
Wolfgang Denkffcf5992009-03-28 20:16:16 +010019#include <net.h>
wdenke58b0dc2003-07-27 00:21:01 +000020
wdenke58b0dc2003-07-27 00:21:01 +000021#include <lynxkdi.h>
22
Wolfgang Denk6405a152006-03-31 18:32:53 +020023DECLARE_GLOBAL_DATA_PTR;
24
Heiko Schocher71cb3e92017-06-07 17:33:10 +020025#if defined(CONFIG_440EP) || defined(CONFIG_440GR)
Stephen Warren6904b6e2011-10-18 11:11:49 +000026void lynxkdi_boot(image_header_t *hdr)
wdenke58b0dc2003-07-27 00:21:01 +000027{
Stephen Warren6904b6e2011-10-18 11:11:49 +000028 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;
Stephen Warren6904b6e2011-10-18 11:11:49 +000031 u32 *psz = (u32 *)(image_get_load(hdr) + 0x0204);
wdenke58b0dc2003-07-27 00:21:01 +000032
Stephen Warren6904b6e2011-10-18 11:11:49 +000033 memset(parms, 0, sizeof(*parms));
wdenke58b0dc2003-07-27 00:21:01 +000034 kbd = gd->bd;
35 parms->clock_ref = kbd->bi_busfreq;
36 parms->dramsz = kbd->bi_memsize;
Mike Frysinger84d03e52009-02-11 18:54:07 -050037 eth_getenv_enetaddr("ethaddr", parms->ethaddr);
Stephen Warren6904b6e2011-10-18 11:11:49 +000038 mtspr(SPRN_SPRG2, 0x0020);
wdenke58b0dc2003-07-27 00:21:01 +000039
40 /* Do a simple check for Bluecat so we can pass the
41 * kernel command line parameters.
42 */
Stephen Warren6904b6e2011-10-18 11:11:49 +000043 /* FIXME: NOT SURE HERE ! */
44 if (le32_to_cpu(*psz) == image_get_data_size(hdr)) {
Marian Balakowicz2df645e2008-01-08 18:17:10 +010045 char *args;
Stephen Warren6904b6e2011-10-18 11:11:49 +000046 char *cmdline = (char *)(image_get_load(hdr) + 0x020c);
Marian Balakowicz2df645e2008-01-08 18:17:10 +010047 int len;
wdenke58b0dc2003-07-27 00:21:01 +000048
Stephen Warren6904b6e2011-10-18 11:11:49 +000049 printf("Booting Bluecat KDI ...\n");
50 udelay(200*1000); /* Allow serial port to flush */
51 if ((args = getenv("bootargs")) == NULL)
Marian Balakowicz2df645e2008-01-08 18:17:10 +010052 args = "";
53 /* Prepend the cmdline */
Stephen Warren6904b6e2011-10-18 11:11:49 +000054 len = strlen(args);
55 if (len && (len + strlen(cmdline) + 2 < (0x0400 - 0x020c))) {
56 memmove(cmdline + strlen(args) + 1, cmdline,
57 strlen(cmdline));
58 strcpy(cmdline, args);
Marian Balakowicz2df645e2008-01-08 18:17:10 +010059 cmdline[len] = ' ';
60 }
wdenke58b0dc2003-07-27 00:21:01 +000061 }
62 else {
Stephen Warren6904b6e2011-10-18 11:11:49 +000063 printf("Booting LynxOS KDI ...\n");
wdenke58b0dc2003-07-27 00:21:01 +000064 }
65
Stephen Warren6904b6e2011-10-18 11:11:49 +000066 lynxkdi();
wdenke58b0dc2003-07-27 00:21:01 +000067}
68#else
69#error "Lynx KDI support not implemented for configured CPU"
70#endif