summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcin Bukat <marcin.bukat@gmail.com>2010-11-26 23:28:08 +0000
committerMarcin Bukat <marcin.bukat@gmail.com>2010-11-26 23:28:08 +0000
commit9a24892e2e8b6ef9f8a616c630d1bb123ce713e7 (patch)
treed341118a6d8beefbf6e0da1761c7f8990967a8d1
parent608bc4ed4bc74560e1d2e6333d25d1254fb9058a (diff)
downloadrockbox-9a24892e2e8b6ef9f8a616c630d1bb123ce713e7.tar.gz
rockbox-9a24892e2e8b6ef9f8a616c630d1bb123ce713e7.zip
MPIO HD300 - initial commit
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28680 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/SOURCES2
-rw-r--r--apps/debug_menu.c2
-rw-r--r--apps/keymaps/keymap-mpio-hd300.c252
-rw-r--r--bootloader/SOURCES2
-rw-r--r--bootloader/mpio_hd200.c12
-rw-r--r--firmware/SOURCES21
-rw-r--r--firmware/drivers/audio/wm8751.c7
-rw-r--r--firmware/export/config.h3
-rw-r--r--firmware/export/config/mpiohd300.h186
-rw-r--r--firmware/target/coldfire/crt0.S8
-rw-r--r--firmware/target/coldfire/debug-target.h3
-rw-r--r--firmware/target/coldfire/mpio/audio-mpio.c8
-rw-r--r--firmware/target/coldfire/mpio/hd300/button-hd300.c234
-rw-r--r--firmware/target/coldfire/mpio/hd300/button-target.h55
-rw-r--r--firmware/target/coldfire/mpio/hd300/lcd-as-hd300.S227
-rw-r--r--firmware/target/coldfire/mpio/hd300/lcd-hd300.c244
-rw-r--r--firmware/target/coldfire/mpio/hd300/powermgmt-hd300.c58
-rw-r--r--firmware/target/coldfire/mpio/power-mpio.c2
-rw-r--r--firmware/target/coldfire/wmcodec-coldfire.c2
-rwxr-xr-xtools/configure24
-rw-r--r--tools/scramble.c4
21 files changed, 1344 insertions, 12 deletions
diff --git a/apps/SOURCES b/apps/SOURCES
index c3020ecb2f..8aa469fa4d 100644
--- a/apps/SOURCES
+++ b/apps/SOURCES
@@ -303,6 +303,8 @@ keymaps/keymap-mini2440.c
303keymaps/keymap-vibe500.c 303keymaps/keymap-vibe500.c
304#elif CONFIG_KEYPAD == MPIO_HD200_PAD 304#elif CONFIG_KEYPAD == MPIO_HD200_PAD
305keymaps/keymap-mpio-hd200.c 305keymaps/keymap-mpio-hd200.c
306#elif CONFIG_KEYPAD == MPIO_HD300_PAD
307keymaps/keymap-mpio-hd300.c
306#elif CONFIG_KEYPAD == ANDROID_PAD 308#elif CONFIG_KEYPAD == ANDROID_PAD
307keymaps/keymap-android.c 309keymaps/keymap-android.c
308#elif CONFIG_KEYPAD == SDL_PAD 310#elif CONFIG_KEYPAD == SDL_PAD
diff --git a/apps/debug_menu.c b/apps/debug_menu.c
index f9f9a29e98..9fcb0719be 100644
--- a/apps/debug_menu.c
+++ b/apps/debug_menu.c
@@ -1893,7 +1893,7 @@ static bool dbg_save_roms(void)
1893 fd = creat("/internal_rom_000000-3FFFFF.bin", 0666); 1893 fd = creat("/internal_rom_000000-3FFFFF.bin", 0666);
1894#elif defined(IAUDIO_X5) || defined(IAUDIO_M5) || defined(IAUDIO_M3) 1894#elif defined(IAUDIO_X5) || defined(IAUDIO_M5) || defined(IAUDIO_M3)
1895 fd = creat("/internal_rom_000000-3FFFFF.bin", 0666); 1895 fd = creat("/internal_rom_000000-3FFFFF.bin", 0666);
1896#elif defined(MPIO_HD200) 1896#elif defined(MPIO_HD200) || defined(MPIO_HD300)
1897 fd = creat("/internal_rom_000000-1FFFFF.bin", 0666); 1897 fd = creat("/internal_rom_000000-1FFFFF.bin", 0666);
1898#endif 1898#endif
1899 if(fd >= 0) 1899 if(fd >= 0)
diff --git a/apps/keymaps/keymap-mpio-hd300.c b/apps/keymaps/keymap-mpio-hd300.c
new file mode 100644
index 0000000000..d93f913d8d
--- /dev/null
+++ b/apps/keymaps/keymap-mpio-hd300.c
@@ -0,0 +1,252 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id:$
9 *
10 * Copyright (C) 2010 Marcin Bukat
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 "config.h"
22#include "action.h"
23#include "button.h"
24#include "settings.h"
25
26/*
27 * The format of the list is as follows
28 * { Action Code, Button code, Prereq button code }
29 * if there's no need to check the previous button's value, use BUTTON_NONE
30 * Insert LAST_ITEM_IN_LIST at the end of each mapping
31 */
32
33/*****************************************************************************
34 * Main control mappings
35 *****************************************************************************/
36
37static const struct button_mapping button_context_standard[] = {
38 { ACTION_STD_PREV, BUTTON_UP, BUTTON_NONE },
39 { ACTION_STD_PREVREPEAT, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE },
40 { ACTION_STD_NEXT, BUTTON_DOWN, BUTTON_NONE },
41 { ACTION_STD_NEXTREPEAT, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE },
42 { ACTION_STD_OK, BUTTON_ENTER|BUTTON_REL, BUTTON_ENTER },
43 { ACTION_STD_CANCEL, BUTTON_MENU|BUTTON_REL, BUTTON_MENU },
44 { ACTION_STD_CONTEXT, BUTTON_ENTER|BUTTON_REPEAT, BUTTON_ENTER },
45 { ACTION_STD_MENU, BUTTON_MENU|BUTTON_REPEAT, BUTTON_MENU },
46/* { ACTION_STD_QUICKSCREEN, BUTTON_, BUTTON_ }, */
47/* { ACTION_STD_KEYLOCK, BUTTON_, BUTTON_ }, */
48/* { ACTION_STD_REC, BUTTON_, BUTTON_ }, */
49/* { ACTION_STD_HOTKEY, BUTTON_, BUTTON_ }, */
50/* { ACTION_F3, BUTTON_, BUTTON_ }, */
51
52 LAST_ITEM_IN_LIST
53}; /* button_context_standard */
54
55static const struct button_mapping button_context_tree[] = {
56/* { ACTION_TREE_ROOT_INIT, BUTTON_, BUTTON_ }, */
57/* { ACTION_TREE_PGLEFT, BUTTON_, BUTTON_ }, */
58/* { ACTION_TREE_PGRIGHT, BUTTON_, BUTTON_ }, */
59 { ACTION_TREE_STOP, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_PLAY },
60 { ACTION_TREE_WPS, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY },
61/* { ACTION_TREE_HOTKEY, BUTTON_, BUTTON_ }, */
62
63 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
64}; /* button_context_tree */
65
66static const struct button_mapping button_context_wps[] = {
67 { ACTION_WPS_BROWSE, BUTTON_ENTER|BUTTON_REL, BUTTON_ENTER },
68 { ACTION_WPS_PLAY, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY },
69 { ACTION_WPS_SEEKBACK, BUTTON_REW|BUTTON_REPEAT, BUTTON_NONE },
70 { ACTION_WPS_SEEKFWD, BUTTON_FF|BUTTON_REPEAT, BUTTON_NONE },
71 { ACTION_WPS_STOPSEEK, BUTTON_REW|BUTTON_REL, BUTTON_REW|BUTTON_REPEAT },
72 { ACTION_WPS_STOPSEEK, BUTTON_FF|BUTTON_REL, BUTTON_FF|BUTTON_REPEAT },
73 { ACTION_WPS_SKIPNEXT, BUTTON_FF|BUTTON_REL, BUTTON_FF },
74 { ACTION_WPS_SKIPPREV, BUTTON_REW|BUTTON_REL, BUTTON_REW },
75 { ACTION_WPS_STOP, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_PLAY },
76 { ACTION_WPS_VOLDOWN, BUTTON_DOWN, BUTTON_NONE },
77 { ACTION_WPS_VOLDOWN, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE },
78 { ACTION_WPS_VOLUP, BUTTON_UP, BUTTON_NONE },
79 { ACTION_WPS_VOLUP, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE },
80/* { ACTION_WPS_PITCHSCREEN, BUTTON_, BUTTON_ }, */
81/* { ACTION_WPS_ID3SCREEN, BUTTON_, BUTTON_ }, */
82 { ACTION_WPS_CONTEXT, BUTTON_ENTER|BUTTON_REPEAT, BUTTON_ENTER },
83 { ACTION_WPS_QUICKSCREEN, BUTTON_REC|BUTTON_REPEAT, BUTTON_REC },
84 { ACTION_WPS_MENU, BUTTON_MENU|BUTTON_REL, BUTTON_MENU },
85/* { ACTION_WPS_VIEW_PLAYLIST, BUTTON_, BUTTON_ }, */
86/* { ACTION_WPS_REC, BUTTON_, BUTTON_ }, */
87/* { ACTION_WPS_ABSETA_PREVDIR, BUTTON_, BUTTON_ }, */
88/* { ACTION_WPS_ABSETB_NEXTDIR, BUTTON_, BUTTON_ }, */
89/* { ACTION_WPS_ABRESET, BUTTON_, BUTTON_ }, */
90/* { ACTION_WPS_HOTKEY, BUTTON_, BUTTON_ }, */
91
92 LAST_ITEM_IN_LIST,
93}; /* button_context_wps */
94
95static const struct button_mapping button_context_settings[] = {
96 { ACTION_SETTINGS_INC, BUTTON_FF, BUTTON_NONE },
97 { ACTION_SETTINGS_INCREPEAT, BUTTON_FF|BUTTON_REPEAT, BUTTON_NONE },
98/* { ACTION_SETTINGS_INCBIGSTEP,BUTTON_, BUTTON_ }, */
99 { ACTION_SETTINGS_DEC, BUTTON_REW, BUTTON_NONE },
100 { ACTION_SETTINGS_DECREPEAT, BUTTON_REW|BUTTON_REPEAT, BUTTON_NONE },
101/* { ACTION_SETTINGS_DECBIGSTEP,BUTTON_, BUTTON_ }, */
102
103 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
104}; /* button_context_settings */
105
106static const struct button_mapping button_context_yesno[] = {
107 { ACTION_YESNO_ACCEPT, BUTTON_ENTER, BUTTON_NONE },
108 { ACTION_YESNO_ACCEPT, BUTTON_PLAY, BUTTON_NONE },
109
110 LAST_ITEM_IN_LIST
111}; /* button_context_yesno */
112
113static const struct button_mapping button_context_bmark[] = {
114 { ACTION_BMS_DELETE, BUTTON_REC|BUTTON_REPEAT, BUTTON_REC },
115
116 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_LIST),
117}; /* button_context_bmark */
118
119/*
120static const struct button_mapping button_context_quickscreen[] = {
121 { ACTION_QS_LEFT, BUTTON_VOL_DOWN, BUTTON_NONE },
122 { ACTION_QS_LEFT, BUTTON_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE },
123 { ACTION_QS_RIGHT, BUTTON_VOL_UP, BUTTON_NONE },
124 { ACTION_QS_RIGHT, BUTTON_VOL_UP|BUTTON_REPEAT, BUTTON_NONE },
125 { ACTION_QS_DOWN, BUTTON_FF, BUTTON_NONE },
126 { ACTION_QS_DOWN, BUTTON_FF|BUTTON_REPEAT, BUTTON_NONE },
127 { ACTION_QS_TOP, BUTTON_REW, BUTTON_NONE },
128 { ACTION_QS_TOP, BUTTON_REW|BUTTON_REPEAT, BUTTON_NONE },
129
130 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
131};*/ /* button_context_quickscreen */
132
133static const struct button_mapping button_context_pitchscreen[] = {
134// { ACTION_PS_INC_SMALL, BUTTON_VOL_UP, BUTTON_NONE },
135// { ACTION_PS_INC_BIG, BUTTON_VOL_UP|BUTTON_REPEAT, BUTTON_NONE },
136// { ACTION_PS_DEC_SMALL, BUTTON_VOL_DOWN, BUTTON_NONE },
137// { ACTION_PS_DEC_BIG, BUTTON_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE },
138 { ACTION_PS_NUDGE_LEFT, BUTTON_REW, BUTTON_NONE },
139 { ACTION_PS_NUDGE_RIGHT, BUTTON_FF, BUTTON_NONE },
140 { ACTION_PS_NUDGE_LEFTOFF, BUTTON_REW|BUTTON_REL, BUTTON_NONE },
141 { ACTION_PS_NUDGE_RIGHTOFF, BUTTON_FF|BUTTON_REL, BUTTON_NONE },
142 { ACTION_PS_TOGGLE_MODE, BUTTON_PLAY, BUTTON_NONE },
143 { ACTION_PS_RESET, BUTTON_ENTER, BUTTON_NONE },
144 { ACTION_PS_EXIT, BUTTON_MENU, BUTTON_NONE },
145 { ACTION_PS_SLOWER, BUTTON_REW|BUTTON_REPEAT, BUTTON_NONE },
146 { ACTION_PS_FASTER, BUTTON_FF|BUTTON_REPEAT, BUTTON_NONE },
147
148 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
149}; /* button_context_pitchscreen */
150
151static const struct button_mapping button_context_radio[] = {
152 { ACTION_FM_MENU, BUTTON_ENTER|BUTTON_REPEAT, BUTTON_NONE },
153 { ACTION_FM_PRESET, BUTTON_ENTER|BUTTON_REL, BUTTON_ENTER },
154/* { ACTION_FM_RECORD, BUTTON_, BUTTON_ }, */
155/* { ACTION_FM_FREEZE, BUTTON_, BUTTON_ }, */
156 { ACTION_FM_STOP, BUTTON_REC|BUTTON_REPEAT, BUTTON_NONE },
157 { ACTION_FM_MODE, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_PLAY },
158 { ACTION_FM_EXIT, BUTTON_REC|BUTTON_REL, BUTTON_REC },
159 { ACTION_FM_PLAY, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY },
160/* { ACTION_FM_RECORD_DBLPRE, BUTTON_, BUTTON_ }, */
161/* { ACTION_FM_NEXT_PRESET, BUTTON_, BUTTON_ }, */
162/* { ACTION_FM_PREV_PRESET, BUTTON_, BUTTON_ }, */
163
164 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_SETTINGS)
165}; /* button_context_radio */
166
167static const struct button_mapping button_context_recscreen[] = {
168/* { ACTION_REC_LCD, BUTTON_, BUTTON_ }, */
169 { ACTION_REC_PAUSE, BUTTON_PLAY, BUTTON_NONE },
170 { ACTION_REC_NEWFILE, BUTTON_ENTER|BUTTON_REPEAT, BUTTON_ENTER },
171/* { ACTION_REC_F2, BUTTON_, BUTTON_ }, */
172/* { ACTION_REC_F3, BUTTON_, BUTTON_ }, */
173
174 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_SETTINGS)
175}; /* button_context_recscreen */
176
177#if 0
178static const struct button_mapping button_context_keyboard[] = {
179 { ACTION_KBD_LEFT, BUTTON_VOL_DOWN, BUTTON_NONE },
180 { ACTION_KBD_LEFT, BUTTON_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE },
181 { ACTION_KBD_RIGHT, BUTTON_VOL_UP, BUTTON_NONE },
182 { ACTION_KBD_RIGHT, BUTTON_VOL_UP|BUTTON_REPEAT, BUTTON_NONE },
183/* { ACTION_KBD_CURSOR_LEFT, BUTTON_, BUTTON_ }, */
184/* { ACTION_KBD_CURSOR_RIGHT, BUTTON_, BUTTON_ }, */
185 { ACTION_KBD_SELECT, BUTTON_FUNC, BUTTON_NONE },
186 { ACTION_KBD_PAGE_FLIP, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_PLAY },
187 { ACTION_KBD_DONE, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY },
188 { ACTION_KBD_ABORT, BUTTON_REC|BUTTON_REL, BUTTON_REC },
189/* { ACTION_KBD_BACKSPACE, BUTTON_, BUTTON_ }, */
190 { ACTION_KBD_UP, BUTTON_REW, BUTTON_NONE },
191 { ACTION_KBD_UP, BUTTON_REW|BUTTON_REPEAT, BUTTON_NONE },
192 { ACTION_KBD_DOWN, BUTTON_FF, BUTTON_NONE },
193 { ACTION_KBD_DOWN, BUTTON_FF|BUTTON_REPEAT, BUTTON_NONE },
194 { ACTION_KBD_MORSE_INPUT, BUTTON_REC|BUTTON_REPEAT, BUTTON_REC },
195 { ACTION_KBD_MORSE_SELECT, BUTTON_FUNC|BUTTON_REL, BUTTON_NONE },
196
197 LAST_ITEM_IN_LIST
198}; /* button_context_keyboard */
199#endif
200
201const struct button_mapping* get_context_mapping(int context)
202{
203 switch (context)
204 {
205 case CONTEXT_STD:
206 return button_context_standard;
207
208 case CONTEXT_WPS:
209 return button_context_wps;
210
211#if CONFIG_TUNER
212 case CONTEXT_FM:
213 return button_context_radio;
214#endif
215
216#ifdef HAVE_RECORDING
217 case CONTEXT_RECSCREEN:
218 return button_context_recscreen;
219#endif
220
221 case CONTEXT_YESNOSCREEN:
222 return button_context_yesno;
223
224 case CONTEXT_BOOKMARKSCREEN:
225 return button_context_bmark;
226
227// case CONTEXT_QUICKSCREEN:
228// return button_context_quickscreen;
229
230 case CONTEXT_PITCHSCREEN:
231 return button_context_pitchscreen;
232
233// case CONTEXT_KEYBOARD:
234// case CONTEXT_MORSE_INPUT:
235// return button_context_keyboard;
236
237 case CONTEXT_SETTINGS:
238 case CONTEXT_SETTINGS_EQ:
239 return button_context_settings;
240
241 case CONTEXT_TREE:
242 case CONTEXT_MAINMENU:
243 case CONTEXT_CUSTOM|CONTEXT_TREE:
244 return button_context_tree;
245
246 case CONTEXT_LIST:
247 default:
248 return button_context_standard;
249 }
250 return button_context_standard;
251}
252
diff --git a/bootloader/SOURCES b/bootloader/SOURCES
index 24d0bd29f6..97ed4493c1 100644
--- a/bootloader/SOURCES
+++ b/bootloader/SOURCES
@@ -63,6 +63,6 @@ show_logo.c
63#elif defined(PBELL_VIBE500) 63#elif defined(PBELL_VIBE500)
64main-pp.c 64main-pp.c
65show_logo.c 65show_logo.c
66#elif defined(MPIO_HD200) 66#elif defined(MPIO_HD200) || defined(MPIO_HD300)
67mpio_hd200.c 67mpio_hd200.c
68#endif 68#endif
diff --git a/bootloader/mpio_hd200.c b/bootloader/mpio_hd200.c
index 98c83239f7..dd4510a2a7 100644
--- a/bootloader/mpio_hd200.c
+++ b/bootloader/mpio_hd200.c
@@ -263,7 +263,9 @@ static void bootmenu(void)
263 switch (button) 263 switch (button)
264 { 264 {
265 case BUTTON_REW: 265 case BUTTON_REW:
266#ifdef MPIO_HD200
266 case BUTTON_RC_REW: 267 case BUTTON_RC_REW:
268#endif
267 if (option > rockbox) 269 if (option > rockbox)
268 option--; 270 option--;
269 else 271 else
@@ -271,7 +273,9 @@ static void bootmenu(void)
271 break; 273 break;
272 274
273 case BUTTON_FF: 275 case BUTTON_FF:
276#ifdef MPIO_HD200
274 case BUTTON_RC_FF: 277 case BUTTON_RC_FF:
278#endif
275 if (option < shutdown) 279 if (option < shutdown)
276 option++; 280 option++;
277 else 281 else
@@ -279,8 +283,10 @@ static void bootmenu(void)
279 break; 283 break;
280 284
281 case BUTTON_PLAY: 285 case BUTTON_PLAY:
286#ifdef MPIO_HD200
282 case BUTTON_RC_PLAY: 287 case BUTTON_RC_PLAY:
283 case (BUTTON_PLAY|BUTTON_REC): 288 case (BUTTON_PLAY|BUTTON_REC):
289#endif
284 reset_screen(); 290 reset_screen();
285 291
286 switch (option) 292 switch (option)
@@ -360,7 +366,11 @@ void main(void)
360 event = EVENT_NONE; 366 event = EVENT_NONE;
361 button = button_get_w_tmo(HZ); 367 button = button_get_w_tmo(HZ);
362 368
363 if ( (button & BUTTON_PLAY) || (button & BUTTON_RC_PLAY) ) 369 if ( (button & BUTTON_PLAY)
370#ifdef MPIO_HD200
371 || (button & BUTTON_RC_PLAY)
372#endif
373 )
364 event |= EVENT_ON; 374 event |= EVENT_ON;
365 375
366 if ( usb_detect() == USB_INSERTED ) 376 if ( usb_detect() == USB_INSERTED )
diff --git a/firmware/SOURCES b/firmware/SOURCES
index a2aaac19e3..5506f98e85 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -1701,6 +1701,27 @@ target/coldfire/mpio/fmradio_i2c-mpio.c
1701#endif /* SIMULATOR */ 1701#endif /* SIMULATOR */
1702#endif 1702#endif
1703 1703
1704#ifdef MPIO_HD300
1705#ifndef SIMULATOR
1706/* TODO: currently including all files */
1707target/coldfire/ata-as-coldfire.S
1708target/coldfire/mpio/system-mpio.c
1709target/coldfire/mpio/power-mpio.c
1710target/coldfire/mpio/backlight-mpio.c
1711target/coldfire/mpio/usb-mpio.c
1712target/coldfire/mpio/ata-mpio.c
1713target/coldfire/mpio/adc-mpio.c
1714target/coldfire/mpio/hd300/button-hd300.c
1715target/coldfire/mpio/hd300/lcd-hd300.c
1716target/coldfire/mpio/hd300/lcd-as-hd300.S
1717target/coldfire/mpio/hd300/powermgmt-hd300.c
1718#ifndef BOOTLOADER
1719target/coldfire/mpio/audio-mpio.c
1720target/coldfire/wmcodec-coldfire.c
1721target/coldfire/mpio/fmradio_i2c-mpio.c
1722#endif /* BOOTLOADER */
1723#endif /* SIMULATOR */
1724#endif
1704 1725
1705#if (CONFIG_PLATFORM & PLATFORM_ANDROID) 1726#if (CONFIG_PLATFORM & PLATFORM_ANDROID)
1706target/hosted/android/fs-android.c 1727target/hosted/android/fs-android.c
diff --git a/firmware/drivers/audio/wm8751.c b/firmware/drivers/audio/wm8751.c
index 06b5f61bd3..aa2505ccfe 100644
--- a/firmware/drivers/audio/wm8751.c
+++ b/firmware/drivers/audio/wm8751.c
@@ -565,6 +565,7 @@ void audiohw_set_recsrc(int source, bool recording)
565 } 565 }
566 break; 566 break;
567 567
568#if (INPUT_SRC_CAPS & SRC_CAP_LINEIN)
568 case AUDIO_SRC_LINEIN: 569 case AUDIO_SRC_LINEIN:
569#ifdef AUDIOHW_HAVE_DEPTH_3D 570#ifdef AUDIOHW_HAVE_DEPTH_3D
570 wmcodec_write(PWRMGMT1, PWRMGMT1_VREF | PWRMGMT1_VMIDSEL_50K); 571 wmcodec_write(PWRMGMT1, PWRMGMT1_VREF | PWRMGMT1_VMIDSEL_50K);
@@ -599,7 +600,8 @@ void audiohw_set_recsrc(int source, bool recording)
599 wmcodec_write(LEFTMIX1, LEFTMIX1_LD2LO); 600 wmcodec_write(LEFTMIX1, LEFTMIX1_LD2LO);
600 wmcodec_write(RIGHTMIX2, RIGHTMIX2_RD2RO); 601 wmcodec_write(RIGHTMIX2, RIGHTMIX2_RD2RO);
601 break; 602 break;
602 603#endif
604#if (INPUT_SRC_CAPS & SRC_CAP_MIC)
603 case AUDIO_SRC_MIC: 605 case AUDIO_SRC_MIC:
604#ifdef AUDIOHW_HAVE_DEPTH_3D 606#ifdef AUDIOHW_HAVE_DEPTH_3D
605 wmcodec_write(PWRMGMT1, PWRMGMT1_VREF | PWRMGMT1_VMIDSEL_50K); 607 wmcodec_write(PWRMGMT1, PWRMGMT1_VREF | PWRMGMT1_VMIDSEL_50K);
@@ -634,7 +636,8 @@ void audiohw_set_recsrc(int source, bool recording)
634 /* route DAC signal to output mixer */ 636 /* route DAC signal to output mixer */
635 wmcodec_write(LEFTMIX1, LEFTMIX1_LD2LO); 637 wmcodec_write(LEFTMIX1, LEFTMIX1_LD2LO);
636 wmcodec_write(RIGHTMIX2, RIGHTMIX2_RD2RO); 638 wmcodec_write(RIGHTMIX2, RIGHTMIX2_RD2RO);
637 639 break;
640#endif
638 } /* switch(source) */ 641 } /* switch(source) */
639} 642}
640 643
diff --git a/firmware/export/config.h b/firmware/export/config.h
index 3a7328315b..52cb79bdae 100644
--- a/firmware/export/config.h
+++ b/firmware/export/config.h
@@ -130,6 +130,7 @@
130#define MPIO_HD200_PAD 44 130#define MPIO_HD200_PAD 44
131#define ANDROID_PAD 45 131#define ANDROID_PAD 45
132#define SDL_PAD 46 132#define SDL_PAD 46
133#define MPIO_HD300_PAD 47
133 134
134/* CONFIG_REMOTE_KEYPAD */ 135/* CONFIG_REMOTE_KEYPAD */
135#define H100_REMOTE 1 136#define H100_REMOTE 1
@@ -428,6 +429,8 @@ Lyre prototype 1 */
428#include "config/vibe500.h" 429#include "config/vibe500.h"
429#elif defined(MPIO_HD200) 430#elif defined(MPIO_HD200)
430#include "config/mpiohd200.h" 431#include "config/mpiohd200.h"
432#elif defined(MPIO_HD300)
433#include "config/mpiohd300.h"
431 434
432#elif defined(APPLICATION) 435#elif defined(APPLICATION)
433#include "config/application.h" 436#include "config/application.h"
diff --git a/firmware/export/config/mpiohd300.h b/firmware/export/config/mpiohd300.h
new file mode 100644
index 0000000000..37f79b4d47
--- /dev/null
+++ b/firmware/export/config/mpiohd300.h
@@ -0,0 +1,186 @@
1/*
2 * This config file is for MPIO HD200
3 */
4#define TARGET_TREE /* this target is using the target tree system */
5
6/* For Rolo and boot loader */
7#define MODEL_NUMBER 70
8
9#define MODEL_NAME "MPIO HD300"
10
11/* define this if you use an ATA controller */
12#define CONFIG_STORAGE STORAGE_ATA
13#define HAVE_LBA48
14#define ATA_SWAP_WORDS
15
16/* define this if you have recording possibility */
17#define HAVE_RECORDING
18
19/* Define bitmask of input sources - recordable bitmask can be defined
20 * explicitly if different
21 */
22#define INPUT_SRC_CAPS (SRC_CAP_MIC | SRC_CAP_FMRADIO)
23
24/* define the bitmask of hardware sample rates */
25#define HW_SAMPR_CAPS (SAMPR_CAP_88 | SAMPR_CAP_44 | SAMPR_CAP_22 | SAMPR_CAP_11)
26
27/* define the bitmask of recording sample rates */
28#define REC_SAMPR_CAPS (SAMPR_CAP_88 | SAMPR_CAP_44 | SAMPR_CAP_22 | SAMPR_CAP_11)
29
30/* define this if you have a bitmap LCD display */
31#define HAVE_LCD_BITMAP
32
33/* define this if you want album art for this target */
34#define HAVE_ALBUMART
35
36/* define this to enable bitmap scaling */
37#define HAVE_BMP_SCALING
38
39/* define this to enable JPEG decoding */
40#define HAVE_JPEG
41
42/* define this if you can flip your LCD */
43#define HAVE_LCD_FLIP
44
45/* define this if you can invert the colours on your LCD */
46#define HAVE_LCD_INVERT
47
48/* define this if you have access to the quickscreen */
49/* #define HAVE_QUICKSCREEN */
50
51/* define this if you have access to the pitchscreen */
52#define HAVE_PITCHSCREEN
53
54/* define this if you would like tagcache to build on this target */
55#define HAVE_TAGCACHE
56
57/* LCD dimensions */
58#define LCD_WIDTH 160
59#define LCD_HEIGHT 128
60#define LCD_DEPTH 2
61
62#define LCD_PIXELFORMAT VERTICAL_PACKING
63
64/* Display colours, for screenshots and sim (0xRRGGBB) */
65#define LCD_DARKCOLOR 0x000000
66#define LCD_BRIGHTCOLOR 0x5a915a
67#define LCD_BL_DARKCOLOR 0x000000
68#define LCD_BL_BRIGHTCOLOR 0x82b4fa
69
70#define CONFIG_KEYPAD MPIO_HD300_PAD
71
72/* Define this if you do software codec */
73#define CONFIG_CODEC SWCODEC
74
75/* Define this if you have RTC */
76#define CONFIG_RTC RTC_S35390A
77
78#define CONFIG_LCD LCD_S1D15E06
79
80/* Define this for LCD backlight available */
81#define HAVE_BACKLIGHT
82#define HAVE_BACKLIGHT_BRIGHTNESS
83#define MIN_BRIGHTNESS_SETTING 0
84#define MAX_BRIGHTNESS_SETTING 31
85#define DEFAULT_BRIGHTNESS_SETTING 20
86
87
88/* define this if you have a disk storage, i.e. something
89 that needs spinups and can cause skips when shaked */
90#define HAVE_DISK_STORAGE
91
92/* Define this if you have a software controlled poweroff */
93#define HAVE_SW_POWEROFF
94
95/* The number of bytes reserved for loadable codecs */
96#define CODEC_SIZE 0x100000
97
98/* The number of bytes reserved for loadable plugins */
99#define PLUGIN_BUFFER_SIZE 0x80000
100
101/* FM Tuner
102 * turn off for now
103 */
104#define CONFIG_TUNER TEA5767
105#define CONFIG_TUNER_XTAL 32768
106
107
108/* we have WM8750 codec in I2S master mode */
109#define HAVE_WM8750
110
111/* clocking setup based on 11.2896 MHz master clock
112 * provided to the codec by MCU
113 * WM8750L Datasheet Table 40, page 46
114 */
115#define CODEC_SRCTRL_11025HZ (0x18 << 1)
116#define CODEC_SRCTRL_22050HZ (0x1A << 1)
117#define CODEC_SRCTRL_44100HZ (0x10 << 1)
118#define CODEC_SRCTRL_88200HZ (0x1E << 1)
119
120/* copied from HD200 for now needs calibration */
121#define BATTERY_TYPES_COUNT 1
122#define BATTERY_CAPACITY_DEFAULT 850 /* this is wild guess */
123#define BATTERY_CAPACITY_MIN 800 /* min. capacity selectable */
124#define BATTERY_CAPACITY_MAX 2500 /* max. capacity selectable */
125#define BATTERY_CAPACITY_INC 50 /* capacity increment */
126
127#define CURRENT_NORMAL 68 /* measured during playback unboosted */
128#define CURRENT_BACKLIGHT 24 /* measured */
129#define CURRENT_RECORD 40 /* additional current while recording */
130#define CURRENT_ATA 100 /* additional current when ata system is ON */
131/* #define CURRENT_REMOTE 0 additional current when remote connected */
132
133#define CONFIG_CHARGING CHARGING_MONITOR
134
135#ifndef SIMULATOR
136
137/* Define this if your LCD can set contrast */
138#define HAVE_LCD_CONTRAST
139
140/* Define this if you have a Motorola SCF5249 */
141#define CONFIG_CPU MCF5249
142
143/* Define this if you want to use coldfire's i2c interface */
144#define CONFIG_I2C I2C_COLDFIRE
145
146/* define this if the hardware can be powered off while charging */
147/* #define HAVE_POWEROFF_WHILE_CHARGING */
148
149/* The size of the flash ROM */
150#define FLASH_SIZE 0x200000
151
152/* Define this to the CPU frequency */
153#define CPU_FREQ 11289600
154
155/* Define this if you have ATA power-off control */
156#define HAVE_ATA_POWER_OFF
157
158/* Offset ( in the firmware file's header ) to the file length */
159#define FIRMWARE_OFFSET_FILE_LENGTH 0
160
161/* Offset ( in the firmware file's header ) to the file CRC */
162#define FIRMWARE_OFFSET_FILE_CRC 0
163
164/* Offset ( in the firmware file's header ) to the real data */
165#define FIRMWARE_OFFSET_FILE_DATA 8
166
167/* Define this if you have adjustable CPU frequency */
168#define HAVE_ADJUSTABLE_CPU_FREQ
169
170#define BOOTFILE_EXT "mpio"
171#define BOOTFILE "rockbox." BOOTFILE_EXT
172#define BOOTDIR "/.rockbox"
173
174#define BOOTLOADER_ENTRYPOINT 0x001F0000
175#define FLASH_ENTRYPOINT 0x00001000
176#define FLASH_MAGIC 0xfbfbfbf1
177
178#endif /* SIMULATOR */
179
180/** Port-specific settings **/
181
182#define MIN_CONTRAST_SETTING 20
183#define MAX_CONTRAST_SETTING 32
184#define DEFAULT_CONTRAST_SETTING 24
185
186#define IRAM_LCDFRAMEBUFFER IBSS_ATTR /* put the lcd frame buffer in IRAM */
diff --git a/firmware/target/coldfire/crt0.S b/firmware/target/coldfire/crt0.S
index 23bf297316..8b0ee91f9b 100644
--- a/firmware/target/coldfire/crt0.S
+++ b/firmware/target/coldfire/crt0.S
@@ -63,14 +63,14 @@ start:
63 move.l #0x00000180,%d0 /* CSCR0 - no wait states, 16 bits, no bursts */ 63 move.l #0x00000180,%d0 /* CSCR0 - no wait states, 16 bits, no bursts */
64 move.l %d0,(0x088,%a0) 64 move.l %d0,(0x088,%a0)
65 65
66#ifdef MPIO_HD200 66#if (defined MPIO_HD200) || (defined MPIO_HD300)
67 /* Chip select 3 - LCD controller */ 67 /* Chip select 3 - LCD controller */
68 /* values taken from original firmware except base address*/ 68 /* FIXME Check if we really need this 2 wait states! */
69 move.l #0xf0000000,%d0 /* CSAR3 - Base = 0xf0000000 */ 69 move.l #0xf0000000,%d0 /* CSAR3 - Base = 0xf0000000 */
70 move.l %d0,(0x0a4,%a0) 70 move.l %d0,(0x0a4,%a0)
71 moveq.l #0x1,%d0 /* CSMR3 - 64K */ 71 moveq.l #0x1,%d0 /* CSMR3 - 64K */
72 move.l %d0,(0x0a8,%a0) 72 move.l %d0,(0x0a8,%a0)
73 move.l #0x00000980,%d0 /* CSCR3 - 1 wait state, 16 bits no bursts */ 73 move.l #0x00000980,%d0 /* CSCR3 - 2 wait states, 16 bits no bursts */
74 move.l %d0,(0x0ac,%a0) 74 move.l %d0,(0x0ac,%a0)
75#elif !(defined IAUDIO_M3) 75#elif !(defined IAUDIO_M3)
76 /* Chip select 1 - LCD controller */ 76 /* Chip select 1 - LCD controller */
@@ -276,7 +276,7 @@ start:
276 or.l %d0,(0xbc,%a1) 276 or.l %d0,(0xbc,%a1)
277#endif 277#endif
278 278
279#ifdef MPIO_HD200 279#if (defined MPIO_HD200) || (defined MPIO_HD300)
280 /* Set KEEP_ACT 280 /* Set KEEP_ACT
281 * Set GPIO57 high to remove hissing nois on startup 281 * Set GPIO57 high to remove hissing nois on startup
282 */ 282 */
diff --git a/firmware/target/coldfire/debug-target.h b/firmware/target/coldfire/debug-target.h
index 76b502e4ff..8d01cdd6f1 100644
--- a/firmware/target/coldfire/debug-target.h
+++ b/firmware/target/coldfire/debug-target.h
@@ -28,7 +28,8 @@
28#elif (CONFIG_KEYPAD == IAUDIO_M3_PAD) 28#elif (CONFIG_KEYPAD == IAUDIO_M3_PAD)
29# define DEBUG_CANCEL BUTTON_RC_REC 29# define DEBUG_CANCEL BUTTON_RC_REC
30 30
31#elif (CONFIG_KEYPAD == MPIO_HD200_PAD) 31#elif (CONFIG_KEYPAD == MPIO_HD200_PAD) || \
32 (CONFIG_KEYPAD == MPIO_HD300_PAD)
32# define DEBUG_CANCEL BUTTON_REC 33# define DEBUG_CANCEL BUTTON_REC
33#endif 34#endif
34bool dbg_ports(void); 35bool dbg_ports(void);
diff --git a/firmware/target/coldfire/mpio/audio-mpio.c b/firmware/target/coldfire/mpio/audio-mpio.c
index 4455281267..ba1258e5e7 100644
--- a/firmware/target/coldfire/mpio/audio-mpio.c
+++ b/firmware/target/coldfire/mpio/audio-mpio.c
@@ -36,9 +36,15 @@ void audio_set_output_source(int source)
36 static const unsigned char txsrc_select[AUDIO_NUM_SOURCES+1] = 36 static const unsigned char txsrc_select[AUDIO_NUM_SOURCES+1] =
37 { 37 {
38 [AUDIO_SRC_PLAYBACK+1] = 3, /* PDOR3 */ 38 [AUDIO_SRC_PLAYBACK+1] = 3, /* PDOR3 */
39#if (INPUT_SRC_CAPS & SRC_CAP_MIC)
39 [AUDIO_SRC_MIC+1] = 4, /* IIS1 RcvData */ 40 [AUDIO_SRC_MIC+1] = 4, /* IIS1 RcvData */
41#endif
42#if (INPUT_SRC_CAPS & SRC_CAP_LINEIN)
40 [AUDIO_SRC_LINEIN+1] = 4, /* IIS1 RcvData */ 43 [AUDIO_SRC_LINEIN+1] = 4, /* IIS1 RcvData */
44#endif
45#if (INPUT_SRC_CAPS & SRC_CAP_FMRADIO)
41 [AUDIO_SRC_FMRADIO+1] = 4, /* IIS1 RcvData */ 46 [AUDIO_SRC_FMRADIO+1] = 4, /* IIS1 RcvData */
47#endif
42 }; 48 };
43 49
44 int level = set_irq_level(DMA_IRQ_LEVEL); 50 int level = set_irq_level(DMA_IRQ_LEVEL);
@@ -74,7 +80,9 @@ void audio_input_mux(int source, unsigned flags)
74 break; 80 break;
75 81
76 case AUDIO_SRC_MIC: 82 case AUDIO_SRC_MIC:
83#if (INPUT_SRC_CAPS & SRC_CAP_LINEIN)
77 case AUDIO_SRC_LINEIN: 84 case AUDIO_SRC_LINEIN:
85#endif
78 /* recording only */ 86 /* recording only */
79 if (source != last_source) 87 if (source != last_source)
80 { 88 {
diff --git a/firmware/target/coldfire/mpio/hd300/button-hd300.c b/firmware/target/coldfire/mpio/hd300/button-hd300.c
new file mode 100644
index 0000000000..19c93abfca
--- /dev/null
+++ b/firmware/target/coldfire/mpio/hd300/button-hd300.c
@@ -0,0 +1,234 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2010 Marcin Bukat
11 * scrollstrip logic inspired by button-mini1g.c
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 "cpu.h"
25#include "system.h"
26#include "button.h"
27#include "backlight.h"
28#include "adc.h"
29#include "powermgmt.h"
30
31#define SLIDER_BASE_SENSITIVITY 6
32
33/* GPI7 H-L, GPI6 H-L, GPI7 L-H, GPI6 L-H */
34#define SLIDER_GPIO_MASK ((1<<15)|(1<<14)|(1<<7)|(1<<6))
35
36static inline void disable_scrollstrip_interrupts(void)
37{
38 and_l(~SLIDER_GPIO_MASK,&GPIO_INT_EN);
39}
40
41static inline void enable_scrollstrip_interrupts(void)
42{
43
44 or_l(SLIDER_GPIO_MASK,&GPIO_INT_EN);
45}
46
47static inline void ack_scrollstrip_interrupt(void)
48{
49 or_l(SLIDER_GPIO_MASK,&GPIO_INT_CLEAR);
50}
51
52void scrollstrip_isr(void) __attribute__ ((interrupt_handler,section(".icode")));
53void scrollstrip_isr(void)
54{
55 /* reading line 6 and 7 forms four possible states:
56 * 0, 1 , 2, 3
57 * tracking the order of line changes we can judge
58 * if the slide is up or down in the following way:
59 * sliding up order: 0 2 3 1 0 2 3 1
60 * sliding down order: 0 1 3 2 0 1 3 2
61 */
62 static const signed char scroll_state[4][4] ICONST_ATTR = {
63 { BUTTON_NONE, BUTTON_DOWN, BUTTON_UP, BUTTON_NONE},
64 { BUTTON_UP, BUTTON_NONE, BUTTON_NONE, BUTTON_DOWN},
65 { BUTTON_DOWN, BUTTON_NONE, BUTTON_NONE, BUTTON_UP},
66 { BUTTON_NONE, BUTTON_UP, BUTTON_DOWN, BUTTON_NONE}
67 };
68
69 static signed char prev_scroll_lines = -1;
70 static signed char direction = 0;
71 static unsigned char count = 0;
72 static long next_backlight_on = 0;
73
74 signed int new_scroll_lines;
75 signed int scroll_dir;
76
77 disable_scrollstrip_interrupts();
78
79 /* read GPIO6 and GPIO7 state*/
80 new_scroll_lines = (GPIO_READ >> 6) & 0x03;
81
82 if ( prev_scroll_lines == -1 )
83 {
84 prev_scroll_lines = new_scroll_lines;
85 ack_scrollstrip_interrupt();
86 enable_scrollstrip_interrupts();
87 return;
88 }
89
90 scroll_dir = scroll_state[prev_scroll_lines][new_scroll_lines];
91 prev_scroll_lines = new_scroll_lines;
92
93 if (direction != scroll_dir)
94 {
95 /* direction reversal */
96 direction = scroll_dir;
97 count = 0;
98 ack_scrollstrip_interrupt();
99 enable_scrollstrip_interrupts();
100 return;
101 }
102
103 /* poke backlight */
104 if (TIME_AFTER(current_tick, next_backlight_on))
105 {
106 backlight_on();
107 reset_poweroff_timer();
108 next_backlight_on = current_tick + HZ/4;
109 }
110
111 if (++count < SLIDER_BASE_SENSITIVITY)
112 {
113 ack_scrollstrip_interrupt();
114 enable_scrollstrip_interrupts();
115 return;
116 }
117
118 count = 0;
119
120 /* post scrollstrip event to the button queue */
121 if (queue_empty(&button_queue))
122 queue_post(&button_queue, scroll_dir, 0);
123
124 ack_scrollstrip_interrupt();
125 enable_scrollstrip_interrupts();
126}
127
128/* register interrupt service routine for scrollstrip lines */
129void GPI6(void) __attribute__ ((alias("scrollstrip_isr")));
130void GPI7(void) __attribute__ ((alias("scrollstrip_isr")));
131
132void button_init_device(void)
133{
134 /* GPIO56 (PLAY) general input
135 * GPIO45 (ENTER) general input
136 * GPIO41 (MENU) dual function pin shared with audio serial data
137 *
138 * GPIO6, GPIO7 scrollstrip lines
139 * GPIO31 scrollstrip enable
140 */
141
142 or_l((1<<24)|(1<<13),&GPIO1_FUNCTION);
143 and_l(~((1<<24)|(1<<13)),&GPIO1_ENABLE);
144
145 or_l((1<<31)|(1<<7)|(1<<6),&GPIO_FUNCTION);
146 and_l(~((1<<7)|(1<<6)),&GPIO_ENABLE);
147
148 /* scrollstrip enable active low */
149 and_l(~(1<<31),&GPIO_OUT);
150 or_l((1<<31),&GPIO_ENABLE);
151
152 /* GPI6, GPI7 interrupt level 4.0 */
153 or_l((4<<28)|(4<<24), &INTPRI5);
154
155 enable_scrollstrip_interrupts();
156}
157
158bool button_hold(void)
159{
160 /* GPIO51 active low */
161 return (GPIO1_READ & (1<<19))?false:true;
162}
163
164/*
165 * Get button pressed from hardware
166 */
167int button_read_device(void)
168{
169 int btn = BUTTON_NONE;
170 int data = 0;
171 static bool hold_button = false;
172
173 bool hold_button_old;
174
175
176 /* read hold buttons status */
177 hold_button_old = hold_button;
178 hold_button = button_hold();
179
180#ifndef BOOTLOADER
181 /* Only main hold affects backlight */
182 if (hold_button != hold_button_old)
183 backlight_hold_changed(hold_button);
184#endif
185
186 /* Skip if main hold is active */
187 if (!hold_button)
188 {
189 data = adc_scan(ADC_BUTTONS);
190
191 if (data < 800) /* middle */
192 {
193 if (data < 450)
194 {
195 if (data > 250)
196 btn |= BUTTON_FF;
197 }
198 else /* 800 - 450 */
199 {
200 if (data > 600)
201 btn |= BUTTON_REW;
202 }
203 }
204 else /* data > 800 */
205 {
206 if (data < 1150)
207 if (data > 950)
208 btn |= BUTTON_REC;
209 }
210 }
211
212 /* Handle GPIOs buttons
213 *
214 * GPIO56 active high PLAY/PAUSE/ON
215 * GPIO45 active low ENTER
216 * GPIO41 active low MENU
217 */
218
219 data = GPIO1_READ;
220
221 if (!hold_button)
222 {
223 if (data & (1<<24))
224 btn |= BUTTON_PLAY;
225
226 if (!(data & (1<<13)))
227 btn |= BUTTON_ENTER;
228
229 if (!(data & (1<<9)))
230 btn |= BUTTON_MENU;
231 }
232
233 return btn;
234}
diff --git a/firmware/target/coldfire/mpio/hd300/button-target.h b/firmware/target/coldfire/mpio/hd300/button-target.h
new file mode 100644
index 0000000000..5cb2ae8bf2
--- /dev/null
+++ b/firmware/target/coldfire/mpio/hd300/button-target.h
@@ -0,0 +1,55 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2010 Marcin Bukat
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#include <stdbool.h>
25#include "config.h"
26
27#define HAS_BUTTON_HOLD
28#define BUTTON_REMOTE 0
29
30bool button_hold(void);
31void button_init_device(void);
32int button_read_device(void);
33
34/* HD300 specific button codes */
35#define BUTTON_PLAY 0x00000001
36#define BUTTON_REW 0x00000004
37#define BUTTON_FF 0x00000002
38#define BUTTON_UP 0x00000008
39#define BUTTON_DOWN 0x00000010
40#define BUTTON_REC 0x00000020
41#define BUTTON_MENU 0x00000040
42#define BUTTON_ENTER 0x00000080
43
44#define BUTTON_LEFT BUTTON_REW
45#define BUTTON_RIGHT BUTTON_FF
46#define BUTTON_ON BUTTON_PLAY
47
48#define BUTTON_MAIN (BUTTON_PLAY|BUTTON_REW|BUTTON_FF|\
49 BUTTON_UP|BUTTON_DOWN|BUTTON_REC|BUTTON_MENU|\
50 BUTTON_ENTER)
51
52#define POWEROFF_BUTTON BUTTON_PLAY
53#define POWEROFF_COUNT 30
54
55#endif /* _BUTTON_TARGET_H_ */
diff --git a/firmware/target/coldfire/mpio/hd300/lcd-as-hd300.S b/firmware/target/coldfire/mpio/hd300/lcd-as-hd300.S
new file mode 100644
index 0000000000..e5b04001dc
--- /dev/null
+++ b/firmware/target/coldfire/mpio/hd300/lcd-as-hd300.S
@@ -0,0 +1,227 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Adopted for MPIO HD300 by Marcin Bukat
11 * Copyright (C) 2007 by Jens Arnold
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 "cpu.h"
25
26 .section .icode,"ax",@progbits
27
28 .align 2
29 .global lcd_write_command
30 .type lcd_write_command,@function
31
32lcd_write_command:
33 move.l (4, %sp), %d0
34 move.w %d0, 0xf0000000
35 rts
36.wc_end:
37 .size lcd_write_command,.wc_end-lcd_write_command
38
39
40 .align 2
41 .global lcd_write_command_ex
42 .type lcd_write_command_ex,@function
43
44lcd_write_command_ex:
45 lea.l 0xf0000000, %a0
46
47 move.l (4, %sp), %d0 /* Command */
48 move.w %d0, (%a0)+ /* Write to LCD, set A0 = 1 */
49
50 move.l (8, %sp), %d0 /* Data */
51 cmp.l #-1, %d0 /* -1? */
52 beq.b .last
53 move.w %d0, (%a0) /* Write to LCD */
54
55 move.l (12, %sp), %d0 /* Data */
56 cmp.l #-1, %d0 /* -1? */
57 beq.b .last
58 move.w %d0, (%a0) /* Write to LCD */
59
60.last:
61 rts
62.wcex_end:
63 .size lcd_write_command_ex,.wcex_end-lcd_write_command_ex
64
65
66 .align 2
67 .global lcd_write_data
68 .type lcd_write_data,@function
69
70lcd_write_data:
71 movem.l (4, %sp), %a0-%a1 /* Data pointer */
72 move.l %a1, %d0 /* Length */
73 lea 0xf0000002, %a1
74
75.loop:
76 /* When running in IRAM, this loop takes 10 cycles plus the LCD write.
77 The 10 cycles are necessary to follow the LCD timing specs
78 at 140MHz */
79 nop /* 3(0/0) */
80 move.b (%a0)+, %d1 /* 3(1/0) */
81 move.w %d1, (%a1) /* 1(0/1) */
82 subq.l #1, %d0 /* 1(0/0) */
83 bne .loop /* 2(0/0) */
84 rts
85.wd_end:
86 .size lcd_write_data,.wd_end-lcd_write_data
87
88
89 .align 2
90 .global lcd_grey_data
91 .type lcd_grey_data,@function
92
93 /* The main loop assumes the buffers are in SDRAM. Otherwise the LCD
94 * controller timing won't be met at 124 MHz and graphical glitches
95 * will occur. */
96
97lcd_grey_data:
98 lea.l (-11*4, %sp), %sp
99 movem.l %d2-%d7/%a2-%a6, (%sp) /* free some registers */
100 movem.l (11*4+4, %sp), %a0-%a2 /* values, phases, length */
101 lea.l (%a1, %a2.l*4), %a2 /* end address */
102 lea 0xf0000002, %a3 /* LCD data port */
103 moveq.l #24, %d6 /* shift count */
104 move.l #0xc30c3, %d7 /* bit shuffle factor */
105
106 moveq.l #12, %d2
107 add.l %a1, %d2
108 and.l #0xfffffff0, %d2 /* first line bound */
109 cmp.l %d2, %a2 /* end address lower than first line bound? */
110 bhs.s 1f
111 move.l %a2, %d2 /* -> adjust end address of head loop */
1121:
113 cmp.l %a1, %d2
114 bls.s .g_hend
115
116.g_hloop:
117 move.l (%a1), %d0 /* fetch 4 pixel phases */
118
119 move.l %d0, %d1
120 and.l #0x80808080, %d1 /* separate MSBs of the 4 phases */
121 eor.l %d1, %d0 /* clear them in %d0 */
122 add.l (%a0)+, %d0 /* add 4 pixel values to the phases */
123 move.l %d0, (%a1)+ /* store new phases, advance pointer */
124
125 lsr.l #1, %d1 /* %d1 = .0.......1.......2.......3...... */
126 mulu.l %d7, %d1 /* %d1 = 00112233112233..2233....33...... */
127 not.l %d1 /* negate bits */
128 lsr.l %d6, %d1 /* %d1 = ........................00112233 */
129 move.w %d1, (%a3) /* write pixel block */
130
131 cmp.l %a1, %d2 /* go up to first line bound */
132 bhi.s .g_hloop
133
134.g_hend:
135 cmp.l %a1, %a2
136 bls.w .g_tend
137 lea.l (-12, %a2), %a2
138 cmp.l %a1, %a2
139 bls.s .g_lend
140
141.g_lloop:
142 movem.l (%a1), %d0-%d3 /* fetch 4 blocks of 4 pixel phases each */
143
144 move.l %d0, %d4 /* calculate first pixel block */
145 and.l #0x80808080, %d4
146 eor.l %d4, %d0
147 lsr.l #1, %d4
148 mulu.l %d7, %d4
149 not.l %d4
150 lsr.l %d6, %d4
151
152 move.w %d4, (%a3) /* write first pixel block to LCD */
153
154 move.l %d1, %d5 /* calculate second pixel block */
155 and.l #0x80808080, %d5
156 eor.l %d5, %d1
157 lsr.l #1, %d5
158 mulu.l %d7, %d5
159 not.l %d5
160 lsr.l %d6, %d5
161
162 move.l %d2, %d4 /* calculate third pixel block */
163 and.l #0x80808080, %d4
164 eor.l %d4, %d2
165 lsr.l #1, %d4
166 mulu.l %d7, %d4
167 not.l %d4
168 lsr.l %d6, %d4
169
170 move.w %d5, (%a3) /* write second pixel block to LCD */
171
172 movem.l (%a0), %d5/%a4-%a6 /* fetch 4 blocks of 4 pixel values each */
173 lea.l (16, %a0), %a0
174
175 move.w %d4, (%a3) /* write third pixel block to LCD */
176
177 move.l %d3, %d4 /* calculate fourth pixel block */
178 and.l #0x80808080, %d4
179 eor.l %d4, %d3
180 lsr.l #1, %d4
181 mulu.l %d7, %d4
182 not.l %d4
183 lsr.l %d6, %d4
184
185 add.l %d5, %d0 /* calculate 4*4 new pixel phases */
186 add.l %a4, %d1 /* (packed addition) */
187 add.l %a5, %d2
188 add.l %a6, %d3
189
190 movem.l %d0-%d3, (%a1) /* store 4*4 new pixel phases */
191 lea.l (16, %a1), %a1
192
193 move.w %d4, (%a3) /* write fourth pixel block to LCD */
194
195 cmp.l %a1, %a2 /* go up to last line bound */
196 bhi.s .g_lloop
197
198.g_lend:
199 lea.l (12, %a2), %a2
200 cmp.l %a1, %a2
201 bls.s .g_tend
202
203.g_tloop:
204 move.l (%a1), %d0 /* fetch 4 pixel phases */
205
206 move.l %d0, %d1
207 and.l #0x80808080, %d1
208 eor.l %d1, %d0
209 add.l (%a0)+, %d0 /* add 4 pixel values to the phases */
210 move.l %d0, (%a1)+ /* store new phases, advance pointer */
211
212 lsr.l #1, %d1
213 mulu.l %d7, %d1
214 not.l %d1
215 lsr.l %d6, %d1
216 move.w %d1, (%a3) /* write pixel block */
217
218 cmp.l %a1, %a2 /* go up to end address */
219 bhi.s .g_tloop
220
221.g_tend:
222 movem.l (%sp), %d2-%d7/%a2-%a6 /* restore registers */
223 lea.l (11*4, %sp), %sp
224 rts
225
226.gd_end:
227 .size lcd_grey_data,.gd_end-lcd_grey_data
diff --git a/firmware/target/coldfire/mpio/hd300/lcd-hd300.c b/firmware/target/coldfire/mpio/hd300/lcd-hd300.c
new file mode 100644
index 0000000000..10ee59571e
--- /dev/null
+++ b/firmware/target/coldfire/mpio/hd300/lcd-hd300.c
@@ -0,0 +1,244 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Adopted for MPIO HD300 by Marcin Bukat
11 * Copyright (C) 2007 by Jens Arnold
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#include "config.h"
23
24#include "system.h"
25#include "kernel.h"
26#include "lcd.h"
27
28/*** definitions ***/
29
30/* LCD command codes */
31#define LCD_CNTL_POWER_CONTROL 0x25
32#define LCD_CNTL_VOLTAGE_SELECT 0x2b
33#define LCD_CNTL_LINE_INVERT_DRIVE 0x36
34#define LCD_CNTL_GRAY_SCALE_PATTERN 0x39
35#define LCD_CNTL_TEMP_GRADIENT_SELECT 0x4e
36#define LCD_CNTL_OSC_FREQUENCY 0x5f
37#define LCD_CNTL_ON_OFF 0xae
38#define LCD_CNTL_OSC_ON_OFF 0xaa
39#define LCD_CNTL_OFF_MODE 0xbe
40#define LCD_CNTL_POWER_SAVE 0xa8
41#define LCD_CNTL_REVERSE 0xa6
42#define LCD_CNTL_ALL_LIGHTING 0xa4
43#define LCD_CNTL_COMMON_OUTPUT_STATUS 0xc4
44#define LCD_CNTL_COLUMN_ADDRESS_DIR 0xa0
45#define LCD_CNTL_NLINE_ON_OFF 0xe4
46#define LCD_CNTL_DISPLAY_MODE 0x66
47#define LCD_CNTL_DUTY_SET 0x6d
48#define LCD_CNTL_ELECTRONIC_VOLUME 0x81
49#define LCD_CNTL_DATA_INPUT_DIR 0x84
50#define LCD_CNTL_DISPLAY_START_LINE 0x8a
51#define LCD_CNTL_AREA_SCROLL 0x10
52
53#define LCD_CNTL_PAGE 0xb1
54#define LCD_CNTL_COLUMN 0x13
55#define LCD_CNTL_DATA_WRITE 0x1d
56
57/*** shared semi-private declarations ***/
58extern const unsigned char lcd_dibits[16] ICONST_ATTR;
59
60/*** hardware configuration ***/
61int lcd_default_contrast(void)
62{
63 return DEFAULT_CONTRAST_SETTING;
64}
65
66void lcd_set_contrast(int val)
67{
68 /* Keep val in acceptable hw range */
69 if (val < 0)
70 val = 0;
71 else if (val > 127)
72 val = 127;
73
74 lcd_write_command_ex(LCD_CNTL_ELECTRONIC_VOLUME, val, -1);
75}
76
77void lcd_set_invert_display(bool yesno)
78{
79 lcd_write_command(LCD_CNTL_REVERSE | (yesno?1:0));
80}
81
82/* turn the display upside down (call lcd_update() afterwards) */
83void lcd_set_flip(bool yesno)
84{
85 if (yesno)
86 {
87 lcd_write_command(LCD_CNTL_COLUMN_ADDRESS_DIR | 1);
88 lcd_write_command(LCD_CNTL_COMMON_OUTPUT_STATUS | 0);
89 lcd_write_command_ex(LCD_CNTL_DUTY_SET, 0x20, 0);
90 }
91 else
92 {
93 lcd_write_command(LCD_CNTL_COLUMN_ADDRESS_DIR | 0);
94 lcd_write_command(LCD_CNTL_COMMON_OUTPUT_STATUS | 1);
95 lcd_write_command_ex(LCD_CNTL_DUTY_SET, 0x20, 1);
96 }
97}
98
99void lcd_init_device(void)
100{
101 and_l(~0x00000800, &GPIO_FUNCTION); /* CS3 line */
102
103 /* LCD Reset GPO34 */
104 or_l(0x00000004, &GPIO1_ENABLE); /* set as output */
105 or_l(0x00000004, &GPIO1_FUNCTION); /* switch to secondary function - GPIO */
106
107 and_l(~0x00000004, &GPIO1_OUT); /* RESET low */
108 sleep(1); /* delay at least 1000 ns */
109 or_l(0x00000004, &GPIO1_OUT); /* RESET high */
110 sleep(1);
111
112 lcd_write_command(LCD_CNTL_ON_OFF | 1); /* LCD ON */
113 lcd_write_command(LCD_CNTL_OFF_MODE | 1); /* OFF -> VCC on drivers */
114 lcd_write_command(LCD_CNTL_REVERSE | 0); /* Reverse OFF */
115 lcd_write_command(LCD_CNTL_ALL_LIGHTING | 0); /* Normal */
116 lcd_write_command(LCD_CNTL_COMMON_OUTPUT_STATUS | 1); /* Reverse dir */
117 lcd_write_command_ex(LCD_CNTL_DISPLAY_START_LINE, 0, -1);
118 lcd_write_command(LCD_CNTL_COLUMN_ADDRESS_DIR | 0); /* Normal */
119 lcd_write_command_ex(LCD_CNTL_DISPLAY_MODE, 0, -1); /* Greyscale mode */
120 lcd_write_command_ex(LCD_CNTL_GRAY_SCALE_PATTERN, 0x53, -1);
121 lcd_write_command_ex(LCD_CNTL_DUTY_SET, 0x20, 1);
122 lcd_write_command_ex(LCD_CNTL_ELECTRONIC_VOLUME, 24, -1); /* 0x18 */
123
124 lcd_write_command(LCD_CNTL_OSC_ON_OFF | 1); /* Oscillator ON */
125 lcd_write_command(LCD_CNTL_POWER_SAVE | 0);
126 lcd_write_command_ex(LCD_CNTL_VOLTAGE_SELECT, 3, -1);
127 lcd_write_command_ex(LCD_CNTL_POWER_CONTROL, 0x17, -1);
128 lcd_write_command_ex(LCD_CNTL_OSC_FREQUENCY, 3, -1);
129 lcd_write_command(LCD_CNTL_NLINE_ON_OFF | 1); /* N-line ON */
130 lcd_write_command_ex(LCD_CNTL_LINE_INVERT_DRIVE, 0x10, -1);
131 lcd_write_command_ex(LCD_CNTL_TEMP_GRADIENT_SELECT, 0, -1);
132
133 lcd_update();
134}
135
136/*** update functions ***/
137
138/* Performance function that works with an external buffer
139 note that by and bheight are in 8-pixel units! */
140void lcd_blit_mono(const unsigned char *data, int x, int by, int width,
141 int bheight, int stride)
142{
143 const unsigned char *src, *src_end;
144 unsigned char *dst_u, *dst_l;
145 static unsigned char upper[LCD_WIDTH] IBSS_ATTR;
146 static unsigned char lower[LCD_WIDTH] IBSS_ATTR;
147 unsigned int byte;
148
149 by *= 2;
150
151 while (bheight--)
152 {
153 src = data;
154 src_end = data + width;
155 dst_u = upper;
156 dst_l = lower;
157 do
158 {
159 byte = *src++;
160 *dst_u++ = lcd_dibits[byte & 0x0F];
161 byte >>= 4;
162 *dst_l++ = lcd_dibits[byte & 0x0F];
163 }
164 while (src < src_end);
165
166 lcd_write_command_ex(LCD_CNTL_PAGE, by++, -1);
167 lcd_write_command_ex(LCD_CNTL_COLUMN, x, -1);
168 lcd_write_command(LCD_CNTL_DATA_WRITE);
169 lcd_write_data(upper, width);
170
171 lcd_write_command_ex(LCD_CNTL_PAGE, by++, -1);
172 lcd_write_command_ex(LCD_CNTL_COLUMN, x, -1);
173 lcd_write_command(LCD_CNTL_DATA_WRITE);
174 lcd_write_data(lower, width);
175
176 data += stride;
177 }
178}
179
180/* Helper function for lcd_grey_phase_blit(). */
181void lcd_grey_data(unsigned char *values, unsigned char *phases, int count);
182
183/* Performance function that works with an external buffer
184 note that by and bheight are in 4-pixel units! */
185void lcd_blit_grey_phase(unsigned char *values, unsigned char *phases,
186 int x, int by, int width, int bheight, int stride)
187{
188 stride <<= 2; /* 4 pixels per block */
189 while (bheight--)
190 {
191 lcd_write_command_ex(LCD_CNTL_PAGE, by++, -1);
192 lcd_write_command_ex(LCD_CNTL_COLUMN, x, -1);
193 lcd_write_command(LCD_CNTL_DATA_WRITE);
194 lcd_grey_data(values, phases, width);
195 values += stride;
196 phases += stride;
197 }
198}
199
200/* Update the display.
201 This must be called after all other LCD functions that change the display. */
202void lcd_update(void) ICODE_ATTR;
203void lcd_update(void)
204{
205 int y;
206
207 /* Copy display bitmap to hardware */
208 for (y = 0; y < LCD_FBHEIGHT; y++)
209 {
210 lcd_write_command_ex(LCD_CNTL_PAGE, y, -1);
211 lcd_write_command_ex(LCD_CNTL_COLUMN, 0, -1);
212
213 lcd_write_command(LCD_CNTL_DATA_WRITE);
214 lcd_write_data (lcd_framebuffer[y], LCD_WIDTH);
215 }
216}
217
218/* Update a fraction of the display. */
219void lcd_update_rect(int, int, int, int) ICODE_ATTR;
220void lcd_update_rect(int x, int y, int width, int height)
221{
222 int ymax;
223
224 /* The Y coordinates have to work on even 8 pixel rows */
225 ymax = (y + height-1) >> 2;
226 y >>= 2;
227
228 if(x + width > LCD_WIDTH)
229 width = LCD_WIDTH - x;
230 if (width <= 0)
231 return; /* nothing left to do, 0 is harmful to lcd_write_data() */
232 if(ymax >= LCD_FBHEIGHT)
233 ymax = LCD_FBHEIGHT-1;
234
235 /* Copy specified rectange bitmap to hardware */
236 for (; y <= ymax; y++)
237 {
238 lcd_write_command_ex(LCD_CNTL_PAGE, y, -1);
239 lcd_write_command_ex(LCD_CNTL_COLUMN, x, -1);
240
241 lcd_write_command(LCD_CNTL_DATA_WRITE);
242 lcd_write_data (&lcd_framebuffer[y][x], width);
243 }
244}
diff --git a/firmware/target/coldfire/mpio/hd300/powermgmt-hd300.c b/firmware/target/coldfire/mpio/hd300/powermgmt-hd300.c
new file mode 100644
index 0000000000..9d95938ff9
--- /dev/null
+++ b/firmware/target/coldfire/mpio/hd300/powermgmt-hd300.c
@@ -0,0 +1,58 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2010 Marcin Bukat
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 "powermgmt.h"
25
26const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] =
27{
28 3600
29};
30
31const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
32{
33 3500
34};
35
36/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
37const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
38{
39 { 3500, 3566, 3597, 3619, 3644, 3676, 3732, 3806, 3868, 3937, 4004 }
40};
41
42/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */
43const unsigned short percent_to_volt_charge[11] =
44{
45 /* values measured over one full charging cycle */
46 3386, 3872, 3904, 3942, 3996, 4029, 4033, 4036, 4038, 4039, 4041
47};
48
49/* 3.33V as reference */
50#define BATTERY_SCALE_FACTOR 3330
51
52
53/* Returns battery voltage from ADC [millivolts] */
54unsigned int battery_adc_voltage(void)
55{
56 return (adc_read(ADC_BATTERY) * BATTERY_SCALE_FACTOR) >> 11;
57}
58
diff --git a/firmware/target/coldfire/mpio/power-mpio.c b/firmware/target/coldfire/mpio/power-mpio.c
index 3034bab82d..5ca3b947b0 100644
--- a/firmware/target/coldfire/mpio/power-mpio.c
+++ b/firmware/target/coldfire/mpio/power-mpio.c
@@ -122,7 +122,9 @@ bool ide_powered(void)
122 122
123void power_off(void) 123void power_off(void)
124{ 124{
125#ifdef HAVE_LCD_SHUTDOWN
125 lcd_shutdown(); 126 lcd_shutdown();
127#endif
126 set_irq_level(DISABLE_INTERRUPTS); 128 set_irq_level(DISABLE_INTERRUPTS);
127 and_l(~(1<<21), &GPIO1_OUT); /* pull KEEPACT low */ 129 and_l(~(1<<21), &GPIO1_OUT); /* pull KEEPACT low */
128 asm("halt"); 130 asm("halt");
diff --git a/firmware/target/coldfire/wmcodec-coldfire.c b/firmware/target/coldfire/wmcodec-coldfire.c
index 4403b9a2a2..e5bf2d65a8 100644
--- a/firmware/target/coldfire/wmcodec-coldfire.c
+++ b/firmware/target/coldfire/wmcodec-coldfire.c
@@ -32,7 +32,7 @@
32#include "i2s.h" 32#include "i2s.h"
33#include "wmcodec.h" 33#include "wmcodec.h"
34 34
35#if defined(MPIO_HD200) 35#if defined(MPIO_HD200) || defined(MPIO_HD300)
36#define I2C_CODEC_ADDRESS 0x34 36#define I2C_CODEC_ADDRESS 0x34
37#define I2C_IFACE I2C_IFACE_1 37#define I2C_IFACE I2C_IFACE_1
38#endif 38#endif
diff --git a/tools/configure b/tools/configure
index a9a6d55abf..1281d9446f 100755
--- a/tools/configure
+++ b/tools/configure
@@ -1088,6 +1088,7 @@ cat <<EOF
1088 1088
1089 ==MPIO== == Application == 1089 ==MPIO== == Application ==
1090 170) HD200 200) Application 1090 170) HD200 200) Application
1091 171) HD300
1091 1092
1092EOF 1093EOF
1093 1094
@@ -2717,6 +2718,29 @@ fi
2717 t_model="hd200" 2718 t_model="hd200"
2718 ;; 2719 ;;
2719 2720
2721 171|mpiohd300)
2722 target_id=70
2723 modelname="mpiohd300"
2724 target="-DMPIO_HD300"
2725 memory=16 # always
2726 coldfirecc
2727 tool="$rootdir/tools/scramble -add=hd30"
2728 bmp2rb_mono="$rootdir/tools/bmp2rb -f 0"
2729 bmp2rb_native="$rootdir/tools/bmp2rb -f 2"
2730 output="rockbox.mpio"
2731 bootoutput="bootloader.mpio"
2732 appextra="recorder:gui:radio"
2733 plugins=""
2734 swcodec="yes"
2735 # toolset is the tools within the tools directory that we build for
2736 # this particular target.
2737 toolset="$genericbitmaptools"
2738 # architecture, manufacturer and model for the target-tree build
2739 t_cpu="coldfire"
2740 t_manufacturer="mpio"
2741 t_model="hd300"
2742 ;;
2743
2720 200|app*) 2744 200|app*)
2721 target_id=100 2745 target_id=100
2722 modelname="application" 2746 modelname="application"
diff --git a/tools/scramble.c b/tools/scramble.c
index 7d33e4b203..b460d51c5e 100644
--- a/tools/scramble.c
+++ b/tools/scramble.c
@@ -125,7 +125,7 @@ void usage(void)
125 "\t tpj2, c200, e200, giga, gigs, m100, m500, d2,\n"); 125 "\t tpj2, c200, e200, giga, gigs, m100, m500, d2,\n");
126 printf("\t 9200, 1630, 6330, ldax, m200, c100, clip, e2v2,\n" 126 printf("\t 9200, 1630, 6330, ldax, m200, c100, clip, e2v2,\n"
127 "\t m2v4, fuze, c2v2, clv2, y820, y920, y925, x747,\n" 127 "\t m2v4, fuze, c2v2, clv2, y820, y920, y925, x747,\n"
128 "\t 747p, x777, nn2g, m244, cli+, fuz2, hd20)\n"); 128 "\t 747p, x777, nn2g, m244, cli+, fuz2, hd20, hd30)\n");
129 printf("\nNo option results in Archos standard player/recorder format.\n"); 129 printf("\nNo option results in Archos standard player/recorder format.\n");
130 130
131 exit(1); 131 exit(1);
@@ -330,6 +330,8 @@ int main (int argc, char** argv)
330 modelnum = 131; 330 modelnum = 131;
331 else if (!strcmp(&argv[1][5], "hd20")) /* MPIO HD200 */ 331 else if (!strcmp(&argv[1][5], "hd20")) /* MPIO HD200 */
332 modelnum = 69; 332 modelnum = 69;
333 else if (!strcmp(&argv[1][5], "hd30")) /* MPIO HD300 */
334 modelnum = 70;
333 else { 335 else {
334 fprintf(stderr, "unsupported model: %s\n", &argv[1][5]); 336 fprintf(stderr, "unsupported model: %s\n", &argv[1][5]);
335 return 2; 337 return 2;