Index: bootloader/mpio_hd200.c =================================================================== --- bootloader/mpio_hd200.c (wersja 0) +++ bootloader/mpio_hd200.c (wersja 0) @@ -0,0 +1,322 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id:$ + * + * Copyright (C) 2010 Marcin Bukat + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#include "config.h" + +#include +#include +#include "inttypes.h" +#include "string.h" +#include "cpu.h" +#include "system.h" +#include "lcd.h" +#include "lcd-remote.h" +#include "kernel.h" +#include "thread.h" +#include "storage.h" +#include "usb.h" +#include "disk.h" +#include "font.h" +#include "adc.h" +#include "backlight.h" +#include "backlight-target.h" +#include "button.h" +#include "panic.h" +#include "power.h" +#include "powermgmt.h" +#include "file.h" + +#include "common.h" + +#include + +/* Maximum allowed firmware image size. 10MB is more than enough */ +#define MAX_LOADSIZE (10*1024*1024) + +#define DRAM_START 0x31000000 + +/* From common.c */ +extern int line; + +int usb_screen(void) +{ + return 0; +} + +char version[] = APPSVERSION; + +/* Reset the cookie for the crt0 crash check */ +inline void __reset_cookie(void) +{ + asm(" move.l #0,%d0"); + asm(" move.l %d0,0x10017ffc"); +} + +void start_firmware(void) +{ + adc_close(); + asm(" move.w #0x2700,%sr"); + __reset_cookie(); + asm(" move.l %0,%%d0" :: "i"(DRAM_START)); + asm(" movec.l %d0,%vbr"); + asm(" move.l %0,%%sp" :: "m"(*(int *)DRAM_START)); + asm(" move.l %0,%%a0" :: "m"(*(int *)(DRAM_START+4))); + asm(" jmp (%a0)"); +} + +void shutdown(void) +{ + printf("Shutting down..."); + + /* We need to gracefully spin down the disk to prevent clicks. */ + if (ide_powered()) + { + /* Make sure ATA has been initialized. */ + storage_init(); + + /* And put the disk into sleep immediately. */ + storage_sleepnow(); + } + + sleep(HZ*2); + + /* Backlight OFF */ + _backlight_off(); + __reset_cookie(); + power_off(); +} + +/* Print the battery voltage (and a warning message). */ +void check_battery(void) +{ + + int battery_voltage, batt_int, batt_frac; + + battery_voltage = battery_adc_voltage(); + batt_int = battery_voltage / 1000; + batt_frac = (battery_voltage % 1000) / 10; + + printf("Batt: %d.%02dV", batt_int, batt_frac); + + if (battery_voltage <= 3500) + { + printf("WARNING! BATTERY LOW!!"); + sleep(HZ*2); + } + +} + +void main(void) +{ + int i; + int rc; + bool rc_on_button = false; + bool on_button = false; + int button; + + /* We want to read the buttons as early as possible, before the user + releases the ON button */ + +#ifdef MPIO_HD200 + + or_l( ((1<<24)|(1<<4)), &GPIO1_FUNCTION); /* main Hold & Play */ + and_l( ~((1<<24)|(1<<4)), &GPIO1_ENABLE); /* HiZ */ + + if (GPIO1_READ & (1<<24)) + on_button = true; + +#endif + + power_init(); + + system_init(); + kernel_init(); + + set_cpu_frequency(CPUFREQ_NORMAL); + coldfire_set_pllcr_audio_bits(DEFAULT_PLLCR_AUDIO_BITS); + + enable_irq(); + lcd_init(); + + backlight_init(); + font_init(); + lcd_setfont(FONT_SYSFIXED); + + adc_init(); + button_init(); + + if ((!on_button || button_hold()) + && !charger_inserted()) + { + /* No need to check for USB connection here, as USB is handled + * in the cowon loader. */ + if (on_button || rc_on_button) + printf("Hold switch on"); + //shutdown(); + } + + printf("Rockbox boot loader"); + printf("Version %s", version); + + check_battery(); + usb_init(); + + + /* GPIO46 is Wall charger detect (active low) */ + if( !(GPIO1_READ & (1<<14))) + { + const char charging_msg[] = "Charging..."; + const char complete_msg[] = "Charging complete"; + const char *msg; + int w, h; + bool blink_toggle = false; + bool request_start = false; + + cpu_idle_mode(true); + + while(!(GPIO1_READ & (1<<14)) && !request_start) + { + button = button_get_w_tmo(HZ); + + switch(button) + { + case BUTTON_ON: + request_start = true; + reset_screen(); + break; + + case BUTTON_NONE: /* Timeout */ + + /* GPIO30 high='battery charging' low='battery full' */ + if(GPIO_READ & (1<<30)) + { + /* To be replaced with a nice animation */ + blink_toggle = !blink_toggle; + msg = charging_msg; + } + else + { + blink_toggle = true; + msg = complete_msg; + } + + font_getstringsize(msg, &w, &h, FONT_SYSFIXED); + reset_screen(); + if(blink_toggle) + lcd_putsxy((LCD_WIDTH-w)/2, (LCD_HEIGHT-h)/2, msg); + + check_battery(); + break; + } + + if(usb_detect() == USB_INSERTED) + request_start = true; + } + if(!request_start) + { + __reset_cookie(); + power_off(); + } + + cpu_idle_mode(false); + } + + + + + if (usb_detect() == USB_INSERTED) + { + const char msg[] = "Bootloader USB mode"; + int w, h; + bool blink_toggle = false; + + font_getstringsize(msg, &w, &h, FONT_SYSFIXED); + + ide_power_enable(true); + sleep(HZ/20); + usb_enable(true); + cpu_idle_mode(true); + + while (usb_detect() == USB_INSERTED) + { + /* Print the battery status. */ + line = 0; + + reset_screen(); + + if(blink_toggle) + { + lcd_putsxy((LCD_WIDTH-w)/2, (LCD_HEIGHT-h)/2, msg); + } + + check_battery(); + blink_toggle = !blink_toggle; + + storage_spin(); /* Prevent the drive from spinning down */ + sleep(HZ); + } + + cpu_idle_mode(false); + usb_enable(false); + + sleep(HZ); + reset_screen(); + lcd_update(); + } + + + rc = storage_init(); + if(rc) + { + printf("ATA error: %d", rc); + sleep(HZ*5); + power_off(); + } + + disk_init(); + + rc = disk_mount_all(); + if (rc<=0) + { + printf("No partition found"); + sleep(HZ*5); + power_off(); + } + + printf("Loading firmware"); + i = load_firmware((unsigned char *)DRAM_START, BOOTFILE, MAX_LOADSIZE); + printf("Result: %s", strerror(i)); + + if (i < EOK) { + printf("Error!"); + printf("Can't load " BOOTFILE ": "); + printf(strerror(rc)); + sleep(HZ*10); + power_off(); + } else { + start_firmware(); + } +} + +/* These functions are present in the firmware library, but we reimplement + them here because the originals do a lot more than we want */ +void screen_dump(void) +{ +} Index: bootloader/SOURCES =================================================================== --- bootloader/SOURCES (wersja 25312) +++ bootloader/SOURCES (kopia robocza) @@ -63,4 +63,6 @@ #elif defined(PBELL_VIBE500) main-pp.c show_logo.c +#elif defined(MPIO_HD200) +mpio_hd200.c #endif Index: tools/configure =================================================================== --- tools/configure (wersja 25312) +++ tools/configure (kopia robocza) @@ -925,6 +925,9 @@ 141) YH-920 ==Lyre project==1 142) YH-925 ==Packard Bell== 130) Lyre proto 1 143) YP-S3 160) Vibe 500 131) Mini2440 + + ==MPIO== + 170) HD200 EOF buildfor=`input`; @@ -2517,6 +2520,28 @@ t_model="vibe500" ;; + 170|hd200) + target_id=69 + modelname="mpiohd200" + target="-DMPIO_HD200" + memory=16 # always + coldfirecc + tool="$rootdir/tools/scramble -add=hd200" + bmp2rb_mono="$rootdir/tools/bmp2rb -f 0" + bmp2rb_native="$rootdir/tools/bmp2rb -f 7" + output="rockbox.mpio" + appextra="recorder:gui" + plugins="" + swcodec="yes" + # toolset is the tools within the tools directory that we build for + # this particular target. + toolset="$genericbitmaptools" + # architecture, manufacturer and model for the target-tree build + t_cpu="coldfire" + t_manufacturer="mpio" + t_model="hd200" + ;; + *) echo "Please select a supported target platform!" exit 7 Index: tools/scramble.c =================================================================== --- tools/scramble.c (wersja 25312) +++ tools/scramble.c (kopia robocza) @@ -125,7 +125,7 @@ "\t tpj2, c200, e200, giga, gigs, m100, m500, d2,\n"); printf("\t 9200, 1630, 6330, ldax, m200, c100, clip, e2v2,\n" "\t m2v4, fuze, c2v2, clv2, y820, y920, y925, x747,\n" - "\t 747p, x777, nn2g, m244, cli+, fuz2)\n"); + "\t 747p, x777, nn2g, m244, cli+, fuz2, hd200)\n"); printf("\nNo option results in Archos standard player/recorder format.\n"); exit(1); @@ -328,6 +328,8 @@ modelnum = 68; else if (!strcmp(&argv[1][5], "m244")) modelnum = 131; + else if (!strcmp(&argv[1][5], "hd200")) /* MPIO HD200 */ + modelnum = 170; else { fprintf(stderr, "unsupported model: %s\n", &argv[1][5]); return 2; Index: apps/plugins/plugin.lds =================================================================== --- apps/plugins/plugin.lds (wersja 25312) +++ apps/plugins/plugin.lds (kopia robocza) @@ -80,17 +80,14 @@ #define DRAMSIZE (MEMORYSIZE * 0x100000) - PLUGIN_BUFFER_SIZE - STUBOFFSET - CODEC_SIZE #endif - -#if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300) -#define ARCH_IRIVER -#endif - -#if defined(ARCH_IRIVER) || defined(IAUDIO_M3) +/* MCF5249 have 96KB of IRAM */ +#if CONFIG_CPU == MCF5249 #define DRAMORIG 0x31000000 #define IRAMORIG 0x1000c000 #define IRAMSIZE 0xc000 -#elif defined(IAUDIO_X5) || defined(IAUDIO_M5) +/* MCF5250 have 128KB of IRAM */ +#elif CONFIG_CPU == MCF5250 #define DRAMORIG 0x31000000 #define IRAMORIG 0x1000c000 #define IRAMSIZE 0x14000 Index: apps/SOURCES =================================================================== --- apps/SOURCES (wersja 25312) +++ apps/SOURCES (kopia robocza) @@ -274,4 +274,6 @@ keymaps/keymap-mini2440.c #elif CONFIG_KEYPAD == PBELL_VIBE500_PAD keymaps/keymap-vibe500.c +#elif CONFIG_KEYPAD == MPIO_HD200_PAD +keymaps/keymap-mpio-hd200.c #endif Index: apps/debug_menu.c =================================================================== --- apps/debug_menu.c (wersja 25312) +++ apps/debug_menu.c (kopia robocza) @@ -987,6 +987,9 @@ #elif (CONFIG_KEYPAD == PBELL_VIBE500_PAD) # define DEBUG_CANCEL BUTTON_CANCEL +#elif (CONFIG_KEYPAD == MPIO_HD200_PAD) +# define DEBUG_CANCEL BUTTON_REC + #endif /* key definitions */ /* Test code!!! */ Index: apps/keymaps/keymap-mpio-hd200.c =================================================================== --- apps/keymaps/keymap-mpio-hd200.c (wersja 0) +++ apps/keymaps/keymap-mpio-hd200.c (wersja 0) @@ -0,0 +1,175 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id:$ + * + * Copyright (C) 2010 Marcin Bukat + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#include "config.h" +#include "action.h" +#include "button.h" +#include "settings.h" + +/* + * The format of the list is as follows + * { Action Code, Button code, Prereq button code } + * if there's no need to check the previous button's value, use BUTTON_NONE + * Insert LAST_ITEM_IN_LIST at the end of each mapping + */ + +/* CONTEXT_CUSTOM's used in this file... + +CONTEXT_CUSTOM|CONTEXT_TREE = the standard list/tree defines (without directions) + + +*/ + +static const struct button_mapping button_context_standard[] = { + { ACTION_STD_PREV, BUTTON_PREV, BUTTON_NONE }, + { ACTION_STD_PREVREPEAT, BUTTON_PREV|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_STD_NEXT, BUTTON_NEXT, BUTTON_NONE }, + { ACTION_STD_NEXTREPEAT, BUTTON_NEXT|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_STD_CANCEL, BUTTON_REC, BUTTON_NONE }, + { ACTION_STD_OK, BUTTON_SELECT, BUTTON_NONE }, + { ACTION_STD_OK, BUTTON_SELECT|BUTTON_REL, BUTTON_SELECT }, + { ACTION_STD_MENU, BUTTON_SELECT|BUTTON_REL, BUTTON_SELECT }, + { ACTION_STD_QUICKSCREEN, BUTTON_SELECT|BUTTON_REPEAT, BUTTON_SELECT }, + { ACTION_STD_CONTEXT, BUTTON_SELECT|BUTTON_REPEAT, BUTTON_SELECT }, + { ACTION_STD_CANCEL, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_NONE }, + + LAST_ITEM_IN_LIST +}; /* button_context_standard */ + +static const struct button_mapping button_context_tree[] = { + { ACTION_TREE_WPS, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY }, + { ACTION_TREE_STOP, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_PLAY }, + + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD) +}; /* button_context_tree */ + +static const struct button_mapping button_context_tree_scroll_lr[] = { + { ACTION_NONE, BUTTON_PREV, BUTTON_NONE }, + { ACTION_STD_CANCEL, BUTTON_PREV|BUTTON_REL, BUTTON_PREV }, + { ACTION_TREE_ROOT_INIT, BUTTON_PREV|BUTTON_REPEAT, BUTTON_PREV }, + { ACTION_TREE_PGLEFT, BUTTON_PREV|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_TREE_PGLEFT, BUTTON_PREV|BUTTON_REL, BUTTON_PREV|BUTTON_REPEAT }, + { ACTION_NONE, BUTTON_NEXT, BUTTON_NONE }, + { ACTION_STD_OK, BUTTON_NEXT|BUTTON_REL, BUTTON_NEXT }, + { ACTION_TREE_PGRIGHT, BUTTON_NEXT|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_TREE_PGRIGHT, BUTTON_NEXT|BUTTON_REL, BUTTON_NEXT|BUTTON_REPEAT }, + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM|CONTEXT_TREE), +}; /* button_context_tree_scroll_lr */ + +static const struct button_mapping button_context_wps[] = { + { ACTION_WPS_PLAY, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY }, + { ACTION_WPS_STOP, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_PLAY }, + { ACTION_WPS_SKIPPREV, BUTTON_PREV|BUTTON_REL, BUTTON_PREV }, + { ACTION_WPS_SEEKBACK, BUTTON_PREV|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_WPS_STOPSEEK, BUTTON_PREV|BUTTON_REL, BUTTON_PREV|BUTTON_REPEAT }, + { ACTION_WPS_SKIPNEXT, BUTTON_NEXT|BUTTON_REL, BUTTON_NEXT }, + { ACTION_WPS_SEEKFWD, BUTTON_NEXT|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_WPS_STOPSEEK, BUTTON_NEXT|BUTTON_REL, BUTTON_NEXT|BUTTON_REPEAT }, + { ACTION_WPS_VOLDOWN, BUTTON_VOL_DOWN, BUTTON_NONE }, + { ACTION_WPS_VOLDOWN, BUTTON_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_WPS_VOLUP, BUTTON_VOL_UP, BUTTON_NONE }, + { ACTION_WPS_VOLUP, BUTTON_VOL_UP|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_WPS_BROWSE, BUTTON_SELECT|BUTTON_REL, BUTTON_SELECT }, + { ACTION_WPS_CONTEXT, BUTTON_SELECT|BUTTON_REPEAT, BUTTON_SELECT }, + { ACTION_WPS_VIEW_PLAYLIST, BUTTON_SELECT|BUTTON_PLAY, BUTTON_NONE }, + { ACTION_WPS_MENU, BUTTON_SELECT|BUTTON_REL, BUTTON_SELECT }, + { ACTION_WPS_QUICKSCREEN, BUTTON_SELECT|BUTTON_REPEAT, BUTTON_SELECT }, + + LAST_ITEM_IN_LIST, +}; /* button_context_wps */ + +static const struct button_mapping button_context_settings[] = { + { ACTION_SETTINGS_INC, BUTTON_VOL_UP, BUTTON_NONE }, + { ACTION_SETTINGS_INCREPEAT, BUTTON_VOL_UP|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_SETTINGS_DEC, BUTTON_VOL_DOWN, BUTTON_NONE }, + { ACTION_SETTINGS_DECREPEAT, BUTTON_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_STD_PREV, BUTTON_PREV, BUTTON_NONE }, + { ACTION_STD_PREVREPEAT, BUTTON_PREV|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_STD_NEXT, BUTTON_NEXT, BUTTON_NONE }, + { ACTION_STD_NEXTREPEAT, BUTTON_NEXT|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_STD_OK, BUTTON_SELECT|BUTTON_REL, BUTTON_NONE }, + { ACTION_STD_CANCEL, BUTTON_REC|BUTTON_REL, BUTTON_REC }, + + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD) +}; /* button_context_settings */ + +static const struct button_mapping button_context_yesno[] = { + { ACTION_YESNO_ACCEPT, BUTTON_SELECT, BUTTON_NONE }, + LAST_ITEM_IN_LIST +}; /* button_context_yesno */ + +static const struct button_mapping button_context_bmark[] = { + { ACTION_BMS_DELETE, BUTTON_SELECT|BUTTON_REPEAT, BUTTON_SELECT }, + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_LIST), +}; /* button_context_bmark */ + +static const struct button_mapping button_context_quickscreen[] = { + { ACTION_QS_TOP, BUTTON_SELECT, BUTTON_NONE }, + { ACTION_QS_TOP, BUTTON_SELECT|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_QS_DOWN, BUTTON_PLAY, BUTTON_NONE }, + { ACTION_QS_DOWN, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_QS_LEFT, BUTTON_PREV, BUTTON_NONE }, + { ACTION_QS_LEFT, BUTTON_PREV|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_QS_RIGHT, BUTTON_NEXT, BUTTON_NONE }, + { ACTION_QS_RIGHT, BUTTON_NEXT|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_STD_CANCEL, BUTTON_REC, BUTTON_NONE }, + + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD) +}; /* button_context_quickscreen */ + +static const struct button_mapping button_context_pitchscreen[] = { + { ACTION_PS_INC_SMALL, BUTTON_VOL_UP, BUTTON_NONE }, + { ACTION_PS_INC_BIG, BUTTON_VOL_UP|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_PS_DEC_SMALL, BUTTON_VOL_DOWN, BUTTON_NONE }, + { ACTION_PS_DEC_BIG, BUTTON_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_PS_NUDGE_LEFT, BUTTON_PREV, BUTTON_NONE }, + { ACTION_PS_NUDGE_LEFTOFF, BUTTON_PREV|BUTTON_REL, BUTTON_NONE }, + { ACTION_PS_NUDGE_RIGHT, BUTTON_NEXT, BUTTON_NONE }, + { ACTION_PS_NUDGE_RIGHTOFF, BUTTON_NEXT|BUTTON_REL, BUTTON_NONE }, + { ACTION_PS_TOGGLE_MODE, BUTTON_PLAY, BUTTON_NONE }, + { ACTION_PS_RESET, BUTTON_SELECT, BUTTON_NONE }, + { ACTION_PS_EXIT, BUTTON_REC, BUTTON_NONE }, + { ACTION_PS_SLOWER, BUTTON_PREV|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_PS_FASTER, BUTTON_NEXT|BUTTON_REPEAT, BUTTON_NONE }, + + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD) +}; /* button_context_pitchscreen */ + +const struct button_mapping* get_context_mapping(int context) +{ + switch (context) + { + case CONTEXT_STD: + return button_context_standard; + case CONTEXT_WPS: + return button_context_wps; + + case CONTEXT_TREE: + case CONTEXT_LIST: + case CONTEXT_MAINMENU: + + case CONTEXT_SETTINGS: + case CONTEXT_SETTINGS|CONTEXT_REMOTE: + default: + return button_context_standard; + } + return button_context_standard; +} + Index: firmware/export/wm8750.h =================================================================== --- firmware/export/wm8750.h (wersja 0) +++ firmware/export/wm8750.h (wersja 0) @@ -0,0 +1,203 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id:$ + * + * For now this is just copy of wm8751.h + * WM8751 is little brother of WM8750 and basic regs are compatibile + * + * Copyright (C) 2005 by Dave Chapman + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#ifndef _WM8750_H +#define _WM8750_H + +/* volume/balance/treble/bass interdependency */ +#define VOLUME_MIN -730 +#define VOLUME_MAX 60 + +#define AUDIOHW_CAPS (BASS_CAP | TREBLE_CAP) + +extern int tenthdb2master(int db); + +extern void audiohw_set_master_vol(int vol_l, int vol_r); +extern void audiohw_set_lineout_vol(int vol_l, int vol_r); + +/* Register addresses and bits */ +#define OUTPUT_MUTED 0x2f +#define OUTPUT_0DB 0x79 + +#define LOUT1 0x02 +#define LOUT1_LOUT1VOL_MASK (0x07f << 0) +#define LOUT1_LOUT1VOL(x) ((x) & 0x7f) +#define LOUT1_LO1ZC (1 << 7) +#define LOUT1_LO1VU (1 << 8) + +#define ROUT1 0x03 +#define ROUT1_ROUT1VOL(x) ((x) & 0x7f) +#define ROUT1_RO1ZC (1 << 7) +#define ROUT1_RO1VU (1 << 8) + +#define DACCTRL 0x05 +#define DACCTRL_DEEMPH_NONE (0 << 1) +#define DACCTRL_DEEMPH_32 (1 << 1) +#define DACCTRL_DEEMPH_44 (2 << 1) +#define DACCTRL_DEEMPH_48 (3 << 1) +#define DACCTRL_DEEMPH(x) ((x) & (0x3 << 1)) +#define DACCTRL_DACMU (1 << 3) +#define DACCTRL_DAT (1 << 7) + +#define AINTFCE 0x07 +#define AINTFCE_FORMAT_RJUST (0 << 0) +#define AINTFCE_FORMAT_LJUST (1 << 0) +#define AINTFCE_FORMAT_I2S (2 << 0) +#define AINTFCE_FORMAT_DSP (3 << 0) +#define AINTFCE_FORMAT(x) ((x) & 0x3) +#define AINTFCE_WL_16 (0 << 2) +#define AINTFCE_WL_20 (1 << 2) +#define AINTFCE_WL_24 (2 << 2) +#define AINTFCE_WL_32 (3 << 2) +#define AINTFCE_WL(x) ((x) & (0x3 << 2)) +#define AINTFCE_LRP (1 << 4) +#define AINTFCE_LRSWAP (1 << 5) +#define AINTFCE_MS (1 << 6) +#define AINTFCE_BCLKINV (1 << 7) + +#define CLOCKING 0x08 +#define CLOCKING_SR_USB (1 << 0) +#define CLOCKING_SR(x) ((x) & (0x1f << 1)) +#define CLOCKING_MCLK_DIV2 (1 << 6) +#define CLOCKING_BCLK_DIV2 (1 << 7) + +#define LEFTGAIN 0x0a +#define LEFTGAIN_LDACVOL(x) ((x) & 0xff) +#define LEFTGAIN_LDVU (1 << 8) + +#define RIGHTGAIN 0x0b +#define RIGHTGAIN_LDACVOL(x) ((x) & 0xff) +#define RIGHTGAIN_LDVU (1 << 8) + +#define BASSCTRL 0x0c +#define BASSCTRL_BASS(x) ((x) & 0xf) +#define BASSCTRL_BC (1 << 6) +#define BASSCTRL_BB (1 << 7) + +#define TREBCTRL 0x0d +#define TREBCTRL_TREB(x) ((x) & 0xf) +#define TREBCTRL_TC (1 << 6) + +#define RESET 0x0f +#define RESET_RESET 0x000 + +#define ADDITIONAL1 0x17 +#define ADDITIONAL1_TOEN (1 << 0) +#define ADDITIONAL1_DACINV (1 << 1) +#define ADDITIONAL1_DMONOMIX_LLRR (0 << 4) +#define ADDITIONAL1_DMONOMIX_ML0R (1 << 4) +#define ADDITIONAL1_DMONOMIX_0LMR (2 << 4) +#define ADDITIONAL1_DMONOMIX_MLMR (3 << 4) +#define ADDITIONAL1_DMONOMIX(x) ((x) & (0x03 << 4)) +#define ADDITIONAL1_VSEL_LOWEST (0 << 6) +#define ADDITIONAL1_VSEL_LOW (1 << 6) +#define ADDITIONAL1_VSEL_DEFAULT2 (2 << 6) +#define ADDITIONAL1_VSEL_DEFAULT (3 << 6) +#define ADDITIONAL1_VSEL(x) ((x) & (0x3 << 6)) +#define ADDITIONAL1_TSDEN (1 << 8) + +#define ADDITIONAL2 0x18 +#define ADDITIONAL2_DACOSR (1 << 0) +#define ADDITIONAL2_HPSWZC (1 << 3) +#define ADDITIONAL2_ROUT2INV (1 << 4) +#define ADDITIONAL2_HPSWPOL (1 << 5) +#define ADDITIONAL2_HPSWEN (1 << 6) +#define ADDITIONAL2_OUT3SW_VREF (0 << 7) +#define ADDITIONAL2_OUT3SW_ROUT1 (1 << 7) +#define ADDITIONAL2_OUT3SW_MONOOUT (2 << 7) +#define ADDITIONAL2_OUT3SW_R_MIX_OUT (3 << 7) +#define ADDITIONAL2_OUT3SW(x) ((x) & (0x3 << 7)) + +#define PWRMGMT1 0x19 +#define PWRMGMT1_DIGENB (1 << 0) +#define PWRMGMT1_VREF (1 << 6) +#define PWRMGMT1_VMIDSEL_DISABLED (0 << 7) +#define PWRMGMT1_VMIDSEL_50K (1 << 7) +#define PWRMGMT1_VMIDSEL_500K (2 << 7) +#define PWRMGMT1_VMIDSEL_5K (3 << 7) +#define PWRMGMT1_VMIDSEL(x) ((x) & (0x3 << 7)) + +#define PWRMGMT2 0x1a +#define PWRMGMT2_OUT3 (1 << 1) +#define PWRMGMT2_MOUT (1 << 2) +#define PWRMGMT2_ROUT2 (1 << 3) +#define PWRMGMT2_LOUT2 (1 << 4) +#define PWRMGMT2_ROUT1 (1 << 5) +#define PWRMGMT2_LOUT1 (1 << 6) +#define PWRMGMT2_DACR (1 << 7) +#define PWRMGMT2_DACL (1 << 8) + +#define ADDITIONAL3 0x1b +#define ADDITIONAL3_ADCLRM ((x) & (0x3 << 7)) +#define ADDITIONAL3_HPFLREN (1 << 5) +#define ADDITIONAL3_VROI (1 << 6) + +#define LEFTMIX1 0x22 +#define LEFTMIX1_LI2LO_DEFAULT (5 << 4) +#define LEFTMIX1_LI2LOVOL(x) ((x) & (0x7 << 4)) +#define LEFTMIX1_LI2LO (1 << 7) +#define LEFTMIX1_LD2LO (1 << 8) + +#define LEFTMIX2 0x23 +#define LEFTMIX2_MI2LO_DEFAULT (5 << 4) +#define LEFTMIX2_MI2LOVOL(x) ((x) & (0x7 << 4)) +#define LEFTMIX2_MI2LO (1 << 7) +#define LEFTMIX2_RD2LO (1 << 8) + +#define RIGHTMIX1 0x24 +#define RIGHTMIX1_MI2RO_DEFAULT (5 << 4) +#define RIGHTMIX1_MI2ROVOL(x) ((x) & (0x7 << 4)) +#define RIGHTMIX1_MI2RO (1 << 7) +#define RIGHTMIX1_LD2RO (1 << 8) + +#define RIGHTMIX2 0x25 +#define RIGHTMIX2_RI2RO_DEFAULT (5 << 4) +#define RIGHTMIX2_RI2ROVOL(x) ((x) & (0x7 << 4)) +#define RIGHTMIX2_RI2RO (1 << 7) +#define RIGHTMIX2_RD2RO (1 << 8) + +#define MONOMIX1 0x26 +#define MONOMIX1_DMEN (1 << 0) +#define MONOMIX1_LI2MOVOL(x) ((x) & (0x7 << 4)) +#define MONOMIX1_LI2MO (1 << 7) +#define MONOMIX1_LD2MO (1 << 8) + +#define MONOMIX2 0x27 +#define MONOMIX2_RI2MOVOL(x) ((x) & (0x7 << 4)) +#define MONOMIX2_RI2MO (1 << 7) +#define MONOMIX2_RD2MO (1 << 8) + +#define LOUT2 0x28 +#define LOUT2_LOUT2VOL(x) ((x) & 0x7f) +#define LOUT2_LO2ZC (1 << 7) +#define LOUT2_LO2VU (1 << 8) + +#define ROUT2 0x29 +#define ROUT2_ROUT2VOL(x) ((x) & 0x7f) +#define ROUT2_RO2ZC (1 << 7) +#define ROUT2_RO2VU (1 << 8) + +#define MONOOUT 0x2a +#define MONOOUT_MOZC (1 << 7) + +#endif /* _WM8750_H */ Index: firmware/export/audiohw.h =================================================================== --- firmware/export/audiohw.h (wersja 25312) +++ firmware/export/audiohw.h (kopia robocza) @@ -38,6 +38,8 @@ #include "uda1380.h" #elif defined(HAVE_UDA1341) #include "uda1341.h" +#elif defined(HAVE_WM8750) +#include "wm8750.h" #elif defined(HAVE_WM8751) #include "wm8751.h" #elif defined(HAVE_WM8978) Index: firmware/export/config.h =================================================================== --- firmware/export/config.h (wersja 25312) +++ firmware/export/config.h (kopia robocza) @@ -117,6 +117,7 @@ #define MINI2440_PAD 41 #define PHILIPS_HDD6330_PAD 42 #define PBELL_VIBE500_PAD 43 +#define MPIO_HD200_PAD 44 /* CONFIG_REMOTE_KEYPAD */ #define H100_REMOTE 1 @@ -412,6 +413,8 @@ #include "config/samsungyps3.h" #elif defined(PBELL_VIBE500) #include "config/vibe500.h" +#elif defined(MPIO_HD200) +#include "config/mpiohd200.h" #else /* no known platform */ #endif Index: firmware/export/config/mpiohd200.h =================================================================== --- firmware/export/config/mpiohd200.h (wersja 0) +++ firmware/export/config/mpiohd200.h (wersja 0) @@ -0,0 +1,184 @@ +/* + * This config file is for MPIO HD200 + */ +#define TARGET_TREE /* this target is using the target tree system */ + +/* For Rolo and boot loader */ +#define MODEL_NUMBER 170 + +#define MODEL_NAME "MPIO HD200" + +/* define this if you use an ATA controller */ +#define CONFIG_STORAGE STORAGE_ATA + +/* define this if you have recording possibility */ +/* not implemented yet + * #define HAVE_RECORDING + */ + + +/* Define bitmask of input sources - recordable bitmask can be defined + * explicitly if different + * not implemented yet + * #define INPUT_SRC_CAPS (SRC_CAP_MIC | SRC_CAP_LINEIN | SRC_CAP_FMRADIO) + */ + +/* define the bitmask of hardware sample rates */ +#define HW_SAMPR_CAPS (SAMPR_CAP_88 | SAMPR_CAP_44 | SAMPR_CAP_22 | SAMPR_CAP_11) + +/* define the bitmask of recording sample rates + * not implemented yet + *#define REC_SAMPR_CAPS (SAMPR_CAP_88 | SAMPR_CAP_44 | SAMPR_CAP_22 | SAMPR_CAP_11) + */ + +/* define this if you have a bitmap LCD display */ +#define HAVE_LCD_BITMAP + +/* define this if you want album art for this target */ +#define HAVE_ALBUMART + +/* define this to enable bitmap scaling */ +#define HAVE_BMP_SCALING + +/* define this to enable JPEG decoding */ +#define HAVE_JPEG + +/* define this if you can flip your LCD */ +#define HAVE_LCD_FLIP + +/* define this if you can invert the colours on your LCD */ +#define HAVE_LCD_INVERT + +/* define this if you have access to the quickscreen */ +#define HAVE_QUICKSCREEN + +/* define this if you have access to the pitchscreen */ +#define HAVE_PITCHSCREEN + +/* define this if you would like tagcache to build on this target */ +#define HAVE_TAGCACHE + +/* LCD dimensions */ +#define LCD_WIDTH 128 +#define LCD_HEIGHT 128 +#define LCD_DEPTH 2 + +#define LCD_PIXELFORMAT VERTICAL_INTERLEAVED + +/* Display colours, for screenshots and sim (0xRRGGBB) */ +#define LCD_DARKCOLOR 0x000000 +#define LCD_BRIGHTCOLOR 0x5a915a +#define LCD_BL_DARKCOLOR 0x000000 +#define LCD_BL_BRIGHTCOLOR 0x82b4fa + +#define CONFIG_KEYPAD MPIO_HD200_PAD + +#define AB_REPEAT_ENABLE 1 +#define ACTION_WPSAB_SINGLE ACTION_WPS_BROWSE + +/* Define this if you do software codec */ +#define CONFIG_CODEC SWCODEC + +#define CONFIG_LCD LCD_TL0350A + +/* Define this for LCD backlight available */ +#define HAVE_BACKLIGHT +#define HAVE_BACKLIGHT_BRIGHTNESS +#define MIN_BRIGHTNESS_SETTING 0 +#define MAX_BRIGHTNESS_SETTING 31 +#define DEFAULT_BRIGHTNESS_SETTING 20 + + +/* define this if you have a disk storage, i.e. something + that needs spinups and can cause skips when shaked */ +#define HAVE_DISK_STORAGE + +/* Define this if you have a software controlled poweroff */ +#define HAVE_SW_POWEROFF + +/* The number of bytes reserved for loadable codecs */ +#define CODEC_SIZE 0x100000 + +/* The number of bytes reserved for loadable plugins */ +#define PLUGIN_BUFFER_SIZE 0x80000 + +/* FM Tuner + * turn off for now + * #define CONFIG_TUNER TEA5767 + * #define CONFIG_TUNER_XTAL 32768 +*/ + +#define HAVE_WM8750 +/* All exact rates for 11.2896MHz clock */ +#define CODEC_SRCTRL_11025HZ (0x18 << 1) +#define CODEC_SRCTRL_22050HZ (0x1a << 1) +#define CODEC_SRCTRL_44100HZ (0x10 << 1) +#define CODEC_SRCTRL_88200HZ (0x1e << 1) + + +#define BATTERY_CAPACITY_DEFAULT 950 /* default battery capacity */ +#define BATTERY_CAPACITY_MIN 950 /* min. capacity selectable */ +#define BATTERY_CAPACITY_MAX 2250 /* max. capacity selectable */ +#define BATTERY_CAPACITY_INC 50 /* capacity increment */ +#define BATTERY_TYPES_COUNT 1 /* only one type */ + +#define CONFIG_CHARGING CHARGING_MONITOR + +/* define current usage levels */ +/* additional current when remote connected */ +/* +#define CURRENT_REMOTE 8 +*/ +#ifndef SIMULATOR + +/* Define this if your LCD can set contrast */ +#define HAVE_LCD_CONTRAST + +/* Define this if you have a Motorola SCF5249 */ +#define CONFIG_CPU MCF5249 + +/* Define this if you want to use coldfire's i2c interface */ +#define CONFIG_I2C I2C_COLDFIRE + +/* define this if the hardware can be powered off while charging */ +#define HAVE_POWEROFF_WHILE_CHARGING + +/* The size of the flash ROM */ +#define FLASH_SIZE 0x200000 + +/* Define this to the CPU frequency */ +#define CPU_FREQ 11289600 + +/* Define this if you have ATA power-off control */ +#define HAVE_ATA_POWER_OFF + +/* Offset ( in the firmware file's header ) to the file length */ +#define FIRMWARE_OFFSET_FILE_LENGTH 0 + +/* Offset ( in the firmware file's header ) to the file CRC */ +#define FIRMWARE_OFFSET_FILE_CRC 0 + +/* Offset ( in the firmware file's header ) to the real data */ +#define FIRMWARE_OFFSET_FILE_DATA 8 + +/* Define this if you have adjustable CPU frequency */ +#define HAVE_ADJUSTABLE_CPU_FREQ + +#define BOOTFILE_EXT "mpio" +#define BOOTFILE "rockbox." BOOTFILE_EXT +#define BOOTDIR "/.rockbox" + +#define BOOTLOADER_ENTRYPOINT 0x001F0000 +#define FLASH_ENTRYPOINT 0x00001000 +#define FLASH_MAGIC 0xfbfbfbf1 + +#endif /* SIMULATOR */ + +/** Port-specific settings **/ + +/* Main LCD contrast range and defaults taken from OF*/ +#define MIN_CONTRAST_SETTING 24 +#define MAX_CONTRAST_SETTING 63 +#define DEFAULT_CONTRAST_SETTING 27 /* 0x1B */ + +#define IRAM_LCDFRAMEBUFFER IBSS_ATTR /* put the lcd frame buffer in IRAM */ Index: firmware/SOURCES =================================================================== --- firmware/SOURCES (wersja 25312) +++ firmware/SOURCES (kopia robocza) @@ -260,6 +260,8 @@ #if !defined(SIMULATOR) && !defined(BOOTLOADER) #if defined(HAVE_UDA1380) drivers/audio/uda1380.c +#elif defined(HAVE_WM8750) +drivers/audio/wm8750.c #elif defined(HAVE_WM8751) drivers/audio/wm8751.c #elif defined(HAVE_WM8978) @@ -1605,3 +1607,22 @@ #endif /* SIMULATOR */ #endif +#ifdef MPIO_HD200 +#ifndef SIMULATOR +/* TODO: currently including all files */ +target/coldfire/mpio/hd200/adc-hd200.c +target/coldfire/mpio/hd200/button-hd200.c +target/coldfire/mpio/hd200/lcd-hd200.c +target/coldfire/mpio/hd200/lcd-as-hd200.S +target/coldfire/mpio/hd200/power-hd200.c +target/coldfire/mpio/hd200/powermgmt-hd200.c +target/coldfire/mpio/hd200/backlight-hd200.c +target/coldfire/mpio/hd200/system-hd200.c +target/coldfire/mpio/hd200/usb-hd200.c +target/coldfire/mpio/ata-mpio.c +#ifndef BOOTLOADER +target/coldfire/mpio/audio-mpio.c +target/coldfire/wmcodec-coldfire.c +#endif /* BOOTLOADER */ +#endif /* SIMULATOR */ +#endif Index: firmware/target/coldfire/pcm-coldfire.c =================================================================== --- firmware/target/coldfire/pcm-coldfire.c (wersja 25312) +++ firmware/target/coldfire/pcm-coldfire.c (kopia robocza) @@ -55,7 +55,25 @@ #define FPARM_CLOCKSEL 0 #define FPARM_CLSEL 1 -#if CONFIG_CPU == MCF5249 && defined(HAVE_UDA1380) + +/* SCLK = Fs * bit clocks per word + * so SCLK should be Fs * 64 + * + * CLOCKSEL sets SCLK freq based on Audio CLK + * 0x0c SCLK = Audio CLK/2 88200 * 64 = 5644800 Hz + * 0x06 SCLK = Audio CLK/4 44100 * 64 = 2822400 Hz + * 0x04 SCLK = Audio CLK/8 22050 * 64 = 1411200 Hz + * 0x02 SCLK = Audio CLK/16 11025 * 64 = 705600 Hz + * + * CLSEL sets MCLK1/2 DAC freq based on XTAL freq + * 0x01 MCLK1/2 = XTAL freq + * 0x02 MCLK1/2 = XTAL/2 freq + * + * Audio CLK can be XTAL freq or XTAL/2 freq (bit22 in PLLCR) + * we always set bit22 so Audio CLK is always XTAL freq + */ + +#if CONFIG_CPU == MCF5249 && (defined(HAVE_UDA1380) || defined(HAVE_WM8750)) static const unsigned char pcm_freq_parms[HW_NUM_FREQ][2] = { [HW_FREQ_88] = { 0x0c, 0x01 }, @@ -154,12 +172,20 @@ other settings. */ or_l(IIS_FIFO_RESET, &IIS_PLAY); IIS_PLAY = IIS_PLAY_DEFPARM | IIS_FIFO_RESET; + +#if INPUT_SRC_CAPS != 0 audio_set_output_source(AUDIO_SRC_PLAYBACK); +#else + /* TXSOURCE = PDOR3 */ + IIS_PLAY = ((IIS_PLAY & ~(7 << 8)) | (3<<8)); +#endif /* Initialize default register values. */ audiohw_init(); +#if INPUT_SRC_CAPS != 0 audio_input_mux(AUDIO_SRC_PLAYBACK, SRCF_PLAYBACK); +#endif audiohw_set_frequency(pcm_fsel); coldfire_set_pllcr_audio_bits(PLLCR_SET_AUDIO_BITS_DEFPARM); @@ -324,6 +350,7 @@ return (void *)((addr + 2) & ~3); } /* pcm_play_dma_get_peak_buffer */ +#ifdef HAVE_RECORDING /**************************************************************************** ** Recording DMA transfer **/ @@ -487,3 +514,4 @@ *count = (end >> 2) - addr; return (void *)(addr << 2); } /* pcm_rec_dma_get_peak_buffer */ +#endif Index: firmware/target/coldfire/wmcodec-coldfire.c =================================================================== --- firmware/target/coldfire/wmcodec-coldfire.c (wersja 0) +++ firmware/target/coldfire/wmcodec-coldfire.c (wersja 0) @@ -0,0 +1,49 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id:$ + * + * Coldfire specific code for Wolfson audio codecs based on + * wmcodec-pp.c + * + * Based on code from the ipodlinux project - http://ipodlinux.org/ + * Adapted for Rockbox in December 2005 + * + * Original file: linux/arch/armnommu/mach-ipod/audio.c + * + * Copyright (c) 2003-2005 Bernard Leach (leachbj@bouncycastle.org) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#include "system.h" +#include "audiohw.h" +#include "i2c-coldfire.h" +#include "i2s.h" +#include "wmcodec.h" + +#if defined(MPIO_HD200) +#define I2C_AUDIO_ADDRESS 0x1a +#endif + +void audiohw_init(void) +{ + audiohw_preinit(); +} + +void wmcodec_write(int reg, int data) +{ + unsigned int wmdata; + wmdata = (reg<<1)|(data&0x1ff); + i2c_write(I2C_IFACE_1,I2C_AUDIO_ADDRESS,(char *)&wmdata,2); +} Index: firmware/target/coldfire/mpio/ata-target.h =================================================================== --- firmware/target/coldfire/mpio/ata-target.h (wersja 0) +++ firmware/target/coldfire/mpio/ata-target.h (wersja 0) @@ -0,0 +1,77 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id:$ + * + * Copyright (C) 2010 Marcin Bukat + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#ifndef ATA_TARGET_H +#define ATA_TARGET_H + +/* asm optimised read & write loops - we skip this for now*/ +/* #define ATA_OPTIMIZED_READING + * #define ATA_OPTIMIZED_WRITING + */ + +#define SWAP_WORDS + +#define ATA_IOBASE 0x20000000 +#define ATA_DATA (*((volatile unsigned short*)(ATA_IOBASE + 0x20))) +#define ATA_CONTROL (*((volatile unsigned short*)(ATA_IOBASE + 0x1c))) + +#define ATA_ERROR (*((volatile unsigned short*)(ATA_IOBASE + 0x22))) +#define ATA_NSECTOR (*((volatile unsigned short*)(ATA_IOBASE + 0x24))) +#define ATA_SECTOR (*((volatile unsigned short*)(ATA_IOBASE + 0x26))) +#define ATA_LCYL (*((volatile unsigned short*)(ATA_IOBASE + 0x28))) +#define ATA_HCYL (*((volatile unsigned short*)(ATA_IOBASE + 0x2a))) +#define ATA_SELECT (*((volatile unsigned short*)(ATA_IOBASE + 0x2c))) +#define ATA_COMMAND (*((volatile unsigned short*)(ATA_IOBASE + 0x2e))) + + +#define STATUS_BSY 0x80 +#define STATUS_RDY 0x40 +#define STATUS_DF 0x20 +#define STATUS_DRQ 0x08 +#define STATUS_ERR 0x01 + +#define ERROR_ABRT 0x04 + +#define WRITE_PATTERN1 0xa5 +#define WRITE_PATTERN2 0x5a +#define WRITE_PATTERN3 0xaa +#define WRITE_PATTERN4 0x55 + +#define READ_PATTERN1 0xa5 +#define READ_PATTERN2 0x5a +#define READ_PATTERN3 0xaa +#define READ_PATTERN4 0x55 + +#define READ_PATTERN1_MASK 0xff +#define READ_PATTERN2_MASK 0xff +#define READ_PATTERN3_MASK 0xff +#define READ_PATTERN4_MASK 0xff + +#define SET_REG(reg,val) reg = (val) +#define SET_16BITREG(reg,val) reg = (val) + +void ata_reset(void); +void ata_enable(bool on); +void ata_device_init(void); +bool ata_is_coldstart(void); + +//void copy_read_sectors(unsigned char* buf, int wordcount); +//void copy_write_sectors(const unsigned char* buf, int wordcount); +#endif Index: firmware/target/coldfire/mpio/boot.lds.flash =================================================================== --- firmware/target/coldfire/mpio/boot.lds.flash (wersja 0) +++ firmware/target/coldfire/mpio/boot.lds.flash (wersja 0) @@ -0,0 +1,81 @@ +#include "config.h" + +ENTRY(start) +OUTPUT_FORMAT(elf32-m68k) +STARTUP(target/coldfire/crt0.o) + +#define DRAMSIZE (MEMORYSIZE * 0x100000) + +#define DRAMORIG 0x31000000 +#define IRAMORIG 0x10000000 +#define IRAMSIZE 0x18000 +#define FLASHORIG 0x000e0000 +#define FLASHSIZE 2M + +MEMORY +{ + DRAM : ORIGIN = DRAMORIG, LENGTH = DRAMSIZE + IRAM : ORIGIN = IRAMORIG, LENGTH = IRAMSIZE + FLASH : ORIGIN = FLASHORIG, LENGTH = FLASHSIZE +} + +SECTIONS +{ + .vectors : + { + _datacopy = .; + } > FLASH + + .data : AT ( _datacopy ) + { + _datastart = .; + KEEP(*(.resetvectors)); + *(.resetvectors); + KEEP(*(.vectors)); + *(.vectors); + . = ALIGN(0x200); + *(.icode) + *(.irodata) + *(.idata) + *(.data*) + . = ALIGN(0x4); + _dataend = .; + . = ALIGN(0x10); /* Maintain proper alignment for .text section */ + } > IRAM + + /* TRICK ALERT! Newer versions of the linker don't allow output sections + to overlap even if one of them is empty, so advance the location pointer + "by hand" */ + .text LOADADDR(.data) + SIZEOF(.data) : + { + *(.init.text) + *(.text*) + . = ALIGN(0x4); + } > FLASH + + .rodata : + { + *(.rodata*) + . = ALIGN(0x4); + _iramcopy = .; + } > FLASH + + .stack : + { + *(.stack) + _stackbegin = .; + stackbegin = .; + . += 0x2000; + _stackend = .; + stackend = .; + } > IRAM + + .bss DRAMORIG+0x800000: + { + _edata = .; + *(.ibss) + *(.bss*) + *(COMMON) + _end = .; + } > DRAM +} Index: firmware/target/coldfire/mpio/app.lds =================================================================== --- firmware/target/coldfire/mpio/app.lds (wersja 0) +++ firmware/target/coldfire/mpio/app.lds (wersja 0) @@ -0,0 +1,145 @@ +#include "config.h" + +ENTRY(start) + +OUTPUT_FORMAT(elf32-m68k) +STARTUP(target/coldfire/crt0.o) + +#define PLUGINSIZE PLUGIN_BUFFER_SIZE +#define CODECSIZE CODEC_SIZE + +#ifdef DEBUG +#define STUBOFFSET 0x10000 +#else +#define STUBOFFSET 0 +#endif + +#define DRAMSIZE (MEMORYSIZE * 0x100000) - PLUGINSIZE - STUBOFFSET - CODECSIZE + +#define DRAMORIG 0x31000000 + STUBOFFSET +#define IRAMORIG 0x10000000 +#define IRAMSIZE 0xc000 + +/* End of the audio buffer, where the codec buffer starts */ +#define ENDAUDIOADDR (DRAMORIG + DRAMSIZE) + +/* Where the codec buffer ends, and the plugin buffer starts */ +#define ENDADDR (ENDAUDIOADDR + CODECSIZE) + +MEMORY +{ + DRAM : ORIGIN = DRAMORIG, LENGTH = DRAMSIZE + IRAM : ORIGIN = IRAMORIG, LENGTH = IRAMSIZE +} + +SECTIONS +{ + .vectors : + { + loadaddress = .; + _loadaddress = .; + KEEP(*(.resetvectors)); + *(.resetvectors); + KEEP(*(.vectors)); + *(.vectors); + } > DRAM + + .text : + { + . = ALIGN(0x200); + *(.init.text) + *(.text*) + . = ALIGN(0x4); + } > DRAM + + .rodata : + { + *(.rodata) /* problems without this, dunno why */ + *(.rodata*) + *(.rodata.str1.1) + *(.rodata.str1.4) + . = ALIGN(0x4); + + /* Pseudo-allocate the copies of the data sections */ + _datacopy = .; + } > DRAM + + /* TRICK ALERT! For RAM execution, we put the .data section at the + same load address as the copy. Thus, we don't waste extra RAM + when we don't actually need the copy. */ + .data : AT ( _datacopy ) + { + _datastart = .; + *(.data*) + . = ALIGN(0x4); + _dataend = .; + } > DRAM + + /DISCARD/ : + { + *(.eh_frame) + } + + .iram IRAMORIG : + { + _iramstart = .; + *(.icode) + *(.irodata) + *(.idata) + _iramend = .; + } > IRAM AT> DRAM + + _iramcopy = LOADADDR(.iram); + _noloaddram = LOADADDR(.iram); + + .ibss (NOLOAD) : + { + _iedata = .; + *(.ibss) + . = ALIGN(0x4); + _iend = .; + } > IRAM + + .stack (NOLOAD) : + { + *(.stack) + stackbegin = .; + . += 0x2000; + stackend = .; + } > IRAM + + .bss _noloaddram (NOLOAD) : + { + _edata = .; + *(.bss*) + *(COMMON) + . = ALIGN(0x4); + _end = .; + } > DRAM + + .audiobuf (NOLOAD) : + { + . = ALIGN(4); + _audiobuffer = .; + audiobuffer = .; + } > DRAM + + .audiobufend ENDAUDIOADDR (NOLOAD) : + { + audiobufend = .; + _audiobufend = .; + } > DRAM + + .codec ENDAUDIOADDR (NOLOAD) : + { + codecbuf = .; + _codecbuf = .; + } + + .plugin ENDADDR (NOLOAD) : + { + _pluginbuf = .; + pluginbuf = .; + } +} + Index: firmware/target/coldfire/mpio/boot.lds =================================================================== --- firmware/target/coldfire/mpio/boot.lds (wersja 0) +++ firmware/target/coldfire/mpio/boot.lds (wersja 0) @@ -0,0 +1,85 @@ +/* this linking script puts everything into IRAM + * this is helpfull in debugging with BDM + */ + +#include "config.h" + +ENTRY(start) +OUTPUT_FORMAT(elf32-m68k) +STARTUP(target/coldfire/crt0.o) + +#define DRAMSIZE (MEMORYSIZE * 0x100000) + +#define DRAMORIG 0x31000000 +#define IRAMORIG 0x10000000 +#define IRAMSIZE 0x18000 +#define FLASHORIG 0x000e0000 +#define FLASHSIZE 2M + +MEMORY +{ + DRAM : ORIGIN = DRAMORIG, LENGTH = DRAMSIZE + IRAM : ORIGIN = IRAMORIG, LENGTH = IRAMSIZE + FLASH : ORIGIN = FLASHORIG, LENGTH = FLASHSIZE +} + +SECTIONS +{ + .vectors : + { + _datacopy = .; + } > IRAM + + .data : AT ( _datacopy ) + { + _datastart = .; + KEEP(*(.resetvectors)); + *(.resetvectors); + KEEP(*(.vectors)); + *(.vectors); + . = ALIGN(0x200); + *(.icode) + *(.irodata) + *(.idata) + *(.data*) + . = ALIGN(0x4); + _dataend = .; + . = ALIGN(0x10); /* Maintain proper alignment for .text section */ + } > IRAM + + /* TRICK ALERT! Newer versions of the linker don't allow output sections + to overlap even if one of them is empty, so advance the location pointer + "by hand" */ + .text LOADADDR(.data) + SIZEOF(.data) : + { + *(.init.text) + *(.text*) + . = ALIGN(0x4); + } > IRAM + + .rodata : + { + *(.rodata*) + . = ALIGN(0x4); + _iramcopy = .; + } > IRAM + + .stack : + { + *(.stack) + _stackbegin = .; + stackbegin = .; + . += 0x2000; + _stackend = .; + stackend = .; + } > IRAM + + .bss DRAMORIG+0x800000: + { + _edata = .; + *(.ibss) + *(.bss*) + *(COMMON) + _end = .; + } > DRAM +} Index: firmware/target/coldfire/mpio/audio-mpio.c =================================================================== --- firmware/target/coldfire/mpio/audio-mpio.c (wersja 0) +++ firmware/target/coldfire/mpio/audio-mpio.c (wersja 0) @@ -0,0 +1,37 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id:$ + * + * Copyright (C) 2010 Marcin Bukat + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#include "system.h" +#include "cpu.h" +#include "audio.h" +#include "sound.h" + +void audio_set_output_source(int source) +{ + (void)source; + /* empty stub */ +} + +void audio_input_mux(int source, unsigned flags) +{ + (void)source; + (void)flags; + /* empty stub */ +} Index: firmware/target/coldfire/mpio/button-target.h =================================================================== --- firmware/target/coldfire/mpio/button-target.h (wersja 0) +++ firmware/target/coldfire/mpio/button-target.h (wersja 0) @@ -0,0 +1,55 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id:$ + * + * Copyright (C) 2010 Marcin Bukat + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#ifndef _BUTTON_TARGET_H_ +#define _BUTTON_TARGET_H_ + +#include +#include "config.h" + +#define HAS_BUTTON_HOLD + +bool button_hold(void); +void button_init_device(void); +int button_read_device(void); + +/* HD200 specific button codes */ +/* Main unit's buttons - flags as in original firmware*/ +#define BUTTON_PLAY 0x00000001 + +#define BUTTON_PREV 0x00000004 +#define BUTTON_NEXT 0x00000002 +#define BUTTON_VOL_UP 0x00000008 +#define BUTTON_VOL_DOWN 0x00000010 +#define BUTTON_REC 0x00000020 +#define BUTTON_SELECT 0x00002000 + +#define BUTTON_LEFT BUTTON_PREV +#define BUTTON_RIGHT BUTTON_NEXT +#define BUTTON_ON BUTTON_PLAY +#define BUTTON_REMOTE 0x0 + +#define BUTTON_MAIN (BUTTON_PLAY|BUTTON_PREV|BUTTON_NEXT|BUTTON_VOL_UP|\ + BUTTON_VOL_DOWN|BUTTON_REC|BUTTON_SELECT) + +#define POWEROFF_BUTTON BUTTON_PLAY +#define POWEROFF_COUNT 30 + +#endif /* _BUTTON_TARGET_H_ */ Index: firmware/target/coldfire/mpio/ata-mpio.c =================================================================== --- firmware/target/coldfire/mpio/ata-mpio.c (wersja 0) +++ firmware/target/coldfire/mpio/ata-mpio.c (wersja 0) @@ -0,0 +1,63 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id:$ + * + * Copyright (C) 2010 Marcin Bukat + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "config.h" +#include "cpu.h" +#include +#include "kernel.h" +#include "system.h" +#include "power.h" +#include "ata-target.h" + +void ata_reset(void) +{ + /* GPIO19 */ + and_l(~(1<<19), &GPIO_OUT); + sleep(1); /* > 25us */ + + or_l((1<<19), &GPIO_OUT); + sleep(1); /* > 25us */ +} + +void ata_enable(bool on) +{ + if (on) + and_l(~(1<<31),&GPIO_OUT); + else + or_l((1<<31),&GPIO_OUT); + + or_l((1<<31),&GPIO_ENABLE); + or_l((1<<31),&GPIO_FUNCTION); +} + +/* to be fixed */ +bool ata_is_coldstart(void) +{ + return true; +} + +void ata_device_init(void) +{ + /* ATA reset line config */ + or_l((1<<19), &GPIO_OUT); + or_l((1<<19), &GPIO_ENABLE); + or_l((1<<19), &GPIO_FUNCTION); +} Index: firmware/target/coldfire/mpio/hd200/lcd-as-hd200.S =================================================================== --- firmware/target/coldfire/mpio/hd200/lcd-as-hd200.S (wersja 0) +++ firmware/target/coldfire/mpio/hd200/lcd-as-hd200.S (wersja 0) @@ -0,0 +1,87 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id:$ + * + * Copyright (C) 2010 Marcin Bukat + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "config.h" +#include "cpu.h" + + +#define LCD_BASE_ADDRESS 0xf0000000 + + .section .icode,"ax",@progbits + + .align 2 + .global lcd_write_command + .type lcd_write_command,@function + +lcd_write_command: + move.l (4, %sp), %d0 + move.w %d0, LCD_BASE_ADDRESS /* data is 1byte but CF uses word + * transfers only */ + rts +.wc_end: + .size lcd_write_command,.wc_end-lcd_write_command + + + .align 2 + .global lcd_write_command_e + .type lcd_write_command_e,@function + +lcd_write_command_e: + lea.l LCD_BASE_ADDRESS, %a0 + + move.l (4, %sp), %d0 /* Command */ + move.w %d0, (%a0) + move.l (8, %sp), %d0 /* Data */ + move.w %d0, (%a0) /* Write to LCD */ + + rts +.wce_end: + .size lcd_write_command_e,.wce_end-lcd_write_command_e + + + .align 2 + .global lcd_write_data + .type lcd_write_data,@function + +/* PIXELFORMAT = VERTICAL_INTERLEAVED + * this means that data is packed verticaly in 8 pixels columns + * first byte is lsb of 2bit color in column + * second byte is msb of 2bit color in column + * so one word of data equals 8 pixels i 2bits color depth packed + * verticaly + */ +lcd_write_data: + movem.l (4, %sp), %a0 /* Data pointer */ + move.l (8, %sp), %d0 /* Length */ + lea LCD_BASE_ADDRESS+2, %a1 /* LCD data port address */ + +.wd_loop: + moveq #0, %d1 /* clear %d1 */ + move.b (%a0)+, %d1 /* load first byte */ + move.w %d1, (%a1) /* transfer */ + move.b (%a0)+, %d1 /* load second byte */ + move.w %d1, (%a1) /* transfer */ + subq.l #1, %d0 /* decrement counter */ + bne .wd_loop + rts +.wd_end: + .size lcd_write_data,.wd_end-lcd_write_data + Index: firmware/target/coldfire/mpio/hd200/system-hd200.c =================================================================== --- firmware/target/coldfire/mpio/hd200/system-hd200.c (wersja 0) +++ firmware/target/coldfire/mpio/hd200/system-hd200.c (wersja 0) @@ -0,0 +1,113 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id:$ + * + * Copyright (C) 2010 Marcin Bukat + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#include "config.h" +#include "cpu.h" +#include "kernel.h" +#include "system.h" +#include "power.h" +#include "timer.h" + +/* Settings for all possible clock frequencies (with properly working timers) + * + * xxx_REFRESH_TIMER below + * system.h, CPUFREQ_xxx_MULT | + * | | + * V V + * PLLCR & Rftim. IDECONFIG1/IDECONFIG2 + * CPUCLK/Hz MULT ~0x70c00000 16MB CSCR0 CSCR1 CS2Pre CS2Post CS2Wait + * ------------------------------------------------------------------------- + * 11289600 1 0x00000200 4 0x0180 0x0180 1 1 0 + * 22579200 2 0x05028049 10 0x0180 0x0180 1 1 0 + * 33868800 3 0x03024049 15 0x0180 0x0180 1 1 0 + * 45158400 4 0x05028045 21 0x0180 0x0180 1 1 0 + * 56448000 5 0x02028049 26 0x0580 0x0580 2 1 0 + * 67737600 6 0x03024045 32 0x0580 0x0980 2 1 0 + * 79027200 7 0x0302a045 37 0x0580 0x0d80 2 1 0 + * 90316800 8 0x03030045 43 0x0980 0x0d80 2 1 0 + * 101606400 9 0x01024049 48 0x0980 0x1180 2 1 0 + * 112896000 10 0x01028049 54 0x0980 0x1580 3 1 0 + * 124185600 11 0x0102c049 59 0x0980 0x1180 3 1 1 + */ + +#define MAX_REFRESH_TIMER 59 +#define NORMAL_REFRESH_TIMER 21 +#define DEFAULT_REFRESH_TIMER 4 + +#ifdef HAVE_ADJUSTABLE_CPU_FREQ +void set_cpu_frequency (long) __attribute__ ((section (".icode"))); +void set_cpu_frequency(long frequency) +#else +void cf_set_cpu_frequency (long) __attribute__ ((section (".icode"))); +void cf_set_cpu_frequency(long frequency) +#endif +{ + switch(frequency) + { + case CPUFREQ_MAX: + DCR = (0x8200 | DEFAULT_REFRESH_TIMER); + /* Refresh timer for bypass frequency */ + PLLCR &= ~1; /* Bypass mode */ + timers_adjust_prescale(CPUFREQ_DEFAULT_MULT, false); + PLLCR = 0x0102c049 | (PLLCR & 0x70C00000); + CSCR0 = 0x00001180; /* Flash: 4 wait states */ + CSCR3 = 0x00001180; /* LCD: 4 wait states */ + while(!(PLLCR & 0x80000000)) {}; /* Wait until the PLL has locked. + This may take up to 10ms! */ + timers_adjust_prescale(CPUFREQ_MAX_MULT, true); + DCR = (0x8200 | MAX_REFRESH_TIMER); /* Refresh timer */ + cpu_frequency = CPUFREQ_MAX; + IDECONFIG1 = (1<<28)|(1<<20)|(1<<18)|(1<<13)|(3<<10); + /* BUFEN2 enable on /CS2 | CS2Post 1 clock| CS2Pre 3 clocks*/ + IDECONFIG2 = (1<<18)|(1<<16)|(1<<8)|(1<<0); /* TA /CS2 enable + CS2wait */ + break; + + case CPUFREQ_NORMAL: + DCR = (DCR & ~0x01ff) | DEFAULT_REFRESH_TIMER; + /* Refresh timer for bypass frequency */ + PLLCR &= ~1; /* Bypass mode */ + timers_adjust_prescale(CPUFREQ_DEFAULT_MULT, false); + PLLCR = 0x05028045 | (PLLCR & 0x70C00000); + CSCR0 = 0x00000580; /* Flash: 1 wait state */ + CSCR3 = 0x00000980; /* LCD: 0 wait states */ + while(!(PLLCR & 0x80000000)) {}; /* Wait until the PLL has locked. + This may take up to 10ms! */ + timers_adjust_prescale(CPUFREQ_NORMAL_MULT, true); + DCR = (0x8000 | NORMAL_REFRESH_TIMER); /* Refresh timer */ + cpu_frequency = CPUFREQ_NORMAL; + IDECONFIG1 = (1<<28)|(1<<20)|(1<<18)|(1<<13)|(1<<10); + IDECONFIG2 = (1<<18)|(1<<16); + break; + default: + DCR = (DCR & ~0x01ff) | DEFAULT_REFRESH_TIMER; + /* Refresh timer for bypass frequency */ + PLLCR &= ~1; /* Bypass mode */ + timers_adjust_prescale(CPUFREQ_DEFAULT_MULT, true); + /* Power down PLL, but keep CLSEL and CRSEL */ + PLLCR = 0x00000200 | (PLLCR & 0x70C00000); + CSCR0 = 0x00000180; /* Flash: 0 wait states */ + CSCR3 = 0x00000980; /* LCD: 0 wait states */ + DCR = (0x8000 | DEFAULT_REFRESH_TIMER); /* Refresh timer */ + cpu_frequency = CPUFREQ_DEFAULT; + IDECONFIG1 = (1<<28)|(1<<20)|(1<<18)|(1<<13)|(1<<10); + IDECONFIG2 = (1<<18)|(1<<16); + break; + } +} Index: firmware/target/coldfire/mpio/hd200/adc-target.h =================================================================== --- firmware/target/coldfire/mpio/hd200/adc-target.h (wersja 0) +++ firmware/target/coldfire/mpio/hd200/adc-target.h (wersja 0) @@ -0,0 +1,41 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id:$ + * + * Copyright (C) 2010 Marcin Bukat + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#ifndef _ADC_TARGET_H_ +#define _ADC_TARGET_H_ + +#define NUM_ADC_CHANNELS 4 + +#define ADC_BUTTONS 1 +#define ADC_REMOTE 0 +#define ADC_BATTERY 2 +#define ADC_REMOTEDETECT 3 +#define ADC_UNREG_POWER ADC_BATTERY /* For compatibility */ + +/* Force a scan now */ +unsigned short adc_scan(int channel); + +static inline unsigned short adc_read(int channel) +{ + return adc_scan(channel); +} + +#endif /* _ADC_TARGET_H_ */ Index: firmware/target/coldfire/mpio/hd200/backlight-target.h =================================================================== --- firmware/target/coldfire/mpio/hd200/backlight-target.h (wersja 0) +++ firmware/target/coldfire/mpio/hd200/backlight-target.h (wersja 0) @@ -0,0 +1,35 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id:$ + * + * Copyright (C) 2010 Marcin Bukat + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#ifndef BACKLIGHT_TARGET_H +#define BACKLIGHT_TARGET_H + +bool _backlight_init(void); /* Returns backlight current state (true=ON). */ +void _backlight_hw_on(void); +void _backlight_hw_off(void); +void _backlight_set_brightness(int val); + +#define _backlight_on() _backlight_hw_on() +#define _backlight_off() _backlight_hw_off() +#define _backlight_on_isr() _backlight_hw_on() +#define _backlight_off_isr() _backlight_hw_off() +#define _backlight_on_normal() _backlight_hw_on() +#define _backlight_off_normal() _backlight_hw_off() +#endif Index: firmware/target/coldfire/mpio/hd200/adc-hd200.c =================================================================== --- firmware/target/coldfire/mpio/hd200/adc-hd200.c (wersja 0) +++ firmware/target/coldfire/mpio/hd200/adc-hd200.c (wersja 0) @@ -0,0 +1,73 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id:$ + * + * Copyright (C) 2010 Marcin Bukat + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "config.h" +#include "cpu.h" +#include "system.h" +#include "kernel.h" +#include "thread.h" +#include "adc.h" + + +/* delay loop */ +#define DELAY \ + ({ \ + int _x_; \ + asm volatile ( \ + "move.l #5000, %[_x_] \r\n" \ + "1: \r\n" \ + "subq.l #1, %[_x_] \r\n" \ + "bhi.b 1b \r\n" \ + : [_x_]"=&d"(_x_) \ + ); \ + }) + +unsigned short adc_scan(int channel) +{ + int level = disable_irq_save(); + unsigned int data = 0; + + /* set source + * remark + * ADCONFIG is 16bit wide so we have to shift data by 16bits left + * thats why we shift <<24 instead of <<8 + */ + + and_l(~(3<<24),&ADCONFIG); + or_l(((channel & 0x03) << 24), &ADCONFIG); + + /* this is needed as setup time for ADC */ + DELAY; + + data = ADVALUE; + + restore_irq(level); + return data; +} + +void adc_init(void) +{ + /* GPIO38 GPIO39 */ + and_l(~((1<<6)|(1<<7)), &GPIO1_FUNCTION); + + /* ADCONFIG taken from OF */ + ADCONFIG = 0x480; +} Index: firmware/target/coldfire/mpio/hd200/backlight-hd200.c =================================================================== --- firmware/target/coldfire/mpio/hd200/backlight-hd200.c (wersja 0) +++ firmware/target/coldfire/mpio/hd200/backlight-hd200.c (wersja 0) @@ -0,0 +1,86 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id:$ + * + * Copyright (C) 2010 Marcin Bukat + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "config.h" +#include "cpu.h" +#include "kernel.h" +#include "system.h" +#include "backlight.h" +#include "backlight-target.h" +#include "lcd.h" + +static bool _backlight_on = false; +static int _brightness = DEFAULT_BRIGHTNESS_SETTING; + +/* Returns the current state of the backlight (true=ON, false=OFF). */ +bool _backlight_init(void) +{ + and_l(~(1<<28),&GPIO_OUT); + or_l((1<<28),&GPIO_FUNCTION); + or_l((1<<28),&GPIO_ENABLE); + return true; +} + +void _backlight_hw_on(void) +{ + + if (_backlight_on) + return; + + _backlight_set_brightness(_brightness); + _backlight_on = true; + +} + +void _backlight_hw_off(void) +{ + /* GPIO28 low */ + and_l(~(1<<28),&GPIO_OUT); + _backlight_on = false; +} + +void _backlight_set_brightness(int val) +{ + unsigned char i; + + and_l(~(1<<28),&GPIO_OUT); + sleep(4); + + for (i=0;i ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id:$ + * + * Copyright (C) 2010 Marcin Bukat + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#include "config.h" +#include +#include "cpu.h" +#include "system.h" +#include "kernel.h" +#include "usb.h" + +void usb_init_device(void) +{ + or_l((1<<4), &GPIO1_OUT); /* GPIO50 low by default*/ + or_l((1<<4)|(1<<18), &GPIO1_ENABLE); + or_l((1<<4)|(1<<10)|(1<<18), &GPIO1_FUNCTION); /* GPIO42 is USB detect input */ + + /* GPIO22 GPIO30*/ + /* GPIO31 has to be low to ATA work */ + or_l((1<<22)|(1<<30), &GPIO_OUT); + or_l((1<<22)|(1<<30)|(1<<31), &GPIO_ENABLE); + or_l((1<<22)|(1<<30)|(1<<31), &GPIO_FUNCTION); +} + +int usb_detect(void) +{ + /* GPIO42 active low*/ + return (GPIO1_READ & (1<<10)) ? USB_EXTRACTED : USB_INSERTED; +} + +void usb_enable(bool on) +{ + + if(on) + { + or_l((1<<18),&GPIO1_OUT); /* GPIO50 high */ + + and_l(~(1<<30),&GPIO_OUT); /* GPIO30 low */ + /* GPIO36 low delay GPIO36 high delay */ + and_l(~(1<<4),&GPIO1_OUT); + or_l((1<<4),&GPIO1_OUT); + + and_l(~(1<<18),&GPIO1_OUT); /* GPIO50 low */ + sleep(HZ/5); /* delay 200 ms */ + and_l(~(1<<22),&GPIO_OUT); /* GPIO22 low */ + } + else + { + /* GPIO36 low delay GPIO36 high delay */ + and_l(~(1<<4),&GPIO1_OUT); + or_l((1<<4),&GPIO1_OUT); + + or_l((1<<22),&GPIO_OUT); /* GPIO22 high */ + or_l((1<<30),&GPIO_OUT); /* GPIO30 high */ + + and_l(~(1<<4),&GPIO1_OUT); /* GPIO36 low */ + + //or_l((1<<18),&GPIO1_OUT); /* GPIO50 high */ + } +} Index: firmware/target/coldfire/mpio/hd200/button-hd200.c =================================================================== --- firmware/target/coldfire/mpio/hd200/button-hd200.c (wersja 0) +++ firmware/target/coldfire/mpio/hd200/button-hd200.c (wersja 0) @@ -0,0 +1,120 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id:$ + * + * Copyright (C) 2010 Marcin Bukat + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "config.h" +#include "cpu.h" +#include "system.h" +#include "button.h" +#include "backlight.h" +#include "adc.h" + +void button_init_device(void) +{ + /* Set GPIO36, GPIO56 as general purpose inputs */ + or_l((1<<4)|(1<<24),&GPIO1_FUNCTION); + and_l(~((1<<4)|(1<<24)),&GPIO1_ENABLE); +} + +bool button_hold(void) +{ + /* GPIO36 active high */ + return (GPIO1_READ & (1<<4))?true:false; +} + + +/* + * Get button pressed from hardware + */ +int button_read_device(void) +{ + int btn = BUTTON_NONE; + int data; + static bool hold_button = false; + static int prev_data = 0xff; + static int last_valid = 0xff; + bool hold_button_old; + + /* normal buttons */ + hold_button_old = hold_button; + hold_button = button_hold(); + + +#ifndef BOOTLOADER + if (hold_button != hold_button_old) + backlight_hold_changed(hold_button); +#endif + + if (!hold_button) + { + data = adc_scan(ADC_BUTTONS); + + /* ADC debouncing: Only accept new reading if it's + * stable (+/-1). Use latest stable value otherwise. */ + if ((unsigned)(data - prev_data + 1) <= 2) + last_valid = data; + prev_data = data; + data = last_valid; + + if (data < 2250) // valid button + { + if (data < 900) /* middle */ + { + if (data < 500) + { + if (data > 200) + /* 200 - 500 */ + btn = BUTTON_REC; + } + else /* 900 - 500 */ + btn = BUTTON_VOL_DOWN; + } + else /* 2250 - 900 */ + { + if (data < 1600) + { + /* 1600 - 900 */ + if (data < 1200) + /* 1200 - 900 */ + btn = BUTTON_VOL_UP; + else /* 1600 - 1200 */ + btn = BUTTON_NEXT; + } + else /* 1600 - 2250 */ + { + if (data < 1900) + /* 1900 - 1600 */ + btn = BUTTON_PREV; + else /* 1900 - 2250 */ + btn = BUTTON_SELECT; + } + } + } + } + + + data = GPIO1_READ; + + /* GPIO56 active high main PLAY/PAUSE/ON */ + if (!hold_button && ((data & (1<<24)))) + btn |= BUTTON_PLAY; + + return btn; +} Index: firmware/target/coldfire/mpio/hd200/power-hd200.c =================================================================== --- firmware/target/coldfire/mpio/hd200/power-hd200.c (wersja 0) +++ firmware/target/coldfire/mpio/hd200/power-hd200.c (wersja 0) @@ -0,0 +1,99 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id:$ + * + * Copyright (C) 2010 Marcin Bukat + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "config.h" +#include "cpu.h" +#include +#include "kernel.h" +#include "system.h" +#include "power.h" + +static bool charger_on; + +#if CONFIG_TUNER +bool tuner_power(bool status) +{ + (void)status; + return true; +} +#endif /* #if CONFIG_TUNER */ + +void power_init(void) +{ + /* GPIO53 has to be high - low resets device */ + or_l((1<<21), &GPIO1_OUT); + or_l((1<<21), &GPIO1_ENABLE); + or_l((1<<14)|(1<<21), &GPIO1_FUNCTION); + + and_l(~(1<<15), &GPIO_OUT); + or_l((1<<15),&GPIO_ENABLE); + or_l((1<<15),&GPIO_FUNCTION); + + /* charger handling default ON*/ + or_l((1<<23), &GPIO_OUT); + or_l((1<<23), &GPIO_ENABLE); + or_l((1<<23), &GPIO_FUNCTION); + +#ifndef BOOTLOADER + /* The boot loader controls the power */ + ide_power_enable(true); +#endif +} + +unsigned int power_input_status(void) +{ + unsigned int status = POWER_INPUT_NONE; +/* GPIO46 is AC plug detect (low = AC plugged) */ + if (!(GPIO1_READ & (1<<14))) + status |= POWER_INPUT_MAIN_CHARGER; + + return status; +} + +/* Returns true if the unit is charging the batteries. */ +bool charging_state(void) +{ + if (!(GPIO1_READ & (1<<14))) + return (GPIO_READ & (1<<30) )?true:false; + else + return false; +} + +void ide_power_enable(bool on) +{ + (void)on; + and_l(~(1<<31),&GPIO_OUT); + or_l((1<<31),&GPIO_ENABLE); + or_l((1<<31),&GPIO_FUNCTION); +} + +bool ide_powered(void) +{ + return true; +} + +void power_off(void) +{ + set_irq_level(DISABLE_INTERRUPTS); + and_l(~(1<<21), &GPIO1_OUT); + asm("halt"); + while(1); +} Index: firmware/target/coldfire/mpio/hd200/powermgmt-hd200.c =================================================================== --- firmware/target/coldfire/mpio/hd200/powermgmt-hd200.c (wersja 0) +++ firmware/target/coldfire/mpio/hd200/powermgmt-hd200.c (wersja 0) @@ -0,0 +1,59 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id:$ + * + * Copyright (C) 2010 Marcin Bukat + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "config.h" +#include "adc.h" +#include "powermgmt.h" + +const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] = +{ + 3700 +}; + +const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] = +{ + 3650 +}; + +/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */ +const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] = +{ + /* from OF and measurements voltage range is 3.7-4.1 V */ + { 3700, 3740, 3780, 3820, 3860, 3900, 3940, 3980, 4020, 4060, 4100 } +}; + +/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */ +const unsigned short percent_to_volt_charge[11] = +{ + /* values measured over one full charging cycle */ + 3540, 3860, 3930, 3980, 4000, 4020, 4040, 4080, 4130, 4180, 4230 /* LiPo */ +}; + +/* 3.33V as reference */ +#define BATTERY_SCALE_FACTOR 3330 + + +/* Returns battery voltage from ADC [millivolts] */ +unsigned int battery_adc_voltage(void) +{ + return (adc_read(ADC_BATTERY) * BATTERY_SCALE_FACTOR) >> 11; +} + Index: firmware/target/coldfire/mpio/hd200/lcd-hd200.c =================================================================== --- firmware/target/coldfire/mpio/hd200/lcd-hd200.c (wersja 0) +++ firmware/target/coldfire/mpio/hd200/lcd-hd200.c (wersja 0) @@ -0,0 +1,241 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id:$ + * + * Copyright (C) 2010 Marcin Bukat + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "config.h" + +#include "system.h" +#include "kernel.h" +#include "lcd.h" + +/*** definitions ***/ +/* TOMATO LSI 0350 - definitions and slightly tweaked functions + * taken from lcd-remote-iaudio.c + */ + +#define LCD_SET_DUTY_RATIO 0x48 +#define LCD_SELECT_ADC 0xa0 +#define LCD_SELECT_SHL 0xc0 +#define LCD_SET_COM0 0x44 +#define LCD_OSC_ON 0xab +#define LCD_SELECT_DCDC 0x64 +#define LCD_SELECT_RES 0x20 +#define LCD_SET_VOLUME 0x81 +#define LCD_SET_BIAS 0x50 +#define LCD_CONTROL_POWER 0x28 +#define LCD_DISPLAY_ON 0xae +#define LCD_SET_INITLINE 0x40 +#define LCD_SET_COLUMN 0x10 +#define LCD_SET_PAGE 0xb0 +#define LCD_SET_GRAY 0x88 +#define LCD_SET_PWM_FRC 0x90 +#define LCD_SET_POWER_SAVE 0xa8 +#define LCD_REVERSE 0xa6 +#define LCD_RESET 0xe2 + +/* cached settings */ +static bool cached_invert = false; +static bool cached_flip = false; +static int cached_contrast = DEFAULT_CONTRAST_SETTING; +bool lcd_initialized = false; + +/*** hardware configuration ***/ +int lcd_default_contrast(void) +{ + return DEFAULT_CONTRAST_SETTING; +} + +void lcd_powersave(bool on) +{ +/* What is the point of having else construct here? */ + if(lcd_initialized) { + if (on) + lcd_write_command(LCD_SET_POWER_SAVE | 1); + else + lcd_write_command(LCD_SET_POWER_SAVE | 1); + } +} + +void lcd_set_contrast(int val) +{ + if (val < MIN_CONTRAST_SETTING) + val = MIN_CONTRAST_SETTING; + else if (val > MAX_CONTRAST_SETTING) + val = MAX_CONTRAST_SETTING; + + cached_contrast = val; + if(lcd_initialized) + lcd_write_command_e(LCD_SET_VOLUME, val); +} + +void lcd_set_invert_display(bool yesno) +{ + cached_invert = yesno; + if(lcd_initialized) + lcd_write_command(LCD_REVERSE | yesno); + +} + +/* turn the display upside down (call lcd_update() afterwards) */ +void lcd_set_flip(bool yesno) +{ + cached_flip = yesno; + if(lcd_initialized) + { + if(yesno) + { + lcd_write_command(LCD_SELECT_ADC | 1); + lcd_write_command(LCD_SELECT_SHL | 0); + lcd_write_command_e(LCD_SET_COM0, 0); + } + else + { + lcd_write_command(LCD_SELECT_ADC | 0); + lcd_write_command(LCD_SELECT_SHL | 8); + lcd_write_command_e(LCD_SET_COM0, 0); + } + } + +} + +void lcd_poweroff(void) +{ + /* Set power save -> Power OFF (VDD - VSS) .. that's it */ + if (lcd_initialized) + lcd_write_command(LCD_SET_POWER_SAVE | 1); +} + +void lcd_init_device(void) +{ + and_l(~0x00000800, &GPIO_FUNCTION); /* CS3 line */ + + /* LCD Reset GPO34 */ + or_l(0x00000004, &GPIO1_ENABLE); /* set as output */ + or_l(0x00000004, &GPIO1_FUNCTION); /* switch to secondary function - GPIO */ + + and_l(~0x00000004, &GPIO1_OUT); /* RESET low */ + sleep(1); /* delay at least 1000 ns */ + or_l(0x00000004, &GPIO1_OUT); /* RESET high */ + sleep(1); + + /* parameters setup taken from original firmware */ + lcd_write_command(LCD_RESET); + lcd_write_command_e(LCD_SET_DUTY_RATIO,0x80); /* 1/128 */ + lcd_write_command(LCD_OSC_ON); + lcd_write_command(LCD_SELECT_DCDC | 3); /* DC/DC 6xboost */ + lcd_write_command(LCD_SELECT_RES | 7); /* Regulator resistor: 7.2 */ + lcd_write_command(LCD_SET_BIAS | 6); /* 1/11 */ + lcd_write_command(LCD_SET_PWM_FRC | 6); /* 3FRC + 12PWM */ + lcd_write_command_e(LCD_SET_GRAY | 0, 0x00); + lcd_write_command_e(LCD_SET_GRAY | 1, 0x00); + lcd_write_command_e(LCD_SET_GRAY | 2, 0x0c); + lcd_write_command_e(LCD_SET_GRAY | 3, 0x00); + lcd_write_command_e(LCD_SET_GRAY | 4, 0xc4); + lcd_write_command_e(LCD_SET_GRAY | 5, 0x00); + lcd_write_command_e(LCD_SET_GRAY | 6, 0xcc); + lcd_write_command_e(LCD_SET_GRAY | 7, 0x00); + + lcd_write_command(LCD_CONTROL_POWER | 7); /* All circuits ON */ + lcd_write_command(LCD_DISPLAY_ON | 1); /* display on */ + + /* Ok we are ready */ + lcd_initialized = true; + + lcd_set_flip(cached_flip); + lcd_set_contrast(cached_contrast); + lcd_set_invert_display(cached_invert); + + lcd_update(); +} + +/* Update the display. + This must be called after all other LCD functions that change the display. */ +void lcd_update(void) ICODE_ATTR; +void lcd_update(void) +{ + int y; + if(!lcd_initialized) + return; + + for(y = 0;y < LCD_FBHEIGHT;y++) + { + lcd_write_command(LCD_SET_PAGE | y); + lcd_write_command_e(LCD_SET_COLUMN, 0); + lcd_write_data(lcd_framebuffer[y], LCD_WIDTH); + } + + +} + +/* Update a fraction of the display. */ +void lcd_update_rect(int, int, int, int) ICODE_ATTR; +void lcd_update_rect(int x, int y, int width, int height) +{ + int ymax; + + if (lcd_initialized) + return; + + + /* The Y coordinates have to work on even 8 pixel rows */ + ymax = (y + height-1) >> 3; + y >>= 3; + + if(x + width > LCD_WIDTH) + width = LCD_WIDTH - x; + if (width <= 0) + return; /* nothing left to do, 0 is harmful to lcd_write_data() */ + if(ymax >= LCD_FBHEIGHT) + ymax = LCD_FBHEIGHT-1; + + /* Copy specified rectange bitmap to hardware */ + for (; y <= ymax; y++) + { + lcd_write_command(LCD_SET_PAGE | y ); + lcd_write_command_e(LCD_SET_COLUMN | ((x >> 4) & 0xf), x & 0x0f); + lcd_write_data (&lcd_framebuffer[y][x], width); + } + +} + +void lcd_blit_grey_phase(unsigned char *values, unsigned char *phases, + int x, int by, int width, int bheight, int stride) +{ + (void)values; + (void)phases; + (void)x; + (void)by; + (void)width; + (void)bheight; + (void)stride; + /* empty stub */ +} + +void lcd_blit_mono(const unsigned char *data, int x, int by, int width, + int bheight, int stride) +{ + (void)data; + (void)x; + (void)by; + (void)width; + (void)bheight; + (void)stride; + /* empty stub */ +} Index: firmware/target/coldfire/crt0.S =================================================================== --- firmware/target/coldfire/crt0.S (wersja 25312) +++ firmware/target/coldfire/crt0.S (kopia robocza) @@ -64,6 +64,16 @@ move.l %d0,(0x088,%a0) #ifndef IAUDIO_M3 +#ifdef MPIO_HD200 + /* Chip select 3 - LCD controller */ + /* values taken from original firmware except base address*/ + move.l #0xf0000000,%d0 /* CSAR3 - Base = 0xf0000000 */ + move.l %d0,(0x0a4,%a0) + moveq.l #0x1,%d0 /* CSMR3 - 64K */ + move.l %d0,(0x0a8,%a0) + move.l #0x00000980,%d0 /* CSCR3 - 1 wait state, 16 bits no bursts */ + move.l %d0,(0x0ac,%a0) +#else /* Chip select 1 - LCD controller */ move.l #0xf0000000,%d0 /* CSAR1 - Base = 0xf0000000 */ move.l %d0,(0x08c,%a0) @@ -72,6 +82,7 @@ move.l #0x00000180,%d0 /* CSCR1 - no wait states, 16 bits, no bursts */ move.l %d0,(0x094,%a0) #endif +#endif /* Chip select 2 - ATA controller */ move.l #0x20000000,%d0 /* CSAR2 - Base = 0x20000000 */ @@ -92,6 +103,8 @@ move.l %d0,(0x0ac,%a0) #endif + + #ifdef BOOTLOADER /* Check if we have a Rockbox ROM image */ lea 0x00100000,%a2 @@ -233,7 +246,7 @@ move.l #0xf000c060,%d0 movec.l %d0,%acr1 -#ifndef BOOTLOADER +ifndef BOOTLOADER /* .iram copy is done first since it is reclaimed for other * uninitialized sections */ @@ -267,6 +280,15 @@ or.l %d0,(0xbc,%a1) #endif + +#ifdef MPIO_HD200 + /* Set KEEP_ACT */ + move.l #0x02200000,%d0 + or.l %d0,(0xb4,%a1) + or.l %d0,(0xb8,%a1) + or.l %d0,(0xbc,%a1) +#endif + /* zero out bss */ lea _edata,%a2 lea _end,%a4 Index: firmware/drivers/audio/wm8750.c =================================================================== --- firmware/drivers/audio/wm8750.c (wersja 0) +++ firmware/drivers/audio/wm8750.c (wersja 0) @@ -0,0 +1,258 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id: wm8751.c 21798 2009-07-12 09:43:44Z kugel $ + * + * Driver for WM8751 audio codec + * + * Based on code from the ipodlinux project - http://ipodlinux.org/ + * Adapted for Rockbox in December 2005 + * + * Original file: linux/arch/armnommu/mach-ipod/audio.c + * + * Copyright (c) 2003-2005 Bernard Leach (leachbj@bouncycastle.org) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#include "kernel.h" +#include "wmcodec.h" +#include "audio.h" +#include "audiohw.h" +#include "system.h" + +const struct sound_settings_info audiohw_settings[] = { + [SOUND_VOLUME] = {"dB", 0, 1, -74, 6, -25}, +#ifdef USE_ADAPTIVE_BASS + [SOUND_BASS] = {"", 0, 1, 0, 15, 0}, +#else + [SOUND_BASS] = {"dB", 1, 15, -60, 90, 0}, +#endif + [SOUND_TREBLE] = {"dB", 1, 15, -60, 90, 0}, + [SOUND_BALANCE] = {"%", 0, 1,-100, 100, 0}, + [SOUND_CHANNELS] = {"", 0, 1, 0, 5, 0}, + [SOUND_STEREO_WIDTH] = {"%", 0, 5, 0, 250, 100}, +}; + +/* Flags used in combination with settings */ + +/* use zero crossing to reduce clicks during volume changes */ +#define LOUT1_BITS (LOUT1_LO1ZC) +/* latch left volume first then update left+right together */ +#define ROUT1_BITS (ROUT1_RO1ZC | ROUT1_RO1VU) +#define LOUT2_BITS (LOUT2_LO2ZC) +#define ROUT2_BITS (ROUT2_RO2ZC | ROUT2_RO2VU) +/* We use linear bass control with 200 Hz cutoff */ +#ifdef USE_ADAPTIVE_BASE +#define BASSCTRL_BITS (BASSCTRL_BC | BASSCTRL_BB) +#else +#define BASSCTRL_BITS (BASSCTRL_BC) +#endif +/* We use linear treble control with 4 kHz cutoff */ +#define TREBCTRL_BITS (TREBCTRL_TC) + +/* convert tenth of dB volume (-730..60) to master volume register value */ +int tenthdb2master(int db) +{ + /* +6 to -73dB 1dB steps (plus mute == 80levels) 7bits */ + /* 1111111 == +6dB (0x7f) */ + /* 1111001 == 0dB (0x79) */ + /* 0110000 == -73dB (0x30) */ + /* 0101111..0000000 == mute (<= 0x2f) */ + if (db < VOLUME_MIN) + return 0x0; + else + return (db / 10) + 73 + 0x30; +} + +static int tone_tenthdb2hw(int value) +{ + /* -6.0db..+0db..+9.0db step 1.5db - translate -60..+0..+90 step 15 + to 10..6..0 step -1. + */ + value = 10 - (value + 60) / 15; + + if (value == 6) + value = 0xf; /* 0db -> off */ + + return value; +} + + +#ifdef USE_ADAPTIVE_BASS +static int adaptivebass2hw(int value) +{ + /* 0 to 15 step 1 - step -1 0 = off is a 15 in the register */ + value = 15 - value; + + return value; +} +#endif + +/* Reset and power up the WM8751 */ +void audiohw_preinit(void) +{ +#ifdef MROBE_100 + /* controls headphone ouput */ + GPIOL_ENABLE |= 0x10; + GPIOL_OUTPUT_EN |= 0x10; + GPIOL_OUTPUT_VAL |= 0x10; /* disable */ +#endif + + /* + * 1. Switch on power supplies. + * By default the WM8751 is in Standby Mode, the DAC is + * digitally muted and the Audio Interface, Line outputs + * and Headphone outputs are all OFF (DACMU = 1 Power + * Management registers 1 and 2 are all zeros). + */ + wmcodec_write(RESET, RESET_RESET); /*Reset*/ + + /* 2. Enable Vmid and VREF. */ + wmcodec_write(PWRMGMT1, PWRMGMT1_VREF | PWRMGMT1_VMIDSEL_5K); + + /* BCLKINV=0(Dont invert BCLK) MS=1(Enable Master) LRSWAP=0 LRP=0 */ + /* IWL=00(16 bit) FORMAT=10(I2S format) */ + wmcodec_write(AINTFCE, AINTFCE_MS | AINTFCE_WL_16 | + AINTFCE_FORMAT_I2S); + + /* Set default samplerate */ + audiohw_set_frequency(HW_FREQ_DEFAULT); +} + +/* Enable DACs and audio output after a short delay */ +void audiohw_postinit(void) +{ + /* From app notes: allow Vref to stabilize to reduce clicks */ + sleep(HZ); + + /* 3. Enable DACs as required. */ + wmcodec_write(PWRMGMT2, PWRMGMT2_DACL | PWRMGMT2_DACR); + + /* 4. Enable line and / or headphone output buffers as required. */ +#ifdef MROBE_100 + wmcodec_write(PWRMGMT2, PWRMGMT2_DACL | PWRMGMT2_DACR | + PWRMGMT2_LOUT1 | PWRMGMT2_ROUT1); +#else + wmcodec_write(PWRMGMT2, PWRMGMT2_DACL | PWRMGMT2_DACR | + PWRMGMT2_LOUT1 | PWRMGMT2_ROUT1 | PWRMGMT2_LOUT2 | + PWRMGMT2_ROUT2); +#endif + + wmcodec_write(ADDITIONAL1, ADDITIONAL1_TSDEN | ADDITIONAL1_TOEN | + ADDITIONAL1_DMONOMIX_LLRR | ADDITIONAL1_VSEL_DEFAULT); + + wmcodec_write(LEFTMIX1, LEFTMIX1_LD2LO | LEFTMIX1_LI2LO_DEFAULT); + wmcodec_write(RIGHTMIX2, RIGHTMIX2_RD2RO | RIGHTMIX2_RI2RO_DEFAULT); + +#ifdef TOSHIBA_GIGABEAT_F +#ifdef HAVE_HARDWARE_BEEP + /* Single-ended mono input */ + wmcodec_write(MONOMIX1, 0); + + /* Route mono input to both outputs at 0dB */ + wmcodec_write(LEFTMIX2, LEFTMIX2_MI2LO | LEFTMIX2_MI2LOVOL(2)); + wmcodec_write(RIGHTMIX1, RIGHTMIX1_MI2RO | RIGHTMIX1_MI2ROVOL(2)); +#endif +#endif + + audiohw_mute(false); + +#ifdef MROBE_100 + /* enable headphone output */ + GPIOL_OUTPUT_VAL &= ~0x10; + GPIOL_OUTPUT_EN |= 0x10; +#endif +} + +void audiohw_set_master_vol(int vol_l, int vol_r) +{ + /* +6 to -73dB 1dB steps (plus mute == 80levels) 7bits */ + /* 1111111 == +6dB */ + /* 1111001 == 0dB */ + /* 0110000 == -73dB */ + /* 0101111 == mute (0x2f) */ + + wmcodec_write(LOUT1, LOUT1_BITS | LOUT1_LOUT1VOL(vol_l)); + wmcodec_write(ROUT1, ROUT1_BITS | ROUT1_ROUT1VOL(vol_r)); +} + +#ifndef MROBE_100 +void audiohw_set_lineout_vol(int vol_l, int vol_r) +{ + wmcodec_write(LOUT2, LOUT2_BITS | LOUT2_LOUT2VOL(vol_l)); + wmcodec_write(ROUT2, ROUT2_BITS | ROUT2_ROUT2VOL(vol_r)); +} +#endif + +void audiohw_set_bass(int value) +{ + wmcodec_write(BASSCTRL, BASSCTRL_BITS | + +#ifdef USE_ADAPTIVE_BASS + BASSCTRL_BASS(adaptivebass2hw(value))); +#else + BASSCTRL_BASS(tone_tenthdb2hw(value))); +#endif +} + +void audiohw_set_treble(int value) +{ + wmcodec_write(TREBCTRL, TREBCTRL_BITS | + TREBCTRL_TREB(tone_tenthdb2hw(value))); +} + +void audiohw_mute(bool mute) +{ + /* Mute: Set DACMU = 1 to soft-mute the audio DACs. */ + /* Unmute: Set DACMU = 0 to soft-un-mute the audio DACs. */ + wmcodec_write(DACCTRL, mute ? DACCTRL_DACMU : 0); +} + +/* Nice shutdown of WM8751 codec */ +void audiohw_close(void) +{ + /* 1. Set DACMU = 1 to soft-mute the audio DACs. */ + audiohw_mute(true); + + /* 2. Disable all output buffers. */ + wmcodec_write(PWRMGMT2, 0x0); + + /* 3. Switch off the power supplies. */ + wmcodec_write(PWRMGMT1, 0x0); +} + +void audiohw_set_frequency(int fsel) +{ + static const unsigned char srctrl_table[HW_NUM_FREQ] = + { + HW_HAVE_11_([HW_FREQ_11] = CODEC_SRCTRL_11025HZ,) + HW_HAVE_22_([HW_FREQ_22] = CODEC_SRCTRL_22050HZ,) + HW_HAVE_44_([HW_FREQ_44] = CODEC_SRCTRL_44100HZ,) + HW_HAVE_88_([HW_FREQ_88] = CODEC_SRCTRL_88200HZ,) + }; + + if ((unsigned)fsel >= HW_NUM_FREQ) + fsel = HW_FREQ_DEFAULT; + + wmcodec_write(CLOCKING, srctrl_table[fsel]); +} + +void audiohw_set_recvol(int left, int right, int type) +{ + (void)left; + (void)right; + (void)type; + /* empty stub */ +} + Index: uisimulator/sdl/UI-mpiohd200.bmp =================================================================== Nie można wyświetlić: plik binarny. svn:mime-type = application/octet-stream Zmiany atrybutów dla: uisimulator/sdl/UI-mpiohd200.bmp ___________________________________________________________________ Dodane: svn:mime-type + application/octet-stream Index: uisimulator/sdl/button.c =================================================================== --- uisimulator/sdl/button.c (wersja 25312) +++ uisimulator/sdl/button.c (kopia robocza) @@ -1305,6 +1305,30 @@ case SDLK_KP_MULTIPLY: new_btn = BUTTON_REC; break; + +#elif CONFIG_KEYPAD == MPIO_HD200_PAD + case SDLK_UP: + new_btn = BUTTON_PREV; + break; + case SDLK_DOWN: + new_btn = BUTTON_NEXT; + break; + case SDLK_SPACE: + new_btn = BUTTON_SELECT; + break; + case SDLK_RETURN: + new_btn = BUTTON_PLAY; + break; + case SDLK_LEFT: + new_btn = BUTTON_VOL_DOWN; + break; + case SDLK_RIGHT: + new_btn = BUTTON_VOL_UP; + break; + case SDLK_ESCAPE: + new_btn = BUTTON_REC; + break; + #else #error No keymap defined! #endif /* CONFIG_KEYPAD */ @@ -1850,6 +1874,16 @@ { SDLK_KP3, 311, 569, 47, "Menu" }, { 0, 0, 0, 0, "None" } }; +#elif defined (MPIO_HD200) +struct button_map bm[] = { + { SDLK_ESCAPE, 353, 135, 20, "Rec" }, + { SDLK_RETURN, 357, 187, 20, "Play/Stop" }, + { SDLK_UP, 339, 44, 10, "Rew" }, + { SDLK_DOWN, 339, 85, 10, "FF" }, + { SDLK_SPACE, 339, 66, 10, "Select" }, + { SDLK_h, 355, 285, 20, "Hold" }, + { 0, 0, 0, 0, "None" } +}; #else struct button_map bm[] = { { 0, 0, 0, 0, ""} Index: uisimulator/sdl/uisdl.h =================================================================== --- uisimulator/sdl/uisdl.h (wersja 25312) +++ uisimulator/sdl/uisdl.h (kopia robocza) @@ -385,6 +385,14 @@ #define UI_HEIGHT 488 /* height of GUI window */ #define UI_LCD_POSX 64 /* x position of lcd */ #define UI_LCD_POSY 61 /* y position of lcd */ + +#elif defined(MPIO_HD200) +#define UI_TITLE "MPIO HD200" +#define UI_WIDTH 406 /* width of GUI window */ +#define UI_HEIGHT 349 /* height of GUI window */ +#define UI_LCD_POSX 86 +#define UI_LCD_POSY 76 + #else #error no UI defines #endif