diff options
author | Karl Kurbjun <kkurbjun@gmail.com> | 2007-09-20 04:46:41 +0000 |
---|---|---|
committer | Karl Kurbjun <kkurbjun@gmail.com> | 2007-09-20 04:46:41 +0000 |
commit | 7b97fe21c0f2c9b6742ad50439020023f385fe6c (patch) | |
tree | 2c1a7312c3373b32e7dbc8a03d76c83dc9c12ce0 /firmware/target/arm/olympus | |
parent | a80c0e8b83eb52a322c2b33e49875159c6d6a12a (diff) | |
download | rockbox-7b97fe21c0f2c9b6742ad50439020023f385fe6c.tar.gz rockbox-7b97fe21c0f2c9b6742ad50439020023f385fe6c.zip |
Beginning of an M:Robe 500i port. Currently only in the bootloader stage. Needs another piece of code to start the boot process - will be in the wiki.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14763 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm/olympus')
16 files changed, 1272 insertions, 0 deletions
diff --git a/firmware/target/arm/olympus/mrobe-500/adc-mr500.c b/firmware/target/arm/olympus/mrobe-500/adc-mr500.c new file mode 100644 index 0000000000..4fb2aa3677 --- /dev/null +++ b/firmware/target/arm/olympus/mrobe-500/adc-mr500.c | |||
@@ -0,0 +1,46 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id: $ | ||
9 | * | ||
10 | * Copyright (C) 2007 by Karl Kurbjun | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | |||
20 | #include "cpu.h" | ||
21 | #include "adc-target.h" | ||
22 | #include "kernel.h" | ||
23 | |||
24 | /* prototypes */ | ||
25 | static void adc_tick(void); | ||
26 | |||
27 | void adc_init(void) | ||
28 | { | ||
29 | /* attach the adc reading to the tick */ | ||
30 | tick_add_task(adc_tick); | ||
31 | } | ||
32 | |||
33 | /* Called to get the recent ADC reading */ | ||
34 | inline unsigned short adc_read(int channel) | ||
35 | { | ||
36 | return (short)channel; | ||
37 | } | ||
38 | |||
39 | /* add this to the tick so that the ADC converts are done in the background */ | ||
40 | static void adc_tick(void) | ||
41 | { | ||
42 | } | ||
43 | |||
44 | |||
45 | |||
46 | |||
diff --git a/firmware/target/arm/olympus/mrobe-500/adc-target.h b/firmware/target/arm/olympus/mrobe-500/adc-target.h new file mode 100644 index 0000000000..fbf38ee13d --- /dev/null +++ b/firmware/target/arm/olympus/mrobe-500/adc-target.h | |||
@@ -0,0 +1,38 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id: $ | ||
9 | * | ||
10 | * Copyright (C) 2007 by Karl Kurbjun | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | |||
20 | #ifndef _ADC_TARGET_H_ | ||
21 | #define _ADC_TARGET_H_ | ||
22 | |||
23 | /* only two channels used by the Gigabeat */ | ||
24 | #define NUM_ADC_CHANNELS 2 | ||
25 | |||
26 | #define ADC_BATTERY 0 | ||
27 | #define ADC_HPREMOTE 1 | ||
28 | #define ADC_UNKNOWN_3 2 | ||
29 | #define ADC_UNKNOWN_4 3 | ||
30 | #define ADC_UNKNOWN_5 4 | ||
31 | #define ADC_UNKNOWN_6 5 | ||
32 | #define ADC_UNKNOWN_7 6 | ||
33 | #define ADC_UNKNOWN_8 7 | ||
34 | |||
35 | #define ADC_UNREG_POWER ADC_BATTERY /* For compatibility */ | ||
36 | #define ADC_READ_ERROR 0xFFFF | ||
37 | |||
38 | #endif | ||
diff --git a/firmware/target/arm/olympus/mrobe-500/ata-mr500.c b/firmware/target/arm/olympus/mrobe-500/ata-mr500.c new file mode 100644 index 0000000000..b4028d5ead --- /dev/null +++ b/firmware/target/arm/olympus/mrobe-500/ata-mr500.c | |||
@@ -0,0 +1,130 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id: $ | ||
9 | * | ||
10 | * Copyright (C) 2007 by Karl Kurbjun | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | |||
20 | #include "config.h" | ||
21 | #include "cpu.h" | ||
22 | #include "kernel.h" | ||
23 | #include "thread.h" | ||
24 | #include "system.h" | ||
25 | #include "power.h" | ||
26 | #include "panic.h" | ||
27 | #include "pcf50606.h" | ||
28 | #include "ata-target.h" | ||
29 | #include "backlight-target.h" | ||
30 | |||
31 | /* ARESET on C7C68300 and RESET on ATA interface (Active Low) */ | ||
32 | #define ATA_RESET_ENABLE return | ||
33 | #define ATA_RESET_DISABLE return | ||
34 | |||
35 | /* ATA_EN on C7C68300 */ | ||
36 | #define USB_ATA_ENABLE return | ||
37 | #define USB_ATA_DISABLE return | ||
38 | |||
39 | void ata_reset(void) | ||
40 | { | ||
41 | ATA_RESET_ENABLE; | ||
42 | sleep(1); /* > 25us */ | ||
43 | ATA_RESET_DISABLE; | ||
44 | sleep(1); /* > 2ms */ | ||
45 | } | ||
46 | |||
47 | /* This function is called before enabling the USB bus */ | ||
48 | void ata_enable(bool on) | ||
49 | { | ||
50 | if(on) | ||
51 | USB_ATA_DISABLE; | ||
52 | else | ||
53 | USB_ATA_ENABLE; | ||
54 | } | ||
55 | |||
56 | bool ata_is_coldstart(void) | ||
57 | { | ||
58 | return false; | ||
59 | } | ||
60 | |||
61 | void ata_device_init(void) | ||
62 | { | ||
63 | /* ATA reset */ | ||
64 | ATA_RESET_DISABLE; /* Set the pin to disable an active low reset */ | ||
65 | } | ||
66 | |||
67 | #if !defined(BOOTLOADER) | ||
68 | void copy_read_sectors(unsigned char* buf, int wordcount) | ||
69 | { | ||
70 | __buttonlight_trigger(); | ||
71 | |||
72 | /* Unaligned transfer - slow copy */ | ||
73 | if ( (unsigned long)buf & 1) | ||
74 | { /* not 16-bit aligned, copy byte by byte */ | ||
75 | unsigned short tmp = 0; | ||
76 | unsigned char* bufend = buf + wordcount*2; | ||
77 | do | ||
78 | { | ||
79 | tmp = ATA_DATA; | ||
80 | *buf++ = tmp & 0xff; /* I assume big endian */ | ||
81 | *buf++ = tmp >> 8; /* and don't use the SWAB16 macro */ | ||
82 | } while (buf < bufend); /* tail loop is faster */ | ||
83 | return; | ||
84 | } | ||
85 | /* This should never happen, but worth watching for */ | ||
86 | if(wordcount > (1 << 18)) | ||
87 | panicf("atd-meg-fx.c: copy_read_sectors: too many sectors per read!"); | ||
88 | |||
89 | //#define GIGABEAT_DEBUG_ATA | ||
90 | #ifdef GIGABEAT_DEBUG_ATA | ||
91 | static int line = 0; | ||
92 | static char str[256]; | ||
93 | snprintf(str, sizeof(str), "ODD DMA to %08x, %d", buf, wordcount); | ||
94 | lcd_puts(10, line, str); | ||
95 | line = (line+1) % 32; | ||
96 | lcd_update(); | ||
97 | #endif | ||
98 | /* Reset the channel */ | ||
99 | DMASKTRIG0 |= 4; | ||
100 | /* Wait for DMA controller to be ready */ | ||
101 | while(DMASKTRIG0 & 0x2) | ||
102 | ; | ||
103 | while(DSTAT0 & (1 << 20)) | ||
104 | ; | ||
105 | /* Source is ATA_DATA, on AHB Bus, Fixed */ | ||
106 | DISRC0 = (int) 0x18000000; | ||
107 | DISRCC0 = 0x1; | ||
108 | /* Dest mapped to physical address, on AHB bus, increment */ | ||
109 | DIDST0 = (int) buf; | ||
110 | if(DIDST0 < 0x30000000) | ||
111 | DIDST0 += 0x30000000; | ||
112 | DIDSTC0 = 0; | ||
113 | |||
114 | /* DACK/DREQ Sync to AHB, Whole service, No reload, 16-bit transfers */ | ||
115 | DCON0 = ((1 << 30) | (1<<27) | (1<<22) | (1<<20)) | wordcount; | ||
116 | |||
117 | /* Activate the channel */ | ||
118 | DMASKTRIG0 = 0x2; | ||
119 | |||
120 | invalidate_dcache_range((void *)buf, wordcount*2); | ||
121 | |||
122 | /* Start DMA */ | ||
123 | DMASKTRIG0 |= 0x1; | ||
124 | |||
125 | /* Wait for transfer to complete */ | ||
126 | while((DSTAT0 & 0x000fffff)) | ||
127 | priority_yield(); | ||
128 | /* Dump cache for the buffer */ | ||
129 | } | ||
130 | #endif | ||
diff --git a/firmware/target/arm/olympus/mrobe-500/ata-target.h b/firmware/target/arm/olympus/mrobe-500/ata-target.h new file mode 100644 index 0000000000..87d8a9b535 --- /dev/null +++ b/firmware/target/arm/olympus/mrobe-500/ata-target.h | |||
@@ -0,0 +1,71 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id: $ | ||
9 | * | ||
10 | * Copyright (C) 2007 by Karl Kurbjun | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | |||
20 | #ifndef ATA_TARGET_H | ||
21 | #define ATA_TARGET_H | ||
22 | |||
23 | /* Plain C read & write loops */ | ||
24 | #define PREFER_C_READING | ||
25 | #define PREFER_C_WRITING | ||
26 | #if !defined(BOOTLOADER) | ||
27 | //#define ATA_OPTIMIZED_READING | ||
28 | //void copy_read_sectors(unsigned char* buf, int wordcount); | ||
29 | #endif | ||
30 | |||
31 | #define ATA_IOBASE 0x50000000 | ||
32 | #define ATA_DATA (*((volatile unsigned short*)(ATA_IOBASE+0xa0))) | ||
33 | #define ATA_ERROR (*((volatile unsigned char*)(ATA_IOBASE + 0xa2))) | ||
34 | #define ATA_NSECTOR (*((volatile unsigned char*)(ATA_IOBASE + 0x24))) | ||
35 | #define ATA_SECTOR (*((volatile unsigned char*)(ATA_IOBASE + 0x26))) | ||
36 | #define ATA_LCYL (*((volatile unsigned char*)(ATA_IOBASE + 0x28))) | ||
37 | #define ATA_HCYL (*((volatile unsigned char*)(ATA_IOBASE + 0x2A))) | ||
38 | #define ATA_SELECT (*((volatile unsigned char*)(ATA_IOBASE + 0x2C))) | ||
39 | #define ATA_COMMAND (*((volatile unsigned char*)(ATA_IOBASE + 0x2E))) | ||
40 | #define ATA_CONTROL (*((volatile unsigned char*)(ATA_IOBASE + 0x9C))) | ||
41 | |||
42 | #define STATUS_BSY 0x80 | ||
43 | #define STATUS_RDY 0x40 | ||
44 | #define STATUS_DF 0x20 | ||
45 | #define STATUS_DRQ 0x08 | ||
46 | #define STATUS_ERR 0x01 | ||
47 | #define ERROR_ABRT 0x04 | ||
48 | |||
49 | #define WRITE_PATTERN1 0xa5 | ||
50 | #define WRITE_PATTERN2 0x5a | ||
51 | #define WRITE_PATTERN3 0xaa | ||
52 | #define WRITE_PATTERN4 0x55 | ||
53 | |||
54 | #define READ_PATTERN1 0xa5 | ||
55 | #define READ_PATTERN2 0x5a | ||
56 | #define READ_PATTERN3 0xaa | ||
57 | #define READ_PATTERN4 0x55 | ||
58 | |||
59 | #define READ_PATTERN1_MASK 0xff | ||
60 | #define READ_PATTERN2_MASK 0xff | ||
61 | #define READ_PATTERN3_MASK 0xff | ||
62 | #define READ_PATTERN4_MASK 0xff | ||
63 | |||
64 | #define SET_REG(reg,val) reg = (val) | ||
65 | #define SET_16BITREG(reg,val) reg = (val) | ||
66 | |||
67 | void ata_reset(void); | ||
68 | void ata_device_init(void); | ||
69 | bool ata_is_coldstart(void); | ||
70 | |||
71 | #endif | ||
diff --git a/firmware/target/arm/olympus/mrobe-500/backlight-mr500.c b/firmware/target/arm/olympus/mrobe-500/backlight-mr500.c new file mode 100644 index 0000000000..6a335d357c --- /dev/null +++ b/firmware/target/arm/olympus/mrobe-500/backlight-mr500.c | |||
@@ -0,0 +1,50 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id: $ | ||
9 | * | ||
10 | * Copyright (C) 2007 by Karl Kurbjun | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | |||
20 | #include "config.h" | ||
21 | #include "cpu.h" | ||
22 | #include "system.h" | ||
23 | #include "backlight-target.h" | ||
24 | #include "backlight.h" | ||
25 | #include "lcd.h" | ||
26 | #include "power.h" | ||
27 | |||
28 | void __backlight_on(void) | ||
29 | { | ||
30 | } | ||
31 | |||
32 | void __backlight_off(void) | ||
33 | { | ||
34 | } | ||
35 | |||
36 | /* Assumes that the backlight has been initialized */ | ||
37 | void __backlight_set_brightness(int brightness) | ||
38 | { | ||
39 | (void) brightness; | ||
40 | } | ||
41 | |||
42 | void __backlight_dim(bool dim_now) | ||
43 | { | ||
44 | (void) dim_now; | ||
45 | } | ||
46 | |||
47 | bool __backlight_init(void) | ||
48 | { | ||
49 | return true; | ||
50 | } | ||
diff --git a/firmware/target/arm/olympus/mrobe-500/backlight-target.h b/firmware/target/arm/olympus/mrobe-500/backlight-target.h new file mode 100644 index 0000000000..d28cfbbdf1 --- /dev/null +++ b/firmware/target/arm/olympus/mrobe-500/backlight-target.h | |||
@@ -0,0 +1,31 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id: $ | ||
9 | * | ||
10 | * Copyright (C) 2007 by Karl Kurbjun | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | |||
20 | #ifndef BACKLIGHT_TARGET_H | ||
21 | #define BACKLIGHT_TARGET_H | ||
22 | |||
23 | bool __backlight_init(void); | ||
24 | void __backlight_on(void); | ||
25 | void __backlight_off(void); | ||
26 | void __backlight_set_brightness(int brightness); | ||
27 | |||
28 | /* true: backlight fades off - false: backlight fades on */ | ||
29 | void __backlight_dim(bool dim); | ||
30 | |||
31 | #endif | ||
diff --git a/firmware/target/arm/olympus/mrobe-500/button-mr500.c b/firmware/target/arm/olympus/mrobe-500/button-mr500.c new file mode 100644 index 0000000000..9cafab5c14 --- /dev/null +++ b/firmware/target/arm/olympus/mrobe-500/button-mr500.c | |||
@@ -0,0 +1,56 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id: $ | ||
9 | * | ||
10 | * Copyright (C) 2007 by Karl Kurbjun | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | |||
20 | #include "config.h" | ||
21 | #include "cpu.h" | ||
22 | #include "system.h" | ||
23 | #include "button.h" | ||
24 | #include "kernel.h" | ||
25 | #include "backlight.h" | ||
26 | #include "adc.h" | ||
27 | #include "system.h" | ||
28 | #include "backlight-target.h" | ||
29 | |||
30 | static int const remote_buttons[] = | ||
31 | { | ||
32 | BUTTON_NONE, /* Headphones connected - remote disconnected */ | ||
33 | BUTTON_RC_PLAY, | ||
34 | BUTTON_RC_DSP, | ||
35 | BUTTON_RC_REW, | ||
36 | BUTTON_RC_FF, | ||
37 | BUTTON_RC_VOL_UP, | ||
38 | BUTTON_RC_VOL_DOWN, | ||
39 | BUTTON_NONE, /* Remote control attached - no buttons pressed */ | ||
40 | BUTTON_NONE, /* Nothing in the headphone socket */ | ||
41 | }; | ||
42 | |||
43 | void button_init_device(void) | ||
44 | { | ||
45 | /* Power, Remote Play & Hold switch */ | ||
46 | } | ||
47 | |||
48 | inline bool button_hold(void) | ||
49 | { | ||
50 | return false; | ||
51 | } | ||
52 | |||
53 | int button_read_device(void) | ||
54 | { | ||
55 | return 0; | ||
56 | } | ||
diff --git a/firmware/target/arm/olympus/mrobe-500/button-target.h b/firmware/target/arm/olympus/mrobe-500/button-target.h new file mode 100644 index 0000000000..6637c5bf2b --- /dev/null +++ b/firmware/target/arm/olympus/mrobe-500/button-target.h | |||
@@ -0,0 +1,99 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id: $ | ||
9 | * | ||
10 | * Copyright (C) 2007 by Karl Kurbjun | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | |||
20 | #ifndef _BUTTON_TARGET_H_ | ||
21 | #define _BUTTON_TARGET_H_ | ||
22 | |||
23 | #include <stdbool.h> | ||
24 | #include "config.h" | ||
25 | |||
26 | #define HAS_BUTTON_HOLD | ||
27 | |||
28 | bool button_hold(void); | ||
29 | void button_init_device(void); | ||
30 | int button_read_device(void); | ||
31 | |||
32 | /* Toshiba Gigabeat specific button codes */ | ||
33 | |||
34 | #define BUTTON_POWER 0x00000001 | ||
35 | #define BUTTON_MENU 0x00000002 | ||
36 | |||
37 | #define BUTTON_LEFT 0x00000004 | ||
38 | #define BUTTON_RIGHT 0x00000008 | ||
39 | #define BUTTON_UP 0x00000010 | ||
40 | #define BUTTON_DOWN 0x00000020 | ||
41 | |||
42 | #define BUTTON_VOL_UP 0x00000040 | ||
43 | #define BUTTON_VOL_DOWN 0x00000080 | ||
44 | |||
45 | #define BUTTON_SELECT 0x00000100 | ||
46 | #define BUTTON_A 0x00000200 | ||
47 | |||
48 | /* Remote control buttons */ | ||
49 | |||
50 | #define BUTTON_RC_VOL_UP 0x00000400 | ||
51 | #define BUTTON_RC_VOL_DOWN 0x00000800 | ||
52 | #define BUTTON_RC_FF 0x00001000 | ||
53 | #define BUTTON_RC_REW 0x00002000 | ||
54 | |||
55 | #define BUTTON_RC_PLAY 0x00004000 | ||
56 | #define BUTTON_RC_DSP 0x00008000 | ||
57 | |||
58 | /* Toshiba Gigabeat specific remote button ADC values */ | ||
59 | /* The remote control uses ADC 1 to emulate button pushes | ||
60 | Reading (approx) Button HP plugged in? Remote plugged in? | ||
61 | 0 N/A Yes No | ||
62 | 125 Play/Pause Cant tell Yes | ||
63 | 241 Speaker+ Cant tell Yes | ||
64 | 369 Rewind Cant tell Yes | ||
65 | 492 Fast Fwd Cant tell Yes | ||
66 | 616 Vol + Cant tell Yes | ||
67 | 742 Vol - Cant tell Yes | ||
68 | 864 None Cant tell Yes | ||
69 | 1023 N/A No No | ||
70 | */ | ||
71 | |||
72 | /* | ||
73 | Notes: | ||
74 | |||
75 | Buttons on the remote are translated into equivalent button presses just | ||
76 | as if you were pressing them on the Gigabeat itself. | ||
77 | |||
78 | We cannot tell if the hold is asserted on the remote. The Hold function on | ||
79 | the remote is to block the output of the buttons changing. | ||
80 | |||
81 | Only one button can be sensed at a time. If another is pressed, the button | ||
82 | with the lowest reading is dominant. So, if Rewind and Vol + are pressed | ||
83 | at the same time, Rewind value is the one that is read. | ||
84 | */ | ||
85 | |||
86 | |||
87 | |||
88 | |||
89 | #define BUTTON_MAIN (BUTTON_POWER|BUTTON_MENU|BUTTON_LEFT|BUTTON_RIGHT\ | ||
90 | |BUTTON_UP|BUTTON_DOWN|BUTTON_VOL_UP|BUTTON_VOL_DOWN\ | ||
91 | |BUTTON_SELECT|BUTTON_A) | ||
92 | |||
93 | #define BUTTON_REMOTE (BUTTON_RC_VOL_UP|BUTTON_RC_VOL_DOWN|BUTTON_RC_FF\ | ||
94 | |BUTTON_RC_REW|BUTTON_RC_PLAY|BUTTON_RC_DSP) | ||
95 | |||
96 | #define POWEROFF_BUTTON BUTTON_POWER | ||
97 | #define POWEROFF_COUNT 10 | ||
98 | |||
99 | #endif /* _BUTTON_TARGET_H_ */ | ||
diff --git a/firmware/target/arm/olympus/mrobe-500/kernel-mr500.c b/firmware/target/arm/olympus/mrobe-500/kernel-mr500.c new file mode 100644 index 0000000000..27bb0475e4 --- /dev/null +++ b/firmware/target/arm/olympus/mrobe-500/kernel-mr500.c | |||
@@ -0,0 +1,48 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id: $ | ||
9 | * | ||
10 | * Copyright (C) 2007 by Karl Kurbjun | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | |||
20 | #include "config.h" | ||
21 | #include "system.h" | ||
22 | #include "kernel.h" | ||
23 | #include "timer.h" | ||
24 | #include "thread.h" | ||
25 | |||
26 | extern void (*tick_funcs[MAX_NUM_TICK_TASKS])(void); | ||
27 | |||
28 | void tick_start(unsigned int interval_in_ms) | ||
29 | { | ||
30 | (void)interval_in_ms; | ||
31 | } | ||
32 | |||
33 | void TIMER4(void) | ||
34 | { | ||
35 | int i; | ||
36 | |||
37 | /* Run through the list of tick tasks */ | ||
38 | for(i = 0; i < MAX_NUM_TICK_TASKS; i++) | ||
39 | { | ||
40 | if(tick_funcs[i]) | ||
41 | { | ||
42 | tick_funcs[i](); | ||
43 | } | ||
44 | } | ||
45 | |||
46 | current_tick++; | ||
47 | |||
48 | } | ||
diff --git a/firmware/target/arm/olympus/mrobe-500/lcd-mr500.c b/firmware/target/arm/olympus/mrobe-500/lcd-mr500.c new file mode 100644 index 0000000000..5e41b829e1 --- /dev/null +++ b/firmware/target/arm/olympus/mrobe-500/lcd-mr500.c | |||
@@ -0,0 +1,206 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id: $ | ||
9 | * | ||
10 | * Copyright (C) 2007 by Karl Kurbjun | ||
11 | * | ||
12 | * Some of this is based on the Cowon A2 Firmware release: | ||
13 | * http://www.cowonglobal.com/download/gnu/cowon_pmp_a2_src_1.59_GPL.tar.gz | ||
14 | * | ||
15 | * All files in this archive are subject to the GNU General Public License. | ||
16 | * See the file COPYING in the source tree root for full license agreement. | ||
17 | * | ||
18 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
19 | * KIND, either express or implied. | ||
20 | * | ||
21 | ****************************************************************************/ | ||
22 | |||
23 | #include "config.h" | ||
24 | #include "cpu.h" | ||
25 | #include "string.h" | ||
26 | #include "lcd.h" | ||
27 | #include "kernel.h" | ||
28 | #include "memory.h" | ||
29 | #include "system-target.h" | ||
30 | |||
31 | static volatile bool lcd_on = true; | ||
32 | volatile bool lcd_poweroff = false; | ||
33 | /* | ||
34 | ** These are imported from lcd-16bit.c | ||
35 | */ | ||
36 | extern unsigned fg_pattern; | ||
37 | extern unsigned bg_pattern; | ||
38 | |||
39 | bool lcd_enabled(void) | ||
40 | { | ||
41 | return lcd_on; | ||
42 | } | ||
43 | |||
44 | /* LCD init - based on code from ingenient-bsp/bootloader/board/dm320/splash.c | ||
45 | * and code by Catalin Patulea from the M:Robe 500i linux port | ||
46 | */ | ||
47 | void lcd_init_device(void) | ||
48 | { | ||
49 | unsigned int addr; | ||
50 | |||
51 | /* Clear the Frame */ | ||
52 | memset16(FRAME, 0x0000, LCD_WIDTH*LCD_HEIGHT); | ||
53 | |||
54 | outw(0x00ff, IO_OSD_MODE); | ||
55 | outw(0x0002, IO_OSD_VIDWINMD); | ||
56 | outw(0x2001, IO_OSD_OSDWINMD0); | ||
57 | outw(0x0002, IO_OSD_OSDWINMD1); | ||
58 | outw(0x0000, IO_OSD_ATRMD); | ||
59 | outw(0x0000, IO_OSD_RECTCUR); | ||
60 | |||
61 | outw((480*2) / 32, IO_OSD_OSDWIN0OFST); | ||
62 | addr = ((int)FRAME-CONFIG_SDRAM_START) / 32; | ||
63 | outw(addr >> 16, IO_OSD_OSDWINADH); | ||
64 | outw(addr & 0xFFFF, IO_OSD_OSDWIN0ADL); | ||
65 | |||
66 | outw(80, IO_OSD_BASEPX); | ||
67 | outw(2, IO_OSD_BASEPY); | ||
68 | |||
69 | outw(0, IO_OSD_OSDWIN0XP); | ||
70 | outw(0, IO_OSD_OSDWIN0YP); | ||
71 | outw(480, IO_OSD_OSDWIN0XL); | ||
72 | outw(640, IO_OSD_OSDWIN0YL); | ||
73 | } | ||
74 | |||
75 | /* Update a fraction of the display. */ | ||
76 | void lcd_update_rect(int x, int y, int width, int height) | ||
77 | { | ||
78 | fb_data *dst, *src; | ||
79 | |||
80 | if (!lcd_on) | ||
81 | return; | ||
82 | |||
83 | if (x + width > LCD_WIDTH) | ||
84 | width = LCD_WIDTH - x; /* Clip right */ | ||
85 | if (x < 0) | ||
86 | width += x, x = 0; /* Clip left */ | ||
87 | if (width <= 0) | ||
88 | return; /* nothing left to do */ | ||
89 | |||
90 | if (y + height > LCD_HEIGHT) | ||
91 | height = LCD_HEIGHT - y; /* Clip bottom */ | ||
92 | if (y < 0) | ||
93 | height += y, y = 0; /* Clip top */ | ||
94 | if (height <= 0) | ||
95 | return; /* nothing left to do */ | ||
96 | |||
97 | dst = (fb_data *)FRAME + LCD_WIDTH*y + x; | ||
98 | src = &lcd_framebuffer[y][x]; | ||
99 | |||
100 | /* Copy part of the Rockbox framebuffer to the second framebuffer */ | ||
101 | if (width < LCD_WIDTH) | ||
102 | { | ||
103 | int y; | ||
104 | /* Not full width - do line-by-line */ | ||
105 | for(y=0;y<height;y++) | ||
106 | { | ||
107 | memcpy(dst, src, width*sizeof(fb_data)); | ||
108 | dst+=LCD_WIDTH; | ||
109 | src+=LCD_WIDTH; | ||
110 | } | ||
111 | } | ||
112 | else | ||
113 | { | ||
114 | /* Full width - copy as one line */ | ||
115 | memcpy(dst, src, LCD_WIDTH*height*sizeof(fb_data)); | ||
116 | } | ||
117 | } | ||
118 | |||
119 | void lcd_enable(bool state) | ||
120 | { | ||
121 | (void)state; | ||
122 | } | ||
123 | |||
124 | /* Update the display. | ||
125 | This must be called after all other LCD functions that change the display. */ | ||
126 | void lcd_update(void) | ||
127 | { | ||
128 | if (!lcd_on) | ||
129 | return; | ||
130 | |||
131 | memcpy((fb_data *)FRAME, &lcd_framebuffer[0][0], | ||
132 | LCD_WIDTH*LCD_HEIGHT*sizeof(fb_data)); | ||
133 | } | ||
134 | |||
135 | /* Line write helper function for lcd_yuv_blit. Write two lines of yuv420. */ | ||
136 | extern void lcd_write_yuv420_lines(fb_data *dst, | ||
137 | unsigned char chroma_buf[LCD_HEIGHT/2*3], | ||
138 | unsigned char const * const src[3], | ||
139 | int width, | ||
140 | int stride); | ||
141 | /* Performance function to blit a YUV bitmap directly to the LCD */ | ||
142 | /* For the Gigabeat - show it rotated */ | ||
143 | /* So the LCD_WIDTH is now the height */ | ||
144 | void lcd_yuv_blit(unsigned char * const src[3], | ||
145 | int src_x, int src_y, int stride, | ||
146 | int x, int y, int width, int height) | ||
147 | { | ||
148 | /* Caches for chroma data so it only need be recaculated every other | ||
149 | line */ | ||
150 | unsigned char chroma_buf[LCD_HEIGHT/2*3]; /* 480 bytes */ | ||
151 | unsigned char const * yuv_src[3]; | ||
152 | off_t z; | ||
153 | |||
154 | if (!lcd_on) | ||
155 | return; | ||
156 | |||
157 | /* Sorry, but width and height must be >= 2 or else */ | ||
158 | width &= ~1; | ||
159 | height >>= 1; | ||
160 | |||
161 | fb_data *dst = (fb_data*)FRAME + x * LCD_WIDTH + (LCD_WIDTH - y) - 1; | ||
162 | |||
163 | z = stride*src_y; | ||
164 | yuv_src[0] = src[0] + z + src_x; | ||
165 | yuv_src[1] = src[1] + (z >> 2) + (src_x >> 1); | ||
166 | yuv_src[2] = src[2] + (yuv_src[1] - src[1]); | ||
167 | |||
168 | do | ||
169 | { | ||
170 | lcd_write_yuv420_lines(dst, chroma_buf, yuv_src, width, | ||
171 | stride); | ||
172 | yuv_src[0] += stride << 1; /* Skip down two luma lines */ | ||
173 | yuv_src[1] += stride >> 1; /* Skip down one chroma line */ | ||
174 | yuv_src[2] += stride >> 1; | ||
175 | dst -= 2; | ||
176 | } | ||
177 | while (--height > 0); | ||
178 | } | ||
179 | |||
180 | void lcd_set_contrast(int val) { | ||
181 | (void) val; | ||
182 | // TODO: | ||
183 | } | ||
184 | |||
185 | void lcd_set_invert_display(bool yesno) { | ||
186 | (void) yesno; | ||
187 | // TODO: | ||
188 | } | ||
189 | |||
190 | void lcd_blit(const fb_data* data, int bx, int y, int bwidth, | ||
191 | int height, int stride) | ||
192 | { | ||
193 | (void) data; | ||
194 | (void) bx; | ||
195 | (void) y; | ||
196 | (void) bwidth; | ||
197 | (void) height; | ||
198 | (void) stride; | ||
199 | //TODO: | ||
200 | } | ||
201 | |||
202 | void lcd_set_flip(bool yesno) { | ||
203 | (void) yesno; | ||
204 | // TODO: | ||
205 | } | ||
206 | |||
diff --git a/firmware/target/arm/olympus/mrobe-500/lcd-target.h b/firmware/target/arm/olympus/mrobe-500/lcd-target.h new file mode 100644 index 0000000000..bac1bef237 --- /dev/null +++ b/firmware/target/arm/olympus/mrobe-500/lcd-target.h | |||
@@ -0,0 +1,21 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id: $ | ||
9 | * | ||
10 | * Copyright (C) 2007 by Karl Kurbjun | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | |||
20 | extern void lcd_enable(bool state); | ||
21 | |||
diff --git a/firmware/target/arm/olympus/mrobe-500/power-mr500.c b/firmware/target/arm/olympus/mrobe-500/power-mr500.c new file mode 100644 index 0000000000..28fe6a297a --- /dev/null +++ b/firmware/target/arm/olympus/mrobe-500/power-mr500.c | |||
@@ -0,0 +1,93 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id: $ | ||
9 | * | ||
10 | * Copyright (C) 2007 by Karl Kurbjun | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | |||
20 | #include "config.h" | ||
21 | #include "cpu.h" | ||
22 | #include <stdbool.h> | ||
23 | #include "kernel.h" | ||
24 | #include "system.h" | ||
25 | #include "power.h" | ||
26 | #include "pcf50606.h" | ||
27 | #include "backlight.h" | ||
28 | #include "backlight-target.h" | ||
29 | |||
30 | #ifndef SIMULATOR | ||
31 | |||
32 | void power_init(void) | ||
33 | { | ||
34 | /* Initialize IDE power pin */ | ||
35 | ide_power_enable(true); | ||
36 | /* Charger detect */ | ||
37 | } | ||
38 | |||
39 | bool charger_inserted(void) | ||
40 | { | ||
41 | return false; | ||
42 | } | ||
43 | |||
44 | /* Returns true if the unit is charging the batteries. */ | ||
45 | bool charging_state(void) { | ||
46 | return false; | ||
47 | } | ||
48 | |||
49 | void ide_power_enable(bool on) | ||
50 | { | ||
51 | if (on) | ||
52 | return; | ||
53 | else | ||
54 | return; | ||
55 | } | ||
56 | |||
57 | bool ide_powered(void) | ||
58 | { | ||
59 | return true; | ||
60 | } | ||
61 | |||
62 | void power_off(void) | ||
63 | { | ||
64 | /* turn off backlight and wait for 1 second */ | ||
65 | __backlight_off(); | ||
66 | sleep(HZ); | ||
67 | /* set SLEEP bit to on in CLKCON to turn off */ | ||
68 | // CLKCON |=(1<<3); | ||
69 | } | ||
70 | |||
71 | #else /* SIMULATOR */ | ||
72 | |||
73 | bool charger_inserted(void) | ||
74 | { | ||
75 | return false; | ||
76 | } | ||
77 | |||
78 | void charger_enable(bool on) | ||
79 | { | ||
80 | (void)on; | ||
81 | } | ||
82 | |||
83 | void power_off(void) | ||
84 | { | ||
85 | } | ||
86 | |||
87 | void ide_power_enable(bool on) | ||
88 | { | ||
89 | (void)on; | ||
90 | } | ||
91 | |||
92 | #endif /* SIMULATOR */ | ||
93 | |||
diff --git a/firmware/target/arm/olympus/mrobe-500/system-mr500.c b/firmware/target/arm/olympus/mrobe-500/system-mr500.c new file mode 100644 index 0000000000..c93c9f6260 --- /dev/null +++ b/firmware/target/arm/olympus/mrobe-500/system-mr500.c | |||
@@ -0,0 +1,181 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id: $ | ||
9 | * | ||
10 | * Copyright (C) 2007 by Karl Kurbjun | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | |||
20 | #include "kernel.h" | ||
21 | #include "system.h" | ||
22 | #include "panic.h" | ||
23 | |||
24 | #define default_interrupt(name) \ | ||
25 | extern __attribute__((weak,alias("UIRQ"))) void name (void) | ||
26 | |||
27 | default_interrupt(TIMER0); | ||
28 | default_interrupt(TIMER1); | ||
29 | default_interrupt(TIMER2); | ||
30 | default_interrupt(TIMER3); | ||
31 | default_interrupt(CCD_VD0); | ||
32 | default_interrupt(CCD_VD1); | ||
33 | default_interrupt(CCD_WEN); | ||
34 | default_interrupt(VENC); | ||
35 | default_interrupt(SERIAL0); | ||
36 | default_interrupt(SERIAL1); | ||
37 | default_interrupt(EXT_HOST); | ||
38 | default_interrupt(DSPHINT); | ||
39 | default_interrupt(UART0); | ||
40 | default_interrupt(UART1); | ||
41 | default_interrupt(USB_DMA); | ||
42 | default_interrupt(USB_CORE); | ||
43 | default_interrupt(VLYNQ); | ||
44 | default_interrupt(MTC0); | ||
45 | default_interrupt(MTC1); | ||
46 | default_interrupt(SD_MMC); | ||
47 | default_interrupt(SDIO_MS); | ||
48 | default_interrupt(GIO0); | ||
49 | default_interrupt(GIO1); | ||
50 | default_interrupt(GIO2); | ||
51 | default_interrupt(GIO3); | ||
52 | default_interrupt(GIO4); | ||
53 | default_interrupt(GIO5); | ||
54 | default_interrupt(GIO6); | ||
55 | default_interrupt(GIO7); | ||
56 | default_interrupt(GIO8); | ||
57 | default_interrupt(GIO9); | ||
58 | default_interrupt(GIO10); | ||
59 | default_interrupt(GIO11); | ||
60 | default_interrupt(GIO12); | ||
61 | default_interrupt(GIO13); | ||
62 | default_interrupt(GIO14); | ||
63 | default_interrupt(GIO15); | ||
64 | default_interrupt(PREVIEW0); | ||
65 | default_interrupt(PREVIEW1); | ||
66 | default_interrupt(WATCHDOG); | ||
67 | default_interrupt(I2C); | ||
68 | default_interrupt(CLKC); | ||
69 | default_interrupt(ICE); | ||
70 | default_interrupt(ARMCOM_RX); | ||
71 | default_interrupt(ARMCOM_TX); | ||
72 | default_interrupt(RESERVED); | ||
73 | |||
74 | static void (* const irqvector[])(void) = | ||
75 | { | ||
76 | TIMER0,TIMER1,TIMER2,TIMER3,CCD_VD0,CCD_VD1, | ||
77 | CCD_WEN,VENC,SERIAL0,SERIAL1,EXT_HOST,DSPHINT, | ||
78 | UART0,UART1,USB_DMA,USB_CORE,VLYNQ,MTC0,MTC1, | ||
79 | SD_MMC,SDIO_MS,GIO0,GIO1,GIO2,GIO3,GIO4,GIO5, | ||
80 | GIO6,GIO7,GIO8,GIO9,GIO10,GIO11,GIO12,GIO13, | ||
81 | GIO14,GIO15,PREVIEW0,PREVIEW1,WATCHDOG,I2C,CLKC, | ||
82 | ICE,ARMCOM_RX,ARMCOM_TX,RESERVED | ||
83 | }; | ||
84 | |||
85 | static const char * const irqname[] = | ||
86 | { | ||
87 | "TIMER0","TIMER1","TIMER2","TIMER3","CCD_VD0","CCD_VD1", | ||
88 | "CCD_WEN","VENC","SERIAL0","SERIAL1","EXT_HOST","DSPHINT", | ||
89 | "UART0","UART1","USB_DMA","USB_CORE","VLYNQ","MTC0","MTC1", | ||
90 | "SD_MMC","SDIO_MS","GIO0","GIO1","GIO2","GIO3","GIO4","GIO5", | ||
91 | "GIO6","GIO7","GIO8","GIO9","GIO10","GIO11","GIO12","GIO13", | ||
92 | "GIO14","GIO15","PREVIEW0","PREVIEW1","WATCHDOG","I2C","CLKC", | ||
93 | "ICE","ARMCOM_RX","ARMCOM_TX","RESERVED" | ||
94 | }; | ||
95 | |||
96 | static void UIRQ(void) | ||
97 | { | ||
98 | unsigned int offset = inw(IO_INTC_IRQENTRY0); | ||
99 | panicf("Unhandled IRQ %02X: %s", offset, irqname[offset]); | ||
100 | } | ||
101 | |||
102 | void irq_handler(void) __attribute__((interrupt ("IRQ"), naked)); | ||
103 | void irq_handler(void) | ||
104 | { | ||
105 | /* | ||
106 | * Based on: linux/arch/arm/kernel/entry-armv.S and system-meg-fx.c | ||
107 | */ | ||
108 | |||
109 | asm volatile ( | ||
110 | "sub lr, lr, #4 \r\n" | ||
111 | "stmfd sp!, {r0-r3, ip, lr} \r\n" | ||
112 | "mov r0, #0x00030000 \r\n" | ||
113 | "ldr r0, [r0, #0x518] \r\n" | ||
114 | "ldr r1, =irqvector \r\n" | ||
115 | "ldr r1, [r1, r0, lsl #2] \r\n" | ||
116 | "mov lr, pc \r\n" | ||
117 | "bx r1 \r\n" | ||
118 | "ldmfd sp!, {r0-r3, ip, pc}^ \r\n" | ||
119 | ); | ||
120 | } | ||
121 | |||
122 | void system_reboot(void) | ||
123 | { | ||
124 | |||
125 | } | ||
126 | |||
127 | void system_init(void) | ||
128 | { | ||
129 | /* taken from linux/arch/arm/mach-itdm320-20/irq.c */ | ||
130 | |||
131 | /* Clearing all FIQs and IRQs. */ | ||
132 | outw(0xFFFF, IO_INTC_IRQ0); | ||
133 | outw(0xFFFF, IO_INTC_IRQ1); | ||
134 | outw(0xFFFF, IO_INTC_IRQ2); | ||
135 | |||
136 | outw(0xFFFF, IO_INTC_FIQ0); | ||
137 | outw(0xFFFF, IO_INTC_FIQ1); | ||
138 | outw(0xFFFF, IO_INTC_FIQ2); | ||
139 | |||
140 | /* Masking all Interrupts. */ | ||
141 | outw(0, IO_INTC_EINT0); | ||
142 | outw(0, IO_INTC_EINT1); | ||
143 | outw(0, IO_INTC_EINT2); | ||
144 | |||
145 | /* Setting INTC to all IRQs. */ | ||
146 | outw(0, IO_INTC_FISEL0); | ||
147 | outw(0, IO_INTC_FISEL1); | ||
148 | outw(0, IO_INTC_FISEL2); | ||
149 | } | ||
150 | |||
151 | int system_memory_guard(int newmode) | ||
152 | { | ||
153 | (void)newmode; | ||
154 | return 0; | ||
155 | } | ||
156 | |||
157 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ | ||
158 | |||
159 | void set_cpu_frequency(long frequency) | ||
160 | { | ||
161 | if (frequency == CPUFREQ_MAX) | ||
162 | { | ||
163 | asm volatile("mov r0, #0\n" | ||
164 | "mrc p15, 0, r0, c1, c0, 0\n" | ||
165 | "orr r0, r0, #3<<30\n" /* set to Asynchronous mode*/ | ||
166 | "mcr p15, 0, r0, c1, c0, 0" : : : "r0"); | ||
167 | |||
168 | FREQ = CPUFREQ_MAX; | ||
169 | } | ||
170 | else | ||
171 | { | ||
172 | asm volatile("mov r0, #0\n" | ||
173 | "mrc p15, 0, r0, c1, c0, 0\n" | ||
174 | "bic r0, r0, #3<<30\n" /* set to FastBus mode*/ | ||
175 | "mcr p15, 0, r0, c1, c0, 0" : : : "r0"); | ||
176 | |||
177 | FREQ = CPUFREQ_NORMAL; | ||
178 | } | ||
179 | } | ||
180 | |||
181 | #endif | ||
diff --git a/firmware/target/arm/olympus/mrobe-500/timer-mr500.c b/firmware/target/arm/olympus/mrobe-500/timer-mr500.c new file mode 100644 index 0000000000..cd3cec5663 --- /dev/null +++ b/firmware/target/arm/olympus/mrobe-500/timer-mr500.c | |||
@@ -0,0 +1,108 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id: $ | ||
9 | * | ||
10 | * Copyright (C) 2007 by Karl Kurbjun | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | |||
20 | #include "config.h" | ||
21 | #include "cpu.h" | ||
22 | #include "system.h" | ||
23 | #include "timer.h" | ||
24 | #include "logf.h" | ||
25 | |||
26 | /* GPB0/TOUT0 should already have been configured as output so that pin | ||
27 | should not be a functional pin and TIMER0 output unseen there */ | ||
28 | void TIMER0(void) | ||
29 | { | ||
30 | if (pfn_timer != NULL) | ||
31 | pfn_timer(); | ||
32 | } | ||
33 | |||
34 | static void stop_timer(void) | ||
35 | { | ||
36 | } | ||
37 | |||
38 | bool __timer_set(long cycles, bool start) | ||
39 | { | ||
40 | /* taken from linux/arch/arm/mach-itdm320-20/time.c and timer-meg-fx.c */ | ||
41 | |||
42 | /* Turn off all timers */ | ||
43 | /* outw(CONFIG_TIMER0_TMMD_STOP, IO_TIMER0_TMMD); | ||
44 | outw(CONFIG_TIMER1_TMMD_STOP, IO_TIMER1_TMMD); | ||
45 | outw(CONFIG_TIMER2_TMMD_STOP, IO_TIMER2_TMMD); | ||
46 | outw(CONFIG_TIMER3_TMMD_STOP, IO_TIMER3_TMMD); | ||
47 | */ | ||
48 | /* Turn Timer0 to Free Run mode */ | ||
49 | // outw(CONFIG_TIMER0_TMMD_FREE_RUN, IO_TIMER0_TMMD); | ||
50 | |||
51 | bool retval = false; | ||
52 | |||
53 | /* Find the minimum factor that puts the counter in range 1-65535 */ | ||
54 | unsigned int prescaler = (cycles + 65534) / 65535; | ||
55 | |||
56 | /* Test this by writing 1's to registers to see how many bits we have */ | ||
57 | /* Maximum divider setting is x / 1024 / 65536 = x / 67108864 */ | ||
58 | { | ||
59 | int oldlevel; | ||
60 | unsigned int divider; | ||
61 | |||
62 | if (start && pfn_unregister != NULL) | ||
63 | { | ||
64 | pfn_unregister(); | ||
65 | pfn_unregister = NULL; | ||
66 | } | ||
67 | |||
68 | oldlevel = set_irq_level(HIGHEST_IRQ_LEVEL); | ||
69 | |||
70 | /* Max prescale is 1023+1 */ | ||
71 | for (divider = 0; prescaler > 1024; prescaler >>= 1, divider++); | ||
72 | |||
73 | /* Setup the Prescalar */ | ||
74 | outw(prescaler, IO_TIMER0_TMPRSCL); | ||
75 | |||
76 | /* Setup the Divisor */ | ||
77 | outw(divider, IO_TIMER0_TMDIV); | ||
78 | |||
79 | set_irq_level(oldlevel); | ||
80 | |||
81 | retval = true; | ||
82 | } | ||
83 | |||
84 | return retval; | ||
85 | } | ||
86 | |||
87 | bool __timer_register(void) | ||
88 | { | ||
89 | bool retval = true; | ||
90 | |||
91 | int oldstatus = set_interrupt_status(IRQ_FIQ_DISABLED, IRQ_FIQ_STATUS); | ||
92 | |||
93 | stop_timer(); | ||
94 | |||
95 | /* Turn Timer0 to Free Run mode */ | ||
96 | outw(0x0002, IO_TIMER0_TMMD); | ||
97 | |||
98 | set_interrupt_status(oldstatus, IRQ_FIQ_STATUS); | ||
99 | |||
100 | return retval; | ||
101 | } | ||
102 | |||
103 | void __timer_unregister(void) | ||
104 | { | ||
105 | int oldstatus = set_interrupt_status(IRQ_FIQ_DISABLED, IRQ_FIQ_STATUS); | ||
106 | stop_timer(); | ||
107 | set_interrupt_status(oldstatus, IRQ_FIQ_STATUS); | ||
108 | } | ||
diff --git a/firmware/target/arm/olympus/mrobe-500/timer-target.h b/firmware/target/arm/olympus/mrobe-500/timer-target.h new file mode 100644 index 0000000000..320b35d5d3 --- /dev/null +++ b/firmware/target/arm/olympus/mrobe-500/timer-target.h | |||
@@ -0,0 +1,39 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id: $ | ||
9 | * | ||
10 | * Copyright (C) 2007 by Karl Kurbjun | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | #ifndef TIMER_TARGET_H | ||
20 | #define TIMER_TARGET_H | ||
21 | |||
22 | /* timer is based on PCLK and minimum division is 2 */ | ||
23 | #define TIMER_FREQ (49156800/2) | ||
24 | |||
25 | bool __timer_set(long cycles, bool set); | ||
26 | bool __timer_register(void); | ||
27 | void __timer_unregister(void); | ||
28 | |||
29 | #define __TIMER_SET(cycles, set) \ | ||
30 | __timer_set(cycles, set) | ||
31 | |||
32 | #define __TIMER_REGISTER(reg_prio, unregister_callback, cycles, \ | ||
33 | int_prio, timer_callback) \ | ||
34 | __timer_register() | ||
35 | |||
36 | #define __TIMER_UNREGISTER(...) \ | ||
37 | __timer_unregister() | ||
38 | |||
39 | #endif /* TIMER_TARGET_H */ | ||
diff --git a/firmware/target/arm/olympus/mrobe-500/usb-mr500.c b/firmware/target/arm/olympus/mrobe-500/usb-mr500.c new file mode 100644 index 0000000000..e8d0e39c2e --- /dev/null +++ b/firmware/target/arm/olympus/mrobe-500/usb-mr500.c | |||
@@ -0,0 +1,55 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id: $ | ||
9 | * | ||
10 | * Copyright (C) 2007 by Karl Kurbjun | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | |||
20 | #include "config.h" | ||
21 | #include "cpu.h" | ||
22 | #include "system.h" | ||
23 | #include "kernel.h" | ||
24 | #include "ata.h" | ||
25 | |||
26 | #define USB_RST_ASSERT | ||
27 | #define USB_RST_DEASSERT | ||
28 | |||
29 | #define USB_VPLUS_PWR_ASSERT | ||
30 | #define USB_VPLUS_PWR_DEASSERT | ||
31 | |||
32 | #define USB_UNIT_IS_PRESENT false | ||
33 | |||
34 | /* The usb detect is one pin to the cpu active low */ | ||
35 | inline bool usb_detect(void) | ||
36 | { | ||
37 | return USB_UNIT_IS_PRESENT; | ||
38 | } | ||
39 | |||
40 | void usb_init_device(void) | ||
41 | { | ||
42 | // ata_enable(true); | ||
43 | } | ||
44 | |||
45 | void usb_enable(bool on) | ||
46 | { | ||
47 | if (on) | ||
48 | { | ||
49 | USB_VPLUS_PWR_ASSERT; | ||
50 | } | ||
51 | else | ||
52 | { | ||
53 | USB_VPLUS_PWR_DEASSERT; | ||
54 | } | ||
55 | } | ||