We have a 3.9 release, update builds.pm
[maemo-rb.git] / bootloader / imx233.c
blob85a545b5233e5815e9126d7a26f90d7f90aaa220
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2011 by amaury Pouly
12 * Based on Rockbox iriver bootloader by Linus Nielsen Feltzing
13 * and the ipodlinux bootloader by Daniel Palffy and Bernard Leach
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation; either version 2
18 * of the License, or (at your option) any later version.
20 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 * KIND, either express or implied.
23 ****************************************************************************/
25 #include <stdio.h>
26 #include <system.h>
27 #include <inttypes.h>
28 #include "config.h"
29 #include "gcc_extensions.h"
30 #include "lcd.h"
31 #include "backlight.h"
32 #include "button-target.h"
33 #include "common.h"
34 #include "storage.h"
35 #include "disk.h"
36 #include "panic.h"
37 #include "power.h"
38 #include "pinctrl-imx233.h"
39 #include "system-target.h"
40 #include "ssp-imx233.h"
42 #include "usb.h"
44 int show_logo(void);
46 void main(void) NORETURN_ATTR;
47 void main(void)
49 unsigned char* loadbuffer;
50 int buffer_size;
51 void(*kernel_entry)(void);
52 int ret;
54 system_init();
55 kernel_init();
57 enable_irq();
59 lcd_init();
60 show_logo();
62 backlight_init();
64 button_init_device();
66 //button_debug_screen();
68 #if 0
69 usb_init();
70 usb_start_monitoring();
71 extern int usb_status;
72 usb_status = USB_INSERTED;
73 usb_status_event(USB_POWERED);
75 printf("USB: Connecting");
77 while(1)
79 int button = button_get_w_tmo(HZ/25);
81 if(button == SYS_USB_CONNECTED)
82 break; /* Hit */
83 if(button_read_device() & BUTTON_POWER)
84 power_off();
85 yield();
88 printf("USB: Connected");
89 while(1)
91 int button = button_get_w_tmo(HZ/25);
93 if(button_read_device() & BUTTON_POWER)
94 power_off();
95 yield();
97 #endif
99 ret = storage_init();
100 if(ret < 0)
101 error(EATA, ret, true);
103 while(!disk_init(IF_MV(0)))
104 panicf("disk_init failed!");
106 while((ret = disk_mount_all()) <= 0)
108 error(EDISK, ret, true);
111 printf("Loading firmware");
113 loadbuffer = (unsigned char*)DRAM_ORIG; /* DRAM */
114 buffer_size = (int)(loadbuffer + DRAM_SIZE - TTB_SIZE);
116 while((ret = load_firmware(loadbuffer, BOOTFILE, buffer_size)) < 0)
118 error(EBOOTFILE, ret, true);
121 kernel_entry = (void*) loadbuffer;
122 //cpucache_invalidate();
123 printf("Executing");
124 kernel_entry();
125 printf("ERR: Failed to boot");
127 /* never returns */
128 while(1) ;