blob: 5644d589e7609c0bea09239f89692ca15a391b57 [file] [log] [blame]
Wolfgang Denk6cb142f2006-03-12 02:12:27 +01001/*
Mike Frysinger81b799a2008-08-07 15:27:52 -04002 * U-boot - boot.c - misc boot helper functions
Wolfgang Denk6cb142f2006-03-12 02:12:27 +01003 *
Mike Frysinger9171fc82008-03-30 15:46:13 -04004 * Copyright (c) 2005-2008 Analog Devices Inc.
Wolfgang Denk6cb142f2006-03-12 02:12:27 +01005 *
6 * (C) Copyright 2000-2004
7 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
8 *
Mike Frysinger9171fc82008-03-30 15:46:13 -04009 * Licensed under the GPL-2 or later.
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010010 */
11
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010012#include <common.h>
13#include <command.h>
14#include <image.h>
Mike Frysinger9171fc82008-03-30 15:46:13 -040015#include <asm/blackfin.h>
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010016
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010017#ifdef SHARED_RESOURCES
Aubrey.Li3f0606a2007-03-09 13:38:44 +080018extern void swap_to(int device_id);
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010019#endif
20
Michael Hennerich5fc564e2009-08-07 02:47:54 +000021#ifdef CONFIG_VIDEO
22extern void video_stop(void);
23#endif
24
Mike Frysinger9171fc82008-03-30 15:46:13 -040025static char *make_command_line(void)
26{
Mike Frysinger36cd52a2008-08-07 15:24:59 -040027 char *dest = (char *)CONFIG_LINUX_CMDLINE_ADDR;
Mike Frysinger9171fc82008-03-30 15:46:13 -040028 char *bootargs = getenv("bootargs");
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010029
Mike Frysinger9171fc82008-03-30 15:46:13 -040030 if (bootargs == NULL)
31 return NULL;
32
Mike Frysinger36cd52a2008-08-07 15:24:59 -040033 strncpy(dest, bootargs, CONFIG_LINUX_CMDLINE_SIZE);
34 dest[CONFIG_LINUX_CMDLINE_SIZE - 1] = 0;
Mike Frysinger9171fc82008-03-30 15:46:13 -040035 return dest;
36}
37
Mike Frysingerb1e94352008-10-11 21:44:00 -040038extern ulong bfin_poweron_retx;
39
Wolfgang Denk54841ab2010-06-28 22:00:46 +020040int do_bootm_linux(int flag, int argc, char * const argv[], bootm_headers_t *images)
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010041{
Marian Balakowiczd5934ad2008-02-04 08:28:09 +010042 int (*appl) (char *cmdline);
43 char *cmdline;
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010044
Simon Glass7af26b12013-07-10 23:08:09 -070045 if (flag & BOOTM_STATE_OS_PREP)
46 return 0;
Kumar Gala49c3a862008-10-21 17:25:45 -050047 if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
48 return 1;
49
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010050#ifdef SHARED_RESOURCES
51 swap_to(FLASH);
52#endif
53
Michael Hennerich5fc564e2009-08-07 02:47:54 +000054#ifdef CONFIG_VIDEO
55 /* maybe this should be standardized and moved to bootm ... */
56 video_stop();
57#endif
58
Kumar Galac160a952008-08-15 08:24:36 -050059 appl = (int (*)(char *))images->ep;
Marian Balakowiczd5934ad2008-02-04 08:28:09 +010060
Mike Frysingerfe033ad2008-10-12 06:02:55 -040061 printf("Starting Kernel at = %p\n", appl);
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010062 cmdline = make_command_line();
Mike Frysinger9171fc82008-03-30 15:46:13 -040063 icache_disable();
64 dcache_disable();
Mike Frysingerb1e94352008-10-11 21:44:00 -040065 asm __volatile__(
66 "RETX = %[retx];"
67 "CALL (%0);"
68 :
69 : "p"(appl), "q0"(cmdline), [retx] "d"(bfin_poweron_retx)
70 );
Marian Balakowiczcd7c5962008-03-12 10:33:00 +010071 /* does not return */
Jean-Christophe PLAGNIOL-VILLARDa3a08c02008-09-10 22:48:09 +020072
Kumar Gala40d7e992008-08-15 08:24:45 -050073 return 1;
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010074}