Enable 'touchscreen areas' on the D2, based on JdGordon's m:robe code. Disable the...
[Rockbox.git] / bootloader / telechips.c
blob666657565dde47393a40628e91d81d7355b113ff
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2007 by Dave Chapman
12 * Based on Rockbox iriver bootloader by Linus Nielsen Feltzing
14 * All files in this archive are subject to the GNU General Public License.
15 * See the file COPYING in the source tree root for full license agreement.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
21 #include "config.h"
23 #include <stdlib.h>
24 #include <stdio.h>
25 #include <string.h>
26 #include "cpu.h"
27 #include "system.h"
28 #include "lcd.h"
29 #include "kernel.h"
30 #include "thread.h"
31 #include "ata.h"
32 #include "fat.h"
33 #include "disk.h"
34 #include "font.h"
35 #include "button.h"
36 #include "adc.h"
37 #include "adc-target.h"
38 #include "backlight.h"
39 #include "backlight-target.h"
40 #include "panic.h"
41 #include "power.h"
42 #include "file.h"
43 #include "common.h"
45 #if defined(COWON_D2)
46 #include "pcf50606.h"
47 #define LOAD_ADDRESS 0x20000000 /* DRAM_START */
48 #endif
50 char version[] = APPSVERSION;
52 extern int line;
54 #define MAX_LOAD_SIZE (8*1024*1024) /* Arbitrary, but plenty. */
56 void show_debug_screen(void)
58 int button;
59 int power_count = 0;
60 int count = 0;
61 bool do_power_off = false;
62 #ifdef HAVE_BUTTON_DATA
63 unsigned int data;
64 #endif
66 while(!do_power_off) {
67 line = 0;
68 printf("Hello World!");
70 #ifdef HAVE_BUTTON_DATA
71 button = button_read_device(&data);
72 #else
73 button = button_read_device();
74 #endif
76 /* Power-off if POWER button has been held for a long time
77 This loop is currently running at about 100 iterations/second
79 if (button & POWEROFF_BUTTON) {
80 power_count++;
81 if (power_count > 200)
82 do_power_off = true;
83 } else {
84 power_count = 0;
87 printf("Btn: 0x%08x",button);
89 count++;
90 printf("Count: %d",count);
93 lcd_clear_display();
94 line = 0;
95 printf("POWER-OFF");
97 /* Power-off */
98 power_off();
100 printf("(NOT) POWERED OFF");
101 while (true);
105 void* main(void)
107 #if defined(COWON_D2) && defined(TCCBOOT)
108 int rc;
109 unsigned char* loadbuffer = (unsigned char*)LOAD_ADDRESS;
110 #endif
112 power_init();
113 system_init();
114 lcd_init();
116 adc_init();
117 button_init();
118 backlight_init();
120 font_init();
121 lcd_setfont(FONT_SYSFIXED);
123 _backlight_on();
125 /* Only load the firmware if TCCBOOT is defined - this ensures SDRAM_START is
126 available for loading the firmware. Otherwise display the debug screen. */
127 #if defined(COWON_D2) && defined(TCCBOOT)
128 printf("Rockbox boot loader");
129 printf("Version %s", version);
131 printf("ATA");
132 rc = ata_init();
133 if(rc)
135 reset_screen();
136 error(EATA, rc);
139 printf("mount");
140 rc = disk_mount_all();
141 if (rc<=0)
143 error(EDISK,rc);
146 rc = load_firmware(loadbuffer, BOOTFILE, MAX_LOAD_SIZE);
148 if (rc < 0)
150 error(EBOOTFILE,rc);
152 else if (rc == EOK)
154 int(*kernel_entry)(void);
156 kernel_entry = (void*) loadbuffer;
157 rc = kernel_entry();
159 #else
160 show_debug_screen();
161 #endif
163 return 0;
166 /* These functions are present in the firmware library, but we reimplement
167 them here because the originals do a lot more than we want */
168 void usb_acknowledge(void)
172 void usb_wait_for_disconnect(void)