diff options
Diffstat (limited to 'firmware/target/arm/olympus')
-rw-r--r-- | firmware/target/arm/olympus/mrobe-100/adc-mr100.c | 141 | ||||
-rw-r--r-- | firmware/target/arm/olympus/mrobe-100/adc-target.h | 39 | ||||
-rw-r--r-- | firmware/target/arm/olympus/mrobe-100/backlight-mr100.c | 57 | ||||
-rw-r--r-- | firmware/target/arm/olympus/mrobe-100/backlight-target.h | 41 | ||||
-rw-r--r-- | firmware/target/arm/olympus/mrobe-100/button-mr100.c | 60 | ||||
-rw-r--r-- | firmware/target/arm/olympus/mrobe-100/button-target.h | 64 | ||||
-rw-r--r-- | firmware/target/arm/olympus/mrobe-100/lcd-mr100.c | 192 | ||||
-rw-r--r-- | firmware/target/arm/olympus/mrobe-100/power-mr100.c | 62 | ||||
-rw-r--r-- | firmware/target/arm/olympus/mrobe-100/powermgmt-mr100.c | 59 |
9 files changed, 715 insertions, 0 deletions
diff --git a/firmware/target/arm/olympus/mrobe-100/adc-mr100.c b/firmware/target/arm/olympus/mrobe-100/adc-mr100.c new file mode 100644 index 0000000000..f63e8b8013 --- /dev/null +++ b/firmware/target/arm/olympus/mrobe-100/adc-mr100.c | |||
@@ -0,0 +1,141 @@ | |||
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 | /* Start conversion */ | ||
35 | ADC_ADDR |= 0x80000000; | ||
36 | |||
37 | /* Wait for conversion to complete */ | ||
38 | while((ADC_STATUS & (0x40<<8*channel))==0); | ||
39 | |||
40 | /* Stop conversion */ | ||
41 | ADC_ADDR &=~ 0x80000000; | ||
42 | |||
43 | /* ADC_DATA_1 and ADC_DATA_2 are both four bytes, one byte per channel. | ||
44 | For each channel, ADC_DATA_1 stores the 8-bit msb, ADC_DATA_2 stores the | ||
45 | 2-bit lsb (in bits 0 and 1). Each channel is 10 bits total. */ | ||
46 | adc_data_1 = ((ADC_DATA_1 >> (8*channel)) & 0xff); | ||
47 | adc_data_2 = ((ADC_DATA_2 >> (8*channel+6)) & 0x3); | ||
48 | |||
49 | adcdata[channel] = (adc_data_1<<2 | adc_data_2); | ||
50 | |||
51 | /* ADC values read low if PLL is enabled */ | ||
52 | if(PLL_CONTROL & 0x80000000){ | ||
53 | adcdata[channel] += 0x14; | ||
54 | if(adcdata[channel] > 0x400) | ||
55 | adcdata[channel] = 0x400; | ||
56 | } | ||
57 | |||
58 | return adcdata[channel]; | ||
59 | } | ||
60 | |||
61 | /* Read 10-bit channel data */ | ||
62 | unsigned short adc_read(int channel) | ||
63 | { | ||
64 | return adcdata[channel]; | ||
65 | } | ||
66 | |||
67 | static int adc_counter; | ||
68 | |||
69 | static void adc_tick(void) | ||
70 | { | ||
71 | if(++adc_counter == HZ) | ||
72 | { | ||
73 | adc_counter = 0; | ||
74 | adc_scan(ADC_BATTERY); | ||
75 | adc_scan(ADC_UNKNOWN_1); | ||
76 | adc_scan(ADC_REMOTE); | ||
77 | adc_scan(ADC_SCROLLPAD); | ||
78 | } | ||
79 | } | ||
80 | |||
81 | /* Figured out from how the OF does things */ | ||
82 | void adc_init(void) | ||
83 | { | ||
84 | ADC_INIT |= 1; | ||
85 | ADC_INIT |= 0x40000000; | ||
86 | udelay(100); | ||
87 | |||
88 | /* Reset ADC */ | ||
89 | DEV_RS2 |= 0x20; | ||
90 | udelay(100); | ||
91 | |||
92 | DEV_RS2 &=~ 0x20; | ||
93 | udelay(100); | ||
94 | |||
95 | /* Enable ADC */ | ||
96 | DEV_EN2 |= 0x20; | ||
97 | udelay(100); | ||
98 | |||
99 | ADC_CLOCK_SRC |= 0x3; | ||
100 | udelay(100); | ||
101 | |||
102 | ADC_ADDR |= 0x40; | ||
103 | ADC_ADDR |= 0x20000000; | ||
104 | udelay(100); | ||
105 | |||
106 | ADC_INIT; | ||
107 | ADC_INIT = 0; | ||
108 | udelay(100); | ||
109 | |||
110 | ADC_STATUS = 0; | ||
111 | |||
112 | /* Enable channel 0 (battery) */ | ||
113 | DEV_INIT1 &=~0x3; | ||
114 | ADC_ADDR |= 0x1000000; | ||
115 | ADC_STATUS |= 0x20; | ||
116 | |||
117 | /* Enable channel 1 (unknown, temperature?) */ | ||
118 | DEV_INIT1 &=~30; | ||
119 | ADC_ADDR |= 0x2000000; | ||
120 | ADC_STATUS |= 0x2000; | ||
121 | |||
122 | /* Enable channel 2 (remote) */ | ||
123 | DEV_INIT1 &=~0x300; | ||
124 | DEV_INIT1 |= 0x100; | ||
125 | ADC_ADDR |= 0x4000000; | ||
126 | ADC_STATUS |= 0x200000; | ||
127 | |||
128 | /* Enable channel 3 (scroll pad) */ | ||
129 | DEV_INIT1 &=~0x3000; | ||
130 | DEV_INIT1 |= 0x1000; | ||
131 | ADC_ADDR |= 0x8000000; | ||
132 | ADC_STATUS |= 0x20000000; | ||
133 | |||
134 | /* Force a scan of all channels to get initial values */ | ||
135 | adc_scan(ADC_BATTERY); | ||
136 | adc_scan(ADC_UNKNOWN_1); | ||
137 | adc_scan(ADC_REMOTE); | ||
138 | adc_scan(ADC_SCROLLPAD); | ||
139 | |||
140 | tick_add_task(adc_tick); | ||
141 | } | ||
diff --git a/firmware/target/arm/olympus/mrobe-100/adc-target.h b/firmware/target/arm/olympus/mrobe-100/adc-target.h new file mode 100644 index 0000000000..f761e761ef --- /dev/null +++ b/firmware/target/arm/olympus/mrobe-100/adc-target.h | |||
@@ -0,0 +1,39 @@ | |||
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_ADDR (*(volatile unsigned long*)(0x7000ad00)) | ||
23 | #define ADC_STATUS (*(volatile unsigned long*)(0x7000ad04)) | ||
24 | #define ADC_DATA_1 (*(volatile unsigned long*)(0x7000ad20)) | ||
25 | #define ADC_DATA_2 (*(volatile unsigned long*)(0x7000ad24)) | ||
26 | #define ADC_INIT (*(volatile unsigned long*)(0x7000ad2c)) | ||
27 | |||
28 | #define NUM_ADC_CHANNELS 4 | ||
29 | |||
30 | #define ADC_BATTERY 0 | ||
31 | #define ADC_UNKNOWN_1 1 | ||
32 | #define ADC_REMOTE 2 | ||
33 | #define ADC_SCROLLPAD 3 | ||
34 | #define ADC_UNREG_POWER ADC_BATTERY /* For compatibility */ | ||
35 | |||
36 | /* Force a scan now */ | ||
37 | unsigned short adc_scan(int channel); | ||
38 | |||
39 | #endif | ||
diff --git a/firmware/target/arm/olympus/mrobe-100/backlight-mr100.c b/firmware/target/arm/olympus/mrobe-100/backlight-mr100.c new file mode 100644 index 0000000000..10a7f666e5 --- /dev/null +++ b/firmware/target/arm/olympus/mrobe-100/backlight-mr100.c | |||
@@ -0,0 +1,57 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2008 by Mark Arigo | ||
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 "backlight-target.h" | ||
21 | #include "system.h" | ||
22 | #include "lcd.h" | ||
23 | #include "backlight.h" | ||
24 | #include "i2c-pp.h" | ||
25 | |||
26 | void _backlight_on(void) | ||
27 | { | ||
28 | } | ||
29 | |||
30 | void _backlight_off(void) | ||
31 | { | ||
32 | } | ||
33 | |||
34 | void _buttonlight_on(void) | ||
35 | { | ||
36 | /* turn on all touchpad leds */ | ||
37 | GPIOA_OUTPUT_VAL |= BUTTONLIGHT_ALL; | ||
38 | |||
39 | #if 0 | ||
40 | /* Writing to 0x7000a010 controls the brightness of the leds. | ||
41 | This routine fades the leds from dim to bright, like when | ||
42 | you first turn the unit on. */ | ||
43 | unsigned long val = 0x80ff08ff; | ||
44 | int i = 0; | ||
45 | for (i = 0; i < 16; i++) | ||
46 | outl(val, 0x7000a010); | ||
47 | udelay(100000); | ||
48 | val -= 0x110000; | ||
49 | } | ||
50 | #endif | ||
51 | } | ||
52 | |||
53 | void _buttonlight_off(void) | ||
54 | { | ||
55 | /* turn off all touchpad leds */ | ||
56 | GPIOA_OUTPUT_VAL &= ~BUTTONLIGHT_ALL; | ||
57 | } | ||
diff --git a/firmware/target/arm/olympus/mrobe-100/backlight-target.h b/firmware/target/arm/olympus/mrobe-100/backlight-target.h new file mode 100644 index 0000000000..e6c8387222 --- /dev/null +++ b/firmware/target/arm/olympus/mrobe-100/backlight-target.h | |||
@@ -0,0 +1,41 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2008 by Mark Arigo | ||
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 | #define _backlight_init() true | ||
24 | void _backlight_on(void); | ||
25 | void _backlight_off(void); | ||
26 | |||
27 | /* Button lights are controlled by GPIOA_OUTPUT_VAL */ | ||
28 | #define BUTTONLIGHT_PLAY 0x01 | ||
29 | #define BUTTONLIGHT_MENU 0x02 | ||
30 | #define BUTTONLIGHT_DISPLAY 0x04 | ||
31 | #define BUTTONLIGHT_LEFT 0x08 | ||
32 | #define BUTTONLIGHT_RIGHT 0x10 | ||
33 | #define BUTTONLIGHT_SCROLL 0x20 | ||
34 | #define BUTTONLIGHT_ALL (BUTTONLIGHT_PLAY | BUTTONLIGHT_MENU | \ | ||
35 | BUTTONLIGHT_DISPLAY | BUTTONLIGHT_LEFT | \ | ||
36 | BUTTONLIGHT_RIGHT | BUTTONLIGHT_SCROLL) | ||
37 | |||
38 | void _buttonlight_on(void); | ||
39 | void _buttonlight_off(void); | ||
40 | |||
41 | #endif | ||
diff --git a/firmware/target/arm/olympus/mrobe-100/button-mr100.c b/firmware/target/arm/olympus/mrobe-100/button-mr100.c new file mode 100644 index 0000000000..141a6d5b0c --- /dev/null +++ b/firmware/target/arm/olympus/mrobe-100/button-mr100.c | |||
@@ -0,0 +1,60 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2008 by Mark Arigo | ||
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 <stdlib.h> | ||
21 | #include "config.h" | ||
22 | #include "cpu.h" | ||
23 | #include "system.h" | ||
24 | #include "button.h" | ||
25 | #include "kernel.h" | ||
26 | #include "backlight.h" | ||
27 | #include "backlight-target.h" | ||
28 | #include "system.h" | ||
29 | |||
30 | void button_int(void) | ||
31 | { | ||
32 | } | ||
33 | |||
34 | void button_init_device(void) | ||
35 | { | ||
36 | /* taken from the mr-100 bootloader (offset 0x1e72) */ | ||
37 | //~ DEV_EN |= 0x20000; /* enable the touchpad ?? */ | ||
38 | |||
39 | /* enable touchpad leds */ | ||
40 | GPIOA_ENABLE |= 0xff; | ||
41 | GPIOA_OUTPUT_EN |= BUTTONLIGHT_ALL; | ||
42 | } | ||
43 | |||
44 | /* | ||
45 | * Get button pressed from hardware | ||
46 | */ | ||
47 | int button_read_device(void) | ||
48 | { | ||
49 | return BUTTON_NONE; | ||
50 | } | ||
51 | |||
52 | bool button_hold(void) | ||
53 | { | ||
54 | return (GPIOD_INPUT_VAL & BUTTON_HOLD) ? false : true; | ||
55 | } | ||
56 | |||
57 | bool headphones_inserted(void) | ||
58 | { | ||
59 | return (GPIOD_INPUT_VAL & 0x80) ? true : false; | ||
60 | } | ||
diff --git a/firmware/target/arm/olympus/mrobe-100/button-target.h b/firmware/target/arm/olympus/mrobe-100/button-target.h new file mode 100644 index 0000000000..99f17bb09b --- /dev/null +++ b/firmware/target/arm/olympus/mrobe-100/button-target.h | |||
@@ -0,0 +1,64 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2008 by Mark Arigo | ||
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 | /* Power button is on GPIOA */ | ||
33 | #define BUTTON_POWER 0x80 | ||
34 | #define POWEROFF_BUTTON BUTTON_POWER | ||
35 | #define POWEROFF_COUNT 10 | ||
36 | |||
37 | /* Hold button is on GPIOD */ | ||
38 | #define BUTTON_HOLD 0x10 | ||
39 | |||
40 | /* FIXME: Until the buttons are figured out, we use the button definitions | ||
41 | for the H10 keypad & remote. THESE ARE NOT CORRECT! */ | ||
42 | |||
43 | /* Main unit's buttons */ | ||
44 | #define BUTTON_LEFT 0x00000002 | ||
45 | #define BUTTON_RIGHT 0x00000004 | ||
46 | #define BUTTON_REW 0x00000008 | ||
47 | #define BUTTON_PLAY 0x00000010 | ||
48 | #define BUTTON_FF 0x00000020 | ||
49 | #define BUTTON_SCROLL_UP 0x00000040 | ||
50 | #define BUTTON_SCROLL_DOWN 0x00000080 | ||
51 | #define BUTTON_MAIN (BUTTON_POWER|BUTTON_O|BUTTON_BACK|BUTTON_REW\ | ||
52 | |BUTTON_PLAY|BUTTON_FF) | ||
53 | |||
54 | /* Remote control's buttons */ | ||
55 | #define BUTTON_RC_REW 0x00080000 | ||
56 | #define BUTTON_RC_PLAY 0x00100000 | ||
57 | #define BUTTON_RC_FF 0x00200000 | ||
58 | #define BUTTON_RC_VOL_UP 0x00400000 | ||
59 | #define BUTTON_RC_VOL_DOWN 0x00800000 | ||
60 | #define BUTTON_REMOTE (BUTTON_RC_PLAY|BUTTON_RC_VOL_UP|BUTTON_RC_VOL_DOWN\ | ||
61 | |BUTTON_RC_REW|BUTTON_RC_FF) | ||
62 | #define RC_POWEROFF_BUTTON BUTTON_RC_PLAY | ||
63 | |||
64 | #endif /* _BUTTON_TARGET_H_ */ | ||
diff --git a/firmware/target/arm/olympus/mrobe-100/lcd-mr100.c b/firmware/target/arm/olympus/mrobe-100/lcd-mr100.c new file mode 100644 index 0000000000..501a0942e5 --- /dev/null +++ b/firmware/target/arm/olympus/mrobe-100/lcd-mr100.c | |||
@@ -0,0 +1,192 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2008 by Mark Arigo | ||
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 | /* send LCD data */ | ||
26 | static void lcd_send_data(unsigned data) | ||
27 | { | ||
28 | while (LCD1_CONTROL & LCD1_BUSY_MASK); /* wait for LCD */ | ||
29 | LCD1_DATA = data; | ||
30 | } | ||
31 | |||
32 | /* send LCD command */ | ||
33 | static void lcd_send_command(unsigned cmd) | ||
34 | { | ||
35 | while (LCD1_CONTROL & LCD1_BUSY_MASK); /* wait for LCD */ | ||
36 | LCD1_CMD = cmd; | ||
37 | } | ||
38 | |||
39 | /* LCD init */ | ||
40 | void lcd_init_device(void) | ||
41 | { | ||
42 | int i; | ||
43 | |||
44 | DEV_INIT1 &= ~0xfc000000; | ||
45 | |||
46 | i = DEV_INIT1; | ||
47 | DEV_INIT1 = i; | ||
48 | |||
49 | DEV_INIT2 &= ~0x400; | ||
50 | udelay(10000); | ||
51 | |||
52 | LCD1_CONTROL &= ~0x4; | ||
53 | udelay(15); | ||
54 | |||
55 | LCD1_CONTROL |= 0x4; | ||
56 | udelay(10); | ||
57 | |||
58 | LCD1_CONTROL = 0x690; | ||
59 | LCD1_CONTROL = 0x694; | ||
60 | |||
61 | /* OF just reads these */ | ||
62 | i = LCD1_CONTROL; | ||
63 | i = inl(0x70003004); | ||
64 | i = LCD1_CMD; | ||
65 | i = inl(0x7000300c); | ||
66 | |||
67 | #if 0 | ||
68 | /* this is skipped in the OF */ | ||
69 | LCD1_CONTROL &= ~0x200; | ||
70 | LCD1_CONTROL &= ~0x800; | ||
71 | LCD1_CONTROL &= ~0x400; | ||
72 | #endif | ||
73 | |||
74 | LCD1_CONTROL |= 0x1; | ||
75 | udelay(15000); | ||
76 | |||
77 | lcd_send_command(0xe2); | ||
78 | lcd_send_command(0x2f); | ||
79 | lcd_send_command(0x26); | ||
80 | lcd_send_command(0xcc); | ||
81 | lcd_send_command(0xe8); | ||
82 | lcd_send_command(0x81); | ||
83 | lcd_send_command(0); | ||
84 | lcd_send_command(0x40); | ||
85 | lcd_send_command(0xa6); | ||
86 | lcd_send_command(0x88); | ||
87 | lcd_send_command(0xb0); | ||
88 | lcd_send_command(0x10); | ||
89 | lcd_send_command(0); | ||
90 | } | ||
91 | |||
92 | /*** hardware configuration ***/ | ||
93 | int lcd_default_contrast(void) | ||
94 | { | ||
95 | return DEFAULT_CONTRAST_SETTING; | ||
96 | } | ||
97 | |||
98 | void lcd_set_contrast(int val) | ||
99 | { | ||
100 | lcd_send_command(0x81); | ||
101 | lcd_send_command(val); | ||
102 | } | ||
103 | |||
104 | void lcd_set_invert_display(bool yesno) | ||
105 | { | ||
106 | /* TODO: Implement lcd_set_invert_display() */ | ||
107 | (void)yesno; | ||
108 | } | ||
109 | |||
110 | /* turn the display upside down (call lcd_update() afterwards) */ | ||
111 | void lcd_set_flip(bool yesno) | ||
112 | { | ||
113 | /* TODO: Implement lcd_set_flip() */ | ||
114 | (void)yesno; | ||
115 | } | ||
116 | |||
117 | /*** update functions ***/ | ||
118 | |||
119 | /* Performance function that works with an external buffer | ||
120 | note that by and bheight are in 4-pixel units! */ | ||
121 | void lcd_blit(const fb_data* data, int x, int by, int width, | ||
122 | int bheight, int stride) | ||
123 | { | ||
124 | /* TODO: Implement lcd_blit() */ | ||
125 | (void)data; | ||
126 | (void)x; | ||
127 | (void)by; | ||
128 | (void)width; | ||
129 | (void)bheight; | ||
130 | (void)stride; | ||
131 | } | ||
132 | |||
133 | /* Performance function to blit a YUV bitmap directly to the LCD */ | ||
134 | void lcd_yuv_blit(unsigned char * const src[3], | ||
135 | int src_x, int src_y, int stride, | ||
136 | int x, int y, int width, int height) | ||
137 | { | ||
138 | (void)src; | ||
139 | (void)src_x; | ||
140 | (void)src_y; | ||
141 | (void)stride; | ||
142 | (void)x; | ||
143 | (void)y; | ||
144 | (void)width; | ||
145 | (void)height; | ||
146 | } | ||
147 | |||
148 | /* Update the display. | ||
149 | This must be called after all other LCD functions that change the display. */ | ||
150 | void lcd_update(void) | ||
151 | { | ||
152 | lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT); | ||
153 | } | ||
154 | |||
155 | /* Update a fraction of the display. */ | ||
156 | void lcd_update_rect(int x0, int y0, int width, int height) | ||
157 | { | ||
158 | unsigned char *addr; | ||
159 | unsigned int cmd0, cmd1, cmd2; | ||
160 | int r, c, x1, y1, start_row, last_row; | ||
161 | |||
162 | x1 = (x0 + width) - 1; | ||
163 | y1 = (y0 + height) - 1; | ||
164 | if ((x1 <= 0) || (y1 <= 0)) | ||
165 | return; | ||
166 | |||
167 | if(x1 >= LCD_WIDTH) | ||
168 | x1 = LCD_WIDTH - 1; | ||
169 | |||
170 | if(y1 >= LCD_HEIGHT) | ||
171 | y1 = LCD_HEIGHT - 1; | ||
172 | |||
173 | start_row = y0/8; | ||
174 | last_row = y1/8; | ||
175 | |||
176 | cmd1 = (x0 & 0xff) >> 4; | ||
177 | cmd1 = (cmd1 + 5) | 0x10; | ||
178 | cmd2 = x0 & 0xf; | ||
179 | |||
180 | for (r = start_row; r <= last_row; r++) { | ||
181 | cmd0 = (r & 0xff) | 0xb0; | ||
182 | lcd_send_command(cmd0); | ||
183 | lcd_send_command(cmd1); | ||
184 | lcd_send_command(cmd2); | ||
185 | |||
186 | addr = (unsigned char*)&lcd_framebuffer[r][x0]; | ||
187 | for (c = x0; c <= x1; c++) | ||
188 | lcd_send_data(*(addr++)); | ||
189 | } | ||
190 | |||
191 | lcd_send_command(0xaf); | ||
192 | } | ||
diff --git a/firmware/target/arm/olympus/mrobe-100/power-mr100.c b/firmware/target/arm/olympus/mrobe-100/power-mr100.c new file mode 100644 index 0000000000..1fb2ecb958 --- /dev/null +++ b/firmware/target/arm/olympus/mrobe-100/power-mr100.c | |||
@@ -0,0 +1,62 @@ | |||
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 | #include "config.h" | ||
21 | #include "cpu.h" | ||
22 | #include <stdbool.h> | ||
23 | #include "adc.h" | ||
24 | #include "kernel.h" | ||
25 | #include "system.h" | ||
26 | #include "power.h" | ||
27 | #include "logf.h" | ||
28 | #include "usb.h" | ||
29 | |||
30 | #if CONFIG_CHARGING == CHARGING_CONTROL | ||
31 | bool charger_enabled; | ||
32 | #endif | ||
33 | |||
34 | void power_init(void) | ||
35 | { | ||
36 | } | ||
37 | |||
38 | bool charger_inserted(void) | ||
39 | { | ||
40 | return false; | ||
41 | } | ||
42 | |||
43 | void ide_power_enable(bool on) | ||
44 | { | ||
45 | (void)on; | ||
46 | /* We do nothing on the iPod */ | ||
47 | } | ||
48 | |||
49 | |||
50 | bool ide_powered(void) | ||
51 | { | ||
52 | /* pretend we are always powered - we don't turn it off on the ipod */ | ||
53 | return true; | ||
54 | } | ||
55 | |||
56 | void power_off(void) | ||
57 | { | ||
58 | /* Give things a second to settle before cutting power */ | ||
59 | sleep(HZ); | ||
60 | |||
61 | //GPIOF_OUTPUT_VAL &=~ 0x20; | ||
62 | } | ||
diff --git a/firmware/target/arm/olympus/mrobe-100/powermgmt-mr100.c b/firmware/target/arm/olympus/mrobe-100/powermgmt-mr100.c new file mode 100644 index 0000000000..1b6a52f517 --- /dev/null +++ b/firmware/target/arm/olympus/mrobe-100/powermgmt-mr100.c | |||
@@ -0,0 +1,59 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 by Heikki Hannikainen, Uwe Freese | ||
11 | * Revisions copyright (C) 2005 by Gerald Van Baren | ||
12 | * | ||
13 | * All files in this archive are subject to the GNU General Public License. | ||
14 | * See the file COPYING in the source tree root for full license agreement. | ||
15 | * | ||
16 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
17 | * KIND, either express or implied. | ||
18 | * | ||
19 | ****************************************************************************/ | ||
20 | |||
21 | #include "config.h" | ||
22 | #include "adc.h" | ||
23 | #include "powermgmt.h" | ||
24 | |||
25 | /* FIXME: All voltages copied from H10/Tatung Elio. This will need changing | ||
26 | proper power management. */ | ||
27 | |||
28 | const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] = | ||
29 | { | ||
30 | 3760 | ||
31 | }; | ||
32 | |||
33 | const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] = | ||
34 | { | ||
35 | 3650 | ||
36 | }; | ||
37 | |||
38 | /* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */ | ||
39 | const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] = | ||
40 | { | ||
41 | { 3760, 3800, 3850, 3870, 3900, 3950, 4020, 4070, 4110, 4180, 4240 } | ||
42 | }; | ||
43 | |||
44 | #if CONFIG_CHARGING | ||
45 | /* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */ | ||
46 | const unsigned short percent_to_volt_charge[11] = | ||
47 | { | ||
48 | 3990, 4030, 4060, 4080, 4100, 4120, 4150, 4180, 4220, 4260, 4310 | ||
49 | }; | ||
50 | #endif /* CONFIG_CHARGING */ | ||
51 | |||
52 | #define BATTERY_SCALE_FACTOR 4650 | ||
53 | /* full-scale ADC readout (2^10) in millivolt */ | ||
54 | |||
55 | /* Returns battery voltage from ADC [millivolts] */ | ||
56 | unsigned int battery_adc_voltage(void) | ||
57 | { | ||
58 | return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10; | ||
59 | } | ||