Maurus Cuelenaere | 0709f0a | 2008-07-14 15:03:10 +0000 | [diff] [blame] | 1 | /*************************************************************************** |
| 2 | * __________ __ ___. |
| 3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
| 4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
| 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
| 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
| 7 | * \/ \/ \/ \/ \/ |
| 8 | * $Id$ |
| 9 | * |
| 10 | * Copyright (C) 2008 by Maurus Cuelenaere |
| 11 | * |
| 12 | * This program is free software; you can redistribute it and/or |
| 13 | * modify it under the terms of the GNU General Public License |
| 14 | * as published by the Free Software Foundation; either version 2 |
| 15 | * of the License, or (at your option) any later version. |
| 16 | * |
| 17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
| 18 | * KIND, either express or implied. |
| 19 | * |
| 20 | ****************************************************************************/ |
| 21 | |
| 22 | #include <stdio.h> |
| 23 | #include <stdarg.h> |
Maurus Cuelenaere | 0709f0a | 2008-07-14 15:03:10 +0000 | [diff] [blame] | 24 | #include "config.h" |
| 25 | #include "jz4740.h" |
| 26 | #include "backlight.h" |
| 27 | #include "font.h" |
| 28 | #include "lcd.h" |
| 29 | #include "system.h" |
Maurus Cuelenaere | 0709f0a | 2008-07-14 15:03:10 +0000 | [diff] [blame] | 30 | #include "button.h" |
Maurus Cuelenaere | ea9d107 | 2008-07-15 17:20:07 +0000 | [diff] [blame] | 31 | #include "timefuncs.h" |
| 32 | #include "rtc.h" |
Maurus Cuelenaere | 975261f | 2008-07-16 15:25:35 +0000 | [diff] [blame] | 33 | #include "common.h" |
Maurus Cuelenaere | 1f692e5 | 2008-07-17 10:13:56 +0000 | [diff] [blame] | 34 | #include "mipsregs.h" |
Maurus Cuelenaere | 0709f0a | 2008-07-14 15:03:10 +0000 | [diff] [blame] | 35 | |
Maurus Cuelenaere | ea9d107 | 2008-07-15 17:20:07 +0000 | [diff] [blame] | 36 | static void audiotest(void) |
Maurus Cuelenaere | 0709f0a | 2008-07-14 15:03:10 +0000 | [diff] [blame] | 37 | { |
| 38 | __i2s_internal_codec(); |
| 39 | __aic_enable(); |
| 40 | __aic_reset(); |
| 41 | __aic_select_i2s(); |
| 42 | __aic_enable_loopback(); |
| 43 | } |
| 44 | |
Maurus Cuelenaere | 0709f0a | 2008-07-14 15:03:10 +0000 | [diff] [blame] | 45 | int main(void) |
Maurus Cuelenaere | 4bf4d2b | 2008-08-10 21:44:48 +0000 | [diff] [blame] | 46 | { |
Maurus Cuelenaere | 0709f0a | 2008-07-14 15:03:10 +0000 | [diff] [blame] | 47 | kernel_init(); |
| 48 | lcd_init(); |
| 49 | font_init(); |
| 50 | lcd_setfont(FONT_SYSFIXED); |
| 51 | button_init(); |
Maurus Cuelenaere | ea9d107 | 2008-07-15 17:20:07 +0000 | [diff] [blame] | 52 | rtc_init(); |
Maurus Cuelenaere | 62c4a28 | 2008-08-26 21:48:49 +0000 | [diff] [blame] | 53 | usb_init(); |
Maurus Cuelenaere | 0709f0a | 2008-07-14 15:03:10 +0000 | [diff] [blame] | 54 | |
| 55 | backlight_init(); |
| 56 | |
Frank Gevaerts | 2f8a008 | 2008-11-01 16:14:28 +0000 | [diff] [blame] | 57 | storage_init(); |
Maurus Cuelenaere | 0709f0a | 2008-07-14 15:03:10 +0000 | [diff] [blame] | 58 | |
Maurus Cuelenaere | ea9d107 | 2008-07-15 17:20:07 +0000 | [diff] [blame] | 59 | int touch, btn; |
Maurus Cuelenaere | 1f692e5 | 2008-07-17 10:13:56 +0000 | [diff] [blame] | 60 | char datetime[30]; |
| 61 | reset_screen(); |
Maurus Cuelenaere | 975261f | 2008-07-16 15:25:35 +0000 | [diff] [blame] | 62 | printf("Rockbox bootloader v0.000001"); |
Maurus Cuelenaere | 88ae902 | 2008-08-06 20:39:02 +0000 | [diff] [blame] | 63 | printf("REG_EMC_SACR0: 0x%x", REG_EMC_SACR0); |
| 64 | printf("REG_EMC_SACR1: 0x%x", REG_EMC_SACR1); |
| 65 | printf("REG_EMC_SACR2: 0x%x", REG_EMC_SACR2); |
| 66 | printf("REG_EMC_SACR3: 0x%x", REG_EMC_SACR3); |
| 67 | printf("REG_EMC_SACR4: 0x%x", REG_EMC_SACR4); |
| 68 | printf("REG_EMC_DMAR0: 0x%x", REG_EMC_DMAR0); |
Maurus Cuelenaere | 1f692e5 | 2008-07-17 10:13:56 +0000 | [diff] [blame] | 69 | unsigned int cpu_id = read_c0_prid(); |
Maurus Cuelenaere | 06efd07 | 2008-07-30 10:24:39 +0000 | [diff] [blame] | 70 | printf("CPU_ID: 0x%x", cpu_id); |
Maurus Cuelenaere | 1f692e5 | 2008-07-17 10:13:56 +0000 | [diff] [blame] | 71 | printf(" * Company ID: 0x%x", (cpu_id >> 16) & 7); |
| 72 | printf(" * Processor ID: 0x%x", (cpu_id >> 8) & 7); |
| 73 | printf(" * Revision ID: 0x%x", cpu_id & 7); |
Maurus Cuelenaere | 06efd07 | 2008-07-30 10:24:39 +0000 | [diff] [blame] | 74 | unsigned int config_data = read_c0_config(); |
| 75 | printf("C0_CONFIG: 0x%x", config_data); |
| 76 | printf(" * Architecture type: 0x%x", (config_data >> 13) & 3); |
| 77 | printf(" * Architecture revision: 0x%x", (config_data >> 10) & 7); |
| 78 | printf(" * MMU type: 0x%x", (config_data >> 7) & 7); |
| 79 | printf("C0_CONFIG1: 0x%x", read_c0_config1()); |
| 80 | if(read_c0_config1() & (1 << 0)) printf(" * FP available"); |
| 81 | if(read_c0_config1() & (1 << 1)) printf(" * EJTAG available"); |
| 82 | if(read_c0_config1() & (1 << 2)) printf(" * MIPS-16 available"); |
| 83 | if(read_c0_config1() & (1 << 4)) printf(" * Performace counters available"); |
| 84 | if(read_c0_config1() & (1 << 5)) printf(" * MDMX available"); |
| 85 | if(read_c0_config1() & (1 << 6)) printf(" * CP2 available"); |
| 86 | printf("C0_STATUS: 0x%x", read_c0_status()); |
Maurus Cuelenaere | 62c4a28 | 2008-08-26 21:48:49 +0000 | [diff] [blame] | 87 | |
| 88 | #if 0 |
| 89 | unsigned char testdata[4096]; |
Maurus Cuelenaere | 88ae902 | 2008-08-06 20:39:02 +0000 | [diff] [blame] | 90 | char msg[30]; |
Maurus Cuelenaere | 1e294e3 | 2008-09-14 16:26:08 +0000 | [diff] [blame] | 91 | int j = 1; |
Maurus Cuelenaere | 88ae902 | 2008-08-06 20:39:02 +0000 | [diff] [blame] | 92 | while(1) |
| 93 | { |
| 94 | memset(testdata, 0, 4096); |
Maurus Cuelenaere | 88ae902 | 2008-08-06 20:39:02 +0000 | [diff] [blame] | 95 | reset_screen(); |
Maurus Cuelenaere | 9407ae8 | 2008-09-17 21:44:47 +0000 | [diff] [blame] | 96 | jz_nand_read(0, j, &testdata); |
Maurus Cuelenaere | 88ae902 | 2008-08-06 20:39:02 +0000 | [diff] [blame] | 97 | printf("Page %d", j); |
| 98 | int i; |
Maurus Cuelenaere | 9407ae8 | 2008-09-17 21:44:47 +0000 | [diff] [blame] | 99 | for(i=0; i<768; i+=16) |
Maurus Cuelenaere | 88ae902 | 2008-08-06 20:39:02 +0000 | [diff] [blame] | 100 | { |
Maurus Cuelenaere | 9407ae8 | 2008-09-17 21:44:47 +0000 | [diff] [blame] | 101 | snprintf(msg, 30, "%02x%02x%02x%02x%02x%02x%02x%02x %02x%02x%02x%02x%02x%02x%02x%02x", |
| 102 | testdata[i], testdata[i+1], testdata[i+2], testdata[i+3], testdata[i+4], testdata[i+5], testdata[i+6], testdata[i+7], |
| 103 | testdata[i+8], testdata[i+9], testdata[i+10], testdata[i+11], testdata[i+12], testdata[i+13], testdata[i+14], testdata[i+15] |
| 104 | ); |
Maurus Cuelenaere | 88ae902 | 2008-08-06 20:39:02 +0000 | [diff] [blame] | 105 | printf(msg); |
| 106 | } |
| 107 | while(!((btn = button_read_device(&touch)) & (BUTTON_VOL_UP|BUTTON_VOL_DOWN))); |
| 108 | if(btn & BUTTON_VOL_UP) |
| 109 | j++; |
| 110 | if(btn & BUTTON_VOL_DOWN) |
| 111 | j--; |
| 112 | if(j<0) |
| 113 | j = 0; |
Maurus Cuelenaere | 62c4a28 | 2008-08-26 21:48:49 +0000 | [diff] [blame] | 114 | } |
| 115 | #endif |
Maurus Cuelenaere | 0709f0a | 2008-07-14 15:03:10 +0000 | [diff] [blame] | 116 | while(1) |
| 117 | { |
Maurus Cuelenaere | e144638 | 2008-09-05 15:09:40 +0000 | [diff] [blame] | 118 | #ifdef ONDA_VX747 |
Maurus Cuelenaere | 9407ae8 | 2008-09-17 21:44:47 +0000 | [diff] [blame] | 119 | #if 1 |
Maurus Cuelenaere | 1e294e3 | 2008-09-14 16:26:08 +0000 | [diff] [blame] | 120 | btn = button_get(false); |
| 121 | touch = button_get_data(); |
Maurus Cuelenaere | e144638 | 2008-09-05 15:09:40 +0000 | [diff] [blame] | 122 | #else |
Maurus Cuelenaere | 9407ae8 | 2008-09-17 21:44:47 +0000 | [diff] [blame] | 123 | btn = button_read_device(&touch); |
| 124 | #endif |
| 125 | #else |
Maurus Cuelenaere | e144638 | 2008-09-05 15:09:40 +0000 | [diff] [blame] | 126 | btn = button_read_device(); |
| 127 | #endif |
Maurus Cuelenaere | 06efd07 | 2008-07-30 10:24:39 +0000 | [diff] [blame] | 128 | #define KNOP(x,y) lcd_set_foreground(LCD_BLACK); \ |
| 129 | if(btn & x) \ |
| 130 | lcd_set_foreground(LCD_WHITE); \ |
Maurus Cuelenaere | 1e294e3 | 2008-09-14 16:26:08 +0000 | [diff] [blame] | 131 | lcd_putsxy(LCD_WIDTH-SYSFONT_WIDTH*strlen(#x), SYSFONT_HEIGHT*y, #x); |
| 132 | KNOP(BUTTON_VOL_UP, 0); |
| 133 | KNOP(BUTTON_VOL_DOWN, 1); |
| 134 | KNOP(BUTTON_MENU, 2); |
| 135 | KNOP(BUTTON_POWER, 3); |
Maurus Cuelenaere | 06efd07 | 2008-07-30 10:24:39 +0000 | [diff] [blame] | 136 | lcd_set_foreground(LCD_WHITE); |
Maurus Cuelenaere | ea9d107 | 2008-07-15 17:20:07 +0000 | [diff] [blame] | 137 | if(button_hold()) |
Maurus Cuelenaere | 1f692e5 | 2008-07-17 10:13:56 +0000 | [diff] [blame] | 138 | { |
Maurus Cuelenaere | 975261f | 2008-07-16 15:25:35 +0000 | [diff] [blame] | 139 | printf("BUTTON_HOLD"); |
Maurus Cuelenaere | 62c4a28 | 2008-08-26 21:48:49 +0000 | [diff] [blame] | 140 | asm("break 0x7"); |
| 141 | } |
Maurus Cuelenaere | 62c4a28 | 2008-08-26 21:48:49 +0000 | [diff] [blame] | 142 | if(btn & BUTTON_POWER) |
| 143 | { |
| 144 | power_off(); |
Maurus Cuelenaere | 1f692e5 | 2008-07-17 10:13:56 +0000 | [diff] [blame] | 145 | } |
Maurus Cuelenaere | e144638 | 2008-09-05 15:09:40 +0000 | [diff] [blame] | 146 | #ifdef ONDA_VX747 |
Maurus Cuelenaere | 06efd07 | 2008-07-30 10:24:39 +0000 | [diff] [blame] | 147 | if(btn & BUTTON_TOUCH) |
Maurus Cuelenaere | 975261f | 2008-07-16 15:25:35 +0000 | [diff] [blame] | 148 | { |
| 149 | lcd_set_foreground(LCD_RGBPACK(touch & 0xFF, (touch >> 8)&0xFF, (touch >> 16)&0xFF)); |
Maurus Cuelenaere | 1e294e3 | 2008-09-14 16:26:08 +0000 | [diff] [blame] | 150 | lcd_fillrect((touch>>16)-10, (touch&0xFFFF)-5, 10, 10); |
Maurus Cuelenaere | 975261f | 2008-07-16 15:25:35 +0000 | [diff] [blame] | 151 | lcd_update(); |
Maurus Cuelenaere | 1f692e5 | 2008-07-17 10:13:56 +0000 | [diff] [blame] | 152 | lcd_set_foreground(LCD_WHITE); |
Maurus Cuelenaere | 975261f | 2008-07-16 15:25:35 +0000 | [diff] [blame] | 153 | } |
Maurus Cuelenaere | e144638 | 2008-09-05 15:09:40 +0000 | [diff] [blame] | 154 | #endif |
Maurus Cuelenaere | 1f692e5 | 2008-07-17 10:13:56 +0000 | [diff] [blame] | 155 | snprintf(datetime, 30, "%02d/%02d/%04d %02d:%02d:%02d", get_time()->tm_mday, get_time()->tm_mon, get_time()->tm_year, |
| 156 | get_time()->tm_hour, get_time()->tm_min, get_time()->tm_sec); |
| 157 | lcd_putsxy(LCD_WIDTH-SYSFONT_WIDTH*strlen(datetime), LCD_HEIGHT-SYSFONT_HEIGHT, datetime); |
Maurus Cuelenaere | 4bf4d2b | 2008-08-10 21:44:48 +0000 | [diff] [blame] | 158 | snprintf(datetime, 30, "%d", current_tick); |
Maurus Cuelenaere | 1f692e5 | 2008-07-17 10:13:56 +0000 | [diff] [blame] | 159 | lcd_putsxy(LCD_WIDTH-SYSFONT_WIDTH*strlen(datetime), LCD_HEIGHT-SYSFONT_HEIGHT*2, datetime); |
Maurus Cuelenaere | 1e294e3 | 2008-09-14 16:26:08 +0000 | [diff] [blame] | 160 | snprintf(datetime, 30, "X: %03d Y: %03d", touch>>16, touch & 0xFFFF); |
Maurus Cuelenaere | 06efd07 | 2008-07-30 10:24:39 +0000 | [diff] [blame] | 161 | lcd_putsxy(LCD_WIDTH-SYSFONT_WIDTH*strlen(datetime), LCD_HEIGHT-SYSFONT_HEIGHT*3, datetime); |
Maurus Cuelenaere | 1e294e3 | 2008-09-14 16:26:08 +0000 | [diff] [blame] | 162 | snprintf(datetime, 30, "PIN3: 0x%08x", REG_GPIO_PXPIN(3)); |
Maurus Cuelenaere | 62c4a28 | 2008-08-26 21:48:49 +0000 | [diff] [blame] | 163 | lcd_putsxy(LCD_WIDTH-SYSFONT_WIDTH*strlen(datetime), LCD_HEIGHT-SYSFONT_HEIGHT*4, datetime); |
Maurus Cuelenaere | 1e294e3 | 2008-09-14 16:26:08 +0000 | [diff] [blame] | 164 | snprintf(datetime, 30, "PIN2: 0x%08x", REG_GPIO_PXPIN(2)); |
Maurus Cuelenaere | 62c4a28 | 2008-08-26 21:48:49 +0000 | [diff] [blame] | 165 | lcd_putsxy(LCD_WIDTH-SYSFONT_WIDTH*strlen(datetime), LCD_HEIGHT-SYSFONT_HEIGHT*5, datetime); |
Maurus Cuelenaere | 1e294e3 | 2008-09-14 16:26:08 +0000 | [diff] [blame] | 166 | snprintf(datetime, 30, "PIN1: 0x%08x", REG_GPIO_PXPIN(1)); |
Maurus Cuelenaere | 62c4a28 | 2008-08-26 21:48:49 +0000 | [diff] [blame] | 167 | lcd_putsxy(LCD_WIDTH-SYSFONT_WIDTH*strlen(datetime), LCD_HEIGHT-SYSFONT_HEIGHT*6, datetime); |
Maurus Cuelenaere | 1e294e3 | 2008-09-14 16:26:08 +0000 | [diff] [blame] | 168 | snprintf(datetime, 30, "PIN0: 0x%08x", REG_GPIO_PXPIN(0)); |
Maurus Cuelenaere | 62c4a28 | 2008-08-26 21:48:49 +0000 | [diff] [blame] | 169 | lcd_putsxy(LCD_WIDTH-SYSFONT_WIDTH*strlen(datetime), LCD_HEIGHT-SYSFONT_HEIGHT*7, datetime); |
Maurus Cuelenaere | 1e294e3 | 2008-09-14 16:26:08 +0000 | [diff] [blame] | 170 | snprintf(datetime, 30, "BadVAddr: 0x%08x", read_c0_badvaddr()); |
Maurus Cuelenaere | 62c4a28 | 2008-08-26 21:48:49 +0000 | [diff] [blame] | 171 | lcd_putsxy(LCD_WIDTH-SYSFONT_WIDTH*strlen(datetime), LCD_HEIGHT-SYSFONT_HEIGHT*8, datetime); |
Maurus Cuelenaere | 1e294e3 | 2008-09-14 16:26:08 +0000 | [diff] [blame] | 172 | snprintf(datetime, 30, "ICSR: 0x%08x", REG_INTC_ISR); |
| 173 | lcd_putsxy(LCD_WIDTH-SYSFONT_WIDTH*strlen(datetime), LCD_HEIGHT-SYSFONT_HEIGHT*9, datetime); |
Maurus Cuelenaere | 1f692e5 | 2008-07-17 10:13:56 +0000 | [diff] [blame] | 174 | lcd_update(); |
Maurus Cuelenaere | 1e294e3 | 2008-09-14 16:26:08 +0000 | [diff] [blame] | 175 | yield(); |
Maurus Cuelenaere | 0709f0a | 2008-07-14 15:03:10 +0000 | [diff] [blame] | 176 | } |
| 177 | |
| 178 | return 0; |
| 179 | } |