summaryrefslogtreecommitdiffstats
path: root/firmware/target
diff options
context:
space:
mode:
authorSolomon Peachy <pizza@shaftnet.org>2020-07-15 19:40:55 -0400
committerSolomon Peachy <pizza@shaftnet.org>2020-07-24 21:20:13 +0000
commit092c340a2062fa98b7387fc5fd63578ddae7d0b6 (patch)
tree98ec96946eeb2ae709cb0528cc6998e21bb9b290 /firmware/target
parent17f7cc92c258bc456a27c3e7c5a19c9409851879 (diff)
downloadrockbox-092c340a2062fa98b7387fc5fd63578ddae7d0b6.tar.gz
rockbox-092c340a2062fa98b7387fc5fd63578ddae7d0b6.tar.bz2
rockbox-092c340a2062fa98b7387fc5fd63578ddae7d0b6.zip
[1/4] Remove SH support and all archos targets
This removes all code specific to SH targets Change-Id: I7980523785d2596e65c06430f4638eec74a06061
Diffstat (limited to 'firmware/target')
-rw-r--r--firmware/target/hosted/sdl/sim-ui-defines.h38
-rw-r--r--firmware/target/sh/adc-sh.c110
-rw-r--r--firmware/target/sh/archos/app.lds145
-rw-r--r--firmware/target/sh/archos/ata-archos.c71
-rw-r--r--firmware/target/sh/archos/ata-as-archos.S233
-rw-r--r--firmware/target/sh/archos/ata-target.h45
-rw-r--r--firmware/target/sh/archos/audio-archos.c543
-rw-r--r--firmware/target/sh/archos/boot.lds81
-rw-r--r--firmware/target/sh/archos/descramble.S121
-rw-r--r--firmware/target/sh/archos/fm_v2/adc-target.h41
-rw-r--r--firmware/target/sh/archos/fm_v2/backlight-target.h51
-rw-r--r--firmware/target/sh/archos/fm_v2/button-fm_v2.c99
-rw-r--r--firmware/target/sh/archos/fm_v2/button-target.h47
-rw-r--r--firmware/target/sh/archos/fm_v2/power-fm_v2.c115
-rw-r--r--firmware/target/sh/archos/fm_v2/powermgmt-fm_v2.c60
-rw-r--r--firmware/target/sh/archos/fm_v2/usb-fm_v2.c49
-rw-r--r--firmware/target/sh/archos/i2c-archos.c254
-rw-r--r--firmware/target/sh/archos/lcd-archos-bitmap.c224
-rw-r--r--firmware/target/sh/archos/lcd-as-archos-bitmap.S354
-rw-r--r--firmware/target/sh/archos/mascodec-archos.c491
-rw-r--r--firmware/target/sh/archos/ondio/adc-target.h37
-rw-r--r--firmware/target/sh/archos/ondio/ata_mmc.c978
-rw-r--r--firmware/target/sh/archos/ondio/backlight-target.h49
-rw-r--r--firmware/target/sh/archos/ondio/button-ondio.c71
-rw-r--r--firmware/target/sh/archos/ondio/button-target.h39
-rw-r--r--firmware/target/sh/archos/ondio/fmradio_i2c-ondio.c202
-rw-r--r--firmware/target/sh/archos/ondio/power-ondio.c78
-rw-r--r--firmware/target/sh/archos/ondio/powermgmt-ondio.c53
-rw-r--r--firmware/target/sh/archos/ondio/usb-ondio.c61
-rw-r--r--firmware/target/sh/archos/player/adc-target.h35
-rw-r--r--firmware/target/sh/archos/player/backlight-target.h46
-rw-r--r--firmware/target/sh/archos/player/button-player.c76
-rw-r--r--firmware/target/sh/archos/player/button-target.h52
-rw-r--r--firmware/target/sh/archos/player/hwcompat-player.c28
-rw-r--r--firmware/target/sh/archos/player/lcd-as-player.S274
-rw-r--r--firmware/target/sh/archos/player/lcd-player.c213
-rw-r--r--firmware/target/sh/archos/player/power-player.c84
-rw-r--r--firmware/target/sh/archos/player/powermgmt-player.c64
-rw-r--r--firmware/target/sh/archos/player/usb-player.c44
-rw-r--r--firmware/target/sh/archos/recorder/adc-target.h41
-rw-r--r--firmware/target/sh/archos/recorder/backlight-target.h51
-rw-r--r--firmware/target/sh/archos/recorder/button-recorder.c110
-rw-r--r--firmware/target/sh/archos/recorder/button-target.h59
-rw-r--r--firmware/target/sh/archos/recorder/power-recorder.c107
-rw-r--r--firmware/target/sh/archos/recorder/powermgmt-recorder.c501
-rw-r--r--firmware/target/sh/archos/recorder/powermgmt-target.h89
-rw-r--r--firmware/target/sh/archos/recorder/usb-recorder.c49
-rw-r--r--firmware/target/sh/archos/timer-archos.c84
-rw-r--r--firmware/target/sh/archos/uart-archos.c167
-rw-r--r--firmware/target/sh/bitswap.S152
-rw-r--r--firmware/target/sh/crt0.S219
-rw-r--r--firmware/target/sh/debug-sh.c285
-rw-r--r--firmware/target/sh/kernel-sh.c65
-rw-r--r--firmware/target/sh/system-sh.c450
-rw-r--r--firmware/target/sh/system-target.h154
55 files changed, 1 insertions, 8238 deletions
diff --git a/firmware/target/hosted/sdl/sim-ui-defines.h b/firmware/target/hosted/sdl/sim-ui-defines.h
index 23825f318b..808804c01f 100644
--- a/firmware/target/hosted/sdl/sim-ui-defines.h
+++ b/firmware/target/hosted/sdl/sim-ui-defines.h
@@ -28,35 +28,7 @@
/* colour definitions are R, G, B */
-#if defined(ARCHOS_RECORDER)
-#define UI_TITLE "Jukebox Recorder"
-#define UI_WIDTH 270 /* width of GUI window */
-#define UI_HEIGHT 406 /* height of GUI window */
-#define UI_LCD_POSX 80 /* x position of lcd */
-#define UI_LCD_POSY 104 /* y position of lcd */
-
-#elif defined(ARCHOS_PLAYER)
-#define UI_TITLE "Jukebox Player"
-#define UI_WIDTH 284 /* width of GUI window */
-#define UI_HEIGHT 420 /* height of GUI window */
-#define UI_LCD_POSX 75 /* x position of lcd */
-#define UI_LCD_POSY 116 /* y position of lcd */
-
-#elif defined(ARCHOS_FMRECORDER) || defined(ARCHOS_RECORDERV2)
-#define UI_TITLE "Jukebox FM Recorder"
-#define UI_WIDTH 285 /* width of GUI window */
-#define UI_HEIGHT 414 /* height of GUI window */
-#define UI_LCD_POSX 87 /* x position of lcd */
-#define UI_LCD_POSY 77 /* y position of lcd */
-
-#elif defined(ARCHOS_ONDIOSP) || defined(ARCHOS_ONDIOFM)
-#define UI_TITLE "Ondio"
-#define UI_WIDTH 155 /* width of GUI window */
-#define UI_HEIGHT 334 /* height of GUI window */
-#define UI_LCD_POSX 21 /* x position of lcd */
-#define UI_LCD_POSY 82 /* y position of lcd */
-
-#elif defined(IRIVER_H120) || defined(IRIVER_H100)
+#if defined(IRIVER_H120) || defined(IRIVER_H100)
#define UI_TITLE "iriver H1x0"
#define UI_WIDTH 379 /* width of GUI window */
#define UI_HEIGHT 508 /* height of GUI window */
@@ -238,14 +210,6 @@
#define UI_LCD_POSX 115 /* x position of lcd */
#define UI_LCD_POSY 54 /* y position of lcd */
-#elif defined(ARCHOS_AV300)
-#define UI_TITLE "Archos AV300"
-/* We are temporarily using a 2bpp LCD driver and dummy bitmap */
-#define UI_WIDTH 420 /* width of GUI window */
-#define UI_HEIGHT 340 /* height of GUI window */
-#define UI_LCD_POSX 50 /* x position of lcd */
-#define UI_LCD_POSY 50 /* y position of lcd */
-
#elif defined(MROBE_100)
#define UI_TITLE "Olympus M:Robe 100"
#define UI_WIDTH 247 /* width of GUI window */
diff --git a/firmware/target/sh/adc-sh.c b/firmware/target/sh/adc-sh.c
deleted file mode 100644
index 2e6d6407b8..0000000000
--- a/firmware/target/sh/adc-sh.c
+++ /dev/null
@@ -1,110 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2002 by Linus Nielsen Feltzing
- *
- * 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 "string.h"
-#include "adc.h"
-
-/**************************************************************************
- ** The A/D conversion is done every tick, in three steps:
- **
- ** 1) On the tick interrupt, the conversion of channels 0-3 is started, and
- ** the A/D interrupt is enabled.
- **
- ** 2) After the conversion is done (approx. 256*4 cycles later), an interrupt
- ** is generated at level 1, which is the same level as the tick interrupt
- ** itself. This interrupt will be pending until the tick interrupt is
- ** finished.
- ** When the A/D interrupt is finally served, it will read the results
- ** from the first conversion and start the conversion of channels 4-7.
- **
- ** 3) When the conversion of channels 4-7 is finished, the interrupt is
- ** triggered again, and the results are read. This time, no new
- ** conversion is started, it will be done in the next tick interrupt.
- **
- ** Thus, each channel will be updated HZ times per second.
- **
- *************************************************************************/
-
-static int current_channel;
-static unsigned short adcdata[NUM_ADC_CHANNELS];
-
-static void adc_tick(void)
-{
- /* Start a conversion of channel group 0. This will trigger an interrupt,
- and the interrupt handler will take care of group 1. */
-
- current_channel = 0;
- ADCSR = ADCSR_ADST | ADCSR_ADIE | ADCSR_SCAN | 3;
-}
-
-void ADITI(void) __attribute__((interrupt_handler));
-void ADITI(void)
-{
- if(ADCSR & ADCSR_ADF)
- {
- ADCSR = 0;
-
- if(current_channel == 0)
- {
- adcdata[0] = ADDRA >> 6;
- adcdata[1] = ADDRB >> 6;
- adcdata[2] = ADDRC >> 6;
- adcdata[3] = ADDRD >> 6;
- current_channel = 4;
-
- /* Convert the next group */
- ADCSR = ADCSR_ADST | ADCSR_ADIE | ADCSR_SCAN | 7;
- }
- else
- {
- adcdata[4] = ADDRA >> 6;
- adcdata[5] = ADDRB >> 6;
- adcdata[6] = ADDRC >> 6;
- adcdata[7] = ADDRD >> 6;
- }
- }
-}
-
-unsigned short adc_read(int channel)
-{
- return adcdata[channel];
-}
-
-void adc_init(void)
-{
- ADCR = 0x7f; /* No external trigger; other bits should be 1 according
- to the manual... */
-
- ADCSR = 0;
-
- current_channel = 0;
-
- /* Enable the A/D IRQ on level 1 */
- IPRE = (IPRE & 0xf0ff) | 0x0100;
-
- tick_add_task(adc_tick);
-
- sleep(2); /* Ensure valid readings when adc_init returns */
-}
diff --git a/firmware/target/sh/archos/app.lds b/firmware/target/sh/archos/app.lds
deleted file mode 100644
index 225f11f705..0000000000
--- a/firmware/target/sh/archos/app.lds
+++ /dev/null
@@ -1,145 +0,0 @@
-#include "config.h"
-
-ENTRY(start)
-
-OUTPUT_FORMAT(elf32-sh)
-STARTUP(target/sh/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 0x09000000 + STUBOFFSET
-#define IRAMORIG 0x0f000000
-#define IRAMSIZE 0x1000
-
-/* 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 _noloaddram (NOLOAD) :
- {
- *(.stack)
- _stackbegin = .;
- . += 0x2000;
- _stackend = .;
- } > DRAM
-
- .bss (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 = .;
- }
-}
-
diff --git a/firmware/target/sh/archos/ata-archos.c b/firmware/target/sh/archos/ata-archos.c
deleted file mode 100644
index 2046d3b33f..0000000000
--- a/firmware/target/sh/archos/ata-archos.c
+++ /dev/null
@@ -1,71 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2006 by Jens Arnold
- *
- * 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 <stdbool.h>
-#include "kernel.h"
-#include "system.h"
-#include "ata-driver.h"
-#include "hwcompat.h"
-
-#define ATA_CONTROL1 ((volatile unsigned char*)0x06200206)
-#define ATA_CONTROL2 ((volatile unsigned char*)0x06200306)
-
-volatile unsigned char* ata_control;
-
-void ata_reset(void)
-{
- /* state HRR0 */
- and_b(~0x02, &PADRH); /* assert _RESET */
- sleep(1); /* > 25us */
-
- /* state HRR1 */
- or_b(0x02, &PADRH); /* negate _RESET */
- sleep(1); /* > 2ms */
-}
-
-void ata_enable(bool on)
-{
- if(on)
- and_b(~0x80, &PADRL); /* enable ATA */
- else
- or_b(0x80, &PADRL); /* disable ATA */
-
- or_b(0x80, &PAIORL);
-}
-
-void ata_device_init(void)
-{
- or_b(0x02, &PAIORH); /* output for ATA reset */
- or_b(0x02, &PADRH); /* release ATA reset */
- PACR2 &= 0xBFFF; /* GPIO function for PA7 (IDE enable) */
-
- if (HW_MASK & ATA_ADDRESS_200)
- ata_control = ATA_CONTROL1;
- else
- ata_control = ATA_CONTROL2;
-}
-
-bool ata_is_coldstart(void)
-{
- return (PACR2 & 0x4000) != 0;
-}
diff --git a/firmware/target/sh/archos/ata-as-archos.S b/firmware/target/sh/archos/ata-as-archos.S
deleted file mode 100644
index c403c4c921..0000000000
--- a/firmware/target/sh/archos/ata-as-archos.S
+++ /dev/null
@@ -1,233 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2004-2006 by Jens Arnold
- *
- * 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.
- *
- ****************************************************************************/
-
- .section .icode,"ax",@progbits
-
- .align 2
- .global _copy_read_sectors
- .type _copy_read_sectors,@function
-
-/* Read a number of words from the ATA data port
- *
- * Assumes wordcount to be a multiple of 4
- *
- * Arguments:
- * r4 - buffer address
- * r5 - word count
- *
- * Register usage:
- * r0 - scratch
- * r1/r2 - read buffers
- * r3 - mask (if unaligned)
- * r4 - current address
- * r5 - end address
- * r6 - ata port
- */
-
-_copy_read_sectors:
- add r5, r5 /* words -> bytes */
- add r4, r5 /* bytes -> end address */
- add #-12, r5 /* adjust for offsets */
- mov.l .ata_data, r6
-
- mov r4, r0
- tst #1, r0 /* 16-bit aligned ? */
- bt .r_aligned /* yes, do word copy */
-
- /* not 16-bit aligned */
- mov #-1, r3 /* prepare a bit mask for high byte */
- shll8 r3 /* r3 = 0xFFFFFF00 */
-
- mov.w @r6, r2 /* read first word (1st round) */
- mov.b r2, @r4 /* store low byte of first word */
- bra .r_start_b /* jump into loop after next instr. */
- add #-5, r4 /* adjust for dest. offsets; now even */
-
- .align 2
-.r_loop_b: /* main loop: copy 4 words in a row */
- mov.w @r6, r2 /* read first word (2+ round) */
- and r3, r1 /* get high byte of fourth word (2+ round) */
- extu.b r2, r0 /* get low byte of first word (2+ round) */
- or r1, r0 /* combine with high byte of fourth word */
- mov.w r0, @(4, r4) /* store at buf[4] */
- nop /* maintain alignment */
-.r_start_b:
- mov.w @r6, r1 /* read second word */
- and r3, r2 /* get high byte of first word */
- extu.b r1, r0 /* get low byte of second word */
- or r2, r0 /* combine with high byte of first word */
- mov.w r0, @(6, r4) /* store at buf[6] */
- add #8, r4 /* buf += 8 */
- mov.w @r6, r2 /* read third word */
- and r3, r1 /* get high byte of second word */
- extu.b r2, r0 /* get low byte of third word */
- or r1, r0 /* combine with high byte of second word */
- mov.w r0, @r4 /* store at buf[0] */
- cmp/hi r4, r5 /* check for end */
- mov.w @r6, r1 /* read fourth word */
- and r3, r2 /* get high byte of third word */
- extu.b r1, r0 /* get low byte of fourth word */
- or r2, r0 /* combine with high byte of third word */
- mov.w r0, @(2, r4) /* store at buf[2] */
- bt .r_loop_b
- /* 24 instructions for 4 copies, takes 30 clock cycles (4 wait) */
- /* avg. 7.5 cycles per word */
-
- swap.b r1, r0 /* get high byte of last word */
- rts
- mov.b r0, @(4, r4) /* and store it */
-
- /* 16-bit aligned, loop(read and store word) */
-.r_aligned:
- mov.w @r6, r2 /* read first word (1st round) */
- bra .r_start_w /* jump into loop after next instr. */
- add #-6, r4 /* adjust for destination offsets */
-
- .align 2
-.r_loop_w: /* main loop: copy 4 words in a row */
- mov.w @r6, r2 /* read first word (2+ round) */
- swap.b r1, r0 /* swap fourth word (2+ round) */
- mov.w r0, @(4, r4) /* store fourth word (2+ round) */
- nop /* maintain alignment */
-.r_start_w:
- mov.w @r6, r1 /* read second word */
- swap.b r2, r0 /* swap first word */
- mov.w r0, @(6, r4) /* store first word in buf[6] */
- add #8, r4 /* buf += 8 */
- mov.w @r6, r2 /* read third word */
- swap.b r1, r0 /* swap second word */
- mov.w r0, @r4 /* store second word in buf[0] */
- cmp/hi r4, r5 /* check for end */
- mov.w @r6, r1 /* read fourth word */
- swap.b r2, r0 /* swap third word */
- mov.w r0, @(2, r4) /* store third word */
- bt .r_loop_w
- /* 16 instructions for 4 copies, takes 22 clock cycles (4 wait) */
- /* avg. 5.5 cycles per word */
-
- swap.b r1, r0 /* swap fourth word (last round) */
- rts
- mov.w r0, @(4, r4) /* and store it */
-
-.r_end:
- .size _copy_read_sectors,.r_end-_copy_read_sectors
-
- .align 2
- .global _copy_write_sectors
- .type _copy_write_sectors,@function
-
-/* Write a number of words to the ATA data port
- *
- * Assumes wordcount to be a multiple of 2.
- * Writing is not unrolled as much as reading, for several reasons:
- *
- * - a similar instruction sequence is faster for writing than for reading
- * because the auto-incrementing load instructions can be used
- * - writing profits from warp mode
- *
- * Both of these add up to have writing faster than the more unrolled reading.
- *
- * Arguments:
- * r4 - buffer address
- * r5 - word count
- *
- * Register usage:
- * r0/r1 - scratch
- * r2/r3 - write buffers
- * r4 - current address
- * r5 - end address
- * r6 - mask (if unaligned)
- * r7 - ata port
- */
-
-_copy_write_sectors:
- add r5, r5 /* words -> bytes */
- add r4, r5 /* bytes -> end address */
- add #-4, r5 /* adjust for offsets */
- mov.l .ata_data, r7
-
- mov r4, r0
- tst #1, r0 /* 16-bit aligned ? */
- bt .w_aligned /* yes, do word copy */
-
- /* not 16-bit aligned */
- mov #-1, r6 /* prepare a bit mask for high byte */
- shll8 r6 /* r6 = 0xFFFFFF00 */
-
- mov.b @r4+, r2 /* load (initial old second) first byte */
- mov.w @r4+, r3 /* load (initial) first word */
- bra .w_start_b
- extu.b r2, r0 /* extend unsigned */
-
- .align 2
-.w_loop_b: /* main loop: copy 2 words in a row */
- mov.w @r4+, r3 /* load first word (2+ round) */
- extu.b r2, r0 /* put away low byte of second word (2+ round) */
- and r6, r2 /* get high byte of second word (2+ round) */
- or r1, r2 /* combine with low byte of old first word */
- mov.w r2, @r7 /* write that */
-.w_start_b:
- cmp/hi r4, r5 /* check for end */
- mov.w @r4+, r2 /* load second word */
- extu.b r3, r1 /* put away low byte of first word */
- and r6, r3 /* get high byte of first word */
- or r0, r3 /* combine with high byte of old second word */
- mov.w r3, @r7 /* write that */
- bt .w_loop_b
- /* 12 instructions for 2 copies, takes 14 clock cycles */
- /* avg. 7 cycles per word */
-
- /* the loop "overreads" 1 byte past the buffer end, however, the last */
- /* byte is not written to disk */
- and r6, r2 /* get high byte of last word */
- or r1, r2 /* combine with low byte of old first word */
- rts
- mov.w r2, @r7 /* write last word */
-
- /* 16-bit aligned, loop(load and write word) */
-.w_aligned:
- bra .w_start_w /* jump into loop after next instr. */
- mov.w @r4+, r2 /* load first word (1st round) */
-
- .align 2
-.w_loop_w: /* main loop: copy 2 words in a row */
- mov.w @r4+, r2 /* load first word (2+ round) */
- swap.b r1, r0 /* swap second word (2+ round) */
- mov.w r0, @r7 /* write second word (2+ round) */
-.w_start_w:
- cmp/hi r4, r5 /* check for end */
- mov.w @r4+, r1 /* load second word */
- swap.b r2, r0 /* swap first word */
- mov.w r0, @r7 /* write first word */
- bt .w_loop_w
- /* 8 instructions for 2 copies, takes 10 clock cycles */
- /* avg. 5 cycles per word */
-
- swap.b r1, r0 /* swap second word (last round) */
- rts
- mov.w r0, @r7 /* and write it */
-
-.w_end:
- .size _copy_write_sectors,.w_end-_copy_write_sectors
-
- .align 2
-.ata_data:
- .long 0x06104100 /* ATA data port */
diff --git a/firmware/target/sh/archos/ata-target.h b/firmware/target/sh/archos/ata-target.h
deleted file mode 100644
index dc55cdd5d5..0000000000
--- a/firmware/target/sh/archos/ata-target.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2006 by Jens Arnold
- *
- * 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 */
-#define ATA_OPTIMIZED_READING
-#define ATA_OPTIMIZED_WRITING
-
-#define ATA_SWAP_WORDS
-
-#define ATA_IOBASE 0x06100100
-#define ATA_DATA (*((volatile unsigned short*)0x06104100))
-#define ATA_CONTROL (*ata_control)
-
-#define ATA_ERROR (*((volatile unsigned char*)ATA_IOBASE + 1))
-#define ATA_NSECTOR (*((volatile unsigned char*)ATA_IOBASE + 2))
-#define ATA_SECTOR (*((volatile unsigned char*)ATA_IOBASE + 3))
-#define ATA_LCYL (*((volatile unsigned char*)ATA_IOBASE + 4))
-#define ATA_HCYL (*((volatile unsigned char*)ATA_IOBASE + 5))
-#define ATA_SELECT (*((volatile unsigned char*)ATA_IOBASE + 6))
-#define ATA_COMMAND (*((volatile unsigned char*)ATA_IOBASE + 7))
-
-extern volatile unsigned char* ata_control;
-
-
-#endif
diff --git a/firmware/target/sh/archos/audio-archos.c b/firmware/target/sh/archos/audio-archos.c
deleted file mode 100644
index 2c2579bec5..0000000000
--- a/firmware/target/sh/archos/audio-archos.c
+++ /dev/null
@@ -1,543 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Code that has been in mpeg.c before, now creating an encapsulated play
- * data module, to be used by other sources than file playback as well.
- *
- * Copyright (C) 2004 by Linus Nielsen Feltzing
- *
- * 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 <stdbool.h>
-#include "config.h"
-#include "debug.h"
-#include "panic.h"
-#include <kernel.h>
-#include "mp3_playback.h"
-#include "sound.h"
-#include "i2c.h"
-#include "system.h"
-#include "audiohw.h"
-
-/* hacking into mpeg.c, recording is still there */
-#if CONFIG_CODEC == MAS3587F
-enum
-{
- MPEG_DECODER,
- MPEG_ENCODER
-} mpeg_mode;
-#endif /* #ifdef MAS3587F */
-
-#if ((CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)) && !defined(SIMULATOR)
-extern unsigned long shadow_io_control_main;
-extern unsigned shadow_codec_reg0;
-#endif
-
-/**** globals ****/
-
-/* own version, independent of mpeg.c */
-static bool paused; /* playback is paused */
-static bool playing; /* We are playing an MP3 stream */
-
-/* the registered callback function to ask for more mp3 data */
-static mp3_play_callback_t callback_for_more;
-
-/* list of tracks in memory */
-#define MAX_ID3_TAGS (1<<4) /* Must be power of 2 */
-#define MAX_ID3_TAGS_MASK (MAX_ID3_TAGS - 1)
-
-bool audio_is_initialized = false;
-
-/* FIX: this code pretty much assumes a MAS */
-
-/* dirty calls to mpeg.c */
-extern void playback_tick(void);
-extern void rec_tick(void);
-
-unsigned long mas_version_code;
-
-#if CONFIG_CODEC == MAS3507D
-static void mas_poll_start(void)
-{
- unsigned int count;
-
- count = 9 * FREQ / 10000 / 8; /* 0.9 ms */
-
- /* We are using timer 1 */
-
- TSTR &= ~0x02; /* Stop the timer */
- TSNC &= ~0x02; /* No synchronization */
- TMDR &= ~0x02; /* Operate normally */
-
- TCNT1 = 0; /* Start counting at 0 */
- GRA1 = count;
- TCR1 = 0x23; /* Clear at GRA match, sysclock/8 */
-
- /* Enable interrupt on level 5 */
- IPRC = (IPRC & ~0x000f) | 0x0005;
-
- TSR1 &= ~0x02;
- TIER1 = 0xf9; /* Enable GRA match interrupt */
-
- TSTR |= 0x02; /* Start timer 1 */
-}
-#elif CONFIG_CODEC != SWCODEC
-static void postpone_dma_tick(void)
-{
- unsigned int count;
-
- count = 8 * FREQ / 10000 / 8; /* 0.8 ms */
-
- /* We are using timer 1 */
-
- TSTR &= ~0x02; /* Stop the timer */
- TSNC &= ~0x02; /* No synchronization */
- TMDR &= ~0x02; /* Operate normally */
-
- TCNT1 = 0; /* Start counting at 0 */
- GRA1 = count;
- TCR1 = 0x23; /* Clear at GRA match, sysclock/8 */
-
- /* Enable interrupt on level 5 */
- IPRC = (IPRC & ~0x000f) | 0x0005;
-
- TSR1 &= ~0x02;
- TIER1 = 0xf9; /* Enable GRA match interrupt */
-
- TSTR |= 0x02; /* Start timer 1 */
-}
-#endif
-
-#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
-void demand_irq_enable(bool on)
-{
- int oldlevel = disable_irq_save();
-
- if(on)
- {
- IPRA = (IPRA & 0xfff0) | 0x000b;
- ICR &= ~0x0010; /* IRQ3 level sensitive */
- }
- else
- IPRA &= 0xfff0;
-
- restore_irq(oldlevel);
-}
-#endif /* #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) */
-
-
-static void play_tick(void)
-{
- if(playing && !paused)
- {
- /* Start DMA if it is disabled and the DEMAND pin is high */
- if(!(SCR0 & 0x80) && (PBDR & 0x4000))
- {
- SCR0 |= 0x80;
- }
-
- playback_tick(); /* dirty call to mpeg.c */
- }
-}
-
-void DEI3(void) __attribute__((interrupt_handler));
-void DEI3(void)
-{
- const void* start;
- size_t size = 0;
-
- if (callback_for_more != NULL)
- {
- callback_for_more(&start, &size);
- }
-
- if (size > 0)
- {
- DTCR3 = size & 0xffff;
- SAR3 = (unsigned int) start;
- }
- else
- {
- CHCR3 &= ~0x0001; /* Disable the DMA interrupt */
- }
-
- CHCR3 &= ~0x0002; /* Clear DMA interrupt */
-}
-
-void IMIA1(void) __attribute__((interrupt_handler));
-void IMIA1(void) /* Timer 1 interrupt */
-{
- if(playing)
- play_tick();
- TSR1 &= ~0x01;
-#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
- /* Disable interrupt */
- IPRC &= ~0x000f;
-#endif
-}
-
-void IRQ6(void) __attribute__((interrupt_handler));
-void IRQ6(void) /* PB14: MAS stop demand IRQ */
-{
- SCR0 &= ~0x80;
-}
-
-#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
-void IRQ3(void) __attribute__((interrupt_handler));
-void IRQ3(void) /* PA15: MAS demand IRQ */
-{
- /* Begin with setting the IRQ to edge sensitive */
- ICR |= 0x0010;
-
-#if CONFIG_CODEC == MAS3587F
- if(mpeg_mode == MPEG_ENCODER)
- rec_tick();
- else
-#endif
- postpone_dma_tick();
-
- /* Workaround for sh-elf-gcc 3.3.x bug with -O2 or -Os and ISRs
- * (invalid cross-jump optimisation) */
- asm volatile ("");
-}
-#endif /* #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) */
-
-static void setup_sci0(void)
-{
- /* PB15 is I/O, PB14 is IRQ6, PB12 is SCK0, PB9 is TxD0 */
- PBCR1 = (PBCR1 & 0x0cff) | 0x1208;
-
- /* Set PB12 to output */
- or_b(0x10, &PBIORH);
-
- /* Disable serial port */
- SCR0 = 0x00;
-
- /* Synchronous, no prescale */
- SMR0 = 0x80;
-
- /* Set baudrate 1Mbit/s */
- BRR0 = 0x02;
-
- /* use SCK as serial clock output */
- SCR0 = 0x01;
-
- /* Clear FER and PER */
- SSR0 &= 0xe7;
-
- /* Set interrupt ITU2 and SCI0 priority to 0 */
- IPRD &= 0x0ff0;
-
- /* set PB15 and PB14 to inputs */
- and_b(~0x80, &PBIORH);
- and_b(~0x40, &PBIORH);
-
- /* Enable End of DMA interrupt at prio 8 */
- IPRC = (IPRC & 0xf0ff) | 0x0800;
-
- /* Enable Tx (only!) */
- SCR0 |= 0x20;
-}
-
-#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
-static void init_playback(void)
-{
- unsigned long val;
- int rc;
-
- mp3_play_pause(false);
-
- mas_reset();
-
- /* Enable the audio CODEC and the DSP core, max analog voltage range */
- rc = mas_direct_config_write(MAS_CONTROL, 0x8c00);
- if(rc < 0)
- panicf("mas_ctrl_w: %d", rc);
-
- /* Stop the current application */
- val = 0;
- mas_writemem(MAS_BANK_D0, MAS_D0_APP_SELECT, &val, 1);
- do
- {
- mas_readmem(MAS_BANK_D0, MAS_D0_APP_RUNNING, &val, 1);
- } while(val);
-
- /* Enable the D/A Converter */
- shadow_codec_reg0 = 0x0001;
- mas_codec_writereg(0x0, shadow_codec_reg0);
-
- /* ADC scale 0%, DSP scale 100% */
- mas_codec_writereg(6, 0x0000);
- mas_codec_writereg(7, 0x4000);
-
-#ifdef HAVE_SPDIF_OUT
- val = 0x09; /* Disable SDO and SDI, low impedance S/PDIF outputs */
-#else
- val = 0x2d; /* Disable SDO and SDI, disable S/PDIF output */
-#endif
- mas_writemem(MAS_BANK_D0, MAS_D0_INTERFACE_CONTROL, &val, 1);
-
- /* Set Demand mode and validate all settings */
- shadow_io_control_main = 0x25;
- mas_writemem(MAS_BANK_D0, MAS_D0_IO_CONTROL_MAIN, &shadow_io_control_main, 1);
-
- /* Start the Layer2/3 decoder applications */
- val = 0x0c;
- mas_writemem(MAS_BANK_D0, MAS_D0_APP_SELECT, &val, 1);
- do
- {
- mas_readmem(MAS_BANK_D0, MAS_D0_APP_RUNNING, &val, 1);
- } while((val & 0x0c) != 0x0c);
-
-#if CONFIG_CODEC == MAS3587F
- mpeg_mode = MPEG_DECODER;
-#endif
-
- /* set IRQ6 to edge detect */
- ICR |= 0x02;
-
- /* set IRQ6 prio 8 */
- IPRB = ( IPRB & 0xff0f ) | 0x0080;
-
- DEBUGF("MAS Decoding application started\n");
-}
-#endif /* #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) */
-
-void mp3_init(int volume, int bass, int treble, int balance, int loudness,
- int avc, int channel_config, int stereo_width,
- int mdb_strength, int mdb_harmonics,
- int mdb_center, int mdb_shape, bool mdb_enable,
- bool superbass)
-{
-#if CONFIG_CODEC == MAS3507D
- unsigned long val;
- (void)loudness;
- (void)avc;
- (void)mdb_strength;
- (void)mdb_harmonics;
- (void)mdb_center;
- (void)mdb_shape;
- (void)mdb_enable;
- (void)superbass;
-#endif
-
- setup_sci0();
-
-#ifdef HAVE_MAS_SIBI_CONTROL
- and_b(~0x01, &PBDRH); /* drive SIBI low */
- or_b(0x01, &PBIORH); /* output for PB8 */
-#endif
-
-#if CONFIG_CODEC == MAS3507D
- mas_reset();
-#elif CONFIG_CODEC == MAS3587F
- or_b(0x08, &PAIORH); /* output for /PR */
- init_playback();
-
- mas_version_code = mas_readver();
- DEBUGF("MAS3587 derivate %d, version %c%d\n",
- (mas_version_code & 0xf000) >> 12,
- 'A' + ((mas_version_code & 0x0f00) >> 8), mas_version_code & 0xff);
-#elif CONFIG_CODEC == MAS3539F
- or_b(0x08, &PAIORH); /* output for /PR */
- init_playback();
-
- mas_version_code = mas_readver();
- DEBUGF("MAS3539 derivate %d, version %c%d\n",
- (mas_version_code & 0xf000) >> 12,
- 'A' + ((mas_version_code & 0x0f00) >> 8), mas_version_code & 0xff);
-#endif
-
-#ifdef HAVE_DAC3550A
- dac_init();
-#endif
-
-#if CONFIG_CODEC == MAS3507D
- /* set IRQ6 to edge detect */
- ICR |= 0x02;
-
- /* set IRQ6 prio 8 */
- IPRB = ( IPRB & 0xff0f ) | 0x0080;
-
- mas_readmem(MAS_BANK_D1, 0xff7, &mas_version_code, 1);
-
- mas_writereg(0x3b, 0x20); /* Don't ask why. The data sheet doesn't say */
- mas_run(1);
- sleep(HZ);
-
- /* Clear the upper 12 bits of the 32-bit samples */
- mas_writereg(0xc5, 0);
- mas_writereg(0xc6, 0);
-
- /* We need to set the PLL for a 14.31818MHz crystal */
- if(mas_version_code == 0x0601) /* Version F10? */
- {
- val = 0x5d9d0;
- mas_writemem(MAS_BANK_D0, 0x32d, &val, 1);
- val = 0xfffceceb;
- mas_writemem(MAS_BANK_D0, 0x32e, &val, 1);
- val = 0x0;
- mas_writemem(MAS_BANK_D0, 0x32f, &val, 1);
- mas_run(0x475);
- }
- else
- {
- val = 0x5d9d0;
- mas_writemem(MAS_BANK_D0, 0x36d, &val, 1);
- val = 0xfffceceb;
- mas_writemem(MAS_BANK_D0, 0x36e, &val, 1);
- val = 0x0;
- mas_writemem(MAS_BANK_D0, 0x36f, &val, 1);
- mas_run(0xfcb);
- }
-
-#endif
-
-#if CONFIG_CODEC == MAS3507D
- mas_poll_start();
-
- mas_writereg(MAS_REG_KPRESCALE, 0xe9400);
- dac_enable(true);
-#endif
-
-#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
- ICR &= ~0x0010; /* IRQ3 level sensitive */
- PACR1 = (PACR1 & 0x3fff) | 0x4000; /* PA15 is IRQ3 */
-#endif
-
- /* Must be done before calling sound_set() */
- audio_is_initialized = true;
-
- sound_set(SOUND_BASS, bass);
- sound_set(SOUND_TREBLE, treble);
- sound_set(SOUND_BALANCE, balance);
- sound_set(SOUND_VOLUME, volume);
- sound_set(SOUND_CHANNELS, channel_config);
- sound_set(SOUND_STEREO_WIDTH, stereo_width);
-
-#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
- sound_set(SOUND_LOUDNESS, loudness);
- sound_set(SOUND_AVC, avc);
- sound_set(SOUND_MDB_STRENGTH, mdb_strength);
- sound_set(SOUND_MDB_HARMONICS, mdb_harmonics);
- sound_set(SOUND_MDB_CENTER, mdb_center);
- sound_set(SOUND_MDB_SHAPE, mdb_shape);
- sound_set(SOUND_MDB_ENABLE, mdb_enable);
- sound_set(SOUND_SUPERBASS, superbass);
-#endif
-
- playing = false;
- paused = true;
-}
-
-void mp3_shutdown(void)
-{
-#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
- unsigned long val = 1;
- mas_writemem(MAS_BANK_D0, MAS_D0_SOFT_MUTE, &val, 1); /* Mute */
-#endif
-
-#if CONFIG_CODEC == MAS3507D
- dac_volume(0, 0, false);
-#endif
-}
-
-/* new functions, to be exported to plugin API */
-
-#if CONFIG_CODEC == MAS3587F
-void mp3_play_init(void)
-{
-#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
- init_playback();
-#endif
- playing = false;
- paused = true;
- callback_for_more = NULL;
-}
-#endif
-
-void mp3_play_data(const void* start, size_t size,
- mp3_play_callback_t get_more)
-{
- /* init DMA */
- DAR3 = 0x5FFFEC3;
- CHCR3 &= ~0x0002; /* Clear interrupt */
- CHCR3 = 0x1504; /* Single address destination, TXI0, IE=1 */
- DMAOR = 0x0001; /* Enable DMA */
-
- callback_for_more = get_more;
-
- SAR3 = (unsigned int)start;
- DTCR3 = size & 0xffff;
-
- playing = true;
- paused = true;
-
- CHCR3 |= 0x0001; /* Enable DMA IRQ */
-
-#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
- demand_irq_enable(true);
-#endif
-}
-
-void mp3_play_pause(bool play)
-{
- if (paused && play)
- { /* resume playback */
- SCR0 |= 0x80;
- paused = false;
- }
- else if (!paused && !play)
- { /* stop playback */
- SCR0 &= 0x7f;
- paused = true;
- }
-}
-
-bool mp3_pause_done(void)
-{
- unsigned long frame_count;
-
- if (!paused)
- return false;
-
- mas_readmem(MAS_BANK_D0, MAS_D0_MPEG_FRAME_COUNT, &frame_count, 1);
- /* This works because the frame counter never wraps,
- * i.e. zero always means lost sync. */
- return frame_count == 0;
-}
-
-void mp3_play_stop(void)
-{
- playing = false;
- mp3_play_pause(false);
- CHCR3 &= ~0x0001; /* Disable the DMA interrupt */
-#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
- demand_irq_enable(false);
-#endif
-}
-
-bool mp3_is_playing(void)
-{
- return playing;
-}
-
-
-/* returns the next byte position which would be transferred */
-unsigned char* mp3_get_pos(void)
-{
- return (unsigned char*)SAR3;
-}
diff --git a/firmware/target/sh/archos/boot.lds b/firmware/target/sh/archos/boot.lds
deleted file mode 100644
index b3c2c90a6c..0000000000
--- a/firmware/target/sh/archos/boot.lds
+++ /dev/null
@@ -1,81 +0,0 @@
-#include "config.h"
-
-ENTRY(start)
-OUTPUT_FORMAT(elf32-sh)
-STARTUP(target/sh/crt0.o)
-
-#define DRAMSIZE (MEMORYSIZE * 0x100000)
-
-#define DRAMORIG 0x09000000
-#define IRAMORIG 0x0f000000
-#define IRAMSIZE 0x1000
-#define FLASHORIG 0x02000000 + ROM_START
-#define FLASHSIZE 256K - ROM_START
-
-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 :
- {
- _edata = .;
- *(.ibss)
- *(.bss*)
- *(COMMON)
- _end = .;
- } > IRAM
-}
diff --git a/firmware/target/sh/archos/descramble.S b/firmware/target/sh/archos/descramble.S
deleted file mode 100644
index 0ab5e93dce..0000000000
--- a/firmware/target/sh/archos/descramble.S
+++ /dev/null
@@ -1,121 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2004 by Jens Arnold
- *
- * 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.
- *
- ****************************************************************************/
-
- .section .icode,"ax",@progbits
-
- .align 2 /* this aligns to 2^2=4 byte bounday */
- .global _descramble
- .type _descramble,@function
-
-/* Descramble a block of byte data, from source to dest, processing len
- * bytes. Size only limited by the len argument. Note that len must
- * be an even multiple of 4 (something rolo_load() already assumes.
- * (Does the Archos firmware loader also require that?).
- *
- * Returns the 16-bit "sum" checksum of the descrambled data.
- *
- * Arguments:
- * r4 - source (unsigned char*)
- * r5 - dest (unsigned char*)
- * r6 - len (unsigned int)
- *
- * Register usage:
- * r0 - data
- * r1 - temp
- * r2 - checksum
- * r3 - current src address
- * r4 - source
- * r5 - dest
- * r6 - len -> source_end
- * r7 - dest_end
- * r8 - len / 4
- */
-
-_descramble:
- mov.l r8,@-r15
- mov r6,r8
- shlr2 r8 /* r8 = len / 4 */
- mov r5,r7
- add r6,r7 /* dest_end = dest + len */
- add r4,r6 /* source_end = source + len */
- mov r4,r3 /* addr = source */
- mov #0,r2 /* checksum = 0 */
-
-.loop:
- mov.b @r3,r0 /* data = *addr */
- add r8,r3 /* addr += len / 4 */
- extu.b r0,r0 /* zero extend data byte */
- swap.b r0,r1 /* byte swap low word to temp */
- or r1,r0 /* r0's two lower bytes now identical */
- shlr r0 /* -> this equals "rotr.b r0" now */
- not r0,r0 /* negate */
- extu.b r0,r0 /* zero extend low byte (only needed for sum) */
- mov.b r0,@r5 /* *dest = data */
- add r0,r2 /* checksum += data */
- add #1,r5 /* dest++ */
- cmp/hi r3,r6 /* addr < source_end ? */
- bt .loop
-
- add #1,r4 /* source++ */
- mov r4,r3 /* addr = source */
- cmp/hi r5,r7 /* dest < dest_end */
- bt .loop
-
-/* 15 clock cycles if no reset of source address, 19 if reset,
- * avg. 16 cycles per byte. Magnus' Version needed 17-22 cycles per byte
- */
-
- mov.l @r15+,r8
- rts
- extu.w r2,r0
-
-
-/* Move len bytes from source to dest (which must be suitably aligned for
- * long moves) and jump to dest + 0x200.
- *
- * Arguments:
- * r4 - source
- * r5 - dest
- * r6 - len
- */
-
- .align 2
- .global _rolo_restart
- .type _rolo_restart,@function
-
-_rolo_restart:
- mov r5,r0
- sub r4,r0 /* r0 = dest - source */
- add #-4,r0 /* adjust for early increment */
- add r4,r6 /* r6 = source + len */
-
-.copy: /* loop takes 6 cycles per longword */
- mov.l @r4+,r1
- cmp/hi r4,r6
- mov.l r1,@(r0,r4)
- bt .copy
-
- mov.l @r5+,r0 /* start address from image */
- jmp @r0
- mov.l @r5+,r15 /* stack pointer from image */
-
-.end:
- .size _descramble,.end-_descramble
diff --git a/firmware/target/sh/archos/fm_v2/adc-target.h b/firmware/target/sh/archos/fm_v2/adc-target.h
deleted file mode 100644
index 0070828cf3..0000000000
--- a/firmware/target/sh/archos/fm_v2/adc-target.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2002 by Linus Nielsen Feltzing
- *
- * 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 8
-
-#define ADC_BATTERY 0 /* Battery voltage always reads 0x3FF due to
- silly scaling */
-#define ADC_CHARGE_REGULATOR 0 /* Uh, we read the battery voltage? */
-#define ADC_USB_POWER 1 /* USB, reads 0x000 when USB is inserted */
-#define ADC_BUTTON_OFF 2 /* the off button, high value if pressed */
-#define ADC_BUTTON_ON 3 /* the on button, low value if pressed */
-#define ADC_BUTTON_ROW1 4 /* Used for scanning the keys, different
- voltages for different keys */
-#define ADC_BUTTON_ROW2 5 /* Used for scanning the keys, different
- voltages for different keys */
-#define ADC_UNREG_POWER 6 /* Battery voltage with a better scaling */
-#define ADC_EXT_POWER 7 /* The external power voltage, 0v or 2.7v */
-
-#define EXT_SCALE_FACTOR 14800
-
-#endif /* _ADC_TARGET_H_ */
diff --git a/firmware/target/sh/archos/fm_v2/backlight-target.h b/firmware/target/sh/archos/fm_v2/backlight-target.h
deleted file mode 100644
index c3dd395eca..0000000000
--- a/firmware/target/sh/archos/fm_v2/backlight-target.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2007 by Jens Arnold
- *
- * 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
-
-#include "config.h"
-#include "rtc.h"
-
-#define backlight_hw_init() true
-
-static inline void backlight_hw_on(void)
-{
- rtc_write(0x13, 0x10); /* 32 kHz square wave */
- rtc_write(0x0a, rtc_read(0x0a) | 0x40); /* Enable square wave */
-}
-
-static inline void backlight_hw_off(void)
-{
- /* While on, backlight is flashing at 32 kHz. If the square wave output
- is disabled while the backlight is lit, it will become constantly lit,
- (brighter) and slowly fade. This resets the square wave counter and
- results in the unlit state */
- unsigned char rtc_0a = rtc_read(0x0a) & ~0x40;
- rtc_write(0x0a, rtc_0a); /* Disable square wave */
- rtc_write(0x13, 0xF0); /* 1 Hz square wave */
- rtc_write(0x0a, rtc_0a | 0x40); /* Enable square wave */
-
- /* When the square wave output is disabled in the unlit state,
- the backlight stays off */
- rtc_write(0x0a, rtc_0a);
-}
-
-#endif
diff --git a/firmware/target/sh/archos/fm_v2/button-fm_v2.c b/firmware/target/sh/archos/fm_v2/button-fm_v2.c
deleted file mode 100644
index 458917d2d5..0000000000
--- a/firmware/target/sh/archos/fm_v2/button-fm_v2.c
+++ /dev/null
@@ -1,99 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2006 by Jens Arnold
- *
- * 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 "button.h"
-#include "backlight.h"
-#include "adc.h"
-
-/*
- Recorder FM/V2 hardware button hookup
- =====================================
-
- F1, F2, F3, UP: connected to AN4 through a resistor network
- DOWN, PLAY, LEFT, RIGHT: likewise connected to AN5
-
- The voltage on AN4/ AN5 depends on which keys (or key combo) is pressed
- FM/V2 has PLAY and RIGHT switched compared to plain recorder
-
- ON: AN3, low active
- OFF: AN2, high active
-*/
-
-void button_init_device(void)
-{
- /* Set PB4 and PB8 as input pins */
- PBCR1 &= 0xfffc; /* PB8MD = 00 */
- PBCR2 &= 0xfcff; /* PB4MD = 00 */
- PBIOR &= ~0x0110; /* Inputs */
-}
-
-int button_read_device(void)
-{
- int btn = BUTTON_NONE;
- int data;
-
- /* check F1..F3 and UP */
- data = adc_read(ADC_BUTTON_ROW1);
- if (data >= 150)
- {
- if (data >= 545)
- if (data >= 700)
- btn = BUTTON_F3;
- else
- btn = BUTTON_UP;
- else
- if (data >= 385)
- btn = BUTTON_F2;
- else
- btn = BUTTON_F1;
- }
-
- /* Some units have mushy keypads, so pressing UP also activates
- the Left/Right buttons. Let's combat that by skipping the AN5
- checks when UP is pressed. */
- if(!(btn & BUTTON_UP))
- {
- /* check DOWN, PLAY, LEFT, RIGHT */
- data = adc_read(ADC_BUTTON_ROW2);
- if (data >= 150)
- {
- if (data >= 545)
- if (data >= 700)
- btn |= BUTTON_DOWN;
- else
- btn |= BUTTON_RIGHT;
- else
- if (data >= 385)
- btn |= BUTTON_LEFT;
- else
- btn |= BUTTON_PLAY;
- }
- }
-
- if ( adc_read(ADC_BUTTON_ON) < 512 )
- btn |= BUTTON_ON;
- if ( adc_read(ADC_BUTTON_OFF) > 512 )
- btn |= BUTTON_OFF;
-
- return btn;
-}
diff --git a/firmware/target/sh/archos/fm_v2/button-target.h b/firmware/target/sh/archos/fm_v2/button-target.h
deleted file mode 100644
index 47eb48c32d..0000000000
--- a/firmware/target/sh/archos/fm_v2/button-target.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2006 by Jens Arnold
- *
- * 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_
-
- /* Main unit's buttons */
-#define BUTTON_ON 0x00000001
-#define BUTTON_OFF 0x00000002
-
-#define BUTTON_LEFT 0x00000004
-#define BUTTON_RIGHT 0x00000008
-#define BUTTON_UP 0x00000010
-#define BUTTON_DOWN 0x00000020
-
-#define BUTTON_PLAY 0x00000040
-
-#define BUTTON_F1 0x00000080
-#define BUTTON_F2 0x00000100
-#define BUTTON_F3 0x00000200
-
-#define BUTTON_MAIN (BUTTON_ON|BUTTON_OFF|BUTTON_LEFT|BUTTON_RIGHT\
- |BUTTON_UP|BUTTON_DOWN|BUTTON_PLAY\
- |BUTTON_F1|BUTTON_F2|BUTTON_F3)
-
-#define POWEROFF_BUTTON BUTTON_OFF
-#define POWEROFF_COUNT 10
-
-#endif /* _BUTTON_TARGET_H_ */
diff --git a/firmware/target/sh/archos/fm_v2/power-fm_v2.c b/firmware/target/sh/archos/fm_v2/power-fm_v2.c
deleted file mode 100644
index ce1ef19970..0000000000
--- a/firmware/target/sh/archos/fm_v2/power-fm_v2.c
+++ /dev/null
@@ -1,115 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2002 by Linus Nielsen Feltzing
- *
- * 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 <stdbool.h>
-#include "adc.h"
-#include "kernel.h"
-#include "system.h"
-#include "power.h"
-#include "usb.h"
-
-#if CONFIG_TUNER
-bool tuner_power(bool status)
-{
- (void)status;
- return true;
-}
-
-#endif /* #if CONFIG_TUNER */
-
-void power_init(void)
-{
- PBCR2 &= ~0x0c00; /* GPIO for PB5 */
- or_b(0x20, &PBIORL);
- or_b(0x20, &PBDRL); /* hold power */
-}
-
-unsigned int power_input_status(void)
-{
- unsigned int status = POWER_INPUT_NONE;
-
- /* FM or V2 can also charge from the USB port */
- if (adc_read(ADC_CHARGE_REGULATOR) < 0x1FF)
- status = POWER_INPUT_MAIN_CHARGER;
-
-#ifdef HAVE_USB_POWER
- if (usb_detect() == USB_INSERTED)
- status |= POWER_INPUT_USB_CHARGER;
-#endif
-
- return status;
-}
-
-/* Returns true if the unit is charging the batteries. */
-bool charging_state(void)
-{
- /* We use the information from the ADC_EXT_POWER ADC channel, which
- tells us the charging current from the LTC1734. When DC is
- connected (either via the external adapter, or via USB), we try
- to determine if it is actively charging or only maintaining the
- charge. My tests show that ADC readings below about 0x80 means
- that the LTC1734 is only maintaining the charge. */
- return adc_read(ADC_EXT_POWER) >= 0x80;
-}
-
-void ide_power_enable(bool on)
-{
- bool touched = false;
-
- if(on)
- {
- or_b(0x20, &PADRL);
- touched = true;
- }
-#ifdef HAVE_ATA_POWER_OFF
- if(!on)
- {
- and_b(~0x20, &PADRL);
- touched = true;
- }
-#endif /* HAVE_ATA_POWER_OFF */
-
-/* late port preparation, else problems with read/modify/write
- of other bits on same port, while input and floating high */
- if (touched)
- {
- or_b(0x20, &PAIORL); /* PA5 is an output */
- PACR2 &= 0xFBFF; /* GPIO for PA5 */
- }
-}
-
-
-bool ide_powered(void)
-{
- if ((PACR2 & 0x0400) || !(PAIORL & 0x20)) /* not configured for output */
- return true; /* would be floating high, disk on */
- else
- return (PADRL & 0x20) != 0;
-}
-
-void power_off(void)
-{
- disable_irq();
- and_b(~0x20, &PBDRL);
- or_b(0x20, &PBIORL);
- while(1);
-}
diff --git a/firmware/target/sh/archos/fm_v2/powermgmt-fm_v2.c b/firmware/target/sh/archos/fm_v2/powermgmt-fm_v2.c
deleted file mode 100644
index 5dd7f26d2f..0000000000
--- a/firmware/target/sh/archos/fm_v2/powermgmt-fm_v2.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2002 by Heikki Hannikainen, Uwe Freese
- * Revisions copyright (C) 2005 by Gerald Van Baren
- *
- * 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] =
-{
- 2800
-};
-
-const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
-{
- 2580
-};
-
-/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
-const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
-{
- /* measured values */
- { 2600, 2850, 2950, 3030, 3110, 3200, 3300, 3450, 3600, 3800, 4000 }
-};
-
-/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */
-const unsigned short percent_to_volt_charge[11] =
-{
- /* TODO: This is identical to the discharge curve.
- * Calibrate charging curve using a battery_bench log. */
- 2600, 2850, 2950, 3030, 3110, 3200, 3300, 3450, 3600, 3800, 4000
-};
-
-/* Battery scale factor (guessed, seems to be 1,25 * value from recorder) */
-#define BATTERY_SCALE_FACTOR 8275
-/* full-scale ADC readout (2^10) in millivolt */
-
-/* Returns battery voltage from ADC [millivolts] */
-int _battery_voltage(void)
-{
- return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10;
-}
diff --git a/firmware/target/sh/archos/fm_v2/usb-fm_v2.c b/firmware/target/sh/archos/fm_v2/usb-fm_v2.c
deleted file mode 100644
index 5b11d778b6..0000000000
--- a/firmware/target/sh/archos/fm_v2/usb-fm_v2.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2007 by Jens Arnold
- *
- * 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 <stdbool.h>
-#include "adc.h"
-#include "cpu.h"
-#include "hwcompat.h"
-#include "system.h"
-#include "usb.h"
-
-int usb_detect(void)
-{
- return (adc_read(ADC_USB_POWER) <= 512) ? USB_INSERTED : USB_EXTRACTED;
-}
-
-void usb_enable(bool on)
-{
- if(HW_MASK & USB_ACTIVE_HIGH)
- on = !on;
-
- if(on)
- and_b(~0x04, &PADRH); /* enable USB */
- else
- or_b(0x04, &PADRH);
-}
-
-void usb_init_device(void)
-{
- usb_enable(false);
- or_b(0x04, &PAIORH);
-}
diff --git a/firmware/target/sh/archos/i2c-archos.c b/firmware/target/sh/archos/i2c-archos.c
deleted file mode 100644
index 5b415926f2..0000000000
--- a/firmware/target/sh/archos/i2c-archos.c
+++ /dev/null
@@ -1,254 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2002 by Linus Nielsen Feltzing
- *
- * 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 "lcd.h"
-#include "cpu.h"
-#include "kernel.h"
-#include "thread.h"
-#include "debug.h"
-#include "system.h"
-#include "i2c.h"
-
-/* cute little functions, atomic read-modify-write */
-
-/* SDA is PB7 */
-#define SDA_LO and_b(~0x80, &PBDRL)
-#define SDA_HI or_b(0x80, &PBDRL)
-#define SDA_INPUT and_b(~0x80, &PBIORL)
-#define SDA_OUTPUT or_b(0x80, &PBIORL)
-#define SDA (PBDRL & 0x80)
-
-#if CONFIG_I2C == I2C_ONDIO
-/* Ondio pinout, SCL moved to PB6 */
-#define SCL_INPUT and_b(~0x40, &PBIORL)
-#define SCL_OUTPUT or_b(0x40, &PBIORL)
-#define SCL_LO and_b(~0x40, &PBDRL)
-#define SCL_HI or_b(0x40, &PBDRL)
-#define SCL (PBDRL & 0x40)
-#else
-/* "classic" pinout, SCL is PB13 */
-#define SCL_INPUT and_b(~0x20, &PBIORH)
-#define SCL_OUTPUT or_b(0x20, &PBIORH)
-#define SCL_LO and_b(~0x20, &PBDRH)
-#define SCL_HI or_b(0x20, &PBDRH)
-#define SCL (PBDRH & 0x20)
-#endif
-
-/* arbitrary delay loop */
-#define DELAY do { int _x; for(_x=0;_x<20;_x++);} while (0)
-
-static struct mutex i2c_mtx SHAREDBSS_ATTR;
-
-void i2c_begin(void)
-{
- mutex_lock(&i2c_mtx);
-}
-
-void i2c_end(void)
-{
- mutex_unlock(&i2c_mtx);
-}
-
-void i2c_start(void)
-{
- SDA_OUTPUT;
- SDA_HI;
- SCL_HI;
- SDA_LO;
- DELAY;
- SCL_LO;
-}
-
-void i2c_stop(void)
-{
- SDA_LO;
- SCL_HI;
- DELAY;
- SDA_HI;
-}
-
-void i2c_init(void)
-{
- int i;
-
- mutex_init(&i2c_mtx);
-
-#if CONFIG_I2C == I2C_ONDIO
- /* make PB6 & PB7 general I/O */
- PBCR2 &= ~0xf000;
-#else /* not Ondio */
- /* make PB7 & PB13 general I/O */
- PBCR1 &= ~0x0c00; /* PB13 */
- PBCR2 &= ~0xc000; /* PB7 */
-#endif
-
- SCL_OUTPUT;
- SDA_OUTPUT;
- SDA_HI;
- SCL_LO;
- for (i=0;i<3;i++)
- i2c_stop();
-}
-
-void i2c_ack(int bit)
-{
- /* Here's the deal. The MAS is slow, and sometimes needs to wait
- before it can receive the acknowledge. Therefore it forces the clock
- low until it is ready. We need to poll the clock line until it goes
- high before we release the ack. */
-
- SCL_LO; /* Set the clock low */
- if ( bit )
- {
- SDA_HI;
- }
- else
- {
- SDA_LO;
- }
-
- SCL_INPUT; /* Set the clock to input */
- while(!SCL) /* and wait for the MAS to release it */
- sleep(0);
-
- DELAY;
- SCL_OUTPUT;
- SCL_LO;
-}
-
-int i2c_getack(void)
-{
- int ret = 1;
-
- /* Here's the deal. The MAS is slow, and sometimes needs to wait
- before it can send the acknowledge. Therefore it forces the clock
- low until it is ready. We need to poll the clock line until it goes
- high before we read the ack. */
-
-#ifdef HAVE_I2C_LOW_FIRST
- SDA_LO; /* First, discharge the data line */
-#endif
- SDA_INPUT; /* And set to input */
- SCL_INPUT; /* Set the clock to input */
- while(!SCL) /* and wait for the MAS to release it */
- sleep(0);
-
- if (SDA)
- /* ack failed */
- ret = 0;
-
- SCL_OUTPUT;
- SCL_LO;
- SDA_HI;
- SDA_OUTPUT;
- return ret;
-}
-
-void i2c_outb(unsigned char byte)
-{
- int i;
-
- /* clock out each bit, MSB first */
- for ( i=0x80; i; i>>=1 ) {
- if ( i & byte )
- {
- SDA_HI;
- }
- else
- {
- SDA_LO;
- }
- SCL_HI;
- SCL_LO;
- }
-
- SDA_HI;
-}
-
-unsigned char i2c_inb(int ack)
-{
- int i;
- unsigned char byte = 0;
-
- /* clock in each bit, MSB first */
- for ( i=0x80; i; i>>=1 ) {
-#ifdef HAVE_I2C_LOW_FIRST
- /* Tricky business. Here we discharge the data line by driving it low
- and then set it to input to see if it stays low or goes high */
- SDA_LO; /* First, discharge the data line */
-#endif
- SDA_INPUT; /* And set to input */
- SCL_HI;
- if ( SDA )
- byte |= i;
- SCL_LO;
- SDA_OUTPUT;
- }
-
- i2c_ack(ack);
-
- return byte;
-}
-
-int i2c_write(int address, const unsigned char* buf, int count )
-{
- int i,x=0;
-
- i2c_start();
- i2c_outb(address & 0xfe);
- if (i2c_getack())
- {
- for (i=0; i<count; i++)
- {
- i2c_outb(buf[i]);
- if (!i2c_getack())
- {
- x=-2;
- break;
- }
- }
- }
- else
- {
- debugf("i2c_write() - no ack\n");
- x=-1;
- }
- i2c_stop();
- return x;
-}
-
-#if 0 /* Currently unused, left for reference and future use */
-int i2c_read(int address, unsigned char* buf, int count )
-{
- int i,x=0;
-
- i2c_start();
- i2c_outb(address | 1);
- if (i2c_getack()) {
- for (i=0; i<count; i++) {
- buf[i] = i2c_inb(0);
- }
- }
- else
- x=-1;
- i2c_stop();
- return x;
-}
-#endif
diff --git a/firmware/target/sh/archos/lcd-archos-bitmap.c b/firmware/target/sh/archos/lcd-archos-bitmap.c
deleted file mode 100644
index f23289053d..0000000000
--- a/firmware/target/sh/archos/lcd-archos-bitmap.c
+++ /dev/null
@@ -1,224 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2002 by Alan Korr
- *
- * 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 "hwcompat.h"
-#include "kernel.h"
-#include "lcd.h"
-#include "system.h"
-
-/*** definitions ***/
-
-#define LCD_SET_LOWER_COLUMN_ADDRESS ((char)0x00)
-#define LCD_SET_HIGHER_COLUMN_ADDRESS ((char)0x10)
-#define LCD_SET_INTERNAL_REGULATOR_RESISTOR_RATIO ((char)0x20)
-#define LCD_SET_POWER_CONTROL_REGISTER ((char)0x28)
-#define LCD_SET_DISPLAY_START_LINE ((char)0x40)
-#define LCD_SET_CONTRAST_CONTROL_REGISTER ((char)0x81)
-#define LCD_SET_SEGMENT_REMAP ((char)0xA0)
-#define LCD_SET_LCD_BIAS ((char)0xA2)
-#define LCD_SET_ENTIRE_DISPLAY_OFF ((char)0xA4)
-#define LCD_SET_ENTIRE_DISPLAY_ON ((char)0xA5)
-#define LCD_SET_NORMAL_DISPLAY ((char)0xA6)
-#define LCD_SET_REVERSE_DISPLAY ((char)0xA7)
-#define LCD_SET_MULTIPLEX_RATIO ((char)0xA8)
-#define LCD_SET_BIAS_TC_OSC ((char)0xA9)
-#define LCD_SET_1OVER4_BIAS_RATIO ((char)0xAA)
-#define LCD_SET_INDICATOR_OFF ((char)0xAC)
-#define LCD_SET_INDICATOR_ON ((char)0xAD)
-#define LCD_SET_DISPLAY_OFF ((char)0xAE)
-#define LCD_SET_DISPLAY_ON ((char)0xAF)
-#define LCD_SET_PAGE_ADDRESS ((char)0xB0)
-#define LCD_SET_COM_OUTPUT_SCAN_DIRECTION ((char)0xC0)
-#define LCD_SET_TOTAL_FRAME_PHASES ((char)0xD2)
-#define LCD_SET_DISPLAY_OFFSET ((char)0xD3)
-#define LCD_SET_READ_MODIFY_WRITE_MODE ((char)0xE0)
-#define LCD_SOFTWARE_RESET ((char)0xE2)
-#define LCD_NOP ((char)0xE3)
-#define LCD_SET_END_OF_READ_MODIFY_WRITE_MODE ((char)0xEE)
-
-/* LCD command codes */
-#define LCD_CNTL_RESET 0xe2 /* Software reset */
-#define LCD_CNTL_POWER 0x2f /* Power control */
-#define LCD_CNTL_CONTRAST 0x81 /* Contrast */
-#define LCD_CNTL_OUTSCAN 0xc8 /* Output scan direction */
-#define LCD_CNTL_SEGREMAP 0xa1 /* Segment remap */
-#define LCD_CNTL_DISPON 0xaf /* Display on */
-
-#define LCD_CNTL_PAGE 0xb0 /* Page address */
-#define LCD_CNTL_HIGHCOL 0x10 /* Upper column address */
-#define LCD_CNTL_LOWCOL 0x00 /* Lower column address */
-
-/** globals **/
-
-static int xoffset; /* needed for flip */
-
-/*** hardware configuration ***/
-
-int lcd_default_contrast(void)
-{
- return (HW_MASK & LCD_CONTRAST_BIAS) ? 31 : 49;
-}
-
-void lcd_set_contrast(int val)
-{
- lcd_write_command(LCD_CNTL_CONTRAST);
- lcd_write_command(val);
-}
-
-void lcd_set_invert_display(bool yesno)
-{
- if (yesno)
- lcd_write_command(LCD_SET_REVERSE_DISPLAY);
- else
- lcd_write_command(LCD_SET_NORMAL_DISPLAY);
-}
-
-/* turn the display upside down (call lcd_update() afterwards) */
-void lcd_set_flip(bool yesno)
-{
-#ifdef HAVE_DISPLAY_FLIPPED
- if (!yesno)
-#else
- if (yesno)
-#endif
- {
- lcd_write_command(LCD_SET_SEGMENT_REMAP);
- lcd_write_command(LCD_SET_COM_OUTPUT_SCAN_DIRECTION);
- xoffset = 132 - LCD_WIDTH; /* 132 colums minus the 112 we have */
- }
- else
- {
- lcd_write_command(LCD_SET_SEGMENT_REMAP | 0x01);
- lcd_write_command(LCD_SET_COM_OUTPUT_SCAN_DIRECTION | 0x08);
- xoffset = 0;
- }
-}
-
-void lcd_init_device(void)
-{
- /* Initialize PB0-3 as output pins */
- PBCR2 &= 0xff00; /* MD = 00 */
- PBIOR |= 0x000f; /* IOR = 1 */
-
- /* inits like the original firmware */
- lcd_write_command(LCD_SOFTWARE_RESET);
- lcd_write_command(LCD_SET_INTERNAL_REGULATOR_RESISTOR_RATIO + 4);
- lcd_write_command(LCD_SET_1OVER4_BIAS_RATIO + 0); /* force 1/4 bias: 0 */
- lcd_write_command(LCD_SET_POWER_CONTROL_REGISTER + 7);
- /* power control register: op-amp=1, regulator=1, booster=1 */
- lcd_write_command(LCD_SET_DISPLAY_ON);
- lcd_write_command(LCD_SET_NORMAL_DISPLAY);
- lcd_set_flip(false);
- lcd_write_command(LCD_SET_DISPLAY_START_LINE + 0);
- lcd_set_contrast(lcd_default_contrast());
- lcd_write_command(LCD_SET_PAGE_ADDRESS);
- lcd_write_command(LCD_SET_LOWER_COLUMN_ADDRESS + 0);
- lcd_write_command(LCD_SET_HIGHER_COLUMN_ADDRESS + 0);
-
- lcd_clear_display();
- lcd_update();
-}
-
-/*** Update functions ***/
-
-/* Performance function that works with an external buffer
- note that by and bheight are in 8-pixel units! */
-void lcd_blit_mono(const unsigned char *data, int x, int by, int width,
- int bheight, int stride)
-{
- /* Copy display bitmap to hardware */
- while (bheight--)
- {
- lcd_write_command (LCD_CNTL_PAGE | (by++ & 0xf));
- lcd_write_command (LCD_CNTL_HIGHCOL | (((x+xoffset)>>4) & 0xf));
- lcd_write_command (LCD_CNTL_LOWCOL | ((x+xoffset) & 0xf));
-
- lcd_write_data(data, width);
- data += stride;
- }
-}
-
-/* Helper function for lcd_grey_phase_blit(). */
-void lcd_grey_data(unsigned char *values, unsigned char *phases, int count);
-
-/* Performance function that works with an external buffer
- note that by and bheight are in 8-pixel units! */
-void lcd_blit_grey_phase(unsigned char *values, unsigned char *phases,
- int x, int by, int width, int bheight, int stride)
-{
- stride <<= 3; /* 8 pixels per block */
- while (bheight--)
- {
- lcd_write_command (LCD_CNTL_PAGE | (by++ & 0xf));
- lcd_write_command (LCD_CNTL_HIGHCOL | (((x+xoffset)>>4) & 0xf));
- lcd_write_command (LCD_CNTL_LOWCOL | ((x+xoffset) & 0xf));
-
- lcd_grey_data(values, phases, width);
- values += stride;
- phases += stride;
- }
-}
-
-
-/* Update the display.
- This must be called after all other LCD functions that change the display. */
-void lcd_update(void)
-{
- int y;
-
- /* Copy display bitmap to hardware */
- for (y = 0; y < LCD_FBHEIGHT; y++)
- {
- lcd_write_command (LCD_CNTL_PAGE | (y & 0xf));
- lcd_write_command (LCD_CNTL_HIGHCOL | ((xoffset >> 4) & 0xf));
- lcd_write_command (LCD_CNTL_LOWCOL | (xoffset & 0xf));
-
- lcd_write_data (FBADDR(0, y), LCD_WIDTH);
- }
-}
-
-/* Update a fraction of the display. */
-void lcd_update_rect(int x, int y, int width, int height)
-{
- int ymax;
-
- /* 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_CNTL_PAGE | (y & 0xf));
- lcd_write_command (LCD_CNTL_HIGHCOL | (((x+xoffset) >> 4) & 0xf));
- lcd_write_command (LCD_CNTL_LOWCOL | ((x+xoffset) & 0xf));
-
- lcd_write_data (FBADDR(x,y), width);
- }
-}
diff --git a/firmware/target/sh/archos/lcd-as-archos-bitmap.S b/firmware/target/sh/archos/lcd-as-archos-bitmap.S
deleted file mode 100644
index 0396483737..0000000000
--- a/firmware/target/sh/archos/lcd-as-archos-bitmap.S
+++ /dev/null
@@ -1,354 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2004 by Jens Arnold
- * Based on the work of Alan Korr and Jörg Hohensohn
- *
- * 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 LCDR (PBDR_ADDR+1)
-
-#define LCD_SD 1 /* PB0 = 1 --- 0001 */
-#define LCD_SC 2 /* PB1 = 1 --- 0010 */
-#define LCD_DS 4 /* PB2 = 1 --- 0100 */
-#define LCD_CS 8 /* PB3 = 1 --- 1000 */
-
-/*
- * About /CS,DS,SC,SD
- * ------------------
- *
- * LCD on JBP and JBR uses a SPI protocol to receive orders (SDA and SCK lines)
- *
- * - /CS -> Chip Selection line :
- * 0 : LCD chipset is activated.
- * - DS -> Data Selection line, latched at the rising edge
- * of the 8th serial clock (*) :
- * 0 : instruction register,
- * 1 : data register;
- * - SC -> Serial Clock line (SDA).
- * - SD -> Serial Data line (SCK), latched at the rising edge
- * of each serial clock (*).
- *
- * _ _
- * /CS \ /
- * \______________________________________________________/
- * _____ ____ ____ ____ ____ ____ ____ ____ ____ _____
- * SD \/ D7 \/ D6 \/ D5 \/ D4 \/ D3 \/ D2 \/ D1 \/ D0 \/
- * _____/\____/\____/\____/\____/\____/\____/\____/\____/\_____
- *
- * _____ _ _ _ _ _ _ _ ________
- * SC \ * \ * \ * \ * \ * \ * \ * \ *
- * \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/
- * _ _________________________________________________________
- * DS \/
- * _/\_________________________________________________________
- *
- */
-
- .section .icode,"ax",@progbits
-
- .align 2
- .global _lcd_write_command
- .type _lcd_write_command,@function
-
-/* Write a command byte to the lcd controller
- *
- * Arguments:
- * r4 - data byte (int)
- *
- * Register usage:
- * r0 - scratch
- * r1 - data byte (copied)
- * r2 - precalculated port value (CS, DS and SC low, SD high),
- * negated (neg)!
- * r3 - lcd port address
- * r5 - 1 (byte count for reuse of the loop in _lcd_write_data)
- */
-
-_lcd_write_command:
- mov.l .lcdr, r3 /* put lcd data port address in r3 */
- mov r4, r1 /* copy data byte to r1 */
-
- /* This code will fail if an interrupt changes the contents of PBDRL.
- * If so, we must disable the interrupt here. */
-
- mov.b @r3, r0 /* r0 = PBDRL */
- mov #0, r5 /* fake end address - stop after first iteration */
- or #(LCD_SD), r0 /* r0 |= LCD_SD */
- and #(~(LCD_CS|LCD_DS|LCD_SC)), r0 /* r0 &= ~(LCD_CS|LCD_DS|LCD_SC) */
-
- bra .single_transfer /* jump into the transfer loop */
- neg r0, r2 /* r2 = 0 - r0 */
-
-
- .align 2
- .global _lcd_write_data
- .type _lcd_write_data,@function
-
-/* A high performance function to write data to the display,
- * one or multiple bytes.
- *
- * Arguments:
- * r4 - data address
- * r5 - byte count
- *
- * Register usage:
- * r0 - scratch
- * r1 - current data byte
- * r2 - precalculated port value (CS and SC low, DS and SD high),
- * negated (neg)!
- * r3 - lcd port address
- */
-
-_lcd_write_data:
- mov.l .lcdr, r3 /* put lcd data port address in r3 */
- add r4, r5 /* end address */
-
- /* This code will fail if an interrupt changes the contents of PBDRL.
- * If so, we must disable the interrupt here. If disabling interrupts
- * for a long time (~9200 clks = ~830 µs for transferring 112 bytes on
- * recorders)is undesirable, the loop has to be rewritten to
- * disable/precalculate/transfer/enable for each iteration. However,
- * this would significantly decrease performance. */
-
- mov.b @r3, r0 /* r0 = PBDRL */
- or #(LCD_DS|LCD_SD), r0 /* r0 |= LCD_DS|LCD_SD */
- and #(~(LCD_CS|LCD_SC)), r0 /* r0 &= ~(LCD_CS|LCD_SC) */
- neg r0, r2 /* r2 = 0 - r0 */
-
- /* loop exploits that SD is on bit 0 for recorders and Ondios */
-
- .align 2
-.multi_transfer:
- mov.b @r4+, r1 /* load data byte from memory */
- nop
-
-.single_transfer:
- shll16 r1 /* shift data to most significant byte */
- shll8 r1
- not r1, r1 /* and invert for use with negc */
-
- shll r1 /* shift the MSB into carry */
- negc r2, r0 /* carry to SD, SC low */
- shll r1 /* next shift here for alignment */
- mov.b r0, @r3 /* set data to port */
- or #(LCD_SC), r0 /* rise SC (independent of SD level) */
- mov.b r0, @r3 /* set to port */
-
- negc r2, r0
- mov.b r0, @r3
- or #(LCD_SC), r0
- mov.b r0, @r3
-
- shll r1
- negc r2, r0
- shll r1
- mov.b r0, @r3
- or #(LCD_SC), r0
- mov.b r0, @r3
-
- negc r2, r0
- mov.b r0, @r3
- or #(LCD_SC), r0
- mov.b r0, @r3
-
- shll r1
- negc r2, r0
- shll r1
- mov.b r0, @r3
- or #(LCD_SC), r0
- mov.b r0, @r3
-
- negc r2, r0
- mov.b r0, @r3
- or #(LCD_SC), r0
- mov.b r0, @r3
-
- shll r1
- negc r2, r0
- shll r1
- mov.b r0, @r3
- or #(LCD_SC), r0
- mov.b r0, @r3
-
- negc r2, r0
- mov.b r0, @r3
- or #(LCD_SC), r0
- mov.b r0, @r3
-
- cmp/hi r4, r5 /* some blocks left? */
- bt .multi_transfer
-
- or #(LCD_CS|LCD_DS|LCD_SD|LCD_SC), r0 /* restore port */
- rts
- mov.b r0, @r3
-
- /* This is the place to reenable the interrupts, if we have disabled
- * them. See above. */
-
-#ifndef BOOTLOADER
- .align 2
- .global _lcd_grey_data
- .type _lcd_grey_data,@function
-
-/* A high performance function to write grey phase data to the display,
- * one or multiple pixels.
- *
- * Arguments:
- * r4 - pixel value data address
- * r5 - pixel phase data address
- * r6 - pixel block count
- *
- * Register usage:
- * r0 - scratch / phase signs mask
- * r1 - scratch
- * r2 - precalculated port value (CS and SC low, DS and SD high),
- * negated (neg)!
- * r3 - lcd port address
- * r4 - current value address
- * r5 - current phase address
- * r6 - end address
- * r7/r8 - current/next block of phases (alternating)
- * r9/r10 - current blocks of values
- * r11 - 0x00000080 \
- * r12 - 0x00008000 > for phase sign check
- * r13 - 0x00800000 /
- */
-
-_lcd_grey_data:
- mov.l r8, @-r15 /* save r8 */
- mov.l r9, @-r15 /* save r9 */
- mov.l r10, @-r15 /* save r10 */
- shll2 r6 /* v */
- mov.l r11, @-r15 /* save r11 */
- shll r6 /* r6 *= 8; (8 pixels per block) */
- mov.l .lcdr, r3 /* put lcd data port address in r3 */
- add r4, r6 /* end address */
-
- /* This code will fail if an interrupt changes the contents of PBDRL.
- * If so, we must disable the interrupt here. If disabling interrupts
- * for a long time is undesirable, the loop has to be rewritten to
- * disable/precalculate/transfer/enable for each iteration. However,
- * this would significantly decrease performance. */
-
- mov.b @r3, r0 /* r0 = PBDRL */
- or #(LCD_DS|LCD_SD), r0 /* r0 |= LCD_DS|LCD_SD */
- mov.l r12, @-r15 /* save r12 */
- and #(~(LCD_CS|LCD_SC)), r0 /* r0 &= ~(LCD_CS|LCD_SC) */
- mov.l r13, @-r15 /* save r13 */
- neg r0, r2 /* r2 = 0 - r0 */
-
- /* loop exploits that SD is on bit 0 for recorders and Ondios */
-
- mov.w .ptest, r11
- swap.b r11, r12
- mov.l @r5, r7
- swap.w r11, r13
- mov.l .pmask, r0
-
-.greyloop:
- cmp/pz r7
- mov.l @r4+, r9
- negc r2, r1
- mov.b r1, @r3
- add #(LCD_SC), r1
- mov.b r1, @r3
-
- tst r13, r7
- mov.l @r4+, r10
- negc r2, r1
- mov.b r1, @r3
- add #(LCD_SC), r1
- mov.b r1, @r3
-
- tst r12, r7
- mov.l @(4,r5), r8
- negc r2, r1
- mov.b r1, @r3
- add #(LCD_SC), r1
- mov.b r1, @r3
-
- tst r11, r7
- or r0, r7
- negc r2, r1
- mov.b r1, @r3
- add #(LCD_SC), r1
- mov.b r1, @r3
-
- cmp/pz r8
- sub r9, r7
- negc r2, r1
- mov.b r1, @r3
- add #(LCD_SC), r1
- mov.b r1, @r3
-
- tst r13, r8
- mov.l r7, @r5
- negc r2, r1
- mov.b r1, @r3
- add #(LCD_SC), r1
- mov.b r1, @r3
-
- tst r12, r8
- mov.l @(8,r5), r7
- negc r2, r1
- mov.b r1, @r3
- add #(LCD_SC), r1
- mov.b r1, @r3
-
- tst r11, r8
- or r0, r8
- negc r2, r1
- mov.b r1, @r3
- add #(LCD_SC), r1
- mov.b r1, @r3
-
- sub r10, r8
- mov.l r8, @(4,r5)
-
- add #8, r5
- cmp/hi r4, r6
- bt .greyloop
-
- mov.l @r15+, r13 /* restore r13 */
- mov #(LCD_CS|LCD_DS|LCD_SD|LCD_SC), r0
- mov.l @r15+, r12 /* restore r12 */
- or r0, r1 /* restore port */
- mov.l @r15+, r11 /* restore r11 */
- mov.l @r15+, r10 /* restore r10 */
- mov.l @r15+, r9 /* restore r9 */
- mov.l @r15+, r8 /* restore r8 */
- rts
- mov.b r1, @r3
-
- /* This is the place to reenable the interrupts, if we have disabled
- * them. See above. */
-
-.ptest:
- .short 0x0080
-
- .align 2
-.pmask:
- .long 0x80808080
-#endif
-
- .align 2
-.lcdr:
- .long LCDR
diff --git a/firmware/target/sh/archos/mascodec-archos.c b/firmware/target/sh/archos/mascodec-archos.c
deleted file mode 100644
index faa5c7ef2b..0000000000
--- a/firmware/target/sh/archos/mascodec-archos.c
+++ /dev/null
@@ -1,491 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2002 by Linus Nielsen Feltzing
- *
- * 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 "stdbool.h"
-#include "config.h"
-#include "sh7034.h"
-#include "i2c.h"
-#include "debug.h"
-#include "mas35xx.h"
-#include "kernel.h"
-#include "system.h"
-#include "hwcompat.h"
-
-static int mas_devread(unsigned long *dest, int len);
-
-#if 0 /* Currently unused, left for reference and future use */
-int mas_default_read(unsigned short *buf)
-{
- unsigned char *dest = (unsigned char *)buf;
- int ret = 0;
-
- i2c_begin();
-
- i2c_start();
- i2c_outb(MAS_DEV_WRITE);
- if (i2c_getack()) {
- i2c_outb(MAS_DATA_READ);
- if (i2c_getack()) {
- i2c_start();
- i2c_outb(MAS_DEV_READ);
- if (i2c_getack()) {
- dest[0] = i2c_inb(0);
- dest[1] = i2c_inb(1);
- }
- else
- ret = -3;
- }
- else
- ret = -2;
- }
- else
- ret = -1;
-
- i2c_stop();
-
- i2c_end();
- return ret;
-}
-#endif
-
-#if CONFIG_CODEC == MAS3507D
-int mas_run(unsigned short address)
-{
- int ret = 0;
- unsigned char buf[3];
-
- i2c_begin();
-
- buf[0] = MAS_DATA_WRITE;
- buf[1] = address >> 8;
- buf[2] = address & 0xff;
-
- /* send run command */
- if (i2c_write(MAS_DEV_WRITE,buf,3))
- {
- ret = -1;
- }
-
- i2c_end();
- return ret;
-}
-#endif
-
-/* note: 'len' is number of 32-bit words, not number of bytes! */
-int mas_readmem(int bank, int addr, unsigned long* dest, int len)
-{
- int ret = 0;
- unsigned char buf[7];
-
- i2c_begin();
-
- buf[0] = MAS_DATA_WRITE;
- buf[1] = bank?MAS_CMD_READ_D1_MEM:MAS_CMD_READ_D0_MEM;
- buf[2] = 0x00;
- buf[3] = (len & 0xff00) >> 8;
- buf[4] = len & 0xff;
- buf[5] = (addr & 0xff00) >> 8;
- buf[6] = addr & 0xff;
-
- /* send read command */
- if (i2c_write(MAS_DEV_WRITE,buf,7))
- {
- ret = -1;
- }
-
- ret = mas_devread(dest, len);
-
- i2c_end();
- return ret;
-}
-
-/* note: 'len' is number of 32-bit words, not number of bytes! */
-int mas_writemem(int bank, int addr, const unsigned long* src, int len)
-{
- int ret = 0;
- int i, j;
- unsigned char buf[60];
- const unsigned char* ptr = (const unsigned char*)src;
-
- i2c_begin();
-
- i=0;
- buf[i++] = MAS_DATA_WRITE;
- buf[i++] = bank?MAS_CMD_WRITE_D1_MEM:MAS_CMD_WRITE_D0_MEM;
- buf[i++] = 0x00;
- buf[i++] = (len & 0xff00) >> 8;
- buf[i++] = len & 0xff;
- buf[i++] = (addr & 0xff00) >> 8;
- buf[i++] = addr & 0xff;
-
- j = 0;
- while(len--) {
-#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
- buf[i++] = 0;
- buf[i++] = ptr[j+1];
- buf[i++] = ptr[j+2];
- buf[i++] = ptr[j+3];
-#else
- buf[i++] = ptr[j+2];
- buf[i++] = ptr[j+3];
- buf[i++] = 0;
- buf[i++] = ptr[j+1];
-#endif
- j += 4;
- }
-
- /* send write command */
- if (i2c_write(MAS_DEV_WRITE,buf,i))
- {
- ret = -1;
- }
-
- i2c_end();
- return ret;
-}
-
-int mas_readreg(int reg)
-{
- int ret = 0;
- unsigned char buf[16];
- unsigned long value;
-
- i2c_begin();
-
- buf[0] = MAS_DATA_WRITE;
- buf[1] = MAS_CMD_READ_REG | (reg >> 4);
- buf[2] = (reg & 0x0f) << 4;
-
- /* send read command */
- if (i2c_write(MAS_DEV_WRITE,buf,3))
- {
- ret = -1;
- }
- else
- {
- if(mas_devread(&value, 1))
- {
- ret = -2;
- }
- else
- {
- ret = value;
- }
- }
-
- i2c_end();
- return ret;
-}
-
-int mas_writereg(int reg, unsigned int val)
-{
- int ret = 0;
- unsigned char buf[5];
-
- i2c_begin();
-
- buf[0] = MAS_DATA_WRITE;
- buf[1] = MAS_CMD_WRITE_REG | (reg >> 4);
-#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
- buf[2] = ((reg & 0x0f) << 4) | (val >> 16 & 0x0f);
- buf[3] = (val >> 8) & 0xff;
- buf[4] = val & 0xff;
-#else
- buf[2] = ((reg & 0x0f) << 4) | (val & 0x0f);
- buf[3] = (val >> 12) & 0xff;
- buf[4] = (val >> 4) & 0xff;
-#endif
-
- /* send write command */
- if (i2c_write(MAS_DEV_WRITE,buf,5))
- {
- ret = -1;
- }
-
- i2c_end();
- return ret;
-}
-
-/* note: 'len' is number of 32-bit words, not number of bytes! */
-static int mas_devread(unsigned long *dest, int len)
-{
- int ret = 0;
- unsigned char* ptr = (unsigned char*)dest;
- int i;
-
- /* handle read-back */
- /* Remember, the MAS values are only 20 bits, so we set
- the upper 12 bits to 0 */
- i2c_start();
- i2c_outb(MAS_DEV_WRITE);
- if (i2c_getack()) {
- i2c_outb(MAS_DATA_READ);
- if (i2c_getack()) {
- i2c_start();
- i2c_outb(MAS_DEV_READ);
- if (i2c_getack()) {
- for (i=0;len;i++) {
- len--;
-#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
- i2c_inb(0); /* Dummy read */
- ptr[i*4+0] = 0;
- ptr[i*4+1] = i2c_inb(0) & 0x0f;
- ptr[i*4+2] = i2c_inb(0);
- if(len)
- ptr[i*4+3] = i2c_inb(0);
- else
- ptr[i*4+3] = i2c_inb(1); /* NAK the last byte */
-#else
- ptr[i*4+2] = i2c_inb(0);
- ptr[i*4+3] = i2c_inb(0);
- ptr[i*4+0] = i2c_inb(0);
- if(len)
- ptr[i*4+1] = i2c_inb(0);
- else
- ptr[i*4+1] = i2c_inb(1); /* NAK the last byte */
-#endif
- }
- }
- else
- ret = -3;
- }
- else
- ret = -2;
- }
- else
- ret = -1;
-
- i2c_stop();
-
- return ret;
-}
-
-void mas_reset(void)
-{
- or_b(0x01, &PAIORH);
-
-#if CONFIG_CODEC == MAS3507D
- /* PB5 is "MAS enable". make it GPIO output and high */
- PBCR2 &= ~0x0c00;
- or_b(0x20, &PBIORL);
- or_b(0x20, &PBDRL);
-
- and_b(~0x01, &PADRH);
- sleep(HZ/100);
- or_b(0x01, &PADRH);
- sleep(HZ/5);
-#elif (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
- if (HW_MASK & ATA_ADDRESS_200)
- {
- and_b(~0x01, &PADRH);
- sleep(HZ/100);
- or_b(0x01, &PADRH);
- sleep(HZ/5);
- }
- else
- {
- /* Older recorder models don't invert the POR signal */
- or_b(0x01, &PADRH);
- sleep(HZ/100);
- and_b(~0x01, &PADRH);
- sleep(HZ/5);
- }
-#endif
-}
-
-#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
-#if 0 /* Currently unused, left for reference and future use */
-int mas_direct_config_read(unsigned char reg)
-{
- int ret = 0;
- unsigned char tmp[2];
-
- i2c_begin();
-
- i2c_start();
- i2c_outb(MAS_DEV_WRITE);
- if (i2c_getack()) {
- i2c_outb(reg);
- if (i2c_getack()) {
- i2c_start();
- i2c_outb(MAS_DEV_READ);
- if (i2c_getack()) {
- tmp[0] = i2c_inb(0);
- tmp[1] = i2c_inb(1); /* NAK the last byte */
- ret = (tmp[0] << 8) | tmp[1];
- }
- else
- ret = -3;
- }
- else
- ret = -2;
- }
- else
- ret = -1;
-
- i2c_stop();
-
- i2c_end();
- return ret;
-}
-#endif
-
-int mas_direct_config_write(unsigned char reg, unsigned int val)
-{
- int ret = 0;
- unsigned char buf[3];
-
- i2c_begin();
-
- buf[0] = reg;
- buf[1] = (val >> 8) & 0xff;
- buf[2] = val & 0xff;
-
- /* send write command */
- if (i2c_write(MAS_DEV_WRITE,buf,3))
- {
- ret = -1;
- }
-
- i2c_end();
- return ret;
-}
-
-int mas_codec_writereg(int reg, unsigned int val)
-{
- int ret = 0;
- unsigned char buf[5];
-
- i2c_begin();
-
- buf[0] = MAS_CODEC_WRITE;
- buf[1] = (reg >> 8) & 0xff;
- buf[2] = reg & 0xff;
- buf[3] = (val >> 8) & 0xff;
- buf[4] = val & 0xff;
-
- /* send write command */
- if (i2c_write(MAS_DEV_WRITE,buf,5))
- {
- ret = -1;
- }
-
- i2c_end();
- return ret;
-}
-
-int mas_codec_readreg(int reg)
-{
- int ret = 0;
- unsigned char buf[16];
- unsigned char tmp[2];
-
- i2c_begin();
-
- buf[0] = MAS_CODEC_WRITE;
- buf[1] = (reg >> 8) & 0xff;
- buf[2] = reg & 0xff;
-
- /* send read command */
- if (i2c_write(MAS_DEV_WRITE,buf,3))
- {
- ret = -1;
- }
- else
- {
- i2c_start();
- i2c_outb(MAS_DEV_WRITE);
- if (i2c_getack()) {
- i2c_outb(MAS_CODEC_READ);
- if (i2c_getack()) {
- i2c_start();
- i2c_outb(MAS_DEV_READ);
- if (i2c_getack()) {
- tmp[0] = i2c_inb(0);
- tmp[1] = i2c_inb(1); /* NAK the last byte */
- ret = (tmp[0] << 8) | tmp[1];
- }
- else
- ret = -4;
- }
- else
- ret = -3;
- }
- else
- ret = -2;
-
- i2c_stop();
- }
-
- i2c_end();
- return ret;
-}
-
-unsigned long mas_readver(void)
-{
- int ret = 0;
- unsigned char buf[16];
- unsigned long value;
-
- i2c_begin();
-
- buf[0] = MAS_DATA_WRITE;
- buf[1] = MAS_CMD_READ_IC_VER;
- buf[2] = 0;
-
- /* send read command */
- if (i2c_write(MAS_DEV_WRITE,buf,3))
- {
- ret = -1;
- }
- else
- {
- if(mas_devread(&value, 1))
- {
- ret = -2;
- }
- else
- {
- ret = value;
- }
- }
-
- i2c_end();
- return ret;
-}
-
-#endif
-
-#if CONFIG_TUNER & S1A0903X01
-static int pllfreq;
-
-void mas_store_pllfreq(int freq)
-{
- pllfreq = freq;
-}
-
-int mas_get_pllfreq(void)
-{
- return pllfreq;
-}
-#endif
-
-
-
diff --git a/firmware/target/sh/archos/ondio/adc-target.h b/firmware/target/sh/archos/ondio/adc-target.h
deleted file mode 100644
index a39ee110f3..0000000000
--- a/firmware/target/sh/archos/ondio/adc-target.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2002 by Linus Nielsen Feltzing
- *
- * 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 8
-
-#define ADC_MMC_SWITCH 0 /* low values if MMC inserted */
-#define ADC_USB_POWER 1 /* USB, reads 0x000 when USB is inserted */
-#define ADC_BUTTON_OPTION 2 /* the option button, low value if pressed */
-#define ADC_BUTTON_ONOFF 3 /* the on/off button, high value if pressed */
-#define ADC_BUTTON_ROW1 4 /* Used for scanning the keys, different
- voltages for different keys */
-#define ADC_USB_ACTIVE 5 /* USB bridge activity */
-#define ADC_UNREG_POWER 7 /* Battery voltage */
-
-#define EXT_SCALE_FACTOR 14800
-
-#endif /* _ADC_TARGET_H_ */
diff --git a/firmware/target/sh/archos/ondio/ata_mmc.c b/firmware/target/sh/archos/ondio/ata_mmc.c
deleted file mode 100644
index f252e1c4ce..0000000000
--- a/firmware/target/sh/archos/ondio/ata_mmc.c
+++ /dev/null
@@ -1,978 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2004 by Jens Arnold
- *
- * 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 "ata_mmc.h"
-#include "sdmmc.h"
-#include "kernel.h"
-#include "led.h"
-#include "sh7034.h"
-#include "system.h"
-#include "debug.h"
-#include "panic.h"
-#include "power.h"
-#include "string.h"
-#include "hwcompat.h"
-#include "adc.h"
-#include "bitswap.h"
-#include "storage.h"
-
-
-#ifdef HAVE_MULTIDRIVE
-#define MMC_NUM_DRIVES 2
-#else
-#define MMC_NUM_DRIVES 1
-#endif
-
-#define BLOCK_SIZE 512 /* fixed */
-
-/* Command definitions */
-#define CMD_GO_IDLE_STATE 0x40 /* R1 */
-#define CMD_SEND_OP_COND 0x41 /* R1 */
-#define CMD_SEND_CSD 0x49 /* R1 */
-#define CMD_SEND_CID 0x4a /* R1 */
-#define CMD_STOP_TRANSMISSION 0x4c /* R1 */
-#define CMD_SEND_STATUS 0x4d /* R2 */
-#define CMD_SET_BLOCKLEN 0x50 /* R1 */
-#define CMD_READ_SINGLE_BLOCK 0x51 /* R1 */
-#define CMD_READ_MULTIPLE_BLOCK 0x52 /* R1 */
-#define CMD_WRITE_BLOCK 0x58 /* R1b */
-#define CMD_WRITE_MULTIPLE_BLOCK 0x59 /* R1b */
-#define CMD_READ_OCR 0x7a /* R3 */
-
-/* Response formats:
- R1 = single byte, msb=0, various error flags
- R1b = R1 + busy token(s)
- R2 = 2 bytes (1st byte identical to R1), additional flags
- R3 = 5 bytes (R1 + OCR register)
-*/
-
-#define R1_PARAMETER_ERR 0x40
-#define R1_ADDRESS_ERR 0x20
-#define R1_ERASE_SEQ_ERR 0x10
-#define R1_COM_CRC_ERR 0x08
-#define R1_ILLEGAL_CMD 0x04
-#define R1_ERASE_RESET 0x02
-#define R1_IN_IDLE_STATE 0x01
-
-#define R2_OUT_OF_RANGE 0x80
-#define R2_ERASE_PARAM 0x40
-#define R2_WP_VIOLATION 0x20
-#define R2_CARD_ECC_FAIL 0x10
-#define R2_CC_ERROR 0x08
-#define R2_ERROR 0x04
-#define R2_ERASE_SKIP 0x02
-#define R2_CARD_LOCKED 0x01
-
-/* Data start tokens */
-
-#define DT_START_BLOCK 0xfe
-#define DT_START_WRITE_MULTIPLE 0xfc
-#define DT_STOP_TRAN 0xfd
-
-/* for compatibility */
-static long last_disk_activity = -1;
-
-/* private variables */
-
-#ifdef CONFIG_STORAGE_MULTI
-static int mmc_first_drive = 0;
-#else
-#define mmc_first_drive 0
-#endif
-
-static struct mutex mmc_mutex SHAREDBSS_ATTR;
-
-static bool initialized = false;
-static bool new_mmc_circuit;
-
-static enum {
- MMC_UNKNOWN,
- MMC_UNTOUCHED,
- MMC_TOUCHED
-} mmc_status = MMC_UNKNOWN;
-
-static enum {
- SER_POLL_WRITE,
- SER_POLL_READ,
- SER_DISABLED
-} serial_mode;
-
-static const unsigned char dummy[] = {
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
-};
-
-/* 2 buffers used alternatively for writing, including start token,
- * dummy CRC and an extra byte to keep word alignment. */
-static unsigned char write_buffer[2][BLOCK_SIZE+4];
-static int current_buffer = 0;
-static const unsigned char *send_block_addr = NULL;
-
-static tCardInfo card_info[2];
-#ifndef HAVE_MULTIDRIVE
-static int current_card = 0;
-#endif
-static bool last_mmc_status = false;
-static int countdown = -1; /* for mmc switch debouncing. -1 because the
- countdown should not happen if the card
- is inserted at boot */
-static bool usb_activity; /* monitoring the USB bridge */
-static long last_usb_activity;
-
-/* private function declarations */
-
-static int select_card(int card_no);
-static void deselect_card(void);
-static void setup_sci1(int bitrate_register);
-static void set_sci1_poll_read(void);
-static void write_transfer(const unsigned char *buf, int len)
- __attribute__ ((section(".icode")));
-static void read_transfer(unsigned char *buf, int len)
- __attribute__ ((section(".icode")));
-static unsigned char poll_byte(long timeout);
-static unsigned char poll_busy(long timeout);
-static unsigned char send_cmd(int cmd, unsigned long parameter, void *data);
-static int receive_cxd(unsigned char *buf);
-static int initialize_card(int card_no);
-static int receive_block(unsigned char *inbuf, long timeout);
-static void send_block_prepare(void);
-static int send_block_send(unsigned char start_token, long timeout,
- bool prepare_next);
-static void mmc_tick(void);
-
-/* implementation */
-
-static void enable_controller(bool on)
-{
- PBCR1 &= ~0x0CF0; /* PB13, PB11 and PB10 become GPIO,
- * if not modified below */
- if (on)
- PBCR1 |= 0x08A0; /* as SCK1, TxD1, RxD1 */
-
- and_b(~0x80, &PADRL); /* assert flash reset */
- sleep(HZ/100);
- or_b(0x80, &PADRL); /* de-assert flash reset */
- sleep(HZ/100);
- card_info[0].initialized = false;
- card_info[1].initialized = false;
-}
-
-void mmc_enable_int_flash_clock(bool on)
-{
- /* Internal flash clock is enabled by setting PA12 high with the new
- * clock circuit, and by setting it low with the old clock circuit */
- if (on ^ new_mmc_circuit)
- and_b(~0x10, &PADRH); /* clear clock gate PA12 */
- else
- or_b(0x10, &PADRH); /* set clock gate PA12 */
-}
-
-static int select_card(int card_no)
-{
- mutex_lock(&mmc_mutex);
- led(true);
- last_disk_activity = current_tick;
-
- mmc_enable_int_flash_clock(card_no == 0);
-
- if (!card_info[card_no].initialized)
- {
- setup_sci1(7); /* Initial rate: 375 kbps (need <= 400 per mmc specs) */
- write_transfer(dummy, 10); /* allow the card to synchronize */
- while (!(SSR1 & SCI_TEND));
- }
-
- if (card_no == 0) /* internal */
- and_b(~0x04, &PADRH); /* assert CS */
- else /* external */
- and_b(~0x02, &PADRH); /* assert CS */
-
- if (card_info[card_no].initialized)
- {
- setup_sci1(card_info[card_no].bitrate_register);
- return 0;
- }
- else
- {
- return initialize_card(card_no);
- }
-}
-
-static void deselect_card(void)
-{
- while (!(SSR1 & SCI_TEND)); /* wait for end of transfer */
- or_b(0x06, &PADRH); /* deassert CS (both cards) */
-
- led(false);
- mutex_unlock(&mmc_mutex);
- last_disk_activity = current_tick;
-}
-
-static void setup_sci1(int bitrate_register)
-{
- while (!(SSR1 & SCI_TEND)); /* wait for end of transfer */
-
- SCR1 = 0; /* disable serial port */
- SMR1 = SYNC_MODE; /* no prescale */
- BRR1 = bitrate_register;
- SSR1 = 0;
-
- SCR1 = SCI_TE; /* enable transmitter */
- serial_mode = SER_POLL_WRITE;
-}
-
-static void set_sci1_poll_read(void)
-{
- while (!(SSR1 & SCI_TEND)); /* wait for end of transfer */
- SCR1 = 0; /* disable transmitter (& receiver) */
- SCR1 = (SCI_TE|SCI_RE); /* re-enable transmitter & receiver */
- while (!(SSR1 & SCI_TEND)); /* wait for SCI init completion (!) */
- serial_mode = SER_POLL_READ;
- TDR1 = 0xFF; /* send do-nothing while reading */
-}
-
-static void write_transfer(const unsigned char *buf, int len)
-{
- const unsigned char *buf_end = buf + len;
- register unsigned char data;
-
- if (serial_mode != SER_POLL_WRITE)
- {
- while (!(SSR1 & SCI_TEND)); /* wait for end of transfer */
- SCR1 = 0; /* disable transmitter & receiver */
- SSR1 = 0; /* clear all flags */
- SCR1 = SCI_TE; /* enable transmitter only */
- serial_mode = SER_POLL_WRITE;
- }
-
- while (buf < buf_end)
- {
- data = fliptable[(signed char)(*buf++)]; /* bitswap */
- while (!(SSR1 & SCI_TDRE)); /* wait for end of transfer */
- TDR1 = data; /* write byte */
- SSR1 = 0; /* start transmitting */
- }
-}
-
-/* don't call this with len == 0 */
-static void read_transfer(unsigned char *buf, int len)
-{
- unsigned char *buf_end = buf + len - 1;
- register signed char data;
-
- if (serial_mode != SER_POLL_READ)
- set_sci1_poll_read();
-
- SSR1 = 0; /* start receiving first byte */
- while (buf < buf_end)
- {
- while (!(SSR1 & SCI_RDRF)); /* wait for data */
- data = RDR1; /* read byte */
- SSR1 = 0; /* start receiving */
- *buf++ = fliptable[data]; /* bitswap */
- }
- while (!(SSR1 & SCI_RDRF)); /* wait for last byte */
- *buf = fliptable[(signed char)(RDR1)]; /* read & bitswap */
-}
-
-/* returns 0xFF on timeout, timeout is in bytes */
-static unsigned char poll_byte(long timeout)
-{
- long i;
- unsigned char data = 0; /* stop the compiler complaining */
-
- if (serial_mode != SER_POLL_READ)
- set_sci1_poll_read();
-
- i = 0;
- do {
- SSR1 = 0; /* start receiving */
- while (!(SSR1 & SCI_RDRF)); /* wait for data */
- data = RDR1; /* read byte */
- } while ((data == 0xFF) && (++i < timeout));
-
- return fliptable[(signed char)data];
-}
-
-/* returns 0 on timeout, timeout is in bytes */
-static unsigned char poll_busy(long timeout)
-{
- long i;
- unsigned char data, dummy;
-
- if (serial_mode != SER_POLL_READ)
- set_sci1_poll_read();
-
- /* get data response */
- SSR1 = 0; /* start receiving */
- while (!(SSR1 & SCI_RDRF)); /* wait for data */
- data = fliptable[(signed char)(RDR1)]; /* read byte */
-
- /* wait until the card is ready again */
- i = 0;
- do {
- SSR1 = 0; /* start receiving */
- while (!(SSR1 & SCI_RDRF)); /* wait for data */
- dummy = RDR1; /* read byte */
- } while ((dummy != 0xFF) && (++i < timeout));
-
- return (dummy == 0xFF) ? data : 0;
-}
-
-/* Send MMC command and get response. Returns R1 byte directly.
- * Returns further R2 or R3 bytes in *data (can be NULL for other commands) */
-static unsigned char send_cmd(int cmd, unsigned long parameter, void *data)
-{
- static struct {
- unsigned char cmd;
- unsigned long parameter;
- const unsigned char crc7; /* fixed, valid for CMD0 only */
- const unsigned char trailer;
- } __attribute__((packed)) command = {0x40, 0, 0x95, 0xFF};
-
- unsigned char ret;
-
- command.cmd = cmd;
- command.parameter = htobe32(parameter);
-
- write_transfer((unsigned char *)&command, sizeof(command));
-
- ret = poll_byte(20);
-
- switch (cmd)
- {
- case CMD_SEND_CSD: /* R1 response, leave open */
- case CMD_SEND_CID:
- case CMD_READ_SINGLE_BLOCK:
- case CMD_READ_MULTIPLE_BLOCK:
- return ret;
-
- case CMD_SEND_STATUS: /* R2 response, close with dummy */
- read_transfer(data, 1);
- break;
-
- case CMD_READ_OCR: /* R3 response, close with dummy */
- read_transfer(data, 4);
- break;
-
- default: /* R1 response, close with dummy */
- break; /* also catches block writes */
- }
- write_transfer(dummy, 1);
- return ret;
-}
-
-/* Receive CID/ CSD data (16 bytes) */
-static int receive_cxd(unsigned char *buf)
-{
- if (poll_byte(20) != DT_START_BLOCK)
- {
- write_transfer(dummy, 1);
- return -1; /* not start of data */
- }
-
- read_transfer(buf, 16);
- write_transfer(dummy, 3); /* 2 bytes dontcare crc + 1 byte trailer */
- return 0;
-}
-
-
-static int initialize_card(int card_no)
-{
- int rc, i;
- int blk_exp, ts_exp, taac_exp;
- tCardInfo *card = &card_info[card_no];
-
- static const char mantissa[] = { /* *10 */
- 0, 10, 12, 13, 15, 20, 25, 30,
- 35, 40, 45, 50, 55, 60, 70, 80
- };
- static const int exponent[] = { /* use varies */
- 1, 10, 100, 1000, 10000, 100000, 1000000,
- 10000000, 100000000, 1000000000
- };
-
- if (card_no == 1)
- mmc_status = MMC_TOUCHED;
-
- /* switch to SPI mode */
- if (send_cmd(CMD_GO_IDLE_STATE, 0, NULL) != 0x01)
- return -1; /* error or no response */
-
- /* initialize card */
- for (i = HZ;;) /* try for 1 second*/
- {
- sleep(1);
- if (send_cmd(CMD_SEND_OP_COND, 0, NULL) == 0)
- break;
- if (--i <= 0)
- return -2; /* timeout */
- }
-
- /* get OCR register */
- if (send_cmd(CMD_READ_OCR, 0, &card->ocr))
- return -3;
- card->ocr = betoh32(card->ocr); /* no-op on big endian */
-
- /* check voltage */
- if (!(card->ocr & 0x00100000)) /* 3.2 .. 3.3 V */
- return -4;
-
- /* get CSD register */
- if (send_cmd(CMD_SEND_CSD, 0, NULL))
- return -5;
- rc = receive_cxd((unsigned char*)card->csd);
- if (rc)
- return rc * 10 - 5;
-
- blk_exp = card_extract_bits(card->csd, 83, 4);
- if (blk_exp < 9) /* block size < 512 bytes not supported */
- return -6;
-
- card->numblocks = (card_extract_bits(card->csd, 73, 12) + 1)
- << (card_extract_bits(card->csd, 49, 3) + 2 + blk_exp - 9);
- card->blocksize = BLOCK_SIZE;
-
- /* max transmission speed, clock divider */
- ts_exp = card_extract_bits(card->csd, 98, 3);
- ts_exp = (ts_exp > 3) ? 3 : ts_exp;
- card->speed = mantissa[card_extract_bits(card->csd, 102, 4)]
- * exponent[ts_exp + 4];
- card->bitrate_register = (FREQ/4-1) / card->speed;
-
- /* NSAC, TAAC, read timeout */
- card->nsac = 100 * card_extract_bits(card->csd, 111, 8);
- card->taac = mantissa[card_extract_bits(card->csd, 118, 4)];
- taac_exp = card_extract_bits(card->csd, 114, 3);
- card->read_timeout = ((FREQ/4) / (card->bitrate_register + 1)
- * card->taac / exponent[9 - taac_exp]
- + (10 * card->nsac));
- card->read_timeout /= 8; /* clocks -> bytes */
- card->taac = card->taac * exponent[taac_exp] / 10;
-
- /* r2w_factor, write timeout */
- card->r2w_factor = BIT_N(card_extract_bits(card->csd, 28, 3));
- card->write_timeout = card->read_timeout * card->r2w_factor;
-
- if (card->r2w_factor > 32) /* Such cards often need extra read delay */
- card->read_timeout *= 4;
-
- /* switch to full speed */
- setup_sci1(card->bitrate_register);
-
- /* always use 512 byte blocks */
- if (send_cmd(CMD_SET_BLOCKLEN, BLOCK_SIZE, NULL))
- return -7;
-
- /* get CID register */
- if (send_cmd(CMD_SEND_CID, 0, NULL))
- return -8;
- rc = receive_cxd((unsigned char*)card->cid);
- if (rc)
- return rc * 10 - 8;
-
- card->initialized = true;
- return 0;
-}
-
-tCardInfo *mmc_card_info(int card_no)
-{
- tCardInfo *card = &card_info[card_no];
-
- if (!card->initialized && ((card_no == 0) || mmc_detect()))
- {
- select_card(card_no);
- deselect_card();
- }
- return card;
-}
-
-/* Receive one block with DMA and bitswap it (chasing bitswap). */
-static int receive_block(unsigned char *inbuf, long timeout)
-{
- unsigned long buf_end;
-
- if (poll_byte(timeout) != DT_START_BLOCK)
- {
- write_transfer(dummy, 1);
- return -1; /* not start of data */
- }
-
- while (!(SSR1 & SCI_TEND)); /* wait for end of transfer */
-
- SCR1 = 0; /* disable serial */
- SSR1 = 0; /* clear all flags */
-
- /* setup DMA channel 0 */
- CHCR0 = 0; /* disable */
- SAR0 = RDR1_ADDR;
- DAR0 = (unsigned long) inbuf;
- DTCR0 = BLOCK_SIZE;
- CHCR0 = 0x4601; /* fixed source address, RXI1, enable */
- DMAOR = 0x0001;
- SCR1 = (SCI_RE|SCI_RIE); /* kick off DMA */
-
- /* DMA receives 2 bytes more than DTCR2, but the last 2 bytes are not
- * stored. The first extra byte is available from RDR1 after the DMA ends,
- * the second one is lost because of the SCI overrun. However, this
- * behaviour conveniently discards the crc. */
-
- yield(); /* be nice */
-
- /* Bitswap received data, chasing the DMA pointer */
- buf_end = (unsigned long)inbuf + BLOCK_SIZE;
- do
- {
- /* Call bitswap whenever (a multiple of) 8 bytes are
- * available (value optimised by experimentation). */
- int swap_now = (DAR0 - (unsigned long)inbuf) & ~0x00000007;
- if (swap_now)
- {
- bitswap(inbuf, swap_now);
- inbuf += swap_now;
- }
- }
- while ((unsigned long)inbuf < buf_end);
-
- while (!(CHCR0 & 0x0002)); /* wait for end of DMA */
- while (!(SSR1 & SCI_ORER)); /* wait for the trailing bytes */
- SCR1 = 0;
- serial_mode = SER_DISABLED;
-
- write_transfer(dummy, 1); /* send trailer */
- last_disk_activity = current_tick;
- return 0;
-}
-
-/* Prepare a block for sending by copying it to the next write buffer
- * and bitswapping it. */
-static void send_block_prepare(void)
-{
- unsigned char *dest;
-
- current_buffer ^= 1; /* toggle buffer */
- dest = write_buffer[current_buffer] + 2;
-
- memcpy(dest, send_block_addr, BLOCK_SIZE);
- bitswap(dest, BLOCK_SIZE);
-
- send_block_addr += BLOCK_SIZE;
-}
-
-/* Send one block with DMA from the current write buffer, possibly preparing
- * the next block within the next write buffer in the background. */
-static int send_block_send(unsigned char start_token, long timeout,
- bool prepare_next)
-{
- int rc = 0;
- unsigned char *curbuf = write_buffer[current_buffer];
-
- curbuf[1] = fliptable[(signed char)start_token];
- *(unsigned short *)(curbuf + BLOCK_SIZE + 2) = 0xFFFF;
-
- while (!(SSR1 & SCI_TEND)); /* wait for end of transfer */
-
- SCR1 = 0; /* disable serial */
- SSR1 = 0; /* clear all flags */
-
- /* setup DMA channel 0 */
- CHCR0 = 0; /* disable */
- SAR0 = (unsigned long)(curbuf + 1);
- DAR0 = TDR1_ADDR;
- DTCR0 = BLOCK_SIZE + 3; /* start token + block + dummy crc */
- CHCR0 = 0x1701; /* fixed dest. address, TXI1, enable */
- DMAOR = 0x0001;
- SCR1 = (SCI_TE|SCI_TIE); /* kick off DMA */
-
- if (prepare_next)
- send_block_prepare();
- yield(); /* be nice */
-
- while (!(CHCR0 & 0x0002)); /* wait for end of DMA */
- while (!(SSR1 & SCI_TEND)); /* wait for end of transfer */
- SCR1 = 0;
- serial_mode = SER_DISABLED;
-
- if ((poll_busy(timeout) & 0x1F) != 0x05) /* something went wrong */
- rc = -1;
-
- write_transfer(dummy, 1);
- last_disk_activity = current_tick;
-
- return rc;
-}
-
-int mmc_read_sectors(IF_MD(int drive,)
- unsigned long start,
- int incount,
- void* inbuf)
-{
- int rc = 0;
- int lastblock = 0;
- unsigned long end_block;
- tCardInfo *card;
-#ifndef HAVE_MULTIDRIVE
- int drive = current_card;
-#endif
-
- card = &card_info[drive];
- rc = select_card(drive);
- if (rc)
- {
- rc = rc * 10 - 1;
- goto error;
- }
-
- end_block = start + incount;
- if (end_block > card->numblocks)
- {
- rc = -2;
- goto error;
- }
-
- /* Some cards don't like reading the very last block with
- * CMD_READ_MULTIPLE_BLOCK, so make sure this block is always
- * read with CMD_READ_SINGLE_BLOCK. */
- if (end_block == card->numblocks)
- lastblock = 1;
-
- if (incount > 1)
- {
- /* MMC4.2: make multiplication conditional */
- if (send_cmd(CMD_READ_MULTIPLE_BLOCK, start * BLOCK_SIZE, NULL))
- {
- rc = -3;
- goto error;
- }
- while (--incount >= lastblock)
- {
- rc = receive_block(inbuf, card->read_timeout);
- if (rc)
- {
- /* If an error occurs during multiple block reading, the
- * host still needs to send CMD_STOP_TRANSMISSION */
- send_cmd(CMD_STOP_TRANSMISSION, 0, NULL);
- rc = rc * 10 - 4;
- goto error;
- }
- inbuf += BLOCK_SIZE;
- start++;
- /* ^^ necessary for the abovementioned last block special case */
- }
- if (send_cmd(CMD_STOP_TRANSMISSION, 0, NULL))
- {
- rc = -5;
- goto error;
- }
- }
- if (incount > 0)
- {
- /* MMC4.2: make multiplication conditional */
- if (send_cmd(CMD_READ_SINGLE_BLOCK, start * BLOCK_SIZE, NULL))
- {
- rc = -6;
- goto error;
- }
- rc = receive_block(inbuf, card->read_timeout);
- if (rc)
- {
- rc = rc * 10 - 7;
- goto error;
- }
- }
-
- error:
-
- deselect_card();
-
- return rc;
-}
-
-int mmc_write_sectors(IF_MD(int drive,)
- unsigned long start,
- int count,
- const void* buf)
-{
- int rc = 0;
- int write_cmd;
- unsigned char start_token;
- tCardInfo *card;
-#ifndef HAVE_MULTIDRIVE
- int drive = current_card;
-#endif
-
- card = &card_info[drive];
- rc = select_card(drive);
- if (rc)
- {
- rc = rc * 10 - 1;
- goto error;
- }
-
- if (start + count > card->numblocks)
- panicf("Writing past end of card");
-
- send_block_addr = buf;
- send_block_prepare();
-
- if (count > 1)
- {
- write_cmd = CMD_WRITE_MULTIPLE_BLOCK;
- start_token = DT_START_WRITE_MULTIPLE;
- }
- else
- {
- write_cmd = CMD_WRITE_BLOCK;
- start_token = DT_START_BLOCK;
- }
- /* MMC4.2: make multiplication conditional */
- if (send_cmd(write_cmd, start * BLOCK_SIZE, NULL))
- {
- rc = -2;
- goto error;
- }
- while (--count >= 0)
- {
- rc = send_block_send(start_token, card->write_timeout, count > 0);
- if (rc)
- {
- rc = rc * 10 - 3;
- break;
- /* If an error occurs during multiple block writing,
- * the STOP_TRAN token still needs to be sent. */
- }
- }
- if (write_cmd == CMD_WRITE_MULTIPLE_BLOCK)
- {
- static const unsigned char stop_tran = DT_STOP_TRAN;
- write_transfer(&stop_tran, 1);
- poll_busy(card->write_timeout);
- }
-
- error:
-
- deselect_card();
-
- return rc;
-}
-
-bool mmc_disk_is_active(void)
-{
- /* this is correct unless early return from write gets implemented */
- return mutex_test(&mmc_mutex);
-}
-
-bool mmc_detect(void)
-{
- return (adc_read(ADC_MMC_SWITCH) < 0x200);
-}
-
-bool mmc_touched(void)
-{
- if (mmc_status == MMC_UNKNOWN) /* try to detect */
- {
- mutex_lock(&mmc_mutex);
- setup_sci1(7); /* safe value */
- and_b(~0x02, &PADRH); /* assert CS */
- if (send_cmd(CMD_SEND_OP_COND, 0, NULL) == 0xFF)
- mmc_status = MMC_UNTOUCHED;
- else
- mmc_status = MMC_TOUCHED;
-
- deselect_card();
- }
- return mmc_status == MMC_TOUCHED;
-}
-
-bool mmc_usb_active(int delayticks)
-{
- /* reading "inactive" is delayed by user-supplied monoflop value */
- return (usb_activity ||
- TIME_BEFORE(current_tick, last_usb_activity + delayticks));
-}
-
-static void mmc_tick(void)
-{
- bool current_status;
-
- if (new_mmc_circuit)
- /* USB bridge activity is 0 on idle, ~527 on active */
- current_status = adc_read(ADC_USB_ACTIVE) > 0x100;
- else
- current_status = adc_read(ADC_USB_ACTIVE) < 0x190;
-
- if (!current_status && usb_activity)
- last_usb_activity = current_tick;
- usb_activity = current_status;
-
- current_status = mmc_detect();
- /* Only report when the status has changed */
- if (current_status != last_mmc_status)
- {
- last_mmc_status = current_status;
- countdown = HZ/3;
- }
- else
- {
- /* Count down until it gets negative */
- if (countdown >= 0)
- countdown--;
-
- if (countdown == 0)
- {
- if (current_status)
- {
- queue_broadcast(SYS_HOTSWAP_INSERTED, mmc_first_drive + 1);
- }
- else
- {
- queue_broadcast(SYS_HOTSWAP_EXTRACTED, mmc_first_drive + 1);
- mmc_status = MMC_UNTOUCHED;
- card_info[1].initialized = false;
- }
- }
- }
-}
-
-void mmc_enable(bool on)
-{
- mutex_lock(&mmc_mutex);
- enable_controller(on);
- mutex_unlock(&mmc_mutex);
-}
-
-int mmc_init(void)
-{
- int rc = 0;
-
- if (!initialized)
- mutex_init(&mmc_mutex);
-
- mutex_lock(&mmc_mutex);
- led(false);
-
- last_mmc_status = mmc_detect();
-#ifndef HAVE_MULTIDRIVE
- /* Use MMC if inserted, internal flash otherwise */
- current_card = last_mmc_status ? 1 : 0;
-#endif
-
- if (!initialized)
- {
- if (!last_mmc_status)
- mmc_status = MMC_UNTOUCHED;
-
- /* Port setup */
- PACR1 &= ~0x0F3C; /* GPIO function for PA13 (flash busy), PA12
- * (clk gate), PA10 (flash CS), PA9 (MMC CS) */
- PACR2 &= ~0x4000; /* GPIO for PA7 (flash reset) */
- PADR |= 0x0680; /* set all the selects + reset high (=inactive) */
- PAIOR |= 0x1680; /* make outputs for them and the PA12 clock gate */
-
- PBCR1 &= ~0x0CF0; /* GPIO function for PB13, PB11 and PB10 */
- PBDR |= 0x2C00; /* SCK1, TxD1 and RxD1 high in GPIO */
- PBIOR |= 0x2000; /* SCK1 output */
- PBIOR &= ~0x0C00; /* TxD1, RxD1 input */
-
- IPRE &= 0x0FFF; /* disable SCI1 interrupts for the CPU */
-
- new_mmc_circuit = ((HW_MASK & MMC_CLOCK_POLARITY) != 0);
- tick_add_task(mmc_tick);
- initialized = true;
- }
- enable_controller(true);
-
- mutex_unlock(&mmc_mutex);
- return rc;
-}
-
-long mmc_last_disk_activity(void)
-{
- return last_disk_activity;
-}
-
-#ifdef STORAGE_GET_INFO
-void mmc_get_info(IF_MD(int drive,) struct storage_info *info)
-{
-#ifndef HAVE_MULTIDRIVE
- const int drive=0;
-#endif
- info->sector_size=card_info[drive].blocksize;
- info->num_sectors=card_info[drive].numblocks;
- info->vendor="Rockbox";
- if(drive==0)
- {
- info->product="Internal Storage";
- }
- else
- {
- info->product="MMC Card Slot";
- }
- info->revision="0.00";
-}
-#endif
-
-#ifdef HAVE_HOTSWAP
-bool mmc_removable(IF_MD_NONVOID(int drive))
-{
-#ifndef HAVE_MULTIDRIVE
- const int drive=0;
-#endif
- return (drive==1);
-}
-
-bool mmc_present(IF_MD_NONVOID(int drive))
-{
-#ifndef HAVE_MULTIDRIVE
- const int drive=0;
-#endif
- if(drive==0)
- {
- return true;
- }
- else
- {
- return mmc_detect();
- }
-}
-#endif
-
-void mmc_spin(void)
-{
-}
-
-void mmc_spindown(int seconds)
-{
- (void)seconds;
-}
-
-#ifdef CONFIG_STORAGE_MULTI
-int mmc_num_drives(int first_drive)
-{
- mmc_first_drive = first_drive;
- return MMC_NUM_DRIVES;
-}
-#endif /* CONFIG_STORAGE_MULTI */
-
-int mmc_event(long id, intptr_t data)
-{
- return storage_event_default_handler(id, data, last_disk_activity,
- STORAGE_MMC);
-}
diff --git a/firmware/target/sh/archos/ondio/backlight-target.h b/firmware/target/sh/archos/ondio/backlight-target.h
deleted file mode 100644
index 438c8c926a..0000000000
--- a/firmware/target/sh/archos/ondio/backlight-target.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2007 by Jens Arnold
- *
- * 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
-
-#include "config.h"
-#include "cpu.h"
-
-#ifdef HAVE_BACKLIGHT
-/* A stock Ondio has no backlight, it needs a hardware mod. */
-
-static inline bool backlight_hw_init(void)
-{
- PACR1 &= ~0x3000; /* Set PA14 (backlight control) to GPIO */
- or_b(0x40, &PADRH); /* drive it high */
- or_b(0x40, &PAIORH); /* ..and output */
- return true;
-}
-
-static inline void backlight_hw_on(void)
-{
- or_b(0x40, &PADRH); /* drive it high */
-}
-
-static inline void backlight_hw_off(void)
-{
- and_b(~0x40, &PADRH); /* drive it low */
-}
-#endif /* HAVE_BACKLIGHT */
-
-#endif
diff --git a/firmware/target/sh/archos/ondio/button-ondio.c b/firmware/target/sh/archos/ondio/button-ondio.c
deleted file mode 100644
index e3b370bc1f..0000000000
--- a/firmware/target/sh/archos/ondio/button-ondio.c
+++ /dev/null
@@ -1,71 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2006 by Jens Arnold
- *
- * 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 "button.h"
-#include "backlight.h"
-#include "adc.h"
-
-/*
- Ondio hardware button hookup
- ============================
-
- LEFT, RIGHT, UP, DOWN: connected to AN4 through a resistor network
-
- The voltage on AN4 depends on which keys (or key combo) is pressed
-
- OPTION: AN2, high active (assigned as MENU)
- ON/OFF: AN3, low active (assigned as OFF)
-*/
-
-void button_init_device(void)
-{
-}
-
-int button_read_device(void)
-{
- int btn = BUTTON_NONE;
- int data;
-
- /* Check the 4 direction keys */
- data = adc_read(ADC_BUTTON_ROW1);
- if (data >= 165)
- {
- if (data >= 585)
- if (data >= 755)
- btn = BUTTON_LEFT;
- else
- btn = BUTTON_RIGHT;
- else
- if (data >= 415)
- btn = BUTTON_UP;
- else
- btn = BUTTON_DOWN;
- }
-
- if(adc_read(ADC_BUTTON_OPTION) > 0x200) /* active high */
- btn |= BUTTON_MENU;
- if(adc_read(ADC_BUTTON_ONOFF) < 0x120) /* active low */
- btn |= BUTTON_OFF;
-
- return btn;
-}
diff --git a/firmware/target/sh/archos/ondio/button-target.h b/firmware/target/sh/archos/ondio/button-target.h
deleted file mode 100644
index a84be2851a..0000000000
--- a/firmware/target/sh/archos/ondio/button-target.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2006 by Jens Arnold
- *
- * 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_
-
-#define BUTTON_OFF 0x00000001
-#define BUTTON_MENU 0x00000002
-
-#define BUTTON_LEFT 0x00000004
-#define BUTTON_RIGHT 0x00000008
-#define BUTTON_UP 0x00000010
-#define BUTTON_DOWN 0x00000020
-
-#define BUTTON_MAIN (BUTTON_OFF|BUTTON_MENU|BUTTON_LEFT|BUTTON_RIGHT\
- |BUTTON_UP|BUTTON_DOWN)
-
-#define POWEROFF_BUTTON BUTTON_OFF
-#define POWEROFF_COUNT 10
-
-#endif /* _BUTTON_TARGET_H_ */
diff --git a/firmware/target/sh/archos/ondio/fmradio_i2c-ondio.c b/firmware/target/sh/archos/ondio/fmradio_i2c-ondio.c
deleted file mode 100644
index b901bd0019..0000000000
--- a/firmware/target/sh/archos/ondio/fmradio_i2c-ondio.c
+++ /dev/null
@@ -1,202 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- * Physical interface of the Philips TEA5767 in Archos Ondio
- *
- * Copyright (C) 2002 by Linus Nielsen Feltzing
- *
- * 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 "logf.h"
-#include "system.h"
-#include "fmradio_i2c.h"
-
-#if (CONFIG_TUNER & TEA5767)
-
-/* cute little functions, atomic read-modify-write */
-/* SDA is PB4 */
-#define SDA_LO and_b(~0x10, &PBDRL)
-#define SDA_HI or_b(0x10, &PBDRL)
-#define SDA_INPUT and_b(~0x10, &PBIORL)
-#define SDA_OUTPUT or_b(0x10, &PBIORL)
-#define SDA (PBDR & 0x0010)
-
-/* SCL is PB1 */
-#define SCL_INPUT and_b(~0x02, &PBIORL)
-#define SCL_OUTPUT or_b(0x02, &PBIORL)
-#define SCL_LO and_b(~0x02, &PBDRL)
-#define SCL_HI or_b(0x02, &PBDRL)
-#define SCL (PBDR & 0x0002)
-
-/* arbitrary delay loop */
-#define DELAY do { int _x; for(_x=0;_x<20;_x++);} while (0)
-
-static void fmradio_i2c_start(void)
-{
- SDA_OUTPUT;
- SDA_HI;
- SCL_HI;
- SDA_LO;
- DELAY;
- SCL_LO;
-}
-
-static void fmradio_i2c_stop(void)
-{
- SDA_LO;
- SCL_HI;
- DELAY;
- SDA_HI;
-}
-
-
-static void fmradio_i2c_ack(bool nack)
-{
- /* Here's the deal. The slave is slow, and sometimes needs to wait
- before it can receive the acknowledge. Therefore it forces the clock
- low until it is ready. We need to poll the clock line until it goes
- high before we release the ack. */
-
- SCL_LO; /* Set the clock low */
-
- if (nack)
- SDA_HI;
- else
- SDA_LO;
-
- SCL_INPUT; /* Set the clock to input */
- while(!SCL) /* and wait for the slave to release it */
- sleep(0);
-
- DELAY;
- SCL_OUTPUT;
- SCL_LO;
-}
-
-static int fmradio_i2c_getack(void)
-{
- int ret = 1;
-
- /* Here's the deal. The slave is slow, and sometimes needs to wait
- before it can send the acknowledge. Therefore it forces the clock
- low until it is ready. We need to poll the clock line until it goes
- high before we read the ack. */
-
- SDA_INPUT; /* And set to input */
- SCL_INPUT; /* Set the clock to input */
- while(!SCL) /* and wait for the slave to release it */
- sleep(0);
-
- if (SDA)
- /* ack failed */
- ret = 0;
-
- SCL_OUTPUT;
- SCL_LO;
- SDA_HI;
- SDA_OUTPUT;
- return ret;
-}
-
-static void fmradio_i2c_outb(unsigned char byte)
-{
- int i;
-
- /* clock out each bit, MSB first */
- for ( i=0x80; i; i>>=1 ) {
- if ( i & byte )
- {
- SDA_HI;
- }
- else
- {
- SDA_LO;
- }
- SCL_HI;
- SCL_LO;
- }
-
- SDA_HI;
-}
-
-static unsigned char fmradio_i2c_inb(void)
-{
- int i;
- unsigned char byte = 0;
-
- /* clock in each bit, MSB first */
- for ( i=0x80; i; i>>=1 ) {
- SDA_INPUT; /* And set to input */
- SCL_HI;
- if ( SDA )
- byte |= i;
- SCL_LO;
- SDA_OUTPUT;
- }
-
- return byte;
-}
-
-int fmradio_i2c_write(unsigned char address, const unsigned char* buf, int count)
-{
- int i,x=0;
-
- fmradio_i2c_start();
- fmradio_i2c_outb(address & 0xfe);
- if (fmradio_i2c_getack())
- {
- for (i=0; i<count; i++)
- {
- fmradio_i2c_outb(buf[i]);
- if (!fmradio_i2c_getack())
- {
- x=-2;
- break;
- }
- }
- }
- else
- {
- logf("fmradio_i2c_write() - no ack\n");
- x=-1;
- }
- fmradio_i2c_stop();
- return x;
-}
-
-int fmradio_i2c_read(unsigned char address, unsigned char* buf, int count)
-{
- int i,x=0;
-
- fmradio_i2c_start();
- fmradio_i2c_outb(address | 1);
- if (fmradio_i2c_getack()) {
- for (i=count; i>0; i--)
- {
- *buf++ = fmradio_i2c_inb();
- fmradio_i2c_ack(i == 1);
- }
- }
- else
- x=-1;
- fmradio_i2c_stop();
- return x;
-}
-
-#endif
diff --git a/firmware/target/sh/archos/ondio/power-ondio.c b/firmware/target/sh/archos/ondio/power-ondio.c
deleted file mode 100644
index d7bbc08f4f..0000000000
--- a/firmware/target/sh/archos/ondio/power-ondio.c
+++ /dev/null
@@ -1,78 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2002 by Linus Nielsen Feltzing
- *
- * 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 <stdbool.h>
-#include "kernel.h"
-#include "system.h"
-#include "power.h"
-#include "usb.h"
-#include "backlight-target.h"
-
-#if CONFIG_TUNER
-
-static bool powered = false;
-
-bool tuner_power(bool status)
-{
- bool old_status = powered;
-
- powered = status;
- if (status)
- {
- and_b(~0x04, &PADRL); /* drive PA2 low for tuner enable */
- sleep(1); /* let the voltage settle */
- }
- else
- or_b(0x04, &PADRL); /* drive PA2 high for tuner disable */
- return old_status;
-}
-
-#endif /* #if CONFIG_TUNER */
-
-void power_init(void)
-{
- PBCR2 &= ~0x0c00; /* GPIO for PB5 */
- or_b(0x20, &PBIORL);
- or_b(0x20, &PBDRL); /* hold power */
-#ifndef HAVE_BACKLIGHT
- /* Disable backlight on backlight-modded Ondios when running
- * a standard build (always on otherwise). */
- PACR1 &= ~0x3000; /* Set PA14 (backlight control) to GPIO */
- and_b(~0x40, &PADRH); /* drive it low */
- or_b(0x40, &PAIORH); /* ..and output */
-#endif
- PACR2 &= ~0x0030; /* GPIO for PA2 */
- or_b(0x04, &PADRL); /* drive PA2 high for tuner disable */
- or_b(0x04, &PAIORL); /* output for PA2 */
-}
-
-void power_off(void)
-{
- disable_irq();
-#ifdef HAVE_BACKLIGHT
- /* Switch off the light on backlight-modded Ondios */
- backlight_hw_off();
-#endif
- and_b(~0x20, &PBDRL);
- or_b(0x20, &PBIORL);
- while(1);
-}
diff --git a/firmware/target/sh/archos/ondio/powermgmt-ondio.c b/firmware/target/sh/archos/ondio/powermgmt-ondio.c
deleted file mode 100644
index dc3cab031f..0000000000
--- a/firmware/target/sh/archos/ondio/powermgmt-ondio.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2002 by Heikki Hannikainen, Uwe Freese
- * Revisions copyright (C) 2005 by Gerald Van Baren
- *
- * 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] =
-{
- 3100, 3450
-};
-
-const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
-{
- 2700, 2800
-};
-
-/* voltages (millivolt) of 0%, 10%, ... 100% */
-const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
-{
- /* measured values */
- { 2800, 3250, 3410, 3530, 3640, 3740, 3850, 3950, 4090, 4270, 4750 }, /* Alkaline */
- { 3100, 3550, 3630, 3690, 3720, 3740, 3760, 3780, 3800, 3860, 4050 } /* NiMH */
-};
-
-#define BATTERY_SCALE_FACTOR 4849 /* average from 3 Ondios */
-/* full-scale ADC readout (2^10) in millivolt */
-
-/* Returns battery voltage from ADC [millivolts] */
-int _battery_voltage(void)
-{
- return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10;
-}
-
diff --git a/firmware/target/sh/archos/ondio/usb-ondio.c b/firmware/target/sh/archos/ondio/usb-ondio.c
deleted file mode 100644
index 093ebd3ad8..0000000000
--- a/firmware/target/sh/archos/ondio/usb-ondio.c
+++ /dev/null
@@ -1,61 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2007 by Jens Arnold
- *
- * 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 <stdbool.h>
-#include "adc.h"
-#include "ata_mmc.h"
-#include "cpu.h"
-#include "hwcompat.h"
-#include "system.h"
-#include "usb.h"
-
-int usb_detect(void)
-{
- return (adc_read(ADC_USB_POWER) <= 512) ? USB_INSERTED : USB_EXTRACTED;
-}
-
-void usb_enable(bool on)
-{
- if (on)
- {
- mmc_enable_int_flash_clock(!mmc_detect());
-
- if (!(HW_MASK & MMC_CLOCK_POLARITY))
- and_b(~0x20, &PBDRH); /* old circuit needs SCK1 = low while on USB */
- or_b(0x20, &PADRL); /* enable USB */
- and_b(~0x08, &PADRL); /* assert card detect */
- }
- else
- {
- if (!(HW_MASK & MMC_CLOCK_POLARITY))
- or_b(0x20, &PBDRH); /* reset SCK1 = high for old circuit */
- and_b(~0x20, &PADRL); /* disable USB */
- or_b(0x08, &PADRL); /* deassert card detect */
- }
-}
-
-void usb_init_device(void)
-{
- PACR2 &= ~0x04C0; /* use PA3 (card detect) and PA5 (USB enabled) as GPIO */
- and_b(~0x20, &PADRL); /* disable USB */
- or_b(0x08, &PADRL); /* deassert card detect */
- or_b(0x28, &PAIORL); /* output for USB enable and card detect */
-}
diff --git a/firmware/target/sh/archos/player/adc-target.h b/firmware/target/sh/archos/player/adc-target.h
deleted file mode 100644
index a26f79de28..0000000000
--- a/firmware/target/sh/archos/player/adc-target.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2002 by Linus Nielsen Feltzing
- *
- * 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 8
-
-#define ADC_BUTTON_LEFT 0
-#define ADC_BUTTON_MENU 1
-#define ADC_BUTTON_RIGHT 2
-#define ADC_BUTTON_PLAY 3
-#define ADC_UNREG_POWER 6 /* Battery voltage with a better scaling */
-#define ADC_EXT_POWER 7 /* The external power voltage, 0v or 2.7v */
-
-#define EXT_SCALE_FACTOR 14800
-
-#endif /* _ADC_TARGET_H_ */
diff --git a/firmware/target/sh/archos/player/backlight-target.h b/firmware/target/sh/archos/player/backlight-target.h
deleted file mode 100644
index b97d21a40f..0000000000
--- a/firmware/target/sh/archos/player/backlight-target.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2007 by Jens Arnold
- *
- * 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
-
-#include "config.h"
-#include "cpu.h"
-
-static inline bool backlight_hw_init(void)
-{
- PACR1 &= ~0x3000; /* Set PA14 (backlight control) to GPIO */
- and_b(~0x40, &PADRH); /* drive and set low */
- or_b(0x40, &PAIORH); /* ..and output */
- return true;
-}
-
-static inline void backlight_hw_on(void)
-{
- and_b(~0x40, &PADRH); /* drive and set low */
- or_b(0x40, &PAIORH);
-}
-
-static inline void backlight_hw_off(void)
-{
- and_b(~0x40, &PAIORH); /* let it float (up) */
-}
-
-#endif
diff --git a/firmware/target/sh/archos/player/button-player.c b/firmware/target/sh/archos/player/button-player.c
deleted file mode 100644
index 3cf634853e..0000000000
--- a/firmware/target/sh/archos/player/button-player.c
+++ /dev/null
@@ -1,76 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2006 by Jens Arnold
- *
- * 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 "button.h"
-#include "backlight.h"
-#include "adc.h"
-
-/*
- Player hardware button hookup
- =============================
-
- Player
- ------
- LEFT: AN0
- MENU: AN1
- RIGHT: AN2
- PLAY: AN3
-
- STOP: PA11
- ON: PA5
-
- All buttons are low active
-*/
-
-void button_init_device(void)
-{
- /* set PA5 and PA11 as input pins */
- PACR1 &= 0xff3f; /* PA11MD = 00 */
- PACR2 &= 0xfbff; /* PA5MD = 0 */
- PAIOR &= ~0x0820; /* Inputs */
-}
-
-int button_read_device(void)
-{
- int btn = BUTTON_NONE;
- int data;
-
- /* buttons are active low */
- if (adc_read(ADC_BUTTON_LEFT) < 0x180)
- btn = BUTTON_LEFT;
- if (adc_read(ADC_BUTTON_MENU) < 0x180)
- btn |= BUTTON_MENU;
- if (adc_read(ADC_BUTTON_RIGHT) < 0x180)
- btn |= BUTTON_RIGHT;
- if (adc_read(ADC_BUTTON_PLAY) < 0x180)
- btn |= BUTTON_PLAY;
-
- /* check port A pins for ON and STOP */
- data = PADR;
- if ( !(data & 0x0020) )
- btn |= BUTTON_ON;
- if ( !(data & 0x0800) )
- btn |= BUTTON_STOP;
-
- return btn;
-}
diff --git a/firmware/target/sh/archos/player/button-target.h b/firmware/target/sh/archos/player/button-target.h
deleted file mode 100644
index dd85d731be..0000000000
--- a/firmware/target/sh/archos/player/button-target.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2006 by Jens Arnold
- *
- * 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_
-
-#define HAS_SERIAL_REMOTE
-
- /* Main unit's buttons */
-#define BUTTON_ON 0x00000001
-#define BUTTON_STOP 0x00000002
-
-#define BUTTON_LEFT 0x00000004
-#define BUTTON_RIGHT 0x00000008
-#define BUTTON_PLAY 0x00000010
-#define BUTTON_MENU 0x00000020
-
-#define BUTTON_MAIN (BUTTON_ON|BUTTON_STOP|BUTTON_LEFT|BUTTON_RIGHT\
- |BUTTON_PLAY|BUTTON_MENU)
-
- /* Remote control's buttons */
-#define BUTTON_RC_PLAY 0x00100000
-#define BUTTON_RC_STOP 0x00080000
-
-#define BUTTON_RC_LEFT 0x00040000
-#define BUTTON_RC_RIGHT 0x00020000
-#define BUTTON_RC_VOL_UP 0x00010000
-#define BUTTON_RC_VOL_DOWN 0x00008000
-
-#define BUTTON_REMOTE (BUTTON_RC_PLAY|BUTTON_RC_STOP\
- |BUTTON_RC_LEFT|BUTTON_RC_RIGHT\
- |BUTTON_RC_VOL_UP|BUTTON_RC_VOL_DOWN)
-
-#endif /* _BUTTON_TARGET_H_ */
diff --git a/firmware/target/sh/archos/player/hwcompat-player.c b/firmware/target/sh/archos/player/hwcompat-player.c
deleted file mode 100644
index 49a333d708..0000000000
--- a/firmware/target/sh/archos/player/hwcompat-player.c
+++ /dev/null
@@ -1,28 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2002 by Linus Nielsen Feltzing
- *
- * 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 <stdbool.h>
-#include "hwcompat.h"
-
-bool is_new_player(void)
-{
- return (ROM_VERSION > 449) || (ROM_VERSION == 116);
-}
diff --git a/firmware/target/sh/archos/player/lcd-as-player.S b/firmware/target/sh/archos/player/lcd-as-player.S
deleted file mode 100644
index 19f812c1c7..0000000000
--- a/firmware/target/sh/archos/player/lcd-as-player.S
+++ /dev/null
@@ -1,274 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2004 by Jens Arnold
- * Based on the work of Alan Korr and Jörg Hohensohn
- *
- * 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 LCDR (PBDR_ADDR+1)
-
-#define LCD_DS 1 /* PB0 = 1 --- 0001 --- LCD-DS */
-#define LCD_CS 2 /* PB1 = 1 --- 0010 --- /LCD-CS */
-#define LCD_SD 4 /* PB2 = 1 --- 0100 --- LCD-SD */
-#define LCD_SC 8 /* PB3 = 1 --- 1000 --- LCD-SC */
-
-/*
- * About /CS,DS,SC,SD
- * ------------------
- *
- * LCD on JBP and JBR uses a SPI protocol to receive orders (SDA and SCK lines)
- *
- * - /CS -> Chip Selection line :
- * 0 : LCD chipset is activated.
- * - DS -> Data Selection line, latched at the rising edge
- * of the 8th serial clock (*) :
- * 0 : instruction register,
- * 1 : data register;
- * - SC -> Serial Clock line (SDA).
- * - SD -> Serial Data line (SCK), latched at the rising edge
- * of each serial clock (*).
- *
- * _ _
- * /CS \ /
- * \______________________________________________________/
- * _____ ____ ____ ____ ____ ____ ____ ____ ____ _____
- * SD \/ D7 \/ D6 \/ D5 \/ D4 \/ D3 \/ D2 \/ D1 \/ D0 \/
- * _____/\____/\____/\____/\____/\____/\____/\____/\____/\_____
- *
- * _____ _ _ _ _ _ _ _ ________
- * SC \ * \ * \ * \ * \ * \ * \ * \ *
- * \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/
- * _ _________________________________________________________
- * DS \/
- * _/\_________________________________________________________
- *
- */
-
- .section .icode,"ax",@progbits
-
- .align 2
- .global _lcd_write_command
- .type _lcd_write_command,@function
-
-/* Write a command byte to the lcd controller
- *
- * Arguments:
- * r4 - command byte (int)
- *
- * Register usage:
- * r0 - scratch
- * r1 - command byte (copied)
- * r2 - precalculated port value (CS, DS and SC low, SD high)
- * r3 - lcd port address
- * r5 - 1 (byte count for reuse of the loop in _lcd_write_data)
- */
-
-_lcd_write_command:
- mov.l .lcdr, r3 /* put lcd data port address in r3 */
- mov r4, r1 /* copy data byte to r1 */
- mov #0, r5 /* fake end address - stop after first iteration */
-
- /* This code will fail if an interrupt changes the contents of PBDRL.
- * If so, we must disable the interrupt here. */
-
- mov.b @r3, r0 /* r0 = PBDRL */
- or #(LCD_SD), r0 /* r0 |= LCD_SD */
- and #(~(LCD_CS|LCD_DS|LCD_SC)),r0 /* r0 &= ~(LCD_CS|LCD_DS|LCD_SC) */
-
- bra .single_transfer /* jump into the transfer loop */
- mov r0, r2
-
-
- .align 2
- .global _lcd_write_command_e
- .type _lcd_write_command_e,@function
-
-/* Write a command byte and a data byte to the lcd controller
- *
- * Arguments:
- * r4 - command byte
- * r5 - data byte
- *
- * Register usage:
- * r0 - scratch
- * r1 - command/data byte (copied)
- * r2 - precalculated port value (CS, DS and SC low, SD high)
- * r3 - lcd port address
- * r5 - fake end address
- * r6 - data byte (saved)
- * r7 - saved pr
- */
-
-_lcd_write_command_e:
- mov.l .lcdr, r3 /* put lcd data port address in r3 */
- mov r4, r1 /* copy data byte to r1 */
- mov r5, r6
- mov #0, r5 /* fake end address - stop after first iteration */
-
- /* This code will fail if an interrupt changes the contents of PBDRL.
- * If so, we must disable the interrupt here. */
-
- mov.b @r3, r0 /* r0 = PBDRL */
- or #(LCD_SD), r0 /* r0 |= LCD_SD */
- and #(~(LCD_CS|LCD_DS|LCD_SC)),r0 /* r0 &= ~(LCD_CS|LCD_DS|LCD_SC) */
-
- sts pr, r7
- bsr .single_transfer /* jump into the transfer loop */
- mov r0, r2
-
- lds r7, pr
- mov r6, r1
- or #(LCD_DS|LCD_SD), r0 /* r0 |= LCD_DS|LCD_SD */
- and #(~(LCD_CS|LCD_SC)), r0 /* r0 &= ~(LCD_CS|LCD_SC) */
- bra .single_transfer /* jump into the transfer loop */
- mov r0, r2
-
-
- .align 2
- .global _lcd_write_data
- .type _lcd_write_data,@function
-
-
-/* A high performance function to write data to the display,
- * one or multiple bytes.
- *
- * Arguments:
- * r4 - data address
- * r5 - byte count
- *
- * Register usage:
- * r0 - scratch
- * r1 - current data byte
- * r2 - precalculated port value (CS and SC low, DS and SD high)
- * r3 - lcd port address
- * r4 - current address
- * r5 - end address
- */
-
-_lcd_write_data:
- mov.l .lcdr, r3 /* put lcd data port address in r3 */
- add r4, r5 /* end address */
-
- /* This code will fail if an interrupt changes the contents of PBDRL.
- * If so, we must disable the interrupt here. If disabling interrupts
- * for a long time (~9200 clks = ~830 µs for transferring 112 bytes on
- * recorders)is undesirable, the loop has to be rewritten to
- * disable/precalculate/transfer/enable for each iteration. However,
- * this would significantly decrease performance. */
-
- mov.b @r3, r0 /* r0 = PBDRL */
- or #(LCD_DS|LCD_SD), r0 /* r0 |= LCD_DS|LCD_SD */
- and #(~(LCD_CS|LCD_SC)), r0 /* r0 &= ~(LCD_CS|LCD_SC) */
- mov r0, r2
-
- .align 2
-.multi_transfer:
- mov.b @r4+, r1 /* load data byte from memory */
-
-.single_transfer:
- shll16 r1 /* shift data to most significant byte */
- shll8 r1
-
- shll r1 /* shift the msb into carry */
- mov r2, r0 /* copy precalculated port value */
- bt 1f /* data bit = 1? */
- and #(~LCD_SD), r0 /* no: r0 &= ~LCD_SD */
-1:
- shll r1 /* next shift here for alignment */
- mov.b r0, @r3 /* set data to port */
- or #(LCD_SC), r0 /* rise SC (independent of SD level) */
- mov.b r0, @r3 /* set to port */
-
- mov r2, r0
- bt 1f
- and #(~LCD_SD), r0
-1:
- mov.b r0, @r3
- or #(LCD_SC), r0
- mov.b r0, @r3
-
- shll r1
- mov r2, r0
- bt 1f
- and #(~LCD_SD), r0
-1:
- shll r1
- mov.b r0, @r3
- or #(LCD_SC), r0
- mov.b r0, @r3
-
- mov r2, r0
- bt 1f
- and #(~LCD_SD), r0
-1:
- mov.b r0, @r3
- or #(LCD_SC), r0
- mov.b r0, @r3
-
- shll r1
- mov r2, r0
- bt 1f
- and #(~LCD_SD), r0
-1:
- shll r1
- mov.b r0, @r3
- or #(LCD_SC), r0
- mov.b r0, @r3
-
- mov r2, r0
- bt 1f
- and #(~LCD_SD), r0
-1:
- mov.b r0, @r3
- or #(LCD_SC), r0
- mov.b r0, @r3
-
- shll r1
- mov r2, r0
- bt 1f
- and #(~LCD_SD), r0
-1:
- shll r1
- mov.b r0, @r3
- or #(LCD_SC), r0
- mov.b r0, @r3
-
- mov r2, r0
- bt 1f
- and #(~LCD_SD), r0
-1:
- mov.b r0, @r3
- or #(LCD_SC), r0
- mov.b r0, @r3
-
- cmp/hi r4, r5 /* some blocks left? */
- bt .multi_transfer
-
- or #(LCD_CS|LCD_DS|LCD_SD|LCD_SC),r0 /* restore port */
- rts
- mov.b r0, @r3
-
- /* This is the place to reenable the interrupts, if we have disabled
- * them. See above. */
-
- .align 2
-.lcdr:
- .long LCDR
diff --git a/firmware/target/sh/archos/player/lcd-player.c b/firmware/target/sh/archos/player/lcd-player.c
deleted file mode 100644
index 95b0164bf5..0000000000
--- a/firmware/target/sh/archos/player/lcd-player.c
+++ /dev/null
@@ -1,213 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2007 by Jens Arnold
- * Based on the work of Alan Korr, Kjell Ericson and others
- *
- * 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 <string.h>
-#include "config.h"
-#include "system.h"
-#include "kernel.h"
-#include "hwcompat.h"
-#include "lcd.h"
-#include "lcd-charcell.h"
-
-#define OLD_LCD_DDRAM ((char)0xB0) /* Display data (characters) */
-#define OLD_LCD_CGRAM ((char)0x80) /* Character generator (patterns) */
-#define OLD_LCD_ICONRAM ((char)0xE0)
-#define OLD_LCD_CONTRAST_SET ((char)0xA8)
-#define OLD_LCD_NOP ((char)0x00)
-#define OLD_LCD_SYSTEM_SET ((char)0x60)
-#define OLD_LCD_SET_POWER_SAVE_OSC_CONTROL ((char)0x40)
-#define OLD_LCD_SET_POWER_CONTROL ((char)0x50)
-#define OLD_LCD_SET_DISPLAY_CONTROL ((char)0x30)
-
-#define NEW_LCD_DDRAM ((char)0x80) /* Display data (characters) */
-#define NEW_LCD_CGRAM ((char)0xC0) /* Character generator (patterns) */
-#define NEW_LCD_ICONRAM ((char)0x40)
-#define NEW_LCD_CONTRAST_SET ((char)0x50)
-#define NEW_LCD_NOP ((char)0x00)
-#define NEW_LCD_FUNCTION_SET ((char)0x10)
-#define NEW_LCD_SET_POWER_SAVE_OSC_CONTROL ((char)0x0c)
-#define NEW_LCD_SET_POWER_CONTROL_REG ((char)0x20)
-#define NEW_LCD_SET_DISPLAY_CONTROL ((char)0x28)
-#define NEW_LCD_SET_DOUBLE_HEIGHT ((char)0x08)
-
-#define LCD_CURSOR(x,y) ((char)(lcd_ddram+((y)*16+(x))))
-#define LCD_ICON(i) ((char)(lcd_iconram+i))
-
-static bool new_lcd;
-static char lcd_contrast_set;
-static char lcd_ddram;
-static char lcd_cgram;
-static char lcd_iconram;
-
-/* hardware configuration */
-
-int lcd_default_contrast(void)
-{
- return 30;
-}
-
-void lcd_set_contrast(int val)
-{
- lcd_write_command_e(lcd_contrast_set, 31 - val);
-}
-
-/* charcell specific */
-
-void lcd_double_height(bool on)
-{
- if(new_lcd)
- lcd_write_command(on ? (NEW_LCD_SET_DOUBLE_HEIGHT|1)
- : NEW_LCD_SET_DOUBLE_HEIGHT);
-}
-
-void lcd_icon(int icon, bool enable)
-{
- static const struct {
- char pos;
- char mask;
- } icontab[] = {
- { 0, 0x02}, { 0, 0x08}, { 0, 0x04}, { 0, 0x10}, /* Battery */
- { 2, 0x04}, /* USB */
- { 3, 0x10}, /* Play */
- { 4, 0x10}, /* Record */
- { 5, 0x02}, /* Pause */
- { 5, 0x10}, /* Audio */
- { 6, 0x02}, /* Repeat */
- { 7, 0x01}, /* 1 */
- { 9, 0x04}, /* Volume */
- { 9, 0x02}, { 9, 0x01}, {10, 0x08}, {10, 0x04}, {10, 0x01}, /* Vol 1-5 */
- {10, 0x10}, /* Param */
- };
- static char icon_mirror[11] = {0};
-
- int pos, mask;
-
- pos = icontab[icon].pos;
- mask = icontab[icon].mask;
-
- if (enable)
- icon_mirror[pos] |= mask;
- else
- icon_mirror[pos] &= ~mask;
-
- lcd_write_command_e(LCD_ICON(pos), icon_mirror[pos]);
-}
-
-/* device specific init */
-void lcd_init_device(void)
-{
- unsigned char data_vector[64];
-
- /* LCD init for cold start */
- PBCR2 &= 0xff00; /* Set PB0..PB3 to GPIO */
- or_b(0x0f, &PBDRL); /* ... high */
- or_b(0x0f, &PBIORL); /* ... and output */
-
- new_lcd = is_new_player();
-
- if (new_lcd)
- {
- lcd_contrast_set = NEW_LCD_CONTRAST_SET;
- lcd_ddram = NEW_LCD_DDRAM;
- lcd_cgram = NEW_LCD_CGRAM;
- lcd_iconram = NEW_LCD_ICONRAM;
-
- lcd_write_command(NEW_LCD_FUNCTION_SET|1); /* CGRAM selected */
- lcd_write_command_e(NEW_LCD_CONTRAST_SET, 0x08);
- lcd_write_command(NEW_LCD_SET_POWER_SAVE_OSC_CONTROL|2);
- /* oscillator on */
- lcd_write_command(NEW_LCD_SET_POWER_CONTROL_REG|7);
- /* opamp buffer + voltage booster on */
-
- memset(data_vector, 0x20, 64);
- lcd_write_command(NEW_LCD_DDRAM); /* Set DDRAM address */
- lcd_write_data(data_vector, 64); /* all spaces */
-
- memset(data_vector, 0, 64);
- lcd_write_command(NEW_LCD_CGRAM); /* Set CGRAM address */
- lcd_write_data(data_vector, 64); /* zero out */
- lcd_write_command(NEW_LCD_ICONRAM); /* Set ICONRAM address */
- lcd_write_data(data_vector, 16); /* zero out */
-
- lcd_write_command(NEW_LCD_SET_DISPLAY_CONTROL|1); /* display on */
- }
- else
- {
- lcd_contrast_set = OLD_LCD_CONTRAST_SET;
- lcd_ddram = OLD_LCD_DDRAM;
- lcd_cgram = OLD_LCD_CGRAM;
- lcd_iconram = OLD_LCD_ICONRAM;
-
- lcd_write_command(OLD_LCD_NOP);
- lcd_write_command(OLD_LCD_SYSTEM_SET|1); /* CGRAM selected */
- lcd_write_command(OLD_LCD_SET_POWER_SAVE_OSC_CONTROL|2);
- /* oscillator on */
- lcd_write_command(OLD_LCD_SET_POWER_CONTROL|7);
- /* voltage regulator, voltage follower and booster on */
-
- memset(data_vector, 0x24, 13);
- lcd_write_command(OLD_LCD_DDRAM); /* Set DDRAM address */
- lcd_write_data(data_vector, 13); /* all spaces */
- lcd_write_command(OLD_LCD_DDRAM + 0x10);
- lcd_write_data(data_vector, 13);
- lcd_write_command(OLD_LCD_DDRAM + 0x20);
- lcd_write_data(data_vector, 13);
-
- memset(data_vector, 0, 32);
- lcd_write_command(OLD_LCD_CGRAM); /* Set CGRAM address */
- lcd_write_data(data_vector, 32); /* zero out */
- lcd_write_command(OLD_LCD_ICONRAM); /* Set ICONRAM address */
- lcd_write_data(data_vector, 13); /* zero out */
- lcd_write_command(OLD_LCD_ICONRAM + 0x10);
- lcd_write_data(data_vector, 13);
-
- sleep(HZ/10);
- lcd_write_command(OLD_LCD_SET_DISPLAY_CONTROL|1); /* display on */
- }
- lcd_set_contrast(lcd_default_contrast());
-}
-
-/*** Update functions ***/
-
-void lcd_update(void)
-{
- int y;
-
- for (y = 0; y < lcd_pattern_count; y++)
- {
- if (lcd_patterns[y].count > 0)
- {
- lcd_write_command(lcd_cgram | (y << 3));
- lcd_write_data(lcd_patterns[y].pattern, 7);
- }
- }
- for (y = 0; y < LCD_HEIGHT; y++)
- {
- lcd_write_command(LCD_CURSOR(0, y));
- lcd_write_data(lcd_charbuffer[y], LCD_WIDTH);
- }
- if (lcd_cursor.visible)
- {
- lcd_write_command_e(LCD_CURSOR(lcd_cursor.x, lcd_cursor.y),
- lcd_cursor.hw_char);
- }
-}
diff --git a/firmware/target/sh/archos/player/power-player.c b/firmware/target/sh/archos/player/power-player.c
deleted file mode 100644
index 33f5959021..0000000000
--- a/firmware/target/sh/archos/player/power-player.c
+++ /dev/null
@@ -1,84 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2002 by Linus Nielsen Feltzing
- *
- * 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 <stdbool.h>
-#include "kernel.h"
-#include "system.h"
-#include "power.h"
-#include "usb.h"
-
-void power_init(void)
-{
-}
-
-unsigned int power_input_status(void)
-{
- /* Player */
- return ((PADR & 1) == 0) ?
- POWER_INPUT_MAIN_CHARGER : POWER_INPUT_NONE;
-}
-
-void ide_power_enable(bool on)
-{
- bool touched = false;
-
- if(on)
- {
- or_b(0x10, &PBDRL);
- touched = true;
- }
-#ifdef HAVE_ATA_POWER_OFF
- if(!on)
- {
- and_b(~0x10, &PBDRL);
- touched = true;
- }
-#endif /* HAVE_ATA_POWER_OFF */
-
-/* late port preparation, else problems with read/modify/write
- of other bits on same port, while input and floating high */
- if (touched)
- {
- or_b(0x10, &PBIORL); /* PB4 is an output */
- PBCR2 &= ~0x0300; /* GPIO for PB4 */
- }
-}
-
-
-bool ide_powered(void)
-{
- /* This is not correct for very old players, since these are unable to
- * control hd power. However, driving the pin doesn't hurt, because it
- * is not connected anywhere */
- if ((PBCR2 & 0x0300) || !(PBIORL & 0x10)) /* not configured for output */
- return false; /* would be floating low, disk off */
- else
- return (PBDRL & 0x10) != 0;
-}
-
-void power_off(void)
-{
- disable_irq();
- and_b(~0x08, &PADRH);
- or_b(0x08, &PAIORH);
- while(1);
-}
diff --git a/firmware/target/sh/archos/player/powermgmt-player.c b/firmware/target/sh/archos/player/powermgmt-player.c
deleted file mode 100644
index 8aa03d88a5..0000000000
--- a/firmware/target/sh/archos/player/powermgmt-player.c
+++ /dev/null
@@ -1,64 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2002 by Heikki Hannikainen, Uwe Freese
- * Revisions copyright (C) 2005 by Gerald Van Baren
- *
- * 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] =
-{
- 4750
-};
-
-const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
-{
- 4400
-};
-
-/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
-const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
-{
- /* original values were taken directly after charging, but it should show
- 100% after turning off the device for some hours, too */
- { 4500, 4810, 4910, 4970, 5030, 5070, 5120, 5140, 5170, 5250, 5400 }
- /* orig. values: ...,5280,5600 */
-};
-
-/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */
-const unsigned short percent_to_volt_charge[11] =
-{
- /* values guessed, see
- http://www.seattlerobotics.org/encoder/200210/LiIon2.pdf until someone
- measures voltages over a charging cycle */
- 4760, 5440, 5510, 5560, 5610, 5640, 5660, 5760, 5820, 5840, 5850 /* NiMH */
-};
-
-#define BATTERY_SCALE_FACTOR 6703
-/* full-scale ADC readout (2^10) in millivolt */
-
-/* Returns battery voltage from ADC [millivolts] */
-int _battery_voltage(void)
-{
- return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10;
-}
-
-
diff --git a/firmware/target/sh/archos/player/usb-player.c b/firmware/target/sh/archos/player/usb-player.c
deleted file mode 100644
index 76f2a2dcdd..0000000000
--- a/firmware/target/sh/archos/player/usb-player.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2007 by Jens Arnold
- *
- * 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 <stdbool.h>
-#include "cpu.h"
-#include "system.h"
-#include "usb.h"
-
-int usb_detect(void)
-{
- return (PADR & 0x8000) ? USB_EXTRACTED : USB_INSERTED;
-}
-
-void usb_enable(bool on)
-{
- if(on)
- and_b(~0x04, &PADRH);
- else
- or_b(0x04, &PADRH);
-}
-
-void usb_init_device(void)
-{
- or_b(0x04, &PADRH);
- or_b(0x04, &PAIORH);
-}
diff --git a/firmware/target/sh/archos/recorder/adc-target.h b/firmware/target/sh/archos/recorder/adc-target.h
deleted file mode 100644
index 06c48a5021..0000000000
--- a/firmware/target/sh/archos/recorder/adc-target.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2002 by Linus Nielsen Feltzing
- *
- * 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 8
-
-/* normal JBR channel assignment */
-#define ADC_BATTERY 0 /* Battery voltage always reads 0x3FF due to
- silly scaling */
-#define ADC_CHARGE_REGULATOR 1 /* Regulator reference voltage, should read
- about 0x1c0 when charging, else 0x3FF */
-#define ADC_USB_POWER 2 /* USB, reads 0x3FF when USB is inserted */
-#define ADC_BUTTON_ROW1 4 /* Used for scanning the keys, different
- voltages for different keys */
-#define ADC_BUTTON_ROW2 5 /* Used for scanning the keys, different
- voltages for different keys */
-#define ADC_UNREG_POWER 6 /* Battery voltage with a better scaling */
-#define ADC_EXT_POWER 7 /* The external power voltage, 0v or 2.7v */
-
-#define EXT_SCALE_FACTOR 14800
-
-#endif /* _ADC_TARGET_H_ */
diff --git a/firmware/target/sh/archos/recorder/backlight-target.h b/firmware/target/sh/archos/recorder/backlight-target.h
deleted file mode 100644
index c3dd395eca..0000000000
--- a/firmware/target/sh/archos/recorder/backlight-target.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2007 by Jens Arnold
- *
- * 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
-
-#include "config.h"
-#include "rtc.h"
-
-#define backlight_hw_init() true
-
-static inline void backlight_hw_on(void)
-{
- rtc_write(0x13, 0x10); /* 32 kHz square wave */
- rtc_write(0x0a, rtc_read(0x0a) | 0x40); /* Enable square wave */
-}
-
-static inline void backlight_hw_off(void)
-{
- /* While on, backlight is flashing at 32 kHz. If the square wave output
- is disabled while the backlight is lit, it will become constantly lit,
- (brighter) and slowly fade. This resets the square wave counter and
- results in the unlit state */
- unsigned char rtc_0a = rtc_read(0x0a) & ~0x40;
- rtc_write(0x0a, rtc_0a); /* Disable square wave */
- rtc_write(0x13, 0xF0); /* 1 Hz square wave */
- rtc_write(0x0a, rtc_0a | 0x40); /* Enable square wave */
-
- /* When the square wave output is disabled in the unlit state,
- the backlight stays off */
- rtc_write(0x0a, rtc_0a);
-}
-
-#endif
diff --git a/firmware/target/sh/archos/recorder/button-recorder.c b/firmware/target/sh/archos/recorder/button-recorder.c
deleted file mode 100644
index 5e5e67487d..0000000000
--- a/firmware/target/sh/archos/recorder/button-recorder.c
+++ /dev/null
@@ -1,110 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2006 by Jens Arnold
- *
- * 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 "button.h"
-#include "backlight.h"
-#include "adc.h"
-
-/*
- Recorder hardware button hookup
- ===============================
-
- F1, F2, F3, UP: connected to AN4 through a resistor network
- DOWN, PLAY, LEFT, RIGHT: likewise connected to AN5
-
- The voltage on AN4/ AN5 depends on which keys (or key combo) is pressed
-
- ON: PB8, low active
- OFF: PB4, low active
-*/
-
-void button_init_device(void)
-{
- /* Set PB4 and PB8 as input pins */
- PBCR1 &= 0xfffc; /* PB8MD = 00 */
- PBCR2 &= 0xfcff; /* PB4MD = 00 */
- PBIOR &= ~0x0110; /* Inputs */
-}
-
-int button_read_device(void)
-{
- int btn = BUTTON_NONE;
- int data;
- static int off_button_count = 0;
-
- /* check F1..F3 and UP */
- data = adc_read(ADC_BUTTON_ROW1);
- if (data >= 250)
- {
- if (data >= 700)
- if (data >= 900)
- btn = BUTTON_F3;
- else
- btn = BUTTON_UP;
- else
- if (data >= 500)
- btn = BUTTON_F2;
- else
- btn = BUTTON_F1;
- }
-
- /* Some units have mushy keypads, so pressing UP also activates
- the Left/Right buttons. Let's combat that by skipping the AN5
- checks when UP is pressed. */
- if(!(btn & BUTTON_UP))
- {
- /* check DOWN, PLAY, LEFT, RIGHT */
- data = adc_read(ADC_BUTTON_ROW2);
- if (data >= 250)
- {
- if (data >= 700)
- if (data >= 900)
- btn |= BUTTON_DOWN;
- else
- btn |= BUTTON_PLAY;
- else
- if (data >= 500)
- btn |= BUTTON_LEFT;
- else
- btn |= BUTTON_RIGHT;
- }
- }
-
- /* check port B pins for ON and OFF */
- data = PBDR;
- if ((data & 0x0100) == 0)
- btn |= BUTTON_ON;
-
- if ((data & 0x0010) == 0)
- {
- /* When the batteries are low, the low-battery shutdown logic causes
- * spurious OFF events due to voltage fluctuation on some units.
- * Only accept OFF when read several times in sequence. */
- if (++off_button_count > 3)
- btn |= BUTTON_OFF;
- }
- else
- off_button_count = 0;
-
- return btn;
-}
diff --git a/firmware/target/sh/archos/recorder/button-target.h b/firmware/target/sh/archos/recorder/button-target.h
deleted file mode 100644
index f387fafe10..0000000000
--- a/firmware/target/sh/archos/recorder/button-target.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2006 by Jens Arnold
- *
- * 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_
-
-#define HAS_SERIAL_REMOTE
-
- /* Main unit's buttons */
-#define BUTTON_ON 0x00000001
-#define BUTTON_OFF 0x00000002
-
-#define BUTTON_LEFT 0x00000004
-#define BUTTON_RIGHT 0x00000008
-#define BUTTON_UP 0x00000010
-#define BUTTON_DOWN 0x00000020
-
-#define BUTTON_PLAY 0x00000040
-
-#define BUTTON_F1 0x00000080
-#define BUTTON_F2 0x00000100
-#define BUTTON_F3 0x00000200
-
-#define BUTTON_MAIN (BUTTON_ON|BUTTON_OFF|BUTTON_LEFT|BUTTON_RIGHT\
- |BUTTON_UP|BUTTON_DOWN|BUTTON_PLAY\
- |BUTTON_F1|BUTTON_F2|BUTTON_F3)
-
- /* Remote control's buttons */
-#define BUTTON_RC_PLAY 0x00100000
-#define BUTTON_RC_STOP 0x00080000
-
-#define BUTTON_RC_LEFT 0x00040000
-#define BUTTON_RC_RIGHT 0x00020000
-#define BUTTON_RC_VOL_UP 0x00010000
-#define BUTTON_RC_VOL_DOWN 0x00008000
-
-#define BUTTON_REMOTE (BUTTON_RC_PLAY|BUTTON_RC_STOP\
- |BUTTON_RC_LEFT|BUTTON_RC_RIGHT\
- |BUTTON_RC_VOL_UP|BUTTON_RC_VOL_DOWN)
-
-#endif /* _BUTTON_TARGET_H_ */
diff --git a/firmware/target/sh/archos/recorder/power-recorder.c b/firmware/target/sh/archos/recorder/power-recorder.c
deleted file mode 100644
index 48cfdc1e17..0000000000
--- a/firmware/target/sh/archos/recorder/power-recorder.c
+++ /dev/null
@@ -1,107 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2002 by Linus Nielsen Feltzing
- *
- * 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 <stdbool.h>
-#include "adc.h"
-#include "kernel.h"
-#include "system.h"
-#include "power.h"
-#include "powermgmt-target.h"
-#include "usb.h"
-
-static bool charger_on;
-
-void power_init(void)
-{
- PBCR2 &= ~0x0c00; /* GPIO for PB5 */
- or_b(0x20, &PBIORL); /* Set charging control bit to output */
- charger_enable(false); /* Default to charger OFF */
-}
-
-unsigned int power_input_status(void)
-{
- /* Recorder */
- return (adc_read(ADC_EXT_POWER) > 0x100) ?
- POWER_INPUT_MAIN_CHARGER : POWER_INPUT_NONE;
-}
-
-void charger_enable(bool on)
-{
- if(on)
- {
- and_b(~0x20, &PBDRL);
- }
- else
- {
- or_b(0x20, &PBDRL);
- }
-
- charger_on = on;
-}
-
-bool charger_enabled(void)
-{
- return charger_on;
-}
-
-void ide_power_enable(bool on)
-{
- bool touched = false;
-
- if(on)
- {
- or_b(0x20, &PADRL);
- touched = true;
- }
-#ifdef HAVE_ATA_POWER_OFF
- if(!on)
- {
- and_b(~0x20, &PADRL);
- touched = true;
- }
-#endif /* HAVE_ATA_POWER_OFF */
-
-/* late port preparation, else problems with read/modify/write
- of other bits on same port, while input and floating high */
- if (touched)
- {
- or_b(0x20, &PAIORL); /* PA5 is an output */
- PACR2 &= 0xFBFF; /* GPIO for PA5 */
- }
-}
-
-
-bool ide_powered(void)
-{
- if ((PACR2 & 0x0400) || !(PAIORL & 0x20)) /* not configured for output */
- return true; /* would be floating high, disk on */
- else
- return (PADRL & 0x20) != 0;
-}
-
-void power_off(void)
-{
- disable_irq();
- and_b(~0x10, &PBDRL);
- or_b(0x10, &PBIORL);
- while(1);
-}
diff --git a/firmware/target/sh/archos/recorder/powermgmt-recorder.c b/firmware/target/sh/archos/recorder/powermgmt-recorder.c
deleted file mode 100644
index ca6067a4cc..0000000000
--- a/firmware/target/sh/archos/recorder/powermgmt-recorder.c
+++ /dev/null
@@ -1,501 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2002 by Heikki Hannikainen, Uwe Freese
- * Revisions copyright (C) 2005 by Gerald Van Baren
- *
- * 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 <stdio.h>
-#include "debug.h"
-#include "storage.h"
-#include "adc.h"
-#include "power.h"
-#include "powermgmt.h"
-
-const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] =
-{
- 4750
-};
-
-const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
-{
- 4400
-};
-
-/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
-const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
-{
- /* original values were taken directly after charging, but it should show
- 100% after turning off the device for some hours, too */
- { 4500, 4810, 4910, 4970, 5030, 5070, 5120, 5140, 5170, 5250, 5400 }
- /* orig. values: ...,5280,5600 */
-};
-
-/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */
-const unsigned short percent_to_volt_charge[11] =
-{
- /* values guessed, see
- http://www.seattlerobotics.org/encoder/200210/LiIon2.pdf until someone
- measures voltages over a charging cycle */
- 4760, 5440, 5510, 5560, 5610, 5640, 5660, 5760, 5820, 5840, 5850 /* NiMH */
-};
-
-#define BATTERY_SCALE_FACTOR 6620
-/* full-scale ADC readout (2^10) in millivolt */
-
-/* Returns battery voltage from ADC [millivolts] */
-int _battery_voltage(void)
-{
- return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10;
-}
-
-void powermgmt_init_target(void)
-{
-}
-
-/** Charger control **/
-#ifdef CHARGING_DEBUG_FILE
-#include "file.h"
-#define DEBUG_FILE_NAME "/powermgmt.csv"
-#define DEBUG_MESSAGE_LEN 133
-static char debug_message[DEBUG_MESSAGE_LEN];
-static int fd = -1; /* write debug information to this file */
-static int wrcount = 0;
-#endif /* CHARGING_DEBUG_FILE */
-
-/*
- * For a complete description of the charging algorithm read
- * docs/CHARGING_ALGORITHM.
- */
-int long_delta; /* long term delta battery voltage */
-int short_delta; /* short term delta battery voltage */
-static bool disk_activity_last_cycle = false; /* flag set to aid charger time
- * calculation */
-char power_message[POWER_MESSAGE_LEN] = ""; /* message that's shown in
- debug menu */
- /* percentage at which charging
- starts */
-int powermgmt_last_cycle_startstop_min = 0; /* how many minutes ago was the
- charging started or
- stopped? */
-int powermgmt_last_cycle_level = 0; /* which level had the
- batteries at this time? */
-int trickle_sec = 0; /* how many seconds should the
- charger be enabled per
- minute for trickle
- charging? */
-int pid_p = 0; /* PID proportional term */
-int pid_i = 0; /* PID integral term */
-
-static unsigned int target_voltage = TRICKLE_VOLTAGE; /* desired topoff/trickle
- * voltage level */
-static int charge_max_time_idle = 0; /* max. charging duration, calculated at
- * beginning of charging */
-static int charge_max_time_now = 0; /* max. charging duration including
- * hdd activity */
-static int minutes_disk_activity = 0; /* count minutes of hdd use during
- * charging */
-static int last_disk_activity = CHARGE_END_LONGD + 1; /* last hdd use x mins ago */
-
-#ifdef CHARGING_DEBUG_FILE
-static void debug_file_close(void)
-{
- if (fd >= 0) {
- close(fd);
- fd = -1;
- }
-}
-
-static void debug_file_log(void)
-{
- if (usb_inserted()) {
- /* It is probably too late to close the file but we can try... */
- debug_file_close();
- }
- else if (fd < 0) {
- fd = open(DEBUG_FILE_NAME, O_WRONLY | O_APPEND | O_CREAT, 0666);
-
- if (fd >= 0) {
- snprintf(debug_message, DEBUG_MESSAGE_LEN,
- "cycle_min, bat_millivolts, bat_percent, chgr_state"
- " ,charge_state, pid_p, pid_i, trickle_sec\n");
- write(fd, debug_message, strlen(debug_message));
- wrcount = 99; /* force a flush */
- }
- }
- else {
- snprintf(debug_message, DEBUG_MESSAGE_LEN,
- "%d, %d, %d, %d, %d, %d, %d, %d\n",
- powermgmt_last_cycle_startstop_min, battery_voltage(),
- battery_level(), charger_input_state, charge_state,
- pid_p, pid_i, trickle_sec);
- write(fd, debug_message, strlen(debug_message));
- wrcount++;
- }
-}
-
-static void debug_file_sync(void)
-{
- /*
- * If we have a lot of pending writes or if the disk is spining,
- * fsync the debug log file.
- */
- if (wrcount > 10 || (wrcount > 0 && storage_disk_is_active())) {
- if (fd >= 0)
- fsync(fd);
-
- wrcount = 0;
- }
-}
-#else /* !CHARGING_DEBUG_FILE */
-#define debug_file_close()
-#define debug_file_log()
-#define debug_file_sync()
-#endif /* CHARGING_DEBUG_FILE */
-
-/*
- * Do tasks that should be done every step.
- */
-static void do_frequent_tasks(void)
-{
- if (storage_disk_is_active()) {
- /* flag hdd use for charging calculation */
- disk_activity_last_cycle = true;
- }
-
- debug_file_sync();
-}
-
-/*
- * The charger was just plugged in. If the battery level is
- * nearly charged, just trickle. If the battery is low, start
- * a full charge cycle. If the battery level is in between,
- * top-off and then trickle.
- */
-static void charger_plugged(void)
-{
- int battery_percent = battery_level();
-
- pid_p = 0;
- pid_i = 0;
- powermgmt_last_cycle_level = battery_percent;
- powermgmt_last_cycle_startstop_min = 0;
-
- snprintf(power_message, POWER_MESSAGE_LEN, "Charger plugged in");
-
- if (battery_percent > START_TOPOFF_CHG) {
-
- if (battery_percent >= START_TRICKLE_CHG) {
- charge_state = TRICKLE;
- target_voltage = TRICKLE_VOLTAGE;
- }
- else {
- charge_state = TOPOFF;
- target_voltage = TOPOFF_VOLTAGE;
- }
- }
- else {
- /*
- * Start the charger full strength
- */
- int i = CHARGE_MAX_MIN_1500 * get_battery_capacity() / 1500;
- charge_max_time_idle = i * (100 + 35 - battery_percent) / 100;
-
- if (charge_max_time_idle > i)
- charge_max_time_idle = i;
-
- charge_max_time_now = charge_max_time_idle;
-
- snprintf(power_message, POWER_MESSAGE_LEN,
- "ChgAt %d%% max %dm", battery_percent,
- charge_max_time_now);
-
- /*
- * Enable the charger after the max time calc is done,
- * because battery_level depends on if the charger is
- * on.
- */
- DEBUGF("power: charger inserted and battery"
- " not full, charging\n");
- trickle_sec = 60;
- long_delta = short_delta = 999999;
- charge_state = CHARGING;
- }
-}
-
-/*
- * The charger was just unplugged.
- */
-static void charger_unplugged(void)
-{
- DEBUGF("power: charger disconnected, disabling\n");
-
- charger_enable(false);
- powermgmt_last_cycle_level = battery_level();
- powermgmt_last_cycle_startstop_min = 0;
- trickle_sec = 0;
- pid_p = 0;
- pid_i = 0;
- charge_state = DISCHARGING;
- snprintf(power_message, POWER_MESSAGE_LEN, "Charger: discharge");
-}
-
-static void charging_step(void)
-{
- int i;
-
- /* alter charge time max length with extra disk use */
- if (disk_activity_last_cycle) {
- minutes_disk_activity++;
- charge_max_time_now = charge_max_time_idle +
- minutes_disk_activity*2 / 5;
- disk_activity_last_cycle = false;
- last_disk_activity = 0;
- }
- else {
- last_disk_activity++;
- }
-
- /*
- * Check the delta voltage over the last X minutes so we can do
- * our end-of-charge logic based on the battery level change
- * (no longer use minimum time as logic for charge end has 50
- * minutes minimum charge built in).
- */
- if (powermgmt_last_cycle_startstop_min > CHARGE_END_SHORTD) {
- short_delta = power_history[0] -
- power_history[CHARGE_END_SHORTD - 1];
- }
-
- if (powermgmt_last_cycle_startstop_min > CHARGE_END_LONGD) {
- /*
- * Scan the history: the points where measurement is taken need to
- * be fairly static. Check prior to short delta 'area'. Also only
- * check first and last 10 cycles (delta in middle OK).
- */
- long_delta = power_history[0] -
- power_history[CHARGE_END_LONGD - 1];
-
- for (i = CHARGE_END_SHORTD; i < CHARGE_END_SHORTD + 10; i++)
- {
- if ((power_history[i] - power_history[i+1]) > 50 ||
- (power_history[i] - power_history[i+1]) < -50) {
- long_delta = 777777;
- break;
- }
- }
-
- for (i = CHARGE_END_LONGD - 11; i < CHARGE_END_LONGD - 1 ; i++)
- {
- if ((power_history[i] - power_history[i+1]) > 50 ||
- (power_history[i] - power_history[i+1]) < -50) {
- long_delta = 888888;
- break;
- }
- }
- }
-
- snprintf(power_message, POWER_MESSAGE_LEN,
- "Chg %dm, max %dm", powermgmt_last_cycle_startstop_min,
- charge_max_time_now);
-
- /*
- * End of charge criteria (any qualify):
- * 1) Charged a long time
- * 2) DeltaV went negative for a short time ( & long delta static)
- * 3) DeltaV was negative over a longer period (no disk use only)
- *
- * Note: short_delta and long_delta are millivolts
- */
- if (powermgmt_last_cycle_startstop_min >= charge_max_time_now ||
- (short_delta <= -50 && long_delta < 50) ||
- (long_delta < -20 && last_disk_activity > CHARGE_END_LONGD)) {
-
- int battery_percent = battery_level();
-
- if (powermgmt_last_cycle_startstop_min > charge_max_time_now) {
- DEBUGF("power: powermgmt_last_cycle_startstop_min > charge_max_time_now, "
- "enough!\n");
- /*
- * Have charged too long and deltaV detection did not
- * work!
- */
- snprintf(power_message, POWER_MESSAGE_LEN,
- "Chg tmout %d min", charge_max_time_now);
- /*
- * Switch to trickle charging. We skip the top-off
- * since we've effectively done the top-off operation
- * already since we charged for the maximum full
- * charge time.
- */
- powermgmt_last_cycle_level = battery_percent;
- powermgmt_last_cycle_startstop_min = 0;
- charge_state = TRICKLE;
-
- /*
- * Set trickle charge target to a relative voltage instead
- * of an arbitrary value - the fully charged voltage may
- * vary according to ambient temp, battery condition etc.
- * Trickle target is -0.15v from full voltage acheived.
- * Topup target is -0.05v from full voltage.
- */
- target_voltage = power_history[0] - 150;
-
- }
- else {
- if(short_delta <= -5) {
- DEBUGF("power: short-term negative"
- " delta, enough!\n");
- snprintf(power_message, POWER_MESSAGE_LEN,
- "end negd %d %dmin", short_delta,
- powermgmt_last_cycle_startstop_min);
- target_voltage = power_history[CHARGE_END_SHORTD - 1] - 50;
- }
- else {
- DEBUGF("power: long-term small "
- "positive delta, enough!\n");
- snprintf(power_message, POWER_MESSAGE_LEN,
- "end lowd %d %dmin", long_delta,
- powermgmt_last_cycle_startstop_min);
- target_voltage = power_history[CHARGE_END_LONGD - 1] - 50;
- }
-
- /*
- * Switch to top-off charging.
- */
- powermgmt_last_cycle_level = battery_percent;
- powermgmt_last_cycle_startstop_min = 0;
- charge_state = TOPOFF;
- }
- }
-}
-
-static void topoff_trickle_step(void)
-{
- unsigned int millivolts;
-
- /*
- *Time to switch from topoff to trickle?
- */
- if (charge_state == TOPOFF &&
- powermgmt_last_cycle_startstop_min > TOPOFF_MAX_MIN) {
-
- powermgmt_last_cycle_level = battery_level();
- powermgmt_last_cycle_startstop_min = 0;
- charge_state = TRICKLE;
- target_voltage = target_voltage - 100;
- }
- /*
- * Adjust trickle charge time (proportional and integral terms).
- * Note: I considered setting the level higher if the USB is
- * plugged in, but it doesn't appear to be necessary and will
- * generate more heat [gvb].
- */
- millivolts = battery_voltage();
-
- pid_p = ((signed)target_voltage - (signed)millivolts) / 5;
- if (pid_p <= PID_DEADZONE && pid_p >= -PID_DEADZONE)
- pid_p = 0;
-
- if ((unsigned)millivolts < target_voltage) {
- if (pid_i < 60)
- pid_i++; /* limit so it doesn't "wind up" */
- }
- else {
- if (pid_i > 0)
- pid_i--; /* limit so it doesn't "wind up" */
- }
-
- trickle_sec = pid_p + pid_i;
-
- if (trickle_sec > 60)
- trickle_sec = 60;
-
- if (trickle_sec < 0)
- trickle_sec = 0;
-}
-
-void charging_algorithm_step(void)
-{
- static int pwm_counter = 0; /* PWM total cycle in steps */
- static int pwm_duty = 0; /* PWM duty cycle in steps */
-
- switch (charger_input_state)
- {
- case CHARGER_PLUGGED:
- charger_plugged();
- break;
-
- case CHARGER_UNPLUGGED:
- charger_unplugged();
- break;
-
- case CHARGER:
- case NO_CHARGER:
- do_frequent_tasks();
-
- if (pwm_counter > 0) {
- if (pwm_duty > 0 && --pwm_duty <= 0)
- charger_enable(false); /* Duty cycle expired */
-
- if (--pwm_counter > 0)
- return;
-
- /* PWM cycle is complete */
- powermgmt_last_cycle_startstop_min++;
- debug_file_log();
- }
- break;
- }
-
- switch (charge_state)
- {
- case CHARGING:
- charging_step();
- break;
-
- case TOPOFF:
- case TRICKLE:
- topoff_trickle_step();
- break;
-
- case DISCHARGING:
- default:
- break;
- }
-
- /* If 100%, ensure pwm_on never expires and briefly disables the
- * charger. */
- pwm_duty = (trickle_sec < 60) ? trickle_sec*2 : 0;
- pwm_counter = 60*2;
- charger_enable(trickle_sec > 0);
-}
-
-void charging_algorithm_close(void)
-{
-#ifdef CHARGING_DEBUG_FILE
- debug_file_close();
-#endif /* CHARGING_DEBUG_FILE */
-}
-
-/* Returns true if the unit is charging the batteries. */
-bool charging_state(void)
-{
- return charge_state == CHARGING;
-}
diff --git a/firmware/target/sh/archos/recorder/powermgmt-target.h b/firmware/target/sh/archos/recorder/powermgmt-target.h
deleted file mode 100644
index 6b68d05bd4..0000000000
--- a/firmware/target/sh/archos/recorder/powermgmt-target.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2002 by Heikki Hannikainen, Uwe Freese
- * Revisions copyright (C) 2005 by Gerald Van Baren
- *
- * 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 POWERMGMT_TARGET_H
-#define POWERMGMT_TARGET_H
-
-/*
- * Define CHARGING_DEBUG_FILE to create a csv (spreadsheet) with battery
- * information in it (one sample per minute/connect/disconnect).
- *
- * This is only for very low level debug.
- */
-#undef CHARGING_DEBUG_FILE
-
-
-/* stop when N minutes have passed with avg delta being < -0.05 V */
-#define CHARGE_END_SHORTD 6
-/* stop when N minutes have passed with avg delta being < -0.02 V */
-#define CHARGE_END_LONGD 50
-
-/* Battery % to start at top-off */
-#define START_TOPOFF_CHG 85
-/* Battery % to start at trickle */
-#define START_TRICKLE_CHG 95
-/* power thread status message */
-#define POWER_MESSAGE_LEN 32
-/* minutes: maximum charging time for 1500 mAh batteries
- * actual max time depends also on BATTERY_CAPACITY! */
-#define CHARGE_MAX_MIN_1500 450
-/* minutes: minimum charging time */
-#define CHARGE_MIN_MIN 10
-/* After charging, go to top off charge. How long should top off charge be? */
-#define TOPOFF_MAX_MIN 90
-/* which voltage is best? (millivolts) */
-#define TOPOFF_VOLTAGE 5650
-/* After top off charge, go to trickle harge. How long should trickle
- * charge be? */
-#define TRICKLE_MAX_MIN 720 /* 12 hrs */
-/* which voltage is best? (millivolts) */
-#define TRICKLE_VOLTAGE 5450
-/* initial trickle_sec for topoff */
-#define START_TOPOFF_SEC 25
-/* initial trickle_sec for trickle */
-#define START_TRICKLE_SEC 15
-
-#define PID_DEADZONE 4 /* PID proportional deadzone */
-
-extern char power_message[POWER_MESSAGE_LEN];
-
-extern int long_delta; /* long term delta battery voltage */
-extern int short_delta; /* short term delta battery voltage */
-
-extern int powermgmt_last_cycle_startstop_min; /* how many minutes ago was
- the charging started or
- stopped? */
-extern int powermgmt_last_cycle_level; /* which level had the batteries
- at this time? */
-
-extern int pid_p; /* PID proportional term */
-extern int pid_i; /* PID integral term */
-extern int trickle_sec; /* how many seconds should the
- charger be enabled per
- minute for trickle
- charging? */
-void charger_enable(bool on);
-bool charger_enabled(void);
-
-/* Battery filter lengths in samples */
-#define BATT_AVE_SAMPLES 32
-
-#endif /* POWERMGMT_TARGET_H */
diff --git a/firmware/target/sh/archos/recorder/usb-recorder.c b/firmware/target/sh/archos/recorder/usb-recorder.c
deleted file mode 100644
index f8b462b802..0000000000
--- a/firmware/target/sh/archos/recorder/usb-recorder.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2007 by Jens Arnold
- *
- * 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 <stdbool.h>
-#include "adc.h"
-#include "cpu.h"
-#include "hwcompat.h"
-#include "system.h"
-#include "usb.h"
-
-int usb_detect(void)
-{
- return (adc_read(ADC_USB_POWER) > 500) ? USB_INSERTED : USB_EXTRACTED;
-}
-
-void usb_enable(bool on)
-{
- if(HW_MASK & USB_ACTIVE_HIGH)
- on = !on;
-
- if(on)
- and_b(~0x04, &PADRH); /* enable USB */
- else
- or_b(0x04, &PADRH);
-}
-
-void usb_init_device(void)
-{
- usb_enable(false);
- or_b(0x04, &PAIORH);
-}
diff --git a/firmware/target/sh/archos/timer-archos.c b/firmware/target/sh/archos/timer-archos.c
deleted file mode 100644
index 98a3afb4b6..0000000000
--- a/firmware/target/sh/archos/timer-archos.c
+++ /dev/null
@@ -1,84 +0,0 @@
-/***************************************************************************
-* __________ __ ___.
-* Open \______ \ ____ ____ | | _\_ |__ _______ ___
-* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
-* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
-* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
-* \/ \/ \/ \/ \/
-* $Id$
-*
-* Copyright (C) 2005 Jens Arnold
-*
-* 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 "cpu.h"
-#include "system.h"
-#include "timer.h"
-
-void IMIA4(void) __attribute__((interrupt_handler));
-void IMIA4(void)
-{
- if (pfn_timer != NULL)
- pfn_timer();
- and_b(~0x01, &TSR4); /* clear the interrupt */
-}
-
-bool timer_set(long cycles, bool start)
-{
- int phi = 0; /* bits for the prescaler */
- int prescale = 1;
-
- while (cycles > 0x10000)
- { /* work out the smallest prescaler that makes it fit */
- phi++;
- prescale <<= 1;
- cycles >>= 1;
- }
-
- if (prescale > 8)
- return false;
-
- if (start)
- {
- if (pfn_unregister != NULL)
- {
- pfn_unregister();
- pfn_unregister = NULL;
- }
-
- and_b(~0x10, &TSTR); /* Stop the timer 4 */
- and_b(~0x10, &TSNC); /* No synchronization */
- and_b(~0x10, &TMDR); /* Operate normally */
-
- TIER4 = 0xF9; /* Enable GRA match interrupt */
- }
-
- TCR4 = 0x20 | phi; /* clear at GRA match, set prescaler */
- GRA4 = (unsigned short)(cycles - 1);
- if (start || (TCNT4 >= GRA4))
- TCNT4 = 0;
- and_b(~0x01, &TSR4); /* clear an eventual interrupt */
-
- return true;
-}
-
-bool timer_start(void)
-{
- IPRD = (IPRD & 0xFF0F) | 1 << 4; /* interrupt priority */
- or_b(0x10, &TSTR); /* start timer 4 */
- return true;
-}
-
-void timer_stop(void)
-{
- and_b(~0x10, &TSTR); /* stop the timer 4 */
- IPRD = (IPRD & 0xFF0F); /* disable interrupt */
-}
diff --git a/firmware/target/sh/archos/uart-archos.c b/firmware/target/sh/archos/uart-archos.c
deleted file mode 100644
index d17678f812..0000000000
--- a/firmware/target/sh/archos/uart-archos.c
+++ /dev/null
@@ -1,167 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2002 by Alan Korr & Nick Robinson
- *
- * 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 <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-
-#include "config.h"
-#include "button.h"
-#include "cpu.h"
-#include "system.h"
-#include "kernel.h"
-#include "serial.h"
-
-/* FIX: this doesn't work on iRiver or iPod yet */
-/* iFP7xx has no remote */
-
-/* Received byte identifiers */
-#define PLAY 0xC1
-#define STOP 0xC2
-#define PREV 0xC4
-#define NEXT 0xC8
-#define VOLUP 0xD0
-#define VOLDN 0xE0
-
-void serial_setup (void)
-{
- /* Set PB10 function to serial Rx */
- PBCR1 = (PBCR1 & 0xffcf) | 0x0020;
-
- SMR1 = 0x00;
- SCR1 = 0;
- BRR1 = (FREQ/(32*9600))-1;
- and_b(0, &SSR1); /* The status bits must be read before they are cleared,
- so we do an AND operation */
-
- /* Let the hardware settle. The serial port needs to wait "at least
- the interval required to transmit or receive one bit" before it
- can be used. */
- sleep(1);
-
- SCR1 = 0x10; /* Enable the receiver, no interrupt */
-}
-
-int tx_rdy(void)
-{
- /* a dummy */
- return 1;
-}
-
-static int rx_rdy(void)
-{
- if(SSR1 & SCI_RDRF)
- return 1;
- else
- return 0;
-}
-
-void tx_writec(unsigned char c)
-{
- /* a dummy */
- (void)c;
-}
-
-static unsigned char rx_readc(void)
-{
- char tmp;
- /* Read byte and clear the Rx Full bit */
- tmp = RDR1;
- and_b(~SCI_RDRF, &SSR1);
- return tmp;
-}
-
-
-/* This function returns the received remote control code only if it is
- received without errors before or after the reception.
- It therefore returns the received code on the second call after the
- code has been received. */
-int remote_control_rx(void)
-{
- static int last_valid_button = BUTTON_NONE;
- static int last_was_error = false;
- int btn;
- int ret = BUTTON_NONE;
-
- /* Errors? Just clear'em. The receiver stops if we don't */
- if(SSR1 & (SCI_ORER | SCI_FER | SCI_PER)) {
- and_b(~(SCI_ORER | SCI_FER | SCI_PER), &SSR1);
- last_valid_button = BUTTON_NONE;
- last_was_error = true;
- return BUTTON_NONE;
- }
-
- if(rx_rdy()) {
- btn = rx_readc();
-
- if(last_was_error)
- {
- last_valid_button = BUTTON_NONE;
- ret = BUTTON_NONE;
- }
- else
- {
- switch (btn)
- {
- case STOP:
- last_valid_button = BUTTON_RC_STOP;
- break;
-
- case PLAY:
- last_valid_button = BUTTON_RC_PLAY;
- break;
-
- case VOLUP:
- last_valid_button = BUTTON_RC_VOL_UP;
- break;
-
- case VOLDN:
- last_valid_button = BUTTON_RC_VOL_DOWN;
- break;
-
- case PREV:
- last_valid_button = BUTTON_RC_LEFT;
- break;
-
- case NEXT:
- last_valid_button = BUTTON_RC_RIGHT;
- break;
-
- default:
- last_valid_button = BUTTON_NONE;
- break;
- }
- }
- }
- else
- {
- /* This means that a valid remote control character was received
- the last time we were called, with no receiver errors either before
- or after. Then we can assume that there really is a remote control
- attached, and return the button code. */
- ret = last_valid_button;
- last_valid_button = BUTTON_NONE;
- }
-
- last_was_error = false;
-
- return ret;
-}
-
diff --git a/firmware/target/sh/bitswap.S b/firmware/target/sh/bitswap.S
deleted file mode 100644
index ba8dd0cc1a..0000000000
--- a/firmware/target/sh/bitswap.S
+++ /dev/null
@@ -1,152 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2004 by Jens Arnold
- *
- * 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.
- *
- ****************************************************************************/
-
- .section .icode,"ax",@progbits
- .align 2
- .global _bitswap
- .type _bitswap,@function
-
-/* Flips the bits of all bytes in a memory area (required for mp3 data on
- * the Archos). This version is optimized for speed and size.
- *
- * arguments:
- * r4 - start address
- * r5 - length
- *
- * return value: void
- *
- * register usage:
- * r0 - temporary
- * r1 - bit mask for rounding to long bound / low byte (after swap)
- * r2 - high byte (after swap) / combined result
- * r4 - data address - 4
- * r5 - end address - 4
- * r7 - flip table (addressing with signed offset)
- *
- * The instruction order below is devised in a way to utilize the pipelining
- * of the SH1 to the max.
- */
-
-_bitswap:
- mova _fliptable,r0
- mov r0,r7
- add #-4,r4 /* address is shifted by 4 */
- add r4,r5 /* r5 = end_address - 4 */
- cmp/hi r4,r5 /* at least something to do? */
- bf .exit /* no, get out of here! */
-
- add #-3,r5 /* end offset for flipping 4 bytes per pass */
- mov r4,r0
- tst #1,r0 /* even address? */
- bt .start2_w /* yes, jump into main loop */
-
- /* no, flip first byte */
- mov.b @(4,r4),r0 /* load byte, sign extension! */
- add #1,r4 /* early increment */
- mov.b @(r0,r7),r0 /* fliptable offset is signed */
- bra .start2_w /* jump into main loop */
- mov.b r0,@(3,r4) /* store byte */
-
- /* main loop: flips 2 words per pass */
- .align 2
-.loop2_w:
- mov.w @(6,r4),r0 /* load second word */
- add #4,r4 /* early increment */
- swap.b r0,r2 /* get high byte (2nd word) */
- exts.b r0,r0 /* prepare low byte (2nd word) */
- mov.b @(r0,r7),r1 /* swap low byte (2nd word) */
- exts.b r2,r0 /* prepare high byte (2nd word) */
- mov.b @(r0,r7),r2 /* swap high byte (2nd word) */
- extu.b r1,r0 /* zero extend low byte (2nd word) */
- mov.w @r4,r1 /* load first word */
- shll8 r2 /* shift high byte (2nd word), low byte zeroed */
- or r2,r0 /* put low byte (2nd word) in result */
- swap.b r1,r2 /* get high byte (1st word) */
- mov.w r0,@(2,r4) /* store result (2nd word) */
- exts.b r1,r0 /* prepare low byte (1st word) */
- mov.b @(r0,r7),r1 /* swap low byte (1st word) */
- exts.b r2,r0 /* prepare high byte (1st word) */
- mov.b @(r0,r7),r2 /* swap high byte (1st word) */
- extu.b r1,r0 /* zero extend low byte (1st word) */
- shll8 r2 /* shift high byte (1st word), low byte zeroed */
- or r2,r0 /* put low byte (1st word) in result */
- mov.w r0,@r4 /* store result (1st word) */
-.start2_w:
- cmp/hi r4,r5 /* runs r4 up to last long bound */
- bt .loop2_w
-
- bra .start_b2 /* jump into trailing byte loop */
- add #3,r5 /* reset end offset */
-
- /* trailing byte loop: flips 0..3 bytes */
-.loop_b2:
- mov.b @(4,r4),r0 /* loand byte, sign extension! */
- add #1,r4 /* early increment */
- mov.b @(r0,r7),r0 /* fliptable offset is signed */
- mov.b r0,@(3,r4) /* store byte */
-.start_b2:
- cmp/hi r4,r5 /* runs r4 up to end address */
- bt .loop_b2
-
-.exit:
- rts
- nop
-
- .align 2
- .global _fliptable
-
- .byte 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1
- .byte 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1
- .byte 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9
- .byte 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9
- .byte 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5
- .byte 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5
- .byte 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed
- .byte 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd
- .byte 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3
- .byte 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3
- .byte 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb
- .byte 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb
- .byte 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7
- .byte 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7
- .byte 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef
- .byte 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff
-_fliptable:
- .byte 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0
- .byte 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0
- .byte 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8
- .byte 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8
- .byte 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4
- .byte 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4
- .byte 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec
- .byte 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc
- .byte 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2
- .byte 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2
- .byte 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea
- .byte 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa
- .byte 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6
- .byte 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6
- .byte 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee
- .byte 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe
-
-
-.end:
- .size _bitswap,.end-_bitswap
diff --git a/firmware/target/sh/crt0.S b/firmware/target/sh/crt0.S
deleted file mode 100644
index 0e8bbfdd68..0000000000
--- a/firmware/target/sh/crt0.S
+++ /dev/null
@@ -1,219 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2002 by Linus Nielsen Feltzing
- *
- * 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"
-
- .section .init.text,"ax",@progbits
-
- .global start
-start:
-
- mov.l .vbr_k,r1
-#ifdef DEBUG
- /* If we have built our code to be loaded via the standalone GDB
- * stub, we will have out VBR at some other location than 0x9000000.
- * We must copy the trap vectors for the GDB stub to our vector table. */
- mov.l .orig_vbr_k,r2
-
- /* Move the invalid instruction vector (4) */
- mov #4,r0
- shll2 r0
- mov.l @(r0,r2),r3
- mov.l r3,@(r0,r1)
-
- /* Move the invalid slot vector (6) */
- mov #6,r0
- shll2 r0
- mov.l @(r0,r2),r3
- mov.l r3,@(r0,r1)
-
- /* Move the bus error vector (9) */
- mov #9,r0
- shll2 r0
- mov.l @(r0,r2),r3
- mov.l r3,@(r0,r1)
-
- /* Move the DMA bus error vector (10) */
- mov #10,r0
- shll2 r0
- mov.l @(r0,r2),r3
- mov.l r3,@(r0,r1)
-
- /* Move the NMI vector as well (11) */
- mov #11,r0
- shll2 r0
- mov.l @(r0,r2),r3
- mov.l r3,@(r0,r1)
-
- /* Move the UserBreak vector as well (12) */
- mov #12,r0
- shll2 r0
- mov.l @(r0,r2),r3
- mov.l r3,@(r0,r1)
-
- /* Move the breakpoint trap vector (32) */
- mov #32,r0
- shll2 r0
- mov.l @(r0,r2),r3
- mov.l r3,@(r0,r1)
-
- /* Move the IO trap vector (33) */
- mov #33,r0
- shll2 r0
- mov.l @(r0,r2),r3
- mov.l r3,@(r0,r1)
-
- /* Move the serial Rx interrupt vector (105) */
- mov #105,r0
- shll2 r0
- mov.l @(r0,r2),r3
- mov.l r3,@(r0,r1)
-
- /* Move the single step trap vector (127) */
- mov #127,r0
- shll2 r0
- mov.l @(r0,r2),r3
- mov.l r3,@(r0,r1)
-#endif /* DEBUG */
- ldc r1,vbr
-
- mov #0,r0
- ldc r0,gbr
-
- /* .iram copy is done first since it is reclaimed for other
- * uninitialized sections */
-
- /* copy the .iram section */
- mov.l .iramcopy_k,r0
- mov.l .iram_k,r1
- mov.l .iramend_k,r2
- /* Note: We cannot put a PC relative load into the delay slot of a 'bra'
- instruction (the offset would be wrong), but there is nothing else to
- do before the loop, so the delay slot would be 'nop'. The cmp / bf
- sequence is the same length, but more efficient. */
- cmp/hi r1,r2
- bf .noiramcopy
-.iramloop:
- mov.l @r0+,r3
- mov.l r3,@r1
- add #4,r1
- cmp/hi r1,r2
- bt .iramloop
-.noiramcopy:
-
- /* zero out .ibss */
- mov.l .iedata_k,r0
- mov.l .iend_k,r1
- bra .iedatastart
- mov #0,r2
-.iedataloop: /* backwards is faster and shorter */
- mov.l r2,@-r1
-.iedatastart:
- cmp/hi r0,r1
- bt .iedataloop
-
- /* zero out bss */
- mov.l .edata_k,r0
- mov.l .end_k,r1
- bra .edatastart
- mov #0,r2
-.edataloop: /* backwards is faster and shorter */
- mov.l r2,@-r1
-.edatastart:
- cmp/hi r0,r1
- bt .edataloop
-
- /* copy the .data section, for rombased execution */
- mov.l .datacopy_k,r0
- mov.l .data_k,r1
- cmp/eq r0,r1
- bt .nodatacopy /* Don't copy if src and dest are equal */
- mov.l .dataend_k,r2
- cmp/hi r1,r2
- bf .nodatacopy
-.dataloop:
- mov.l @r0+,r3
- mov.l r3,@r1
- add #4,r1
- cmp/hi r1,r2
- bt .dataloop
-.nodatacopy:
-
- /* Munge the main thread stack */
- mov.l .stackbegin_k,r0
- mov.l .stackend_k,r1
- mov r1,r15
- mov.l .deadbeef_k,r2
-.mungeloop: /* backwards is faster and shorter */
- mov.l r2,@-r1
- cmp/hi r0,r1
- bt .mungeloop
-
- /* call the mainline */
- mov.l .main_k,r0
- jsr @r0
- nop
-.hoo:
- bra .hoo
- nop
-
- .align 2
-.vbr_k:
- .long vectors
-#ifdef DEBUG
-.orig_vbr_k:
- .long 0x09000000
-#endif
-.iedata_k:
- .long _iedata
-.iend_k:
- .long _iend
-.iramcopy_k:
- .long _iramcopy
-.iram_k:
- .long _iramstart
-.iramend_k:
- .long _iramend
-.edata_k:
- .long _edata
-.end_k:
- .long _end
-.datacopy_k:
- .long _datacopy
-.data_k:
- .long _datastart
-.dataend_k:
- .long _dataend
-.stackbegin_k:
- .long _stackbegin
-.stackend_k:
- .long _stackend
-.deadbeef_k:
- .long 0xdeadbeef
-.main_k:
- .long _main
-
- .section .resetvectors
-vectors:
- .long start
- .long _stackend
- .long start
- .long _stackend
diff --git a/firmware/target/sh/debug-sh.c b/firmware/target/sh/debug-sh.c
deleted file mode 100644
index bee4896174..0000000000
--- a/firmware/target/sh/debug-sh.c
+++ /dev/null
@@ -1,285 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2002 Heikki Hannikainen
- *
- * 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 <stdbool.h>
-#include <string.h>
-
-#include "config.h"
-#include "system.h"
-#include "kernel.h"
-#include "font.h"
-#include "lcd.h"
-#include "button.h"
-#include "powermgmt.h"
-#include "adc.h"
-#include "hwcompat.h" /* ROM_VERSION */
-#include "crc32.h"
-
-#if CONFIG_KEYPAD == RECORDER_PAD
-# define DEBUG_CANCEL BUTTON_OFF
-
-#elif CONFIG_KEYPAD == ONDIO_PAD
-# define DEBUG_CANCEL BUTTON_MENU
-#endif
-
-/* Tool function to read the flash manufacturer and type, if available.
- Only chips which could be reprogrammed in system will return values.
- (The mode switch addresses vary between flash manufacturers, hence addr1/2) */
- /* In IRAM to avoid problems when running directly from Flash */
-static bool dbg_flash_id(unsigned* p_manufacturer, unsigned* p_device,
- unsigned addr1, unsigned addr2)
- ICODE_ATTR __attribute__((noinline));
-static bool dbg_flash_id(unsigned* p_manufacturer, unsigned* p_device,
- unsigned addr1, unsigned addr2)
-{
- unsigned not_manu, not_id; /* read values before switching to ID mode */
- unsigned manu, id; /* read values when in ID mode */
-
- volatile unsigned char* flash = (unsigned char*)0x2000000; /* flash mapping */
- int old_level; /* saved interrupt level */
-
- not_manu = flash[0]; /* read the normal content */
- not_id = flash[1]; /* should be 'A' (0x41) and 'R' (0x52) from the "ARCH" marker */
-
- /* disable interrupts, prevent any stray flash access */
- old_level = disable_irq_save();
-
- flash[addr1] = 0xAA; /* enter command mode */
- flash[addr2] = 0x55;
- flash[addr1] = 0x90; /* ID command */
- /* Atmel wants 20ms pause here */
- /* sleep(HZ/50); no sleeping possible while interrupts are disabled */
-
- manu = flash[0]; /* read the IDs */
- id = flash[1];
-
- flash[0] = 0xF0; /* reset flash (back to normal read mode) */
- /* Atmel wants 20ms pause here */
- /* sleep(HZ/50); no sleeping possible while interrupts are disabled */
-
- restore_irq(old_level); /* enable interrupts again */
- /* I assume success if the obtained values are different from
- the normal flash content. This is not perfectly bulletproof, they
- could theoretically be the same by chance, causing us to fail. */
- if (not_manu != manu || not_id != id) /* a value has changed */
- {
- *p_manufacturer = manu; /* return the results */
- *p_device = id;
- return true; /* success */
- }
- return false; /* fail */
-}
-
-bool dbg_ports(void)
-{
- int adc_battery_voltage;
-#ifndef HAVE_LCD_BITMAP
- int currval = 0;
- int button;
-#else
- int adc_battery_level;
-
- lcd_setfont(FONT_SYSFIXED);
-#endif
- lcd_clear_display();
-
- while(1)
- {
-#ifdef HAVE_LCD_BITMAP
- lcd_putsf(0, 0, "PADR: %04x", (unsigned short)PADR);
- lcd_putsf(0, 1, "PBDR: %04x", (unsigned short)PBDR);
-
- lcd_putsf(0, 2, "AN0: %03x AN4: %03x", adc_read(0), adc_read(4));
- lcd_putsf(0, 3, "AN1: %03x AN5: %03x", adc_read(1), adc_read(5));
- lcd_putsf(0, 4, "AN2: %03x AN6: %03x", adc_read(2), adc_read(6));
- lcd_putsf(0, 5, "AN3: %03x AN7: %03x", adc_read(3), adc_read(7));
-
- battery_read_info(&adc_battery_voltage, &adc_battery_level);
- lcd_putsf(0, 6, "Batt: %d.%03dV %d%% ", adc_battery_voltage / 1000,
- adc_battery_voltage % 1000, adc_battery_level);
-
- lcd_update();
-
- while (button_get_w_tmo(HZ/10) != (DEBUG_CANCEL|BUTTON_REL));
-
- lcd_setfont(FONT_UI);
-
-#else /* !HAVE_LCD_BITMAP */
-
- if (currval == 0) {
- lcd_putsf(0, 0, "PADR: %04x", (unsigned short)PADR);
- } else if (currval == 1) {
- lcd_putsf(0, 0, "PBDR: %04x", (unsigned short)PBDR);
- } else {
- int idx = currval - 2; /* idx < 7 */
- lcd_putsf(0, 0, "AN%d: %03x", idx, adc_read(idx));
- }
-
- battery_read_info(&adc_battery_voltage, NULL);
- lcd_putsf(0, 1, "Batt: %d.%03dV", adc_battery_voltage / 1000,
- adc_battery_voltage % 1000);
- lcd_update();
-
- button = button_get_w_tmo(HZ/5);
- switch(button)
- {
- case BUTTON_STOP:
- return false;
-
- case BUTTON_LEFT:
- currval--;
- if(currval < 0)
- currval = 9;
- break;
-
- case BUTTON_RIGHT:
- currval++;
- if(currval > 9)
- currval = 0;
- break;
- }
-#endif
- }
- return false;
-}
-
-bool dbg_hw_info(void)
-{
-#ifndef HAVE_LCD_BITMAP
- int button;
- int currval = 0;
-#else
- int bitmask = HW_MASK;
-#endif
- int rom_version = ROM_VERSION;
- unsigned manu, id; /* flash IDs */
- bool got_id; /* flag if we managed to get the flash IDs */
- unsigned rom_crc = 0xffffffff; /* CRC32 of the boot ROM */
- bool has_bootrom; /* flag for boot ROM present */
- int oldmode; /* saved memory guard mode */
-
- oldmode = system_memory_guard(MEMGUARD_NONE); /* disable memory guard */
-
- /* get flash ROM type */
- got_id = dbg_flash_id(&manu, &id, 0x5555, 0x2AAA); /* try SST, Atmel, NexFlash */
- if (!got_id)
- got_id = dbg_flash_id(&manu, &id, 0x555, 0x2AA); /* try AMD, Macronix */
-
- /* check if the boot ROM area is a flash mirror */
- has_bootrom = (memcmp((char*)0, (char*)0x02000000, 64*1024) != 0);
- if (has_bootrom) /* if ROM and Flash different */
- {
- /* calculate CRC16 checksum of boot ROM */
- rom_crc = crc_32((unsigned char*)0x0000, 64*1024, 0xffffffff);
- }
-
- system_memory_guard(oldmode); /* re-enable memory guard */
-
- lcd_clear_display();
-
-#ifdef HAVE_LCD_BITMAP
- lcd_setfont(FONT_SYSFIXED);
-
- lcd_puts(0, 0, "[Hardware info]");
-
- lcd_putsf(0, 1, "ROM: %d.%02d", rom_version/100, rom_version%100);
-
- lcd_putsf(0, 2, "Mask: 0x%04x", bitmask);
- if (got_id)
- lcd_putsf(0, 3, "Flash: M=%02x D=%02x", manu, id);
- else
- lcd_puts(0, 3, "Flash: M=?? D=??"); /* unknown, sorry */
-
- if (has_bootrom)
- {
- if (rom_crc == 0x56DBA4EE) /* known Version 1 */
- lcd_puts(0, 4, "Boot ROM: V1");
- else
- lcd_putsf(0, 4, "ROMcrc: 0x%08x", rom_crc);
- }
- else
- {
- lcd_puts(0, 4, "Boot ROM: none");
- }
-
- lcd_update();
-
- /* wait for exit */
- while (button_get_w_tmo(HZ/10) != (DEBUG_CANCEL|BUTTON_REL));
-
- lcd_setfont(FONT_UI);
-
-#else /* !HAVE_LCD_BITMAP */
- lcd_puts(0, 0, "[HW Info]");
- while(1)
- {
- switch(currval)
- {
- case 0:
- lcd_putsf(0, 1, "ROM: %d.%02d",
- rom_version/100, rom_version%100);
- break;
- case 1:
- if (got_id)
- lcd_putsf(0, 1, "Flash:%02x,%02x", manu, id);
- else
- lcd_puts(0, 1, "Flash:??,??"); /* unknown, sorry */
- break;
- case 2:
- if (has_bootrom)
- {
- if (rom_crc == 0x56DBA4EE) /* known Version 1 */
- lcd_puts(0, 1, "BootROM: V1");
- else if (rom_crc == 0x358099E8)
- lcd_puts(0, 1, "BootROM: V2");
- /* alternative boot ROM found in one single player so far */
- else
- lcd_putsf(0, 1, "R: %08x", rom_crc);
- }
- else
- lcd_puts(0, 1, "BootROM: no");
- }
-
- lcd_update();
-
- button = button_get_w_tmo(HZ/10);
-
- switch(button)
- {
- case BUTTON_STOP:
- return false;
-
- case BUTTON_LEFT:
- currval--;
- if(currval < 0)
- currval = 2;
- break;
-
- case BUTTON_RIGHT:
- currval++;
- if(currval > 2)
- currval = 0;
- break;
- }
- }
-#endif
- return false;
-}
diff --git a/firmware/target/sh/kernel-sh.c b/firmware/target/sh/kernel-sh.c
deleted file mode 100644
index 65b27e47f0..0000000000
--- a/firmware/target/sh/kernel-sh.c
+++ /dev/null
@@ -1,65 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2002 by Björn Stenberg
- *
- * 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 "panic.h"
-
-void tick_start(unsigned int interval_in_ms)
-{
- unsigned long count;
-
- count = CPU_FREQ * interval_in_ms / 1000 / 8;
-
- if(count > 0x10000)
- {
- panicf("Error! The tick interval is too long (%d ms)\n",
- interval_in_ms);
- return;
- }
-
- /* We are using timer 0 */
-
- TSTR &= ~0x01; /* Stop the timer */
- TSNC &= ~0x01; /* No synchronization */
- TMDR &= ~0x01; /* Operate normally */
-
- TCNT0 = 0; /* Start counting at 0 */
- GRA0 = (unsigned short)(count - 1);
- TCR0 = 0x23; /* Clear at GRA match, sysclock/8 */
-
- /* Enable interrupt on level 1 */
- IPRC = (IPRC & ~0x00f0) | 0x0010;
-
- TSR0 &= ~0x01;
- TIER0 = 0xf9; /* Enable GRA match interrupt */
-
- TSTR |= 0x01; /* Start timer 1 */
-}
-
-void IMIA0(void) __attribute__ ((interrupt_handler));
-void IMIA0(void)
-{
- /* Run through the list of tick tasks */
- call_tick_tasks();
-
- TSR0 &= ~0x01;
-}
diff --git a/firmware/target/sh/system-sh.c b/firmware/target/sh/system-sh.c
deleted file mode 100644
index e054801b57..0000000000
--- a/firmware/target/sh/system-sh.c
+++ /dev/null
@@ -1,450 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2007 by Jens Arnold
- * Based on the work of Alan Korr and others
- *
- * 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 <stdio.h>
-#include "config.h"
-#include "system.h"
-#include "lcd.h"
-#include "font.h"
-#include "led.h"
-
-const unsigned bit_n_table[32] = {
- 1LU<< 0, 1LU<< 1, 1LU<< 2, 1LU<< 3,
- 1LU<< 4, 1LU<< 5, 1LU<< 6, 1LU<< 7,
- 1LU<< 8, 1LU<< 9, 1LU<<10, 1LU<<11,
- 1LU<<12, 1LU<<13, 1LU<<14, 1LU<<15,
- 1LU<<16, 1LU<<17, 1LU<<18, 1LU<<19,
- 1LU<<20, 1LU<<21, 1LU<<22, 1LU<<23,
- 1LU<<24, 1LU<<25, 1LU<<26, 1LU<<27,
- 1LU<<28, 1LU<<29, 1LU<<30, 1LU<<31
-};
-
-static const char* const irqname[] = {
- "", "", "", "", "IllInstr", "", "IllSltIn","","",
- "CPUAdrEr", "DMAAdrEr", "NMI", "UserBrk",
- "","","","","","","","","","","","","","","","","","","",
- "Trap32","Trap33","Trap34","Trap35","Trap36","Trap37","Trap38","Trap39",
- "Trap40","Trap41","Trap42","Trap43","Trap44","Trap45","Trap46","Trap47",
- "Trap48","Trap49","Trap50","Trap51","Trap52","Trap53","Trap54","Trap55",
- "Trap56","Trap57","Trap58","Trap59","Trap60","Trap61","Trap62","Trap63",
- "Irq0","Irq1","Irq2","Irq3","Irq4","Irq5","Irq6","Irq7",
- "Dma0","","Dma1","","Dma2","","Dma3","",
- "IMIA0","IMIB0","OVI0","", "IMIA1","IMIB1","OVI1","",
- "IMIA2","IMIB2","OVI2","", "IMIA3","IMIB3","OVI3","",
- "IMIA4","IMIB4","OVI4","",
- "Ser0Err","Ser0Rx","Ser0Tx","Ser0TE",
- "Ser1Err","Ser1Rx","Ser1Tx","Ser1TE",
- "ParityEr","A/D conv","","","Watchdog","DRAMRefr"
-};
-
-#define RESERVE_INTERRUPT(number) "\t.long\t_UIE" #number "\n"
-#define DEFAULT_INTERRUPT(name, number) "\t.weak\t_" #name \
- "\n\t.set\t_" #name ",_UIE" #number \
- "\n\t.long\t_" #name "\n"
-
-asm (
-
-/* Vector table.
- * Handled in asm because gcc 4.x doesn't allow weak aliases to symbols
- * defined in an asm block -- silly.
- * Reset vectors (0..3) are handled in crt0.S */
-
- ".section\t.vectors,\"aw\",@progbits\n"
- DEFAULT_INTERRUPT (GII, 4)
- RESERVE_INTERRUPT ( 5)
- DEFAULT_INTERRUPT (ISI, 6)
- RESERVE_INTERRUPT ( 7)
- RESERVE_INTERRUPT ( 8)
- DEFAULT_INTERRUPT (CPUAE, 9)
- DEFAULT_INTERRUPT (DMAAE, 10)
- DEFAULT_INTERRUPT (NMI, 11)
- DEFAULT_INTERRUPT (UB, 12)
- RESERVE_INTERRUPT ( 13)
- RESERVE_INTERRUPT ( 14)
- RESERVE_INTERRUPT ( 15)
- RESERVE_INTERRUPT ( 16) /* TCB #0 */
- RESERVE_INTERRUPT ( 17) /* TCB #1 */
- RESERVE_INTERRUPT ( 18) /* TCB #2 */
- RESERVE_INTERRUPT ( 19) /* TCB #3 */
- RESERVE_INTERRUPT ( 20) /* TCB #4 */
- RESERVE_INTERRUPT ( 21) /* TCB #5 */
- RESERVE_INTERRUPT ( 22) /* TCB #6 */
- RESERVE_INTERRUPT ( 23) /* TCB #7 */
- RESERVE_INTERRUPT ( 24) /* TCB #8 */
- RESERVE_INTERRUPT ( 25) /* TCB #9 */
- RESERVE_INTERRUPT ( 26) /* TCB #10 */
- RESERVE_INTERRUPT ( 27) /* TCB #11 */
- RESERVE_INTERRUPT ( 28) /* TCB #12 */
- RESERVE_INTERRUPT ( 29) /* TCB #13 */
- RESERVE_INTERRUPT ( 30) /* TCB #14 */
- RESERVE_INTERRUPT ( 31) /* TCB #15 */
- DEFAULT_INTERRUPT (TRAPA32, 32)
- DEFAULT_INTERRUPT (TRAPA33, 33)
- DEFAULT_INTERRUPT (TRAPA34, 34)
- DEFAULT_INTERRUPT (TRAPA35, 35)
- DEFAULT_INTERRUPT (TRAPA36, 36)
- DEFAULT_INTERRUPT (TRAPA37, 37)
- DEFAULT_INTERRUPT (TRAPA38, 38)
- DEFAULT_INTERRUPT (TRAPA39, 39)
- DEFAULT_INTERRUPT (TRAPA40, 40)
- DEFAULT_INTERRUPT (TRAPA41, 41)
- DEFAULT_INTERRUPT (TRAPA42, 42)
- DEFAULT_INTERRUPT (TRAPA43, 43)
- DEFAULT_INTERRUPT (TRAPA44, 44)
- DEFAULT_INTERRUPT (TRAPA45, 45)
- DEFAULT_INTERRUPT (TRAPA46, 46)
- DEFAULT_INTERRUPT (TRAPA47, 47)
- DEFAULT_INTERRUPT (TRAPA48, 48)
- DEFAULT_INTERRUPT (TRAPA49, 49)
- DEFAULT_INTERRUPT (TRAPA50, 50)
- DEFAULT_INTERRUPT (TRAPA51, 51)
- DEFAULT_INTERRUPT (TRAPA52, 52)
- DEFAULT_INTERRUPT (TRAPA53, 53)
- DEFAULT_INTERRUPT (TRAPA54, 54)
- DEFAULT_INTERRUPT (TRAPA55, 55)
- DEFAULT_INTERRUPT (TRAPA56, 56)
- DEFAULT_INTERRUPT (TRAPA57, 57)
- DEFAULT_INTERRUPT (TRAPA58, 58)
- DEFAULT_INTERRUPT (TRAPA59, 59)
- DEFAULT_INTERRUPT (TRAPA60, 60)
- DEFAULT_INTERRUPT (TRAPA61, 61)
- DEFAULT_INTERRUPT (TRAPA62, 62)
- DEFAULT_INTERRUPT (TRAPA63, 63)
- DEFAULT_INTERRUPT (IRQ0, 64)
- DEFAULT_INTERRUPT (IRQ1, 65)
- DEFAULT_INTERRUPT (IRQ2, 66)
- DEFAULT_INTERRUPT (IRQ3, 67)
- DEFAULT_INTERRUPT (IRQ4, 68)
- DEFAULT_INTERRUPT (IRQ5, 69)
- DEFAULT_INTERRUPT (IRQ6, 70)
- DEFAULT_INTERRUPT (IRQ7, 71)
- DEFAULT_INTERRUPT (DEI0, 72)
- RESERVE_INTERRUPT ( 73)
- DEFAULT_INTERRUPT (DEI1, 74)
- RESERVE_INTERRUPT ( 75)
- DEFAULT_INTERRUPT (DEI2, 76)
- RESERVE_INTERRUPT ( 77)
- DEFAULT_INTERRUPT (DEI3, 78)
- RESERVE_INTERRUPT ( 79)
- DEFAULT_INTERRUPT (IMIA0, 80)
- DEFAULT_INTERRUPT (IMIB0, 81)
- DEFAULT_INTERRUPT (OVI0, 82)
- RESERVE_INTERRUPT ( 83)
- DEFAULT_INTERRUPT (IMIA1, 84)
- DEFAULT_INTERRUPT (IMIB1, 85)
- DEFAULT_INTERRUPT (OVI1, 86)
- RESERVE_INTERRUPT ( 87)
- DEFAULT_INTERRUPT (IMIA2, 88)
- DEFAULT_INTERRUPT (IMIB2, 89)
- DEFAULT_INTERRUPT (OVI2, 90)
- RESERVE_INTERRUPT ( 91)
- DEFAULT_INTERRUPT (IMIA3, 92)
- DEFAULT_INTERRUPT (IMIB3, 93)
- DEFAULT_INTERRUPT (OVI3, 94)
- RESERVE_INTERRUPT ( 95)
- DEFAULT_INTERRUPT (IMIA4, 96)
- DEFAULT_INTERRUPT (IMIB4, 97)
- DEFAULT_INTERRUPT (OVI4, 98)
- RESERVE_INTERRUPT ( 99)
- DEFAULT_INTERRUPT (REI0, 100)
- DEFAULT_INTERRUPT (RXI0, 101)
- DEFAULT_INTERRUPT (TXI0, 102)
- DEFAULT_INTERRUPT (TEI0, 103)
- DEFAULT_INTERRUPT (REI1, 104)
- DEFAULT_INTERRUPT (RXI1, 105)
- DEFAULT_INTERRUPT (TXI1, 106)
- DEFAULT_INTERRUPT (TEI1, 107)
- RESERVE_INTERRUPT ( 108)
- DEFAULT_INTERRUPT (ADITI, 109)
-
-/* UIE# block.
- * Must go into the same section as the UIE() handler */
-
- "\t.text\n"
- "_UIE4:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE5:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE6:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE7:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE8:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE9:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE10:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE11:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE12:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE13:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE14:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE15:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE16:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE17:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE18:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE19:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE20:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE21:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE22:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE23:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE24:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE25:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE26:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE27:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE28:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE29:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE30:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE31:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE32:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE33:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE34:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE35:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE36:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE37:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE38:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE39:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE40:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE41:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE42:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE43:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE44:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE45:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE46:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE47:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE48:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE49:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE50:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE51:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE52:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE53:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE54:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE55:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE56:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE57:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE58:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE59:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE60:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE61:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE62:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE63:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE64:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE65:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE66:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE67:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE68:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE69:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE70:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE71:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE72:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE73:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE74:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE75:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE76:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE77:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE78:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE79:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE80:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE81:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE82:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE83:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE84:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE85:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE86:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE87:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE88:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE89:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE90:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE91:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE92:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE93:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE94:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE95:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE96:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE97:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE98:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE99:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE100:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE101:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE102:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE103:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE104:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE105:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE106:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE107:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE108:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
- "_UIE109:\tbsr\t_UIE\n\tmov.l\t@r15+,r4\n"
-
-);
-
-extern void UIE4(void); /* needed for calculating the UIE number */
-
-void UIE (unsigned int pc) __attribute__((section(".text")));
-void UIE (unsigned int pc) /* Unexpected Interrupt or Exception */
-{
- unsigned int n;
-
- asm volatile ("sts\tpr,%0" : "=r"(n));
-
- /* clear screen */
-#ifdef HAVE_LCD_BITMAP
-#if LCD_DEPTH > 1
- lcd_set_backdrop(NULL);
- lcd_set_drawmode(DRMODE_SOLID);
- lcd_set_foreground(LCD_BLACK);
- lcd_set_background(LCD_WHITE);
-#endif
- lcd_setfont(FONT_SYSFIXED);
- lcd_set_viewport(NULL);
-#endif
-
- lcd_clear_display();
- /* output exception */
- n = (n - (unsigned)UIE4 + 12)>>2; /* get exception or interrupt number */
- lcd_putsf(0, 0, "I%02x:%s", n, irqname[n]);
- lcd_putsf(0, 1, "at %08x", pc);
- lcd_update();
-
- /* try to restart firmware if ON is pressed */
- system_exception_wait();
-
- /* enable the watchguard timer, but don't service it */
- RSTCSR_W = 0x5a40; /* Reset enabled, power-on reset */
- TCSR_W = 0xa560; /* Watchdog timer mode, timer enabled, sysclk/2 */
- while (1);
-}
-
-void system_init(void)
-{
- /* Disable all interrupts */
- IPRA = 0;
- IPRB = 0;
- IPRC = 0;
- IPRD = 0;
- IPRE = 0;
-
- /* NMI level low, falling edge on all interrupts */
- ICR = 0;
-
- /* Enable burst and RAS down mode on DRAM */
- DCR |= 0x5000;
-
- /* Activate Warp mode (simultaneous internal and external mem access) */
- BCR |= 0x2000;
-
- /* Bus state controller initializations. These are only necessary when
- running from flash. */
- WCR1 = 0x40FD; /* Long wait states for CS6 (ATA), short for the rest. */
- WCR3 = 0x8000; /* WAIT is pulled up, 1 state inserted for CS6 */
-}
-
-void system_reboot (void)
-{
- disable_irq();
-
- asm volatile ("ldc\t%0,vbr" : : "r"(0));
-
- PACR2 |= 0x4000; /* for coldstart detection */
- IPRA = 0;
- IPRB = 0;
- IPRC = 0;
- IPRD = 0;
- IPRE = 0;
- ICR = 0;
-
- asm volatile ("jmp @%0; mov.l @%1,r15" : :
- "r"(*(int*)0),"r"(4));
-}
-
-void system_exception_wait(void)
-{
-#if (CONFIG_LED == LED_REAL)
- bool state = false;
- int i = 0;
-#endif
-
- while (1)
- {
-#if (CONFIG_LED == LED_REAL)
- if (--i <= 0)
- {
- state = !state;
- led(state);
- i = 240000;
- }
-#endif
-
-#if CONFIG_KEYPAD == PLAYER_PAD
- /* Player */
- if (!(PADRL & 0x20))
-#elif CONFIG_KEYPAD == RECORDER_PAD
- /* Recorder */
-#ifdef HAVE_FMADC
- if (!(PCDR & 0x0008))
-#else
- if (!(PBDRH & 0x01))
-#endif
-#elif CONFIG_KEYPAD == ONDIO_PAD
- /* Ondio */
- if (!(PCDR & 0x0008))
-#endif /* CONFIG_KEYPAD */
- return;
- }
-}
-
-/* Utilise the user break controller to catch invalid memory accesses. */
-int system_memory_guard(int newmode)
-{
- static const struct {
- unsigned long addr;
- unsigned long mask;
- unsigned short bbr;
- } modes[MAXMEMGUARD] = {
- /* catch nothing */
- { 0x00000000, 0x00000000, 0x0000 },
- /* catch writes to area 02 (flash ROM) */
- { 0x02000000, 0x00FFFFFF, 0x00F8 },
- /* catch all accesses to areas 00 (internal ROM) and 01 (free) */
- { 0x00000000, 0x01FFFFFF, 0x00FC }
- };
-
- int oldmode = MEMGUARD_NONE;
- int i;
-
- /* figure out the old mode from what is in the UBC regs. If the register
- values don't match any mode, assume MEMGUARD_NONE */
- for (i = MEMGUARD_NONE; i < MAXMEMGUARD; i++)
- {
- if (BAR == modes[i].addr && BAMR == modes[i].mask &&
- BBR == modes[i].bbr)
- {
- oldmode = i;
- break;
- }
- }
-
- if (newmode == MEMGUARD_KEEP)
- newmode = oldmode;
-
- BBR = 0; /* switch off everything first */
-
- /* always set the UBC according to the mode, in case the old settings
- didn't match any valid mode */
- BAR = modes[newmode].addr;
- BAMR = modes[newmode].mask;
- BBR = modes[newmode].bbr;
-
- return oldmode;
-}
diff --git a/firmware/target/sh/system-target.h b/firmware/target/sh/system-target.h
deleted file mode 100644
index a62a024823..0000000000
--- a/firmware/target/sh/system-target.h
+++ /dev/null
@@ -1,154 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2007 by Jens Arnold
- * Based on the work of Alan Korr and others
- *
- * 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 SYSTEM_TARGET_H
-#define SYSTEM_TARGET_H
-
-#define or_b(mask, address) \
- asm \
- ("or.b %0,@(r0,gbr)" \
- : \
- : /* %0 */ I_CONSTRAINT((char)(mask)), \
- /* %1 */ "z"(address-GBR))
-
-#define and_b(mask, address) \
- asm \
- ("and.b %0,@(r0,gbr)" \
- : \
- : /* %0 */ I_CONSTRAINT((char)(mask)), \
- /* %1 */ "z"(address-GBR))
-
-#define xor_b(mask, address) \
- asm \
- ("xor.b %0,@(r0,gbr)" \
- : \
- : /* %0 */ I_CONSTRAINT((char)(mask)), \
- /* %1 */ "z"(address-GBR))
-
-
-/****************************************************************************
- * Interrupt level setting
- * The level is left shifted 4 bits
- ****************************************************************************/
-#define HIGHEST_IRQ_LEVEL (15<<4)
-
-static inline int set_irq_level(int level)
-{
- int i;
- /* Read the old level and set the new one */
-
- /* Not volatile - will be optimized away if the return value isn't used */
- asm ("stc sr, %0" : "=r" (i));
- asm volatile ("ldc %0, sr" : : "r" (level));
- return i;
-}
-
-static inline void enable_irq(void)
-{
- int i;
- asm volatile ("mov %1, %0 \n" /* Save a constant load from RAM */
- "ldc %0, sr \n" : "=&r"(i) : "i"(0));
-}
-
-#define disable_irq() \
- ((void)set_irq_level(HIGHEST_IRQ_LEVEL))
-
-#define disable_irq_save() \
- set_irq_level(HIGHEST_IRQ_LEVEL)
-
-#define restore_irq(i) \
- ((void)set_irq_level(i))
-
-static inline uint16_t swap16_hw(uint16_t value)
- /*
- result[15..8] = value[ 7..0];
- result[ 7..0] = value[15..8];
- */
-{
- uint16_t result;
- asm ("swap.b\t%1,%0" : "=r"(result) : "r"(value));
- return result;
-}
-
-static inline uint32_t swaw32_hw(uint32_t value)
- /*
- result[31..16] = value[15.. 0];
- result[15.. 0] = value[31..16];
- */
-{
- uint32_t result;
- asm ("swap.w\t%1,%0" : "=r"(result) : "r"(value));
- return result;
-}
-
-static inline uint32_t swap32_hw(uint32_t value)
- /*
- result[31..24] = value[ 7.. 0];
- result[23..16] = value[15.. 8];
- result[15.. 8] = value[23..16];
- result[ 7.. 0] = value[31..24];
- */
-{
- asm ("swap.b\t%0,%0\n"
- "swap.w\t%0,%0\n"
- "swap.b\t%0,%0\n" : "+r"(value));
- return value;
-}
-
-static inline uint32_t swap_odd_even32_hw(uint32_t value)
-{
- /*
- result[31..24],[15.. 8] = value[23..16],[ 7.. 0]
- result[23..16],[ 7.. 0] = value[31..24],[15.. 8]
- */
- asm ("swap.b\t%0,%0\n"
- "swap.w\t%0,%0\n"
- "swap.b\t%0,%0\n"
- "swap.w\t%0,%0\n" : "+r"(value));
- return value;
-}
-
-extern const unsigned bit_n_table[32];
-#define BIT_N(n) ( \
- __builtin_constant_p(n) \
- ? (1U << (n)) \
- : bit_n_table[n] \
-)
-
-static inline void commit_dcache(void) {}
-static inline void commit_discard_dcache(void) {}
-static inline void commit_discard_idcache(void) {}
-
-/*---------------------------------------------------------------------------
- * Put core in a power-saving state.
- *---------------------------------------------------------------------------
- */
-static inline void core_sleep(void)
-{
- asm volatile (
- "and.b #0x7f, @(r0, gbr) \n" /* Clear SBY (bit 7) in SBYCR */
- "mov #0, r1 \n" /* Enable interrupts */
- "ldc r1, sr \n" /* Following instruction cannot be interrupted */
- "sleep \n" /* Execute standby */
- : : "z"(&SBYCR-GBR) : "r1");
-}
-
-#endif /* SYSTEM_TARGET_H */