diff options
Diffstat (limited to 'firmware/target/arm')
-rw-r--r-- | firmware/target/arm/rk27xx/backlight-rk27xx.c | 7 | ||||
-rw-r--r-- | firmware/target/arm/rk27xx/debug-rk27xx.c | 3 | ||||
-rw-r--r-- | firmware/target/arm/rk27xx/ihifi/button-ihifi.c | 53 | ||||
-rw-r--r-- | firmware/target/arm/rk27xx/ihifi/button-target.h | 40 | ||||
-rw-r--r-- | firmware/target/arm/rk27xx/ihifi/lcd-ihifi.c | 224 | ||||
-rw-r--r-- | firmware/target/arm/rk27xx/ihifi/lcd-target.h | 26 | ||||
-rw-r--r-- | firmware/target/arm/rk27xx/ihifi/power-ihifi.c | 51 | ||||
-rw-r--r-- | firmware/target/arm/rk27xx/ihifi/powermgmt-ihifi760.c | 65 | ||||
-rw-r--r-- | firmware/target/arm/rk27xx/ihifi/powermgmt-ihifi960.c | 65 | ||||
-rw-r--r-- | firmware/target/arm/rk27xx/sd-rk27xx.c | 3 |
10 files changed, 536 insertions, 1 deletions
diff --git a/firmware/target/arm/rk27xx/backlight-rk27xx.c b/firmware/target/arm/rk27xx/backlight-rk27xx.c index 5d92cd827b..361d18c948 100644 --- a/firmware/target/arm/rk27xx/backlight-rk27xx.c +++ b/firmware/target/arm/rk27xx/backlight-rk27xx.c | |||
@@ -68,6 +68,13 @@ static const unsigned short lin_brightness[] = { | |||
68 | 198, 227, 260, 295, 334, 376, 421, 470, | 68 | 198, 227, 260, 295, 334, 376, 421, 470, |
69 | 522, 578, 638, 702, 770, 842, 918, 1000 | 69 | 522, 578, 638, 702, 770, 842, 918, 1000 |
70 | }; | 70 | }; |
71 | #elif defined(IHIFI760) || defined(IHIFI960) | ||
72 | static const unsigned short lin_brightness[] = { | ||
73 | 700, 701, 702, 703, 704, 706, 708, 711, | ||
74 | 714, 717, 721, 726, 731, 737, 743, 751, | ||
75 | 759, 768, 778, 788, 800, 812, 826, 841, | ||
76 | 856, 873, 891, 910, 931, 952, 975, 1000 | ||
77 | }; | ||
71 | #endif | 78 | #endif |
72 | 79 | ||
73 | bool _backlight_init(void) | 80 | bool _backlight_init(void) |
diff --git a/firmware/target/arm/rk27xx/debug-rk27xx.c b/firmware/target/arm/rk27xx/debug-rk27xx.c index 79c779461b..83bc1a5af6 100644 --- a/firmware/target/arm/rk27xx/debug-rk27xx.c +++ b/firmware/target/arm/rk27xx/debug-rk27xx.c | |||
@@ -32,7 +32,8 @@ | |||
32 | 32 | ||
33 | #ifdef RK27_GENERIC | 33 | #ifdef RK27_GENERIC |
34 | #define DEBUG_CANCEL BUTTON_VOL | 34 | #define DEBUG_CANCEL BUTTON_VOL |
35 | #elif defined(HM60X) || defined(HM801) || (CONFIG_KEYPAD == MA_PAD) | 35 | #elif defined(HM60X) || defined(HM801) || (CONFIG_KEYPAD == MA_PAD) || \ |
36 | (CONFIG_KEYPAD == IHIFI_PAD) | ||
36 | #define DEBUG_CANCEL BUTTON_LEFT | 37 | #define DEBUG_CANCEL BUTTON_LEFT |
37 | #endif | 38 | #endif |
38 | 39 | ||
diff --git a/firmware/target/arm/rk27xx/ihifi/button-ihifi.c b/firmware/target/arm/rk27xx/ihifi/button-ihifi.c new file mode 100644 index 0000000000..6477400255 --- /dev/null +++ b/firmware/target/arm/rk27xx/ihifi/button-ihifi.c | |||
@@ -0,0 +1,53 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2013 Andrew Ryabinin | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #include "config.h" | ||
23 | #include "system.h" | ||
24 | #include "button.h" | ||
25 | #include "adc.h" | ||
26 | #include "backlight.h" | ||
27 | |||
28 | void button_init_device(void) { | ||
29 | /* setup button gpio as input */ | ||
30 | GPIO_PCCON &= ~(POWEROFF_BUTTON); | ||
31 | } | ||
32 | |||
33 | int button_read_device(void) { | ||
34 | int adc_val = adc_read(ADC_BUTTONS); | ||
35 | int gpio_btn = GPIO_PCDR & BUTTON_PLAY; | ||
36 | |||
37 | if (adc_val < 270) { | ||
38 | if (adc_val < 110) { /* 0 - 109 */ | ||
39 | return BUTTON_RETURN | gpio_btn; | ||
40 | } else { /* 110 - 269 */ | ||
41 | return BUTTON_MENU |gpio_btn; | ||
42 | } | ||
43 | } else { | ||
44 | if (adc_val < 420) { /* 270 - 419 */ | ||
45 | return BUTTON_BWD | gpio_btn; | ||
46 | } else if (adc_val < 580) { /* 420 - 579 */ | ||
47 | return BUTTON_FWD | gpio_btn; | ||
48 | } | ||
49 | } | ||
50 | return gpio_btn; | ||
51 | } | ||
52 | |||
53 | |||
diff --git a/firmware/target/arm/rk27xx/ihifi/button-target.h b/firmware/target/arm/rk27xx/ihifi/button-target.h new file mode 100644 index 0000000000..f78727b0f5 --- /dev/null +++ b/firmware/target/arm/rk27xx/ihifi/button-target.h | |||
@@ -0,0 +1,40 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2013 Andrew Ryabinin | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | #ifndef _BUTTON_TARGET_H_ | ||
22 | #define _BUTTON_TARGET_H_ | ||
23 | |||
24 | #define BUTTON_FWD 0x00000001 | ||
25 | #define BUTTON_PLAY 0x00000002 | ||
26 | #define BUTTON_BWD 0x00000004 | ||
27 | #define BUTTON_RETURN 0x00000008 | ||
28 | #define BUTTON_MENU 0x00000010 | ||
29 | |||
30 | #define BUTTON_LEFT BUTTON_RETURN | ||
31 | #define BUTTON_RIGHT BUTTON_MENU | ||
32 | |||
33 | #define BUTTON_MAIN (BUTTON_FWD|BUTTON_PLAY| \ | ||
34 | BUTTON_BWD|BUTTON_RETURN| \ | ||
35 | BUTTON_MENU) | ||
36 | |||
37 | #define POWEROFF_BUTTON BUTTON_PLAY | ||
38 | #define POWEROFF_COUNT 30 | ||
39 | |||
40 | #endif /* _BUTTON_TARGET_H_ */ | ||
diff --git a/firmware/target/arm/rk27xx/ihifi/lcd-ihifi.c b/firmware/target/arm/rk27xx/ihifi/lcd-ihifi.c new file mode 100644 index 0000000000..d5906b9dd5 --- /dev/null +++ b/firmware/target/arm/rk27xx/ihifi/lcd-ihifi.c | |||
@@ -0,0 +1,224 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2013 Andrew Ryabinin | ||
11 | * | ||
12 | * | ||
13 | * This program is free software; you can redistribute it and/or | ||
14 | * modify it under the terms of the GNU General Public License | ||
15 | * as published by the Free Software Foundation; either version 2 | ||
16 | * of the License, or (at your option) any later version. | ||
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 "kernel.h" | ||
25 | #include "lcd.h" | ||
26 | #include "system.h" | ||
27 | #include "cpu.h" | ||
28 | #include "lcdif-rk27xx.h" | ||
29 | |||
30 | static bool display_on = false; | ||
31 | |||
32 | void lcd_display_init(void) | ||
33 | { | ||
34 | unsigned int x, y; | ||
35 | |||
36 | lcd_cmd(0xEF); | ||
37 | lcd_data(0x03); | ||
38 | lcd_data(0x80); | ||
39 | lcd_data(0x02); | ||
40 | |||
41 | lcd_cmd(0x00CF); | ||
42 | lcd_data(0x00); | ||
43 | lcd_data(0xC1); | ||
44 | lcd_data(0x30); | ||
45 | |||
46 | lcd_cmd(0xED); | ||
47 | lcd_data(0x67); | ||
48 | lcd_data(0x03); | ||
49 | lcd_data(0x12); | ||
50 | lcd_data(0x81); | ||
51 | |||
52 | lcd_cmd(0xE8); | ||
53 | lcd_data(0x85); | ||
54 | lcd_data(0x11); | ||
55 | lcd_data(0x79); | ||
56 | |||
57 | lcd_cmd(0xCB); | ||
58 | lcd_data(0x39); | ||
59 | lcd_data(0x2C); | ||
60 | lcd_data(0x00); | ||
61 | lcd_data(0x34); | ||
62 | lcd_data(0x06); | ||
63 | |||
64 | lcd_cmd(0xF7); | ||
65 | lcd_data(0x20); | ||
66 | |||
67 | lcd_cmd(0xEA); | ||
68 | lcd_data(0x00); | ||
69 | lcd_data(0x00); | ||
70 | |||
71 | lcd_cmd(0xC0); | ||
72 | lcd_data(0x1D); | ||
73 | |||
74 | lcd_cmd(0xC1); | ||
75 | lcd_data(0x12); | ||
76 | |||
77 | lcd_cmd(0xC5); | ||
78 | lcd_data(0x44); | ||
79 | lcd_data(0x3C); | ||
80 | |||
81 | lcd_cmd(0xC7); | ||
82 | lcd_data(0x88); | ||
83 | |||
84 | lcd_cmd(0x3A); | ||
85 | lcd_data(0x55); | ||
86 | |||
87 | lcd_cmd(0x36); | ||
88 | lcd_data(0xA8); | ||
89 | |||
90 | lcd_cmd(0xB1); | ||
91 | lcd_data(0x00); | ||
92 | lcd_data(0x17); | ||
93 | |||
94 | lcd_cmd(0xB6); | ||
95 | lcd_data(0x0A); | ||
96 | lcd_data(0xA2); | ||
97 | |||
98 | lcd_cmd(0xF2); | ||
99 | lcd_data(0x00); | ||
100 | |||
101 | lcd_cmd(0x26); | ||
102 | lcd_data(0x01); | ||
103 | |||
104 | lcd_cmd(0xE0); | ||
105 | lcd_data(0x0F); | ||
106 | lcd_data(0x22); | ||
107 | lcd_data(0x1C); | ||
108 | lcd_data(0x1B); | ||
109 | lcd_data(0x08); | ||
110 | lcd_data(0x0F); | ||
111 | lcd_data(0x48); | ||
112 | lcd_data(0xB8); | ||
113 | lcd_data(0x34); | ||
114 | lcd_data(0x05); | ||
115 | lcd_data(0x0C); | ||
116 | lcd_data(0x09); | ||
117 | lcd_data(0x0F); | ||
118 | lcd_data(0x07); | ||
119 | lcd_data(0x00); | ||
120 | |||
121 | lcd_cmd(0xE1); | ||
122 | lcd_data(0x00); | ||
123 | lcd_data(0x23); | ||
124 | lcd_data(0x24); | ||
125 | lcd_data(0x07); | ||
126 | lcd_data(0x10); | ||
127 | lcd_data(0x07); | ||
128 | lcd_data(0x38); | ||
129 | lcd_data(0x47); | ||
130 | lcd_data(0x4B); | ||
131 | lcd_data(0x0A); | ||
132 | lcd_data(0x13); | ||
133 | lcd_data(0x06); | ||
134 | lcd_data(0x30); | ||
135 | lcd_data(0x38); | ||
136 | lcd_data(0x0F); | ||
137 | |||
138 | lcd_cmd(0x2A); | ||
139 | lcd_data(0x00); | ||
140 | lcd_data(0x00); | ||
141 | lcd_data(0x01); | ||
142 | lcd_data(0x3F); | ||
143 | |||
144 | lcd_cmd(0x2B); | ||
145 | lcd_data(0x00); | ||
146 | lcd_data(0x00); | ||
147 | lcd_data(0x00); | ||
148 | lcd_data(0xEF); | ||
149 | |||
150 | lcd_cmd(0x11); | ||
151 | |||
152 | udelay(120000); | ||
153 | |||
154 | lcd_cmd(0x29); | ||
155 | lcd_cmd(0x2C); | ||
156 | |||
157 | for (x = 0; x < LCD_WIDTH; x++) | ||
158 | for(y=0; y < LCD_HEIGHT; y++) | ||
159 | lcd_data(0x00); | ||
160 | |||
161 | display_on = true; | ||
162 | } | ||
163 | |||
164 | void lcd_enable (bool on) | ||
165 | { | ||
166 | if (on == display_on) | ||
167 | return; | ||
168 | |||
169 | lcdctrl_bypass(1); | ||
170 | LCDC_CTRL |= RGB24B; | ||
171 | |||
172 | if (on) { | ||
173 | lcd_cmd(0x11); | ||
174 | udelay(120000); | ||
175 | lcd_cmd(0x29); | ||
176 | lcd_cmd(0x2C); | ||
177 | } else { | ||
178 | lcd_cmd(0x28); | ||
179 | } | ||
180 | |||
181 | display_on = on; | ||
182 | LCDC_CTRL &= ~RGB24B; | ||
183 | } | ||
184 | |||
185 | void lcd_set_gram_area(int x_start, int y_start, | ||
186 | int x_end, int y_end) | ||
187 | { | ||
188 | lcdctrl_bypass(1); | ||
189 | LCDC_CTRL |= RGB24B; | ||
190 | lcd_cmd(0x002A); | ||
191 | lcd_data((x_start&0xff00)>>8); | ||
192 | lcd_data(x_start&0x00ff); | ||
193 | lcd_data((x_end&0xff00)>>8); | ||
194 | lcd_data(x_end&0x00ff); | ||
195 | lcd_cmd(0x002B); | ||
196 | lcd_data((y_start&0xff00)>>8); | ||
197 | lcd_data(y_start&0x00ff); | ||
198 | lcd_data((y_end&0xff00)>>8); | ||
199 | lcd_data(y_end&0x00ff); | ||
200 | |||
201 | lcd_cmd(0x2C); | ||
202 | LCDC_CTRL &= ~RGB24B; | ||
203 | |||
204 | } | ||
205 | |||
206 | bool lcd_active() | ||
207 | { | ||
208 | return display_on; | ||
209 | } | ||
210 | |||
211 | /* Blit a YUV bitmap directly to the LCD */ | ||
212 | void lcd_blit_yuv(unsigned char * const src[3], | ||
213 | int src_x, int src_y, int stride, | ||
214 | int x, int y, int width, int height) | ||
215 | { | ||
216 | (void)src; | ||
217 | (void)src_x; | ||
218 | (void)src_y; | ||
219 | (void)stride; | ||
220 | (void)x; | ||
221 | (void)y; | ||
222 | (void)width; | ||
223 | (void)height; | ||
224 | } | ||
diff --git a/firmware/target/arm/rk27xx/ihifi/lcd-target.h b/firmware/target/arm/rk27xx/ihifi/lcd-target.h new file mode 100644 index 0000000000..0d245c888b --- /dev/null +++ b/firmware/target/arm/rk27xx/ihifi/lcd-target.h | |||
@@ -0,0 +1,26 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2012 Andrew Ryabinin | ||
11 | * | ||
12 | * | ||
13 | * This program is free software; you can redistribute it and/or | ||
14 | * modify it under the terms of the GNU General Public License | ||
15 | * as published by the Free Software Foundation; either version 2 | ||
16 | * of the License, or (at your option) any later version. | ||
17 | * | ||
18 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
19 | * KIND, either express or implied. | ||
20 | * | ||
21 | ****************************************************************************/ | ||
22 | #ifndef LCD_TARGET_H | ||
23 | #define LCD_TARGET_H | ||
24 | |||
25 | #define LCD_DATABUS_WIDTH LCDIF_16BIT | ||
26 | #endif | ||
diff --git a/firmware/target/arm/rk27xx/ihifi/power-ihifi.c b/firmware/target/arm/rk27xx/ihifi/power-ihifi.c new file mode 100644 index 0000000000..780d476112 --- /dev/null +++ b/firmware/target/arm/rk27xx/ihifi/power-ihifi.c | |||
@@ -0,0 +1,51 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright © 2013 Andrew Ryabinin | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | #include <stdbool.h> | ||
22 | #include "config.h" | ||
23 | #include "inttypes.h" | ||
24 | #include "power.h" | ||
25 | #include "panic.h" | ||
26 | #include "system.h" | ||
27 | #include "usb_core.h" /* for usb_charging_maxcurrent_change */ | ||
28 | |||
29 | void power_off(void) | ||
30 | { | ||
31 | GPIO_PCCON &= ~(1<<0); | ||
32 | while(1); | ||
33 | } | ||
34 | |||
35 | void power_init(void) | ||
36 | { | ||
37 | GPIO_PCDR |= (1<<0); | ||
38 | GPIO_PCCON |= (1<<0); | ||
39 | } | ||
40 | |||
41 | unsigned int power_input_status(void) | ||
42 | { | ||
43 | unsigned int status = POWER_INPUT_NONE; | ||
44 | /* TODO: implement */ | ||
45 | return status; | ||
46 | } | ||
47 | |||
48 | bool charging_state(void) | ||
49 | { | ||
50 | return true; | ||
51 | } | ||
diff --git a/firmware/target/arm/rk27xx/ihifi/powermgmt-ihifi760.c b/firmware/target/arm/rk27xx/ihifi/powermgmt-ihifi760.c new file mode 100644 index 0000000000..c849bc27e6 --- /dev/null +++ b/firmware/target/arm/rk27xx/ihifi/powermgmt-ihifi760.c | |||
@@ -0,0 +1,65 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright © 2013 Andrew Ryabinin | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #include "config.h" | ||
23 | #include "adc.h" | ||
24 | #include "adc-target.h" | ||
25 | #include "powermgmt.h" | ||
26 | |||
27 | /* Battery voltage calculation and discharge/charge curves for the HiFiMAN HM-60x. | ||
28 | |||
29 | Battery voltage is calculated under the assumption that the adc full-scale | ||
30 | readout represents 3.00V and that the battery ADC channel is fed with | ||
31 | exactly half of the battery voltage (through a resistive divider). | ||
32 | Charge curve have not been calibrated yet. | ||
33 | */ | ||
34 | |||
35 | const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] = | ||
36 | { | ||
37 | /* TODO: this is just an initial guess */ | ||
38 | 3350, | ||
39 | }; | ||
40 | |||
41 | const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] = | ||
42 | { | ||
43 | 3300, | ||
44 | }; | ||
45 | |||
46 | /* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */ | ||
47 | const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] = | ||
48 | { | ||
49 | /* FIXME: Uncalibrated curve */ | ||
50 | { 3300, 3350, 3433, 3516, 3600, 3683, 3767, 3850, 3933, 4017, 4100 } | ||
51 | }; | ||
52 | |||
53 | /* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */ | ||
54 | const unsigned short percent_to_volt_charge[11] = | ||
55 | /* TODO: simple copy of discharge curve */ | ||
56 | { 3300, 3350, 3433, 3516, 3600, 3683, 3767, 3850, 3933, 4017, 4100 }; | ||
57 | |||
58 | /* full-scale ADC readout (2^10) in millivolt */ | ||
59 | #define BATTERY_SCALE_FACTOR 6100 | ||
60 | |||
61 | /* Returns battery voltage from ADC [millivolts] */ | ||
62 | int _battery_voltage(void) | ||
63 | { | ||
64 | return (adc_read(ADC_BATTERY) * BATTERY_SCALE_FACTOR) >> 10; | ||
65 | } | ||
diff --git a/firmware/target/arm/rk27xx/ihifi/powermgmt-ihifi960.c b/firmware/target/arm/rk27xx/ihifi/powermgmt-ihifi960.c new file mode 100644 index 0000000000..c8797c0a32 --- /dev/null +++ b/firmware/target/arm/rk27xx/ihifi/powermgmt-ihifi960.c | |||
@@ -0,0 +1,65 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright © 2013 Andrew Ryabinin | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #include "config.h" | ||
23 | #include "adc.h" | ||
24 | #include "adc-target.h" | ||
25 | #include "powermgmt.h" | ||
26 | |||
27 | /* Battery voltage calculation and discharge/charge curves for the HiFiMAN HM-60x. | ||
28 | |||
29 | Battery voltage is calculated under the assumption that the adc full-scale | ||
30 | readout represents 3.00V and that the battery ADC channel is fed with | ||
31 | exactly half of the battery voltage (through a resistive divider). | ||
32 | Charge curve have not been calibrated yet. | ||
33 | */ | ||
34 | |||
35 | const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] = | ||
36 | { | ||
37 | /* TODO: this is just an initial guess */ | ||
38 | 7050, | ||
39 | }; | ||
40 | |||
41 | const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] = | ||
42 | { | ||
43 | 7000, | ||
44 | }; | ||
45 | |||
46 | /* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */ | ||
47 | const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] = | ||
48 | { | ||
49 | /* FIXME: Uncalibrated curve */ | ||
50 | { 7000, 7050, 7100, 7150, 7200, 7250, 7300, 7350, 7400, 7450, 7500 } | ||
51 | }; | ||
52 | |||
53 | /* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */ | ||
54 | const unsigned short percent_to_volt_charge[11] = | ||
55 | /* TODO: simple copy of discharge curve */ | ||
56 | { 7000, 7050, 7100, 7150, 7200, 7250, 7300, 7350, 7400, 7450, 7500 }; | ||
57 | |||
58 | /* full-scale ADC readout (2^10) in millivolt */ | ||
59 | #define BATTERY_SCALE_FACTOR 13000 | ||
60 | |||
61 | /* Returns battery voltage from ADC [millivolts] */ | ||
62 | int _battery_voltage(void) | ||
63 | { | ||
64 | return (adc_read(ADC_BATTERY) * BATTERY_SCALE_FACTOR) >> 10; | ||
65 | } | ||
diff --git a/firmware/target/arm/rk27xx/sd-rk27xx.c b/firmware/target/arm/rk27xx/sd-rk27xx.c index 9f6ba467b7..deca8a1fa7 100644 --- a/firmware/target/arm/rk27xx/sd-rk27xx.c +++ b/firmware/target/arm/rk27xx/sd-rk27xx.c | |||
@@ -134,6 +134,9 @@ static inline bool card_detect_target(void) | |||
134 | return !(GPIO_PFDR & (1<<2)); | 134 | return !(GPIO_PFDR & (1<<2)); |
135 | #elif defined(MA9) || defined(MA9C) || defined(MA8) || defined(MA8C) | 135 | #elif defined(MA9) || defined(MA9C) || defined(MA8) || defined(MA8C) |
136 | return (GPIO_PCDR & 0x80); | 136 | return (GPIO_PCDR & 0x80); |
137 | #elif defined(IHIFI760) || defined(IHIFI960) | ||
138 | /* TODO: find out pin */ | ||
139 | return true; | ||
137 | #else | 140 | #else |
138 | #error "Unknown target" | 141 | #error "Unknown target" |
139 | #endif | 142 | #endif |