diff options
Diffstat (limited to 'firmware/target/arm')
-rw-r--r-- | firmware/target/arm/tatung/tpj1022/adc-target.h | 42 | ||||
-rw-r--r-- | firmware/target/arm/tatung/tpj1022/adc-tpj1022.c | 101 | ||||
-rw-r--r-- | firmware/target/arm/tatung/tpj1022/backlight-target.h | 28 | ||||
-rw-r--r-- | firmware/target/arm/tatung/tpj1022/backlight-tpj1022.c | 44 | ||||
-rw-r--r-- | firmware/target/arm/tatung/tpj1022/button-target.h | 58 | ||||
-rw-r--r-- | firmware/target/arm/tatung/tpj1022/button-tpj1022.c | 83 | ||||
-rw-r--r-- | firmware/target/arm/tatung/tpj1022/lcd-tpj1022.c | 97 | ||||
-rw-r--r-- | firmware/target/arm/tatung/tpj1022/power-tpj1022.c | 67 | ||||
-rw-r--r-- | firmware/target/arm/tatung/tpj1022/usb-target.h | 27 | ||||
-rw-r--r-- | firmware/target/arm/tatung/tpj1022/usb-tpj1022.c | 107 |
10 files changed, 654 insertions, 0 deletions
diff --git a/firmware/target/arm/tatung/tpj1022/adc-target.h b/firmware/target/arm/tatung/tpj1022/adc-target.h new file mode 100644 index 0000000000..3aab373290 --- /dev/null +++ b/firmware/target/arm/tatung/tpj1022/adc-target.h | |||
@@ -0,0 +1,42 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2006 by Barry Wardell | ||
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 _ADC_TARGET_H_ | ||
20 | #define _ADC_TARGET_H_ | ||
21 | |||
22 | #define ADC_ENABLE_ADDR (*(volatile unsigned long*)(0x70000010)) | ||
23 | #define ADC_ENABLE 0x1100 | ||
24 | |||
25 | #define ADC_ADDR (*(volatile unsigned long*)(0x7000ad00)) | ||
26 | #define ADC_STATUS (*(volatile unsigned long*)(0x7000ad04)) | ||
27 | #define ADC_DATA_1 (*(volatile unsigned long*)(0x7000ad20)) | ||
28 | #define ADC_DATA_2 (*(volatile unsigned long*)(0x7000ad24)) | ||
29 | #define ADC_INIT (*(volatile unsigned long*)(0x7000ad2c)) | ||
30 | |||
31 | #define NUM_ADC_CHANNELS 4 | ||
32 | |||
33 | #define ADC_BATTERY 0 | ||
34 | #define ADC_UNKNOWN_1 1 | ||
35 | #define ADC_UNKNOWN_2 2 | ||
36 | #define ADC_SCROLLPAD 3 | ||
37 | #define ADC_UNREG_POWER ADC_BATTERY /* For compatibility */ | ||
38 | |||
39 | /* Force a scan now */ | ||
40 | unsigned short adc_scan(int channel); | ||
41 | |||
42 | #endif | ||
diff --git a/firmware/target/arm/tatung/tpj1022/adc-tpj1022.c b/firmware/target/arm/tatung/tpj1022/adc-tpj1022.c new file mode 100644 index 0000000000..134b90b587 --- /dev/null +++ b/firmware/target/arm/tatung/tpj1022/adc-tpj1022.c | |||
@@ -0,0 +1,101 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2006 by Barry Wardell | ||
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 | #include "config.h" | ||
20 | #include "cpu.h" | ||
21 | #include "system.h" | ||
22 | #include "kernel.h" | ||
23 | #include "thread.h" | ||
24 | #include "adc.h" | ||
25 | |||
26 | static unsigned short adcdata[NUM_ADC_CHANNELS]; | ||
27 | |||
28 | /* Scan ADC so that adcdata[channel] gets updated */ | ||
29 | unsigned short adc_scan(int channel) | ||
30 | { | ||
31 | unsigned int adc_data_1; | ||
32 | unsigned int adc_data_2; | ||
33 | |||
34 | /* Initialise */ | ||
35 | ADC_ADDR=0x130; | ||
36 | ADC_STATUS=0; /* 4 bytes, 1 per channel. Each byte is 0 if the channel is | ||
37 | off, 0x40 if the channel is on */ | ||
38 | |||
39 | /* Enable Channel */ | ||
40 | ADC_ADDR |= (0x1000000<<channel); | ||
41 | |||
42 | /* Start? */ | ||
43 | ADC_ADDR |= 0x20000000; | ||
44 | ADC_ADDR |= 0x80000000; | ||
45 | |||
46 | /* ADC_DATA_1 and ADC_DATA_2 are both four bytes, one byte per channel. | ||
47 | For each channel, ADC_DATA_1 stores the 8-bit msb, ADC_DATA_2 stores the | ||
48 | 2-bit lsb (in bits 0 and 1). Each channel is 10 bits total. */ | ||
49 | adc_data_1 = ((ADC_DATA_1 >> (8*channel)) & 0xff); | ||
50 | adc_data_2 = ((ADC_DATA_2 >> (8*channel+6)) & 0x3); | ||
51 | |||
52 | adcdata[channel] = (adc_data_1<<2 | adc_data_2); | ||
53 | |||
54 | return adcdata[channel]; | ||
55 | } | ||
56 | |||
57 | /* Read 10-bit channel data */ | ||
58 | unsigned short adc_read(int channel) | ||
59 | { | ||
60 | return adcdata[channel]; | ||
61 | } | ||
62 | |||
63 | static int adc_counter; | ||
64 | |||
65 | static void adc_tick(void) | ||
66 | { | ||
67 | if(++adc_counter == HZ) | ||
68 | { | ||
69 | adc_counter = 0; | ||
70 | adc_scan(ADC_BATTERY); | ||
71 | adc_scan(ADC_UNKNOWN_1); | ||
72 | adc_scan(ADC_UNKNOWN_2); | ||
73 | adc_scan(ADC_SCROLLPAD); | ||
74 | } | ||
75 | } | ||
76 | |||
77 | void adc_init(void) | ||
78 | { | ||
79 | /* Enable ADC */ | ||
80 | ADC_ENABLE_ADDR |= ADC_ENABLE; | ||
81 | |||
82 | /* Initialise */ | ||
83 | ADC_INIT=0; | ||
84 | ADC_ADDR=0x130; | ||
85 | ADC_STATUS=0; | ||
86 | |||
87 | /* Enable Channels 1-4 */ | ||
88 | ADC_ADDR |= 0x1000000; | ||
89 | ADC_ADDR |= 0x2000000; | ||
90 | ADC_ADDR |= 0x4000000; | ||
91 | ADC_ADDR |= 0x8000000; | ||
92 | |||
93 | /* Start? */ | ||
94 | ADC_ADDR |= 0x20000000; | ||
95 | ADC_ADDR |= 0x80000000; | ||
96 | |||
97 | /* Wait 50ms for things to settle */ | ||
98 | sleep(HZ/20); | ||
99 | |||
100 | tick_add_task(adc_tick); | ||
101 | } | ||
diff --git a/firmware/target/arm/tatung/tpj1022/backlight-target.h b/firmware/target/arm/tatung/tpj1022/backlight-target.h new file mode 100644 index 0000000000..b5fe2f7c5d --- /dev/null +++ b/firmware/target/arm/tatung/tpj1022/backlight-target.h | |||
@@ -0,0 +1,28 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2006 by Barry Wardell | ||
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 | /* Taken from the x5's implementation */ | ||
21 | |||
22 | #ifndef BACKLIGHT_TARGET_H | ||
23 | #define BACKLIGHT_TARGET_H | ||
24 | |||
25 | void __backlight_on(void); | ||
26 | void __backlight_off(void); | ||
27 | |||
28 | #endif | ||
diff --git a/firmware/target/arm/tatung/tpj1022/backlight-tpj1022.c b/firmware/target/arm/tatung/tpj1022/backlight-tpj1022.c new file mode 100644 index 0000000000..51218e21be --- /dev/null +++ b/firmware/target/arm/tatung/tpj1022/backlight-tpj1022.c | |||
@@ -0,0 +1,44 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2006 by Barry Wardell | ||
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 | /* The H10 display (and hence backlight) possibly identical to that of the X5, | ||
21 | so that code was used here but left #if 0'ed out for the moment */ | ||
22 | |||
23 | #include "config.h" | ||
24 | #include "cpu.h" | ||
25 | #include "system.h" | ||
26 | #include "backlight.h" | ||
27 | |||
28 | void __backlight_on(void) | ||
29 | { | ||
30 | #if 0 | ||
31 | int level = set_irq_level(HIGHEST_IRQ_LEVEL); | ||
32 | pcf50606_write(0x38, 0xb0); /* Backlight ON, GPO1INV=1, GPO1ACT=011 */ | ||
33 | set_irq_level(level); | ||
34 | #endif | ||
35 | } | ||
36 | |||
37 | void __backlight_off(void) | ||
38 | { | ||
39 | #if 0 | ||
40 | int level = set_irq_level(HIGHEST_IRQ_LEVEL); | ||
41 | pcf50606_write(0x38, 0x80); /* Backlight OFF, GPO1INV=1, GPO1ACT=000 */ | ||
42 | set_irq_level(level); | ||
43 | #endif | ||
44 | } | ||
diff --git a/firmware/target/arm/tatung/tpj1022/button-target.h b/firmware/target/arm/tatung/tpj1022/button-target.h new file mode 100644 index 0000000000..74bd61ed3d --- /dev/null +++ b/firmware/target/arm/tatung/tpj1022/button-target.h | |||
@@ -0,0 +1,58 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2006 by Barry Wardell | ||
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 | /* Tatung Elio TPJ-1022 button codes */ | ||
33 | |||
34 | /* Main unit's buttons */ | ||
35 | #define BUTTON_POWER 0x00000001 | ||
36 | |||
37 | #define BUTTON_LEFT 0x00000002 | ||
38 | #define BUTTON_RIGHT 0x00000004 | ||
39 | #define BUTTON_UP 0x00000008 | ||
40 | #define BUTTON_DOWN 0x00000010 | ||
41 | |||
42 | #define BUTTON_MENU 0x00000020 | ||
43 | #define BUTTON_FF 0x00000040 | ||
44 | #define BUTTON_REW 0x00000080 | ||
45 | #define BUTTON_REC 0x00000100 | ||
46 | #define BUTTON_AB 0x00000200 | ||
47 | #define BUTTON_PLUS 0x00000400 | ||
48 | #define BUTTON_MINUS 0x00000800 | ||
49 | |||
50 | #define BUTTON_MAIN 0x00000fff | ||
51 | |||
52 | /* No Remote control */ | ||
53 | #define BUTTON_REMOTE 0 | ||
54 | |||
55 | #define POWEROFF_BUTTON BUTTON_POWER | ||
56 | #define POWEROFF_COUNT 10 | ||
57 | |||
58 | #endif /* _BUTTON_TARGET_H_ */ | ||
diff --git a/firmware/target/arm/tatung/tpj1022/button-tpj1022.c b/firmware/target/arm/tatung/tpj1022/button-tpj1022.c new file mode 100644 index 0000000000..f0b338c1c1 --- /dev/null +++ b/firmware/target/arm/tatung/tpj1022/button-tpj1022.c | |||
@@ -0,0 +1,83 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2006 by Barry Wardell | ||
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 | /* Custom written for the TPJ-1022 based on analysis of the GPIO data */ | ||
21 | |||
22 | #include <stdlib.h> | ||
23 | #include "config.h" | ||
24 | #include "cpu.h" | ||
25 | #include "system.h" | ||
26 | #include "button.h" | ||
27 | #include "kernel.h" | ||
28 | #include "backlight.h" | ||
29 | #include "adc.h" | ||
30 | #include "system.h" | ||
31 | |||
32 | void button_init_device(void) | ||
33 | { | ||
34 | /* No hardware initialisation required as it is done by the bootloader */ | ||
35 | } | ||
36 | |||
37 | bool button_hold(void) | ||
38 | { | ||
39 | return false; | ||
40 | } | ||
41 | |||
42 | /* | ||
43 | * Get button pressed from hardware | ||
44 | */ | ||
45 | int button_read_device(void) | ||
46 | { | ||
47 | int btn = BUTTON_NONE; | ||
48 | unsigned char state; | ||
49 | static bool hold_button = false; | ||
50 | |||
51 | #if 0 | ||
52 | /* light handling */ | ||
53 | if (hold_button && !button_hold()) | ||
54 | { | ||
55 | backlight_on(); | ||
56 | } | ||
57 | #endif | ||
58 | |||
59 | hold_button = button_hold(); | ||
60 | if (!hold_button) | ||
61 | { | ||
62 | /* Read normal buttons */ | ||
63 | state = GPIOA_INPUT_VAL; | ||
64 | if ((state & 0x2) == 0) btn |= BUTTON_REW; | ||
65 | if ((state & 0x4) == 0) btn |= BUTTON_FF; | ||
66 | if ((state & 0x80) == 0) btn |= BUTTON_RIGHT; | ||
67 | |||
68 | /* Buttons left to figure out: | ||
69 | button_hold() | ||
70 | BUTTON_POWER | ||
71 | BUTTON_LEFT | ||
72 | BUTTON_UP | ||
73 | BUTTON_DOWN | ||
74 | BUTTON_MENU | ||
75 | BUTTON_REC | ||
76 | BUTTON_AB | ||
77 | BUTTON_PLUS | ||
78 | BUTTON_MINUS | ||
79 | */ | ||
80 | } | ||
81 | |||
82 | return btn; | ||
83 | } | ||
diff --git a/firmware/target/arm/tatung/tpj1022/lcd-tpj1022.c b/firmware/target/arm/tatung/tpj1022/lcd-tpj1022.c new file mode 100644 index 0000000000..53f32792c3 --- /dev/null +++ b/firmware/target/arm/tatung/tpj1022/lcd-tpj1022.c | |||
@@ -0,0 +1,97 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2006 by Barry Wardell | ||
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 | #include "config.h" | ||
20 | #include "cpu.h" | ||
21 | #include "lcd.h" | ||
22 | #include "kernel.h" | ||
23 | #include "system.h" | ||
24 | |||
25 | /*** hardware configuration ***/ | ||
26 | |||
27 | void lcd_set_contrast(int val) | ||
28 | { | ||
29 | /* TODO: Implement lcd_set_contrast() */ | ||
30 | (void)val; | ||
31 | } | ||
32 | |||
33 | void lcd_set_invert_display(bool yesno) | ||
34 | { | ||
35 | /* TODO: Implement lcd_set_invert_display() */ | ||
36 | (void)yesno; | ||
37 | } | ||
38 | |||
39 | /* turn the display upside down (call lcd_update() afterwards) */ | ||
40 | void lcd_set_flip(bool yesno) | ||
41 | { | ||
42 | /* TODO: Implement lcd_set_flip() */ | ||
43 | (void)yesno; | ||
44 | } | ||
45 | |||
46 | /* LCD init */ | ||
47 | void lcd_init_device(void) | ||
48 | { | ||
49 | |||
50 | } | ||
51 | |||
52 | /*** update functions ***/ | ||
53 | |||
54 | /* Performance function that works with an external buffer | ||
55 | note that by and bheight are in 4-pixel units! */ | ||
56 | void lcd_blit(const fb_data* data, int x, int by, int width, | ||
57 | int bheight, int stride) | ||
58 | { | ||
59 | /* TODO: Implement lcd_blit() */ | ||
60 | (void)data; | ||
61 | (void)x; | ||
62 | (void)by; | ||
63 | (void)width; | ||
64 | (void)bheight; | ||
65 | (void)stride; | ||
66 | } | ||
67 | |||
68 | /* Performance function to blit a YUV bitmap directly to the LCD */ | ||
69 | void lcd_yuv_blit(unsigned char * const src[3], | ||
70 | int src_x, int src_y, int stride, | ||
71 | int x, int y, int width, int height) | ||
72 | { | ||
73 | (void)src; | ||
74 | (void)src_x; | ||
75 | (void)src_y; | ||
76 | (void)stride; | ||
77 | (void)x; | ||
78 | (void)y; | ||
79 | (void)width; | ||
80 | (void)height; | ||
81 | } | ||
82 | |||
83 | /* Update a fraction of the display. */ | ||
84 | void lcd_update_rect(int x0, int y0, int width, int height) | ||
85 | { | ||
86 | (void)x0; | ||
87 | (void)y0; | ||
88 | (void)width; | ||
89 | (void)height; | ||
90 | } | ||
91 | |||
92 | /* Update the display. | ||
93 | This must be called after all other LCD functions that change the display. */ | ||
94 | void lcd_update(void) | ||
95 | { | ||
96 | lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT); | ||
97 | } | ||
diff --git a/firmware/target/arm/tatung/tpj1022/power-tpj1022.c b/firmware/target/arm/tatung/tpj1022/power-tpj1022.c new file mode 100644 index 0000000000..e8bc4e1fb0 --- /dev/null +++ b/firmware/target/arm/tatung/tpj1022/power-tpj1022.c | |||
@@ -0,0 +1,67 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2006 by Barry Wardell | ||
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 | /* Created from power.c using some iPod code, and some custom stuff based on | ||
21 | GPIO analysis | ||
22 | */ | ||
23 | |||
24 | #include "config.h" | ||
25 | #include "cpu.h" | ||
26 | #include <stdbool.h> | ||
27 | #include "adc.h" | ||
28 | #include "kernel.h" | ||
29 | #include "system.h" | ||
30 | #include "power.h" | ||
31 | #include "hwcompat.h" | ||
32 | #include "logf.h" | ||
33 | #include "usb.h" | ||
34 | |||
35 | #if CONFIG_CHARGING == CHARGING_CONTROL | ||
36 | bool charger_enabled; | ||
37 | #endif | ||
38 | |||
39 | void power_init(void) | ||
40 | { | ||
41 | } | ||
42 | |||
43 | bool charger_inserted(void) | ||
44 | { | ||
45 | return false; | ||
46 | } | ||
47 | |||
48 | void ide_power_enable(bool on) | ||
49 | { | ||
50 | (void)on; | ||
51 | /* We do nothing on the iPod */ | ||
52 | } | ||
53 | |||
54 | |||
55 | bool ide_powered(void) | ||
56 | { | ||
57 | /* pretend we are always powered - we don't turn it off on the ipod */ | ||
58 | return true; | ||
59 | } | ||
60 | |||
61 | void power_off(void) | ||
62 | { | ||
63 | /* Give things a second to settle before cutting power */ | ||
64 | sleep(HZ); | ||
65 | |||
66 | //GPIOF_OUTPUT_VAL &=~ 0x20; | ||
67 | } | ||
diff --git a/firmware/target/arm/tatung/tpj1022/usb-target.h b/firmware/target/arm/tatung/tpj1022/usb-target.h new file mode 100644 index 0000000000..7a17f7bacf --- /dev/null +++ b/firmware/target/arm/tatung/tpj1022/usb-target.h | |||
@@ -0,0 +1,27 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2006 by Barry Wardelll | ||
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 | /* Based off x5 version */ | ||
21 | |||
22 | #ifndef USB_TARGET_H | ||
23 | #define USB_TARGET_H | ||
24 | |||
25 | bool usb_init_device(void); | ||
26 | |||
27 | #endif | ||
diff --git a/firmware/target/arm/tatung/tpj1022/usb-tpj1022.c b/firmware/target/arm/tatung/tpj1022/usb-tpj1022.c new file mode 100644 index 0000000000..b238de4369 --- /dev/null +++ b/firmware/target/arm/tatung/tpj1022/usb-tpj1022.c | |||
@@ -0,0 +1,107 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2006 by Barry Wardell | ||
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 | /* Code from the iPod port but commented out. USB detection custom made based | ||
21 | on GPIO analysis */ | ||
22 | |||
23 | #include "config.h" | ||
24 | #include "cpu.h" | ||
25 | #include "kernel.h" | ||
26 | #include "thread.h" | ||
27 | #include "system.h" | ||
28 | #include "debug.h" | ||
29 | #include "ata.h" | ||
30 | #include "fat.h" | ||
31 | #include "disk.h" | ||
32 | #include "panic.h" | ||
33 | #include "lcd.h" | ||
34 | #include "adc.h" | ||
35 | #include "usb.h" | ||
36 | #include "button.h" | ||
37 | #include "sprintf.h" | ||
38 | #include "string.h" | ||
39 | #include "hwcompat.h" | ||
40 | #ifdef HAVE_MMC | ||
41 | #include "ata_mmc.h" | ||
42 | #endif | ||
43 | |||
44 | void usb_init_device(void) | ||
45 | { | ||
46 | #if 0 | ||
47 | int r0; | ||
48 | outl(inl(0x70000084) | 0x200, 0x70000084); | ||
49 | |||
50 | outl(inl(0x7000002C) | 0x3000000, 0x7000002C); | ||
51 | outl(inl(0x6000600C) | 0x400000, 0x6000600C); | ||
52 | |||
53 | outl(inl(0x60006004) | 0x400000, 0x60006004); /* reset usb start */ | ||
54 | outl(inl(0x60006004) & ~0x400000, 0x60006004); /* reset usb end */ | ||
55 | |||
56 | outl(inl(0x70000020) | 0x80000000, 0x70000020); | ||
57 | while ((inl(0x70000028) & 0x80) == 0); | ||
58 | |||
59 | outl(inl(0xc5000184) | 0x100, 0xc5000184); | ||
60 | while ((inl(0xc5000184) & 0x100) != 0); | ||
61 | |||
62 | outl(inl(0xc50001A4) | 0x5F000000, 0xc50001A4); | ||
63 | if ((inl(0xc50001A4) & 0x100) == 0) { | ||
64 | outl(inl(0xc50001A8) & ~0x3, 0xc50001A8); | ||
65 | outl(inl(0xc50001A8) | 0x2, 0xc50001A8); | ||
66 | outl(inl(0x70000028) | 0x4000, 0x70000028); | ||
67 | outl(inl(0x70000028) | 0x2, 0x70000028); | ||
68 | } else { | ||
69 | outl(inl(0xc50001A8) | 0x3, 0xc50001A8); | ||
70 | outl(inl(0x70000028) &~0x4000, 0x70000028); | ||
71 | outl(inl(0x70000028) | 0x2, 0x70000028); | ||
72 | } | ||
73 | outl(inl(0xc5000140) | 0x2, 0xc5000140); | ||
74 | while((inl(0xc5000140) & 0x2) != 0); | ||
75 | r0 = inl(0xc5000184); | ||
76 | |||
77 | /* Note from IPL source (referring to next 5 lines of code: | ||
78 | THIS NEEDS TO BE CHANGED ONCE THERE IS KERNEL USB */ | ||
79 | outl(inl(0x70000020) | 0x80000000, 0x70000020); | ||
80 | outl(inl(0x6000600C) | 0x400000, 0x6000600C); | ||
81 | while ((inl(0x70000028) & 0x80) == 0); | ||
82 | outl(inl(0x70000028) | 0x2, 0x70000028); | ||
83 | |||
84 | udelay(0x186A0); | ||
85 | #endif | ||
86 | } | ||
87 | |||
88 | bool usb_detect(void) | ||
89 | { | ||
90 | return false; | ||
91 | } | ||
92 | |||
93 | void usb_enable(bool on) | ||
94 | { | ||
95 | (void)on; | ||
96 | #if 0 | ||
97 | /* For the ipod, we can only do one thing with USB mode - reboot | ||
98 | into Apple's flash-based disk-mode. This does not return. */ | ||
99 | if (on) | ||
100 | { | ||
101 | /* The following code is copied from ipodlinux */ | ||
102 | unsigned char* storage_ptr = (unsigned char *)0x40017F00; | ||
103 | memcpy(storage_ptr, "diskmode\0\0hotstuff\0\0\1", 21); | ||
104 | DEV_RS |= 4; /* Reboot */ | ||
105 | } | ||
106 | #endif | ||
107 | } | ||