Nuke all TCC77x targets: iAudio 7, Sansa C100, M200(v1-3), Logik DAX

They were never finished, never saw any release ever, and haven't
compiled for the better part of a decade.  Given their HW capabilities [1],
they are not worth trying to fix.

[1] 1-2MB RAM, ~256MB onboard flash, no expandability

Change-Id: I7b2a5806d687114c22156bb0458d4a10a9734190
This commit is contained in:
Solomon Peachy 2021-04-23 11:09:49 -04:00
parent 77188e41f5
commit 3ba2f6e5c7
103 changed files with 48 additions and 5873 deletions

View file

@ -48,7 +48,7 @@ static long next_yield = 0;
static struct mutex ata_mtx SHAREDBSS_ATTR;
#if defined(COWON_D2) || defined(IAUDIO_7)
#if defined(COWON_D2)
#define FTL_V2
#define MAX_WRITE_CACHES 8
#else
@ -906,13 +906,6 @@ int nand_init(void)
mutex_init(&ata_mtx);
#ifdef CPU_TCC77X
CSCFG2 = 0x018a8010 | tcc77x_cscfg_bw(TCC77X_CSCFG_BW8);
GPIOC_FUNC &= ~(CS_GPIO_BIT | WE_GPIO_BIT);
GPIOC_FUNC |= 0x1;
#endif
/* Set GPIO direction for chip select & write protect */
NAND_GPIO_OUT_EN(CS_GPIO_BIT | WE_GPIO_BIT);

View file

@ -144,81 +144,6 @@ void lcd_init_device(void)
lcd_write_command(LCD_SET_NORMAL_DISPLAY);
}
#elif defined(CPU_TCC77X)
/* TCC77x specific defines */
#define LCD_BASE 0x50000000
#define LCD_CMD *(volatile unsigned char*)(LCD_BASE)
#define LCD_DATA *(volatile unsigned char*)(LCD_BASE+1)
void lcd_write_command(int byte)
{
LCD_CMD = byte;
asm volatile (
"nop \n\t"
"nop \n\t"
"nop \n\t"
);
}
void lcd_write_data(const fb_data* p_bytes, int count)
{
while (count--)
{
LCD_DATA = *(p_bytes++);
asm volatile (
"nop \n\t"
"nop \n\t"
"nop \n\t"
);
}
}
/* LCD init */
void lcd_init_device(void)
{
uint32_t bus_width;
/* Telechips init the same as the original firmware */
CSCFG1 &= 0xc3ffc000;
CSCFG1 |= 0x3400101a;
CSCFG1 |= (1 << 21);
CSCFG1 &= ~(1 << 21);
bus_width = ((MCFG >> 11) & 0x3) ^ 3;
CSCFG1 = (bus_width << 28) |
(3 << 26) | /* MTYPE = 3 */
((LCD_BASE >> 28) << 22) | /* CSBASE = 0x5 */
(1 << 20) | /* Unknown */
(3 << 11) | /* Setup time = 3 cycles */
(3 << 3) | /* Pulse width = 3+1 cycles */
(1 << 0); /* Hold time = 1 cycle */
/* SSD1815 inits like the original firmware */
lcd_write_command(LCD_SET_DISPLAY_OFF);
lcd_set_flip(false);
lcd_write_command(LCD_SET_INTERNAL_REGULATOR_RESISTOR_RATIO | 5);
lcd_set_contrast(lcd_default_contrast());
lcd_write_command(LCD_SET_POWER_CONTROL_REGISTER | 7);
/* power control register: op-amp=1, regulator=1, booster=1 */
lcd_write_command(LCD_SET_BIAS_TC_OSC);
/* 0xc2 = 110 000 10: Osc. Freq 110 - ???
TC value 000 - "-0.01%/C (TC0, POR)"
Bias ratio 10 - "1/9, 1/7 (POR)"
*/
lcd_write_command(0xc2);
lcd_write_command(LCD_SET_DISPLAY_ON);
lcd_clear_display();
lcd_update();
}
/* End of TCC77x specific defines */
#endif

View file

@ -82,19 +82,6 @@ void pcm_play_dma_init(void)
/* Enable DAI block in Master mode, 256fs->32fs, 16bit LSB */
DAMR = 0x3c8e80;
#elif defined(IAUDIO_7)
BCLKCTR &= ~DEV_DAI;
PCLK_DAI = (0x800a << 16) | (PCLK_DAI & 0xffff);
BCLKCTR |= DEV_DAI;
/* Master mode, 256->64fs, 16bit LSB*/
DAMR = 0x3cce20;
#elif defined(LOGIK_DAX)
/* TODO */
#elif defined(SANSA_M200)
/* TODO */
#elif defined(SANSA_C100)
/* TODO */
#else
#error "Target isn't supported"
#endif
@ -228,7 +215,7 @@ const void * pcm_rec_dma_get_peak_buffer(void)
}
#endif
#if defined(CPU_TCC77X) || defined(CPU_TCC780X)
#if defined(CPU_TCC780X)
void fiq_handler(void) ICODE_ATTR __attribute__((naked));
void fiq_handler(void)
{
@ -245,9 +232,6 @@ void fiq_handler(void)
#if defined(CPU_TCC780X)
"mov r8, #0xc000 \n" /* DAI_TX_IRQ_MASK | DAI_RX_IRQ_MASK */
"ldr r9, =0xf3001004 \n" /* CREQ */
#elif defined(CPU_TCC77X)
"mov r8, #0x0030 \n" /* DAI_TX_IRQ_MASK | DAI_RX_IRQ_MASK */
"ldr r9, =0x80000104 \n" /* CREQ */
#endif
"str r8, [r9] \n" /* clear DAI IRQs */
"ldmia r11, { r8-r9 } \n" /* r8 = p, r9 = size */

View file

@ -382,7 +382,7 @@ static inline uint32_t swaw32_hw(uint32_t value)
}
#if defined(CPU_TCC780X) || defined(CPU_TCC77X) /* Single core only for now */ \
#if defined(CPU_TCC780X) /* Single core only for now */ \
|| CONFIG_CPU == IMX31L || CONFIG_CPU == DM320 || CONFIG_CPU == AS3525 \
|| CONFIG_CPU == S3C2440 || CONFIG_CPU == S5L8701 || CONFIG_CPU == AS3525v2 \
|| CONFIG_CPU == S5L8702

View file

@ -1,121 +0,0 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2007 by Dave Chapman
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#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, 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 channel_group;
static unsigned short adcdata[8];
/* Tick task */
static void adc_tick(void)
{
/* Start a conversion of channels 0-3. This will trigger an interrupt,
and the interrupt handler will take care of channels 4-7. */
int i;
PCLKCFG6 |= (1<<15); /* Enable ADC clock */
channel_group = 0;
/* Start converting the first 4 channels */
for (i = 0; i < 4; i++)
ADCCON = i;
}
/* IRQ handler */
void ADC(void)
{
int num;
int i;
uint32_t adc_status;
do
{
adc_status = ADCSTATUS;
num = (adc_status>>24) & 7;
if (num) adcdata[(adc_status >> 16) & 0x7] = adc_status & 0x3ff;
} while (num);
if (channel_group == 0)
{
/* Start conversion of channels 4-7 */
for (i = 4; i < 8; i++)
ADCCON = i;
channel_group = 1;
}
else
{
PCLKCFG6 &= ~(1<<15); /* Disable ADC clock */
}
}
unsigned short adc_read(int channel)
{
return adcdata[channel];
}
void adc_init(void)
{
/* Initialize ADC clocks */
PCLKCFG6 = (PCLKCFG6 & 0xffff0000) | 4004;
ADCCON = (1<<4); /* Leave standby mode */
/* IRQ enable, auto power-down, single-mode */
ADCCFG |= (1<<3) | (1<<1) | (1<<0);
/* Unmask ADC IRQ */
IEN |= ADC_IRQ_MASK;
tick_add_task(adc_tick);
sleep(2); /* Ensure adc_data[] contains data before returning */
}

View file

@ -1,99 +0,0 @@
#include "config.h"
ENTRY(start)
OUTPUT_FORMAT(elf32-littlearm)
OUTPUT_ARCH(arm)
STARTUP(target/arm/tcc77x/crt0.o)
#define PLUGINSIZE PLUGIN_BUFFER_SIZE
#define CODECSIZE CODEC_SIZE
#define DRAMSIZE (MEMORYSIZE * 0x100000) - PLUGINSIZE - CODECSIZE
#define DRAMORIG 0x20000000
#define IRAMORIG 0x00000000
#define IRAMSIZE 64K
/* 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
{
#ifdef TCCBOOT
DRAM : ORIGIN = DRAMORIG + DRAMSIZE - 0x100000, LENGTH = 0x100000
#else
DRAM : ORIGIN = DRAMORIG, LENGTH = DRAMSIZE
#endif
IRAM : ORIGIN = IRAMORIG, LENGTH = IRAMSIZE
}
SECTIONS
{
.text : {
loadaddress = .;
_loadaddress = .;
. = ALIGN(0x200);
*(.init.text)
*(.text)
*(.text*)
*(.glue_7)
*(.glue_7t)
} > DRAM
.data : {
*(.icode)
*(.irodata)
*(.idata)
*(.data*)
*(.rodata.*)
*(.rodata)
. = ALIGN(0x4);
_dataend = . ;
} > DRAM
.stack :
{
*(.stack)
_stackbegin = .;
stackbegin = .;
. += 0x2000;
_stackend = .;
stackend = .;
} > DRAM
.bss : {
_edata = .;
*(.bss*);
*(.ibss);
*(COMMON)
_end = .;
} > DRAM
.audiobuf ALIGN(4) :
{
_audiobuffer = .;
audiobuffer = .;
} > DRAM
.audiobufend ENDAUDIOADDR:
{
audiobufend = .;
_audiobufend = .;
} > DRAM
.codec ENDAUDIOADDR:
{
codecbuf = .;
_codecbuf = .;
}
.plugin ENDADDR:
{
_pluginbuf = .;
pluginbuf = .;
}
}

View file

@ -1,33 +0,0 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2007 Dave Chapman
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#ifndef ATA_TARGET_H
#define ATA_TARGET_H
/* GPIOs */
#define NAND_GPIO_SET(n) GPIOC |= n
#define NAND_GPIO_CLEAR(n) GPIOC &= (~n)
#define NAND_GPIO_OUT_EN(n) GPIOC_DIR |= n
#define CS_GPIO_BIT (1<<24) /* Chip Select */
#define WE_GPIO_BIT (1<<25) /* Write Enable */
#endif

View file

@ -1,63 +0,0 @@
#include "config.h"
ENTRY(start)
OUTPUT_FORMAT(elf32-littlearm)
OUTPUT_ARCH(arm)
STARTUP(target/arm/tcc77x/crt0.o)
#define DRAMSIZE (MEMORYSIZE * 0x100000)
#define DRAMORIG 0x20000000
#define IRAMORIG 0x00000000
#define IRAMSIZE 64K
MEMORY
{
#ifdef TCCBOOT
DRAM : ORIGIN = DRAMORIG + DRAMSIZE - 0x100000, LENGTH = 0x100000
#else
DRAM : ORIGIN = DRAMORIG, LENGTH = DRAMSIZE
#endif
IRAM : ORIGIN = IRAMORIG, LENGTH = IRAMSIZE
}
SECTIONS
{
.text : {
*(.init.text)
*(.text)
*(.text*)
*(.glue_7)
*(.glue_7t)
} > DRAM
.data : {
*(.icode)
*(.irodata)
*(.idata)
*(.data*)
*(.rodata.*)
*(.rodata)
. = ALIGN(0x4);
_dataend = . ;
} > DRAM
.stack (NOLOAD) :
{
*(.stack)
_stackbegin = .;
stackbegin = .;
. += 0x2000;
_stackend = .;
stackend = .;
} > DRAM
.bss (NOLOAD) : {
_edata = .;
*(.bss*);
*(.ibss);
*(COMMON)
_end = .;
} > DRAM
}

View file

@ -1,26 +0,0 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2007 Dave Chapman
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#ifndef _ADC_TARGET_H_
#define _ADC_TARGET_H_
#define NUM_ADC_CHANNELS 8
#endif /* _ADC_TARGET_H_ */

View file

@ -1,40 +0,0 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2007 by Dave Chapman
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#ifndef BACKLIGHT_TARGET_H
#define BACKLIGHT_TARGET_H
#include "tcc77x.h"
#define backlight_hw_init() true
static inline void backlight_hw_on(void)
{
/* Enable backlight */
GPIOE |= 0x2;
}
static inline void backlight_hw_off(void)
{
/* Disable backlight */
GPIOE &= ~0x2;
}
#endif

View file

@ -1,64 +0,0 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2007 by Dave Chapman
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#include "config.h"
#include "cpu.h"
#include "button.h"
void button_init_device(void)
{
GPIOA_DIR |= 0xC;
}
int button_read_device(void)
{
int btn = BUTTON_NONE;
if (!button_hold())
{
GPIOA |= 0x4;
GPIOA &= ~0x8;
int i=20; while (i--);
if (GPIOA & 0x10) btn |= BUTTON_UP;
if (GPIOA & 0x20) btn |= BUTTON_RIGHT;
if (GPIOA & 0x40) btn |= BUTTON_LEFT;
GPIOA |= 0x8;
GPIOA &= ~0x4;
i=20; while (i--);
if (GPIOA & 0x10) btn |= BUTTON_VOLUP;
if (GPIOA & 0x20) btn |= BUTTON_VOLDOWN;
if (GPIOA & 0x40) btn |= BUTTON_DOWN;
if (GPIOA & 0x80) btn |= BUTTON_SELECT;
if (GPIOA & 0x100) btn |= BUTTON_POWER;
}
return btn;
}
bool button_hold(void)
{
return (GPIOA & 0x2);
}

View file

@ -1,45 +0,0 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2007 by Dave Chapman
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#ifndef _BUTTON_TARGET_H_
#define _BUTTON_TARGET_H_
#define HAS_BUTTON_HOLD
/* Main unit's buttons */
#define BUTTON_POWER 0x00000001
#define BUTTON_VOLUP 0x00000002
#define BUTTON_VOLDOWN 0x00000004
#define BUTTON_UP 0x00000008
#define BUTTON_DOWN 0x00000010
#define BUTTON_LEFT 0x00000020
#define BUTTON_RIGHT 0x00000040
#define BUTTON_SELECT 0x00000080
#define BUTTON_MAIN (BUTTON_POWER|BUTTON_VOLUP|BUTTON_VOLDOWN\
|BUTTON_UP|BUTTON_DOWN|BUTTON_LEFT\
|BUTTON_RIGHT|BUTTON_SELECT)
/* Software power-off */
#define POWEROFF_BUTTON BUTTON_POWER
#define POWEROFF_COUNT 40
#endif /* _BUTTON_TARGET_H_ */

View file

@ -1,286 +0,0 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2007 by Mark Arigo
*
* 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 "lcd.h"
#include "kernel.h"
#include "system.h"
/* Display status */
static unsigned lcd_yuv_options SHAREDBSS_ATTR = 0;
/* LCD command set for Samsung S6B33B2 */
#define R_NOP 0x00
#define R_OSCILLATION_MODE 0x02
#define R_DRIVER_OUTPUT_MODE 0x10
#define R_DCDC_SET 0x20
#define R_BIAS_SET 0x22
#define R_DCDC_CLOCK_DIV 0x24
#define R_DCDC_AMP_ONOFF 0x26
#define R_TEMP_COMPENSATION 0x28
#define R_CONTRAST_CONTROL1 0x2a
#define R_CONTRAST_CONTROL2 0x2b
#define R_STANDBY_OFF 0x2c
#define R_STANDBY_ON 0x2d
#define R_DDRAM_BURST_OFF 0x2e
#define R_DDRAM_BURST_ON 0x2f
#define R_ADDRESSING_MODE 0x30
#define R_ROW_VECTOR_MODE 0x32
#define R_N_LINE_INVERSION 0x34
#define R_FRAME_FREQ_CONTROL 0x36
#define R_RED_PALETTE 0x38
#define R_GREEN_PALETTE 0x3a
#define R_BLUE_PALETTE 0x3c
#define R_ENTRY_MODE 0x40
#define R_X_ADDR_AREA 0x42
#define R_Y_ADDR_AREA 0x43
#define R_RAM_SKIP_AREA 0x45
#define R_DISPLAY_OFF 0x50
#define R_DISPLAY_ON 0x51
#define R_SPEC_DISPLAY_PATTERN 0x53
#define R_PARTIAL_DISPLAY_MODE 0x55
#define R_PARTIAL_START_LINE 0x56
#define R_PARTIAL_END_LINE 0x57
#define R_AREA_SCROLL_MODE 0x59
#define R_SCROLL_START_LINE 0x5a
#define R_DATA_FORMAT_SELECT 0x60
/* TCC77x specific defines */
#define LCD_BASE 0x50000000
#define LCD_CMD *(volatile unsigned char*)(LCD_BASE)
#define LCD_DATA *(volatile unsigned char*)(LCD_BASE+1)
static void lcd_send_command(unsigned cmd)
{
LCD_CMD = cmd;
asm volatile (
"nop \n\t"
"nop \n\t"
"nop \n\t"
);
}
static void lcd_send_data(unsigned data)
{
LCD_DATA = (data & 0xff00) >> 8;
LCD_DATA = (data & 0x00ff);
}
/* End of TCC77x specific defines */
/* LCD init */
void lcd_init_device(void)
{
uint32_t bus_width;
/* Telechips init the same as the original firmware */
bus_width = ((MCFG >> 11) & 0x3) ^ 3;
CSCFG1 = (bus_width << 28) |
(3 << 26) | /* MTYPE = 3 */
((LCD_BASE >> 28) << 22) | /* CSBASE = 0x5 */
(1 << 20) | /* Unknown */
(2 << 11) | /* Setup time = 2 cycles */
(2 << 3) | /* Pulse width = 2+1 cycles */
(2 << 0); /* Hold time = 2 cycle */
GPIOE &= ~0x8;
sleep(HZ/100); /* 10ms */
GPIOE |= 0x08;
sleep(HZ/100); /* 10ms */
lcd_send_command(R_STANDBY_OFF);
sleep(HZ/20); /* 50ms */
lcd_send_command(R_OSCILLATION_MODE);
lcd_send_command(0x01);
sleep(HZ/100); /* 10ms */
lcd_send_command(R_DCDC_AMP_ONOFF);
lcd_send_command(0x01);
sleep(HZ/100); /* 10ms */
lcd_send_command(R_DCDC_AMP_ONOFF);
lcd_send_command(0x09);
sleep(HZ/100); /* 10ms */
lcd_send_command(R_DCDC_AMP_ONOFF);
lcd_send_command(0x0b);
sleep(HZ/100); /* 10ms */
lcd_send_command(R_DCDC_AMP_ONOFF);
lcd_send_command(0x0f);
sleep(HZ/100); /* 10ms */
lcd_send_command(R_DCDC_SET);
lcd_send_command(0x01);
sleep(HZ/100); /* 10ms */
sleep(HZ/10); /* 100ms */
lcd_send_command(R_TEMP_COMPENSATION);
lcd_send_command(0x01);
sleep(HZ/100); /* 10ms */
lcd_send_command(R_DRIVER_OUTPUT_MODE);
lcd_send_command(0x03);
lcd_send_command(R_ENTRY_MODE);
lcd_send_command(0x81);
lcd_send_command(R_N_LINE_INVERSION);
lcd_send_command(0x04);
lcd_send_command(0xfa);
lcd_send_command(0x5f);
lcd_set_contrast(0x28);
lcd_send_command(R_SPEC_DISPLAY_PATTERN);
lcd_send_command(0x0);
sleep(HZ/100); /* 10ms */
lcd_send_command(R_ADDRESSING_MODE);
lcd_send_command(0x0);
sleep(HZ/100); /* 10ms */
lcd_send_command(R_PARTIAL_DISPLAY_MODE);
lcd_send_command(0x0);
sleep(HZ/100); /* 10ms */
lcd_send_command(R_X_ADDR_AREA);
lcd_send_command(0);
lcd_send_command(0x80);
lcd_send_command(R_Y_ADDR_AREA);
lcd_send_command(0x0);
lcd_send_command(0x80);
lcd_send_command(R_DISPLAY_ON);
lcd_send_command(R_SPEC_DISPLAY_PATTERN);
lcd_send_command(0x0);
/* Rockbox init */
lcd_clear_display();
lcd_update();
}
/*** hardware configuration ***/
int lcd_default_contrast(void)
{
return 0x28;
}
void lcd_set_contrast(int val)
{
//val &= 0xFF;
lcd_send_command(R_CONTRAST_CONTROL1);
lcd_send_command(val);
}
void lcd_set_invert_display(bool yesno)
{
/* TODO: Implement lcd_set_invert_display() */
(void)yesno;
}
/* turn the display upside down (call lcd_update() afterwards) */
void lcd_set_flip(bool yesno)
{
lcd_send_command(R_DRIVER_OUTPUT_MODE);
lcd_send_command(yesno ? 0x02 : 0x07);
}
/*** update functions ***/
void lcd_yuv_set_options(unsigned options)
{
lcd_yuv_options = options;
}
/* TODO: implement me */
void lcd_blit_yuv(unsigned char *const src[3],
int src_x, int src_y, int stride,
int x, int y, int width, int height)
{
(void) src;
(void) src_x;
(void) src_y;
(void) stride;
(void) x;
(void) y;
return;
}
/* Update the display.
This must be called after all other LCD functions that change the display. */
void lcd_update(void)
{
lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT);
}
/* Update a fraction of the display. */
void lcd_update_rect(int x, int y, int width, int height)
{
const fb_data *addr;
if (x + width >= LCD_WIDTH)
width = LCD_WIDTH - x;
if (y + height >= LCD_HEIGHT)
height = LCD_HEIGHT - y;
if ((width <= 0) || (height <= 0))
return; /* Nothing left to do. */
addr = FBADDR(x,y);
if (width <= 1) {
lcd_send_command(R_ENTRY_MODE); /* The X end address must be larger */
lcd_send_command(0x80); /* that the X start address, so we */
lcd_send_command(R_X_ADDR_AREA); /* switch to vertical mode for */
lcd_send_command(x); /* single column updates and set */
lcd_send_command(x + 1); /* the window width to 2 */
} else {
lcd_send_command(R_ENTRY_MODE);
lcd_send_command(0x82);
lcd_send_command(R_X_ADDR_AREA);
lcd_send_command(x);
lcd_send_command(x + width - 1);
}
lcd_send_command(R_Y_ADDR_AREA);
lcd_send_command(y);
lcd_send_command(y + height - 1);
/* NOP needed because on some c200s, the previous lcd_send_command is
interpreted as a separate command instead of part of R_Y_ADDR_AREA. */
lcd_send_command(R_NOP);
do {
int w = width;
do {
lcd_send_data(*addr++);
} while (--w > 0);
addr += LCD_WIDTH - width;
} while (--height > 0);
}

View file

@ -1,43 +0,0 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2007 Dave Chapman
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#include "config.h"
#include "cpu.h"
#include <stdbool.h>
#include "kernel.h"
#include "system.h"
#include "power.h"
void power_init(void)
{
}
void ide_power_enable(bool on)
{
}
bool ide_powered(void)
{
return true;
}
void power_off(void)
{
}

View file

@ -1,230 +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.
*
****************************************************************************/
/* Arm bootloader and startup code based on startup.s from the iPodLinux loader
*
* Copyright (c) 2003, Daniel Palffy (dpalffy (at) rainstorm.org)
* Copyright (c) 2005, Bernard Leach <leachbj@bouncycastle.org>
*
*/
#include "config.h"
#include "cpu.h"
.section .init.text,"ax",%progbits
.extern irq
.extern fiq
.extern UIE
.extern main
.global start
/* Telechips firmware files start with a 32-byte header, as part of the code. */
start:
#ifdef TCCBOOT
/* Add -DTCCBOOT to EXTRA_DEFINES in the bootloader Makefile to
enable building the bootloader to be appended to the end of the
original firmware, dual-booting based on a key-press.
The following two values are filled in by mktccboot.
*/
of_entrypoint: .word 0 /* Saved entrypoint of original firmware*/
bl_entrypoint: .word 0 /* Location in RAM of the start of our bootloader */
#else
// ldr pc, =start_loc /* jump to the main entry point */
b start_loc
.word 0xffff0601 /* Unknown magic */
.word 0x3a726556 /* "Ver:" */
.word 0x31373030 /* "0071" */
.word 0 /* First CRC32 */
.word 0 /* Unknown - always 0 */
.word 0 /* Second CRC32 */
.word 0 /* length of firmware file */
#if defined(LOGIK_DAX) || defined(SANSA_C100)
/* Some original firmwares have 0x40 bytes of zeroes here - we
don't know why, but err on the side of caution and include it
here. */
.space 0x40
#endif
#endif
start_loc:
#ifdef BOOTLOADER
/*
If we are appended to the OF (i.e. dual-booting), do a simple GPIO
button check, and branch to the OF's entry point (saved by mktccboot)
if not active
*/
#ifdef TCCBOOT
mov r0, #0x80000000
#if defined(LOGIK_DAX) || defined(SANSA_C100)
ldr r0, [r0, #0x300] /* Hold button is GPIO A, pin 0x2 */
tst r0, #0x2
#elif defined(SANSA_M200)
ldr r0, [r0, #0x310] /* Hold button is GPIO B, pin 0x200 */
tst r0, #0x200
#elif defined(IAUDIO_7)
ldr r0, [r0, #0x300] /* Hold button is !GPIO A, pin 0x2 */
tst r0, #0x2
#else
#error No bootup key detection implemented for this target
#endif
ldrne pc, of_entrypoint /* Jump to OF if HOLD button not pressed */
#endif /* TCCBOOT */
/* We are now definitely executing the bootloader, so we relocate to the
linked address (see boot.lds) - 1MB from the end of DRAM.
*/
#ifdef TCCBOOT
ldr r0, bl_entrypoint
#else
mov r0, #0x20000000 /* Otherwise, load address is the start of DRAM */
#endif
mov r1, #0x20000000 /* Destination: 1MB from end of DRAM */
add r1, r1, #((MEMORYSIZE - 1) * 0x100000)
ldr r2, =_dataend
1:
cmp r2, r1
ldrhi r3, [r0], #4
strhi r3, [r1], #4
bhi 1b
ldr pc, =copied_start /* jump to the relocated start_loc: */
copied_start:
#endif /* BOOTLOADER */
/* Set up stack for IRQ mode */
mov r0,#0xd2
msr cpsr, r0
ldr sp, =irq_stack
/* Set up stack for FIQ mode */
mov r0,#0xd1
msr cpsr, r0
ldr sp, =fiq_stack
#ifndef BOOTLOADER
/* Load the banked FIQ mode registers with useful values here.
These values will be used in the FIQ handler in pcm-telechips.c */
.equ DADO_BASE, 0x80000020
ldr r10, =DADO_BASE
ldr r11, =dma_play_data
#endif
/* Let svc, abort and undefined modes use irq stack */
msr cpsr, #0xd3
ldr sp, =irq_stack
msr cpsr, #0xd7
ldr sp, =irq_stack
msr cpsr, #0xdb
ldr sp, =irq_stack
/* Switch to sys mode */
mov r0,#0xdf
msr cpsr, r0
ldr sp, =stackend
/* Copy exception handler code to address 0 */
mov r2, #0x0
ldr r3, =vectors_start
ldr r4, =vectors_end
1:
cmp r4, r3
ldrhi r5, [r3], #4
strhi r5, [r2], #4
bhi 1b
/* Initialise bss section to zero */
ldr r2, =_edata
ldr r3, =_end
mov r4, #0
1:
cmp r3, r2
strhi r4, [r2], #4
bhi 1b
/* Set up some stack and munge it with 0xdeadbeef */
ldr sp, =stackend
mov r3, sp
ldr r2, =stackbegin
ldr r4, =0xdeadbeef
1:
cmp r3, r2
strhi r4, [r2], #4
bhi 1b
bl main
/* main() should never return */
/* Exception handlers. Will be copied to address 0 after memory remapping */
vectors_start:
ldr pc, [pc, #24]
ldr pc, [pc, #24]
ldr pc, [pc, #24]
ldr pc, [pc, #24]
ldr pc, [pc, #24]
ldr pc, [pc, #24]
ldr pc, [pc, #24]
ldr pc, [pc, #24]
/* Exception vectors */
.global vectors
vectors:
.word start
.word undef_instr_handler
.word software_int_handler
.word prefetch_abort_handler
.word data_abort_handler
.word reserved_handler
.word irq_handler
.word fiq_handler
vectors_end:
.text
irq_handler:
stmfd sp!, {r0-r3, r12, lr}
bl irq
ldmfd sp!, {r0-r3, r12, lr}
subs pc, lr, #4
/* Align stacks to cache line boundary */
.balign 16
/* 256 words of IRQ stack */
.space 256*4
irq_stack:
/* 256 words of FIQ stack */
.space 256*4
fiq_stack:

View file

@ -1,77 +0,0 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2007 by Rob Purchase
*
* 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 "string.h"
#include <stdio.h>
#include <stdbool.h>
#include "button.h"
#include "lcd.h"
#include "font.h"
#include "adc.h"
bool dbg_ports(void)
{
return false;
}
bool dbg_hw_info(void)
{
int line = 0, i, button, oldline;
bool done=false;
lcd_setfont(FONT_SYSFIXED);
lcd_clear_display();
/* Put all the static text before the while loop */
lcd_puts(0, line++, "[Hardware info]");
line++;
oldline=line;
while(!done)
{
line = oldline;
button = button_get(false);
button &= ~BUTTON_REPEAT;
#ifdef BUTTON_SELECT
if (button == BUTTON_SELECT)
#else
if (button == BUTTON_STOP)
#endif
done=true;
lcd_putsf(0, line++, "current tick: %08lx Seconds running: %08ld",
current_tick, current_tick/HZ);
lcd_putsf(0, line++, "GPIOA: 0x%08lx GPIOB: 0x%08lx", GPIOA, GPIOB);
lcd_putsf(0, line++, "GPIOC: 0x%08lx GPIOD: 0x%08lx", GPIOC, GPIOD);
lcd_putsf(0, line++, "GPIOE: 0x%08lx", GPIOE);
for (i = 0; i<4; i++)
lcd_putsf(0, line++, "ADC%d: 0x%04x", i, adc_read(i));
lcd_update();
}
return false;
}

View file

@ -1,39 +0,0 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2008 by Rob Purchase
*
* 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 I2C_TARGET_H
#define I2C_TARGET_H
/* Definitions for the TCC77X I2C bus */
#define SDA_BIT (1<<10)
#define SCL_BIT (1<<11)
#define SCL (GPIOB & SCL_BIT)
#define SCL_HI GPIOB |= SCL_BIT
#define SCL_LO GPIOB &= ~SCL_BIT
#define SDA (GPIOB & SDA_BIT)
#define SDA_HI GPIOB |= SDA_BIT
#define SDA_LO GPIOB &= ~SDA_BIT
#define SDA_INPUT GPIOB_DIR &= ~SDA_BIT
#define SDA_OUTPUT GPIOB_DIR |= SDA_BIT
#endif /* I2C_TARGET_H */

View file

@ -1,28 +0,0 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2007 Dave Chapman
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#ifndef _ADC_TARGET_H_
#define _ADC_TARGET_H_
#define NUM_ADC_CHANNELS 8
#define ADC_BUTTONS 0
#endif /* _ADC_TARGET_H_ */

View file

@ -1,110 +0,0 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2008 Vitja Makarov
*
* 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 "cpu.h"
#include "button.h"
#include "ata2501.h"
#define STB (1<<5)
#define SDATA (1<<4)
#define RESET (1<<6)
#define SIFMD (1<<7)
#define STB_DELAY 200
static inline void ndelay(unsigned long nsecs)
{
nsecs /= 8;
while (nsecs)
nsecs--;
}
/*
TODO: sensitivity
*/
void ata2501_init(void)
{
GPIOD_DIR |= (RESET | STB | SIFMD | (1 << 8) | (1 << 9));
GPIOD_DIR &= ~SDATA;
GPIOD &= ~STB;
GPIOD |= (1 << 8) | SIFMD | (1 << 9);
GPIOD &= ~RESET;
ndelay(1000);
GPIOD |= RESET;
}
unsigned short ata2501_read(void)
{
unsigned short ret = 0;
int i;
for (i = 0; i < 12; i++) {
GPIOD |= STB;
ndelay(100);
ret <<= 1;
if (GPIOD & SDATA)
ret |= 1;
GPIOD &= ~STB;
ndelay(100);
}
return ret;
}
//#define ATA2501_TEST
#ifdef ATA2501_TEST
#include "lcd.h"
static
void bits(char *str, unsigned short val)
{
int i;
for (i = 0; i < 12; i++)
str[i] = (val & (1 << i)) ? '1' : '0';
str[i] = 0;
}
void ata2501_test(void)
{
char buf[100];
ata2501_init();
while (1) {
unsigned short data;
int line = 0;
data = ata2501_read();
lcd_clear_display();
lcd_puts(0, line++, "ATA2501 test");
bits(buf, data);
lcd_puts(0, line++, buf);
lcd_update();
sleep(HZ/10);
}
}
#endif

View file

@ -1,27 +0,0 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2008 Vitja Makarov
*
* 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 _ATA2501_H_
#define _ATA2501_H_
void ata2501_init(void);
unsigned short ata2501_read(void);
#endif /* _ATA2501_H_ */

View file

@ -1,94 +0,0 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2007 by Michael Sevakis
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#include "system.h"
#include "cpu.h"
#include "audio.h"
#include "sound.h"
int audio_channels = 2;
int audio_output_source = AUDIO_SRC_PLAYBACK;
void audio_set_output_source(int source)
{
int oldmode = set_fiq_status(FIQ_DISABLED);
if ((unsigned)source >= AUDIO_NUM_SOURCES)
source = AUDIO_SRC_PLAYBACK;
audio_output_source = source;
set_fiq_status(oldmode);
}
void audio_input_mux(int source, unsigned flags)
{
static int last_source = AUDIO_SRC_PLAYBACK;
static bool last_recording = false;
bool recording = flags & SRCF_RECORDING;
switch (source)
{
default: /* playback - no recording */
source = AUDIO_SRC_PLAYBACK;
case AUDIO_SRC_PLAYBACK:
audio_channels = 2;
if (source != last_source)
{
audiohw_set_monitor(false);
/* audiohw_disable_recording();*/
}
break;
case AUDIO_SRC_MIC: /* recording only */
GPIOD |= 0x1;
audio_channels = 1;
if (source != last_source)
{
/*audiohw_set_monitor(false);
audiohw_enable_recording(true); /. source mic */
}
break;
case AUDIO_SRC_FMRADIO: /* recording and playback */
GPIOD &= ~0x1;
audio_channels = 2;
if (source == last_source && recording == last_recording)
break;
last_recording = recording;
if (recording)
{
/*audiohw_set_monitor(false);
audiohw_enable_recording(false);*/
}
else
{
/*audiohw_disable_recording(); */
audiohw_set_monitor(true); /* line 1 analog audio path */
}
break;
} /* end switch */
last_source = source;
} /* audio_input_mux */

View file

@ -1,48 +0,0 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2008 Vitja Makarov
*
* 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 <stdbool.h>
#include "tcc77x.h"
void power_touch_panel(bool on);
static inline bool backlight_hw_init(void)
{
GPIOD_DIR |= 0x2;
/* set backlight on by default, since the screen is unreadable without it */
GPIOD |= 0x2;
return true;
}
static inline void backlight_hw_on(void)
{
GPIOD |= 0x2;
power_touch_panel(true);
}
static inline void backlight_hw_off(void)
{
GPIOD &= ~0x2;
power_touch_panel(false);
}
#endif /* BACKLIGHT_TARGET_H */

View file

@ -1,93 +0,0 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2008 Vitja Makarov
*
* 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 "button.h"
#include "backlight.h"
#include "adc.h"
#include "button-target.h"
#include "ata2501.h"
void button_init_device(void)
{
ata2501_init();
}
/*
touchpad:
0: stop
1-8: between next & prev
9: play
10: next
11: prev
*/
int button_read_device(void)
{
static bool hold_button = false;
bool hold_button_old;
int btn = BUTTON_NONE;
int adc;
int sensor;
hold_button_old = hold_button;
hold_button = button_hold();
#ifndef BOOTLOADER
if (hold_button != hold_button_old)
backlight_hold_changed(hold_button);
#endif
if (button_hold())
return BUTTON_NONE;
adc = adc_read(0);
sensor = ata2501_read();
if (0 == (GPIOA & 4))
btn |= BUTTON_POWER;
/* seems they can't be hold together */
if (adc < 0x120)
btn |= BUTTON_VOLUP;
else if (adc < 0x270)
btn |= BUTTON_VOLDOWN;
else if (adc < 0x300)
btn |= BUTTON_MENU;
if (sensor & (1 << 0))
btn |= BUTTON_STOP;
if (sensor & (1 << 9))
btn |= BUTTON_PLAY;
if (sensor & ((1 << 10) | 0x1c0))
btn |= BUTTON_RIGHT;
if (sensor & ((1 << 11) | 0xe))
btn |= BUTTON_LEFT;
return btn;
}
bool button_hold(void)
{
return !(GPIOA & 0x2);
}

View file

@ -1,47 +0,0 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2008 Vitja Makarov
*
* 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 _IAUDIO7_BUTTON_TARGET_H_
#define _IAUDIO7_BUTTON_TARGET_H_
#define HAS_BUTTON_HOLD
/* Main unit's buttons */
#define BUTTON_POWER 0x00000001
#define BUTTON_VOLUP 0x00000002
#define BUTTON_VOLDOWN 0x00000004
#define BUTTON_MENU 0x00000008
#define BUTTON_LEFT 0x00000010
#define BUTTON_RIGHT 0x00000020
#define BUTTON_PLAY 0x00000040
#define BUTTON_STOP 0x00000080
#define BUTTON_ON BUTTON_POWER
#define BUTTON_MAIN (BUTTON_POWER|BUTTON_VOLUP|BUTTON_VOLDOWN| \
BUTTON_MENU|BUTTON_LEFT|BUTTON_RIGHT| \
BUTTON_PLAY|BUTTON_STOP)
/* Software power-off */
#define POWEROFF_BUTTON BUTTON_POWER
#define POWEROFF_COUNT 10
#endif /* _IAUDIO7_BUTTON_TARGET_H_ */

View file

@ -1,260 +0,0 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* 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.
*
****************************************************************************/
/*
Thanks Hein-Pieter van Braam for initial work.
Mostly based on lcd-h300.c, adapted for the iaudio 7 by Vitja Makarov
*/
#include <config.h>
#include <kernel.h>
#include <cpu.h>
#include <lcd.h>
#include <system-target.h>
#include <panic.h>
#include "hd66789r.h"
static bool display_on = false; /* is the display turned on? */
static inline void lcd_write_reg(int reg, int data)
{
GPIOA &= ~0x400;
outw(0, 0x50010000);
outw(reg << 1, 0x50010000);
GPIOA |= 0x400;
outw((data & 0xff00) >> 7, 0x50010008);
outw((data << 24) >> 23, 0x50010008);
}
static void lcd_write_cmd(int reg)
{
GPIOA &= ~0x400;
outw(0, 0x50010000);
outw(reg << 1, 0x50010000);
GPIOA |= 0x400;
}
/* Do what OF do */
static void lcd_delay(int x)
{
int i;
x *= 0xc35;
for (i = 0; i < x * 8; i++) {
}
}
static void _display_on(void)
{
GPIOA_DIR |= 0x8000 | 0x400;
GPIOA |= 0x8000;
/* power setup */
lcd_write_reg(R_START_OSC, 0x0001);
lcd_delay(0xf);
lcd_write_reg(R_DISP_CONTROL1, 0x000);
lcd_delay(0xa);
lcd_write_reg(R_POWER_CONTROL2, 0x0002);
lcd_write_reg(R_POWER_CONTROL3, 0x000a);
lcd_write_reg(R_POWER_CONTROL4, 0xc5a);
lcd_write_reg(R_POWER_CONTROL1, 0x0004);
lcd_write_reg(R_POWER_CONTROL1, 0x0134);
lcd_write_reg(R_POWER_CONTROL2, 0x0111);
lcd_write_reg(R_POWER_CONTROL3, 0x001c);
lcd_delay(0x28);
lcd_write_reg(R_POWER_CONTROL4, 0x2c40);
lcd_write_reg(R_POWER_CONTROL1, 0x0510);
lcd_delay(0x3c);
/* lcd init 2 */
lcd_write_reg(R_DRV_OUTPUT_CONTROL, 0x0113);
lcd_write_reg(R_DRV_WAVEFORM_CONTROL, 0x0700);
lcd_write_reg(R_ENTRY_MODE, 0x1038);
lcd_write_reg(R_DISP_CONTROL2, 0x0508); // 0x3c8, TMM
lcd_write_reg(R_DISP_CONTROL3, 0x0000);
lcd_write_reg(R_FRAME_CYCLE_CONTROL, 0x0003);
lcd_write_reg(R_RAM_ADDR_SET, 0x0000);
lcd_write_reg(R_GAMMA_FINE_ADJ_POS1, 0x0406);
lcd_write_reg(R_GAMMA_FINE_ADJ_POS2, 0x0303);
lcd_write_reg(R_GAMMA_FINE_ADJ_POS3, 0x0000);
lcd_write_reg(R_GAMMA_GRAD_ADJ_POS, 0x0305);
lcd_write_reg(R_GAMMA_FINE_ADJ_NEG1, 0x0404);
lcd_write_reg(R_GAMMA_FINE_ADJ_NEG2, 0x0000);
lcd_write_reg(R_GAMMA_FINE_ADJ_NEG3, 0x0000);
lcd_write_reg(R_GAMMA_GRAD_ADJ_NEG, 0x0503);
lcd_write_reg(R_GAMMA_AMP_ADJ_RES_POS, 0x1d05);
lcd_write_reg(R_GAMMA_AMP_AVG_ADJ_RES_NEG, 0x1d05);
lcd_write_reg(R_VERT_SCROLL_CONTROL, 0x0000);
lcd_write_reg(R_1ST_SCR_DRV_POS, 0x9f00);
lcd_write_reg(R_2ND_SCR_DRV_POS, 0x9f00);
lcd_write_reg(R_HORIZ_RAM_ADDR_POS, 0x7f00);
lcd_write_reg(R_VERT_RAM_ADDR_POS, 0x9f00);
/* lcd init 3 */
lcd_write_reg(R_POWER_CONTROL1, 0x4510);
lcd_write_reg(R_DISP_CONTROL1, 0x0005);
lcd_delay(0x28);
lcd_write_reg(R_DISP_CONTROL1, 0x0025);
lcd_write_reg(R_DISP_CONTROL1, 0x0027);
lcd_delay(0x28);
lcd_write_reg(R_DISP_CONTROL1, 0x0037);
display_on = true;
}
void lcd_init_device(void)
{
/* Configure external memory banks */
CSCFG1 = 0x0d500023 | tcc77x_cscfg_bw(TCC77X_CSCFG_BW16);
/* may be reset */
GPIOA |= 0x8000;
_display_on();
}
void lcd_enable(bool on)
{
if (display_on == on)
return;
if (on) {
_display_on();
send_event(LCD_EVENT_ACTIVATION, NULL);
} else {
/** Off sequence according to datasheet, p. 130 **/
lcd_write_reg(R_FRAME_CYCLE_CONTROL, 0x0002); /* EQ=0, 18 clks/line */
lcd_write_reg(R_DISP_CONTROL1, 0x0036); /* GON=1, DTE=1, REV=1, D1-0=10 */
sleep(2);
lcd_write_reg(R_DISP_CONTROL1, 0x0026); /* GON=1, DTE=0, REV=1, D1-0=10 */
sleep(2);
lcd_write_reg(R_DISP_CONTROL1, 0x0000); /* GON=0, DTE=0, D1-0=00 */
lcd_write_reg(R_POWER_CONTROL1, 0x0000); /* SAP2-0=000, AP2-0=000 */
lcd_write_reg(R_POWER_CONTROL3, 0x0000); /* PON=0 */
lcd_write_reg(R_POWER_CONTROL4, 0x0000); /* VCOMG=0 */
/* datasheet p. 131 */
lcd_write_reg(R_POWER_CONTROL1, 0x0001); /* STB=1: standby mode */
display_on = false;
}
}
bool lcd_active(void)
{
return display_on;
}
#define RGB(r,g,b) ((((r)&0x3f) << 12)|(((g)&0x3f) << 6)|(((b)&0x3f)))
void lcd_update(void)
{
lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT);
}
/* todo: need tests */
void lcd_update_rect(int sx, int sy, int width, int height)
{
int x, y;
if (!display_on)
return;
if (width <= 0 || height <= 0) /* nothing to do */
return;
width += sx;
height += sy;
if (width > LCD_WIDTH)
width = LCD_WIDTH;
if (height > LCD_HEIGHT)
height = LCD_HEIGHT;
lcd_write_reg(R_ENTRY_MODE, 0x1028);
/* set update window */
lcd_write_reg(R_HORIZ_RAM_ADDR_POS, (LCD_HEIGHT - 1) << 8);
lcd_write_reg(R_VERT_RAM_ADDR_POS, ((width - 1) << 8) | sx);
lcd_write_reg(R_RAM_ADDR_SET, (sx << 8) | (LCD_HEIGHT - sy - 1));
lcd_write_cmd(R_WRITE_DATA_2_GRAM);
for (y = sy; y < height; y++) {
for (x = sx; x < width; x++) {
fb_data c;
unsigned long color;
c = *FBADDR(x,y);
color =
((c & 0x1f) << 1) | ((c & 0x7e0) << 1) | ((c & 0xf800) <<
2);
/* TODO: our color is 18-bit */
outw((color >> 9) & 0x1ff, 0x50010008);
outw((color) & 0x1ff, 0x50010008);
}
}
}
void lcd_set_contrast(int val)
{
(void) val;
}
void lcd_set_invert_display(bool yesno)
{
(void) yesno;
}
void lcd_set_flip(bool yesno)
{
(void) yesno;
}
/* TODO: implement me */
void lcd_blit_yuv(unsigned char *const src[3],
int src_x, int src_y, int stride,
int x, int y, int width, int height)
{
(void) src;
(void) src_x;
(void) src_y;
(void) stride;
(void) x;
(void) y;
if (!display_on)
return;
width &= ~1; /* stay on the safe side */
height &= ~1;
panicf("%s", __func__);
}

View file

@ -1,149 +0,0 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2008 Vitja Makarov
*
* 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 "cpu.h"
#include "kernel.h"
#include "system.h"
#include "power.h"
#include "backlight-target.h"
#include "pcf50606.h"
void power_init(void)
{
pcf50606_write(PCF5060X_DCDC1, 0x90);
pcf50606_write(PCF5060X_DCDC2, 0x48);
pcf50606_write(PCF5060X_DCDC3, 0xfc);
pcf50606_write(PCF5060X_DCDC4, 0xb1);
pcf50606_write(PCF5060X_IOREGC, 0xe9);
/* 3.3V, touch-panel */
pcf50606_write(PCF5060X_D1REGC1, 0xf8);
pcf50606_write(PCF5060X_D2REGC1, 0xf2);
pcf50606_write(PCF5060X_D3REGC1, 0xf5);
pcf50606_write(PCF5060X_LPREGC1, 0x00);
pcf50606_write(PCF5060X_LPREGC2, 0x02);
pcf50606_write(PCF5060X_DCUDC1, 0xe6);
pcf50606_write(PCF5060X_DCUDC2, 0x30);
pcf50606_write(PCF5060X_DCDEC1, 0xe7);
pcf50606_write(PCF5060X_DCDEC2, 0x02);
pcf50606_write(PCF5060X_INT1M, 0x5b);
pcf50606_write(PCF5060X_INT1M, 0xaf);
pcf50606_write(PCF5060X_INT1M, 0x8f);
pcf50606_write(PCF5060X_OOCC1, 0x40);
pcf50606_write(PCF5060X_OOCC2, 0x05);
pcf50606_write(PCF5060X_MBCC3, 0x3a);
pcf50606_write(PCF5060X_GPOC1, 0x00);
pcf50606_write(PCF5060X_BBCC, 0xf8);
}
/* Control leds on ata2501 board */
void power_touch_panel(bool on)
{
if (on)
pcf50606_write(PCF5060X_D1REGC1, 0xf8);
else
pcf50606_write(PCF5060X_D1REGC1, 0x00);
}
void ide_power_enable(bool on)
{
(void) on;
}
bool ide_powered(void)
{
return true;
}
void power_off(void)
{
/* Forcibly cut power to SoC & peripherals by putting the PCF to sleep */
pcf50606_write(PCF5060X_OOCC1, GOSTDBY | CHGWAK | EXTONWAK);
}
#if CONFIG_TUNER
#include "tuner.h"
/** Tuner **/
static bool powered = false;
#define TUNNER_CLK (1 << 5)
#define TUNNER_DATA (1 << 6)
#define TUNNER_NR_W (1 << 7)
bool tuner_power(bool status)
{
bool old_status;
lv24020lp_lock();
old_status = powered;
if (status != old_status)
{
if (status)
{
/* When power up, host should initialize the 3-wire bus
in host read mode: */
/* 1. Set direction of the DATA-line to input-mode. */
GPIOA_DIR &= ~TUNNER_DATA;
/* 2. Drive NR_W low */
GPIOA &= ~TUNNER_NR_W;
GPIOA_DIR |= TUNNER_NR_W;
/* 3. Drive CLOCK high */
GPIOA |= TUNNER_CLK;
GPIOA_DIR |= TUNNER_CLK;
lv24020lp_power(true);
}
else
{
lv24020lp_power(false);
/* set all as inputs */
GPIOC_DIR &= ~(TUNNER_CLK | TUNNER_DATA | TUNNER_NR_W);
}
powered = status;
}
lv24020lp_unlock();
return old_status;
}
#endif /* CONFIG_TUNER */
unsigned int power_input_status(void)
{
return (GPIOA & 0x1) ?
POWER_INPUT_MAIN_CHARGER : POWER_INPUT_NONE;
}

View file

@ -1,84 +0,0 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id: powermgmt-cowond2.c 17847 2008-06-28 18:10:04Z bagder $
*
* Copyright (C) 2007 by Karl Kurbjun
*
* 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"
#include "kernel.h"
#include "pcf50606.h"
unsigned short current_voltage = 5150;
const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] =
{
/* FIXME: calibrate value */
4400
};
const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
{
/* FIXME: calibrate value */
4600
};
/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
{
/* FIXME: calibrate values. Table is "inherited" from iPod-PCF / H100 */
{ 4500, 4810, 4910, 4970, 5030, 5070, 5120, 5140, 5170, 5250, 5400 }
};
#if CONFIG_CHARGING
/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */
const unsigned short percent_to_volt_charge[11] =
{
/* FIXME: calibrate values. Table is "inherited" from iPod-PCF / H100 */
4760, 5440, 5510, 5560, 5610, 5640, 5660, 5760, 5820, 5840, 5850 /* NiMH */
};
#endif /* CONFIG_CHARGING */
#define BATTERY_SCALE_FACTOR 6000
/* full-scale ADC readout (2^10) in millivolt */
/* Returns battery voltage from ADC [millivolts] */
int _battery_voltage(void)
{
static unsigned last_tick = 0;
if (0 == last_tick || TIME_BEFORE(last_tick+HZ, current_tick))
{
int adc_val, irq_status;
unsigned char buf[2];
irq_status = disable_irq_save();
pcf50606_write(PCF5060X_ADCC2, 0x1);
pcf50606_read_multiple(PCF5060X_ADCS1, buf, 2);
restore_interrupt(irq_status);
adc_val = (buf[0]<<2) | (buf[1] & 3); //ADCDAT1H+ADCDAT1L
current_voltage = (adc_val * BATTERY_SCALE_FACTOR) >> 10;
last_tick = current_tick;
}
return current_voltage;
}

View file

@ -1,47 +0,0 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2008 by Rob Purchase
*
* 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 "timer.h"
#include "thread.h"
void tick_start(unsigned int interval_in_ms)
{
/* configure Timer T-Clock to 2Mhz (clock source 4 (Xin) divided by 6) */
PCLKCFG4 = (1 << 31) | (4 << 28) | (5 << 16);
/* disable Timer0 */
TCFG0 &= ~1;
/* set counter reference value based on 1Mhz tick */
TREF0 = interval_in_ms * 1000;
/* Timer0 = reset to 0, divide=2, IRQ enable, enable (continuous) */
TCFG0 = (1<<8) | (0<<4) | (1<<3) | 1;
/* Unmask timer IRQ */
IEN |= TIMER0_IRQ_MASK;
}
/* NB: Since we are using a single timer IRQ, tick tasks are dispatched as
part of the central timer IRQ processing in timer-tcc77x.c */

View file

@ -1,28 +0,0 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2007 Dave Chapman
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#ifndef _ADC_TARGET_H_
#define _ADC_TARGET_H_
#define NUM_ADC_CHANNELS 8
#define ADC_BUTTONS 0
#endif /* _ADC_TARGET_H_ */

View file

@ -1,40 +0,0 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2007 by Michael Sevakis
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#include "system.h"
#include "cpu.h"
#include "audio.h"
#include "sound.h"
int audio_channels = 2;
int audio_output_source = AUDIO_SRC_PLAYBACK;
#if INPUT_SRC_CAPS != 0
void audio_set_output_source(int source)
{
(void)source;
}
void audio_input_mux(int source, unsigned flags)
{
(void)source;
(void)flags;
}
#endif

View file

@ -1,40 +0,0 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2007 by Dave Chapman
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#ifndef BACKLIGHT_TARGET_H
#define BACKLIGHT_TARGET_H
#include "tcc77x.h"
#define backlight_hw_init() true
static inline void backlight_hw_on(void)
{
/* Enable backlight */
GPIOD |= 0x10;
}
static inline void backlight_hw_off(void)
{
/* Disable backlight */
GPIOD &= ~0x10;
}
#endif

View file

@ -1,100 +0,0 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2007 by Dave Chapman
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#include "config.h"
#include "cpu.h"
#include "button.h"
#include "adc.h"
/*
Results of button testing:
HOLD: GPIOA & 0x0002 (0=pressed, 0x0002 = released)
POWER: GPIOA & 0x8000 (0=pressed, 0x8000 = released)
ADC[0]: (approx values)
RIGHT - 0x37
LEFT - 0x7f
JOYSTICK PRESS - 0xc7
UP - 0x11e
DOWN - 0x184
MODE - 0x1f0/0x1ff
PRESET - 0x268/0x269
REC - 0x2dd
Values of ADC[0] tested in OF disassembly: 0x50, 0x96, 0xdc, 0x208, 0x384
*/
void button_init_device(void)
{
/* Nothing to do */
}
int button_read_device(void)
{
int btn = BUTTON_NONE;
int adc;
adc = adc_read(ADC_BUTTONS);
if (adc < 0x384) {
if (adc < 0x140) {
if (adc < 0x96) {
if (adc < 0x50) {
btn |= BUTTON_RIGHT; /* 0x00..0x4f */
} else {
btn |= BUTTON_LEFT; /* 0x50..0x95 */
}
} else {
if (adc < 0xe0) {
btn |= BUTTON_SELECT; /* 0x96..0xdf */
} else {
btn |= BUTTON_UP; /* 0xe0..0x13f */
}
}
} else {
if (adc < 0x208) {
if (adc < 0x1b0) {
btn |= BUTTON_DOWN; /* 0x140..0x1af */
} else {
btn |= BUTTON_MODE; /* 0x1b0..0x207 */
}
} else {
if (adc < 0x290) {
btn |= BUTTON_PRESET; /* 0x208..0x28f */
} else {
btn |= BUTTON_REC; /* 0x290..0x383 */
}
}
}
}
if (!(GPIOA & 0x2))
btn |= BUTTON_HOLD;
if (!(GPIOA & 0x8000))
btn |= BUTTON_POWERPLAY;
return btn;
}

View file

@ -1,45 +0,0 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2007 by Dave Chapman
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#ifndef _BUTTON_TARGET_H_
#define _BUTTON_TARGET_H_
/* Main unit's buttons */
#define BUTTON_POWERPLAY 0x00000001
#define BUTTON_MODE 0x00000002
#define BUTTON_HOLD 0x00000004
#define BUTTON_REC 0x00000008
#define BUTTON_PRESET 0x00000010
#define BUTTON_LEFT 0x00000020
#define BUTTON_RIGHT 0x00000040
#define BUTTON_UP 0x00000080
#define BUTTON_DOWN 0x00000100
#define BUTTON_SELECT 0x00000200
#define BUTTON_MAIN (BUTTON_POWERPLAY|BUTTON_MODE|BUTTON_HOLD\
|BUTTON_REC|BUTTON_PRESET|BUTTON_LEFT\
|BUTTON_RIGHT|BUTTON_UP|BUTTON_DOWN|BUTTON_SELECT)
/* Software power-off */
#define POWEROFF_BUTTON BUTTON_POWERPLAY
#define POWEROFF_COUNT 40
#endif /* _BUTTON_TARGET_H_ */

View file

@ -1,44 +0,0 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2007 Dave Chapman
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#include "config.h"
#include "cpu.h"
#include <stdbool.h>
#include "kernel.h"
#include "system.h"
#include "power.h"
void power_init(void)
{
}
void ide_power_enable(bool on)
{
(void)on;
}
bool ide_powered(void)
{
return true;
}
void power_off(void)
{
}

View file

@ -1,28 +0,0 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2007 Dave Chapman
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#ifndef _ADC_TARGET_H_
#define _ADC_TARGET_H_
#define NUM_ADC_CHANNELS 8
#define ADC_BUTTONS 1
#endif /* _ADC_TARGET_H_ */

View file

@ -1,38 +0,0 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2007 by Michael Sevakis
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#include "system.h"
#include "cpu.h"
#include "audio.h"
#include "sound.h"
int audio_channels = 2;
int audio_output_source = AUDIO_SRC_PLAYBACK;
void audio_set_output_source(int source)
{
(void)source;
}
void audio_input_mux(int source, unsigned flags)
{
(void)source;
(void)flags;
}

View file

@ -1,44 +0,0 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2008 by Dave Chapman
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#ifndef BACKLIGHT_TARGET_H
#define BACKLIGHT_TARGET_H
#include "tcc77x.h"
static inline bool backlight_hw_init(void)
{
GPIOA_DIR |= 0x40;
return true;
}
static inline void backlight_hw_on(void)
{
/* Enable backlight */
GPIOA |= 0x40;
}
static inline void backlight_hw_off(void)
{
/* Disable backlight */
GPIOA &= ~0x40;
}
#endif

View file

@ -1,99 +0,0 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2007 by Dave Chapman
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#include "config.h"
#include "cpu.h"
#include "button.h"
#include "adc.h"
/*
Results of button testing (viewing ADC values whilst pressing buttons):
HOLD: GPIOB & 0x0200 (0=hold active, 0x0200 = hold inactive)
ADC[1]: (approx values)
Idle - 0x3ff
MENU - unknown
REPEAT/AB - 0x03?
LEFT - 0x07?-0x08?
SELECT - 0x0c?
RIGHT - 0x11?
PLAY/PAUSE - 0x17?-0x018?
VOL UP - 0x1e?-0x01f?
VOL DOWN - 0x26?
*/
void button_init_device(void)
{
/* Nothing to do */
}
int button_read_device(void)
{
int btn = BUTTON_NONE;
int adc;
/* TODO - determine how to detect BUTTON_MENU - it doesn't appear to
be connected to a GPIO or to an ADC
*/
adc = adc_read(ADC_BUTTONS);
if (adc < 0x384) {
if (adc < 0x140) {
if (adc < 0x96) {
if (adc < 0x50) {
btn |= BUTTON_REPEATAB; /* 0x00..0x4f */
} else {
btn |= BUTTON_LEFT; /* 0x50..0x95 */
}
} else {
if (adc < 0xe0) {
btn |= BUTTON_SELECT; /* 0x96..0xdf */
} else {
btn |= BUTTON_RIGHT; /* 0xe0..0x13f */
}
}
} else {
if (adc < 0x208) {
if (adc < 0x1b0) {
btn |= BUTTON_PLAYPAUSE; /* 0x140..0x1af */
} else {
btn |= BUTTON_VOLUP; /* 0x1b0..0x207 */
}
} else {
btn |= BUTTON_VOLDOWN; /* 0x209..0x383 */
}
}
}
return btn;
}
bool button_hold(void)
{
return (GPIOB & 0x200)?false:true;
}

View file

@ -1,45 +0,0 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2007 by Dave Chapman
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#ifndef _BUTTON_TARGET_H_
#define _BUTTON_TARGET_H_
#define HAS_BUTTON_HOLD
/* Main unit's buttons */
#define BUTTON_MENU 0x00000001
#define BUTTON_VOLUP 0x00000002
#define BUTTON_VOLDOWN 0x00000004
#define BUTTON_PLAYPAUSE 0x00000008
#define BUTTON_REPEATAB 0x00000010
#define BUTTON_LEFT 0x00000020
#define BUTTON_RIGHT 0x00000040
#define BUTTON_SELECT 0x00000080
#define BUTTON_MAIN (BUTTON_MENU|BUTTON_VOLUP|BUTTON_VOLDOWN\
|BUTTON_PLAYPAUSE|BUTTON_REPEATAB|BUTTON_LEFT\
|BUTTON_RIGHT|BUTTON_SELECT)
/* Software power-off */
#define POWEROFF_BUTTON BUTTON_MENU
#define POWEROFF_COUNT 40
#endif /* _BUTTON_TARGET_H_ */

View file

@ -1,43 +0,0 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2007 Dave Chapman
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#include "config.h"
#include "cpu.h"
#include <stdbool.h>
#include "kernel.h"
#include "system.h"
#include "power.h"
void power_init(void)
{
}
void ide_power_enable(bool on)
{
}
bool ide_powered(void)
{
return true;
}
void power_off(void)
{
}

View file

@ -1,66 +0,0 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2007 by Karl Kurbjun
*
* 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"
#include "kernel.h"
#include "pcf50606.h"
unsigned short current_voltage = 3910;
const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] =
{
/* FIXME: calibrate value */
3380
};
const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
{
/* FIXME: calibrate value */
3300
};
/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
{
/* FIXME: calibrate values. Table is "inherited" from iPod-PCF / H100 */
{ 3370, 3650, 3700, 3740, 3780, 3820, 3870, 3930, 4000, 4080, 4160 }
};
#if CONFIG_CHARGING
/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */
const unsigned short percent_to_volt_charge[11] =
{
/* FIXME: calibrate values. Table is "inherited" from iPod-PCF / H100 */
3370, 3650, 3700, 3740, 3780, 3820, 3870, 3930, 4000, 4080, 4160
};
#endif /* CONFIG_CHARGING */
#define BATTERY_SCALE_FACTOR 6000
/* full-scale ADC readout (2^10) in millivolt */
/* Returns battery voltage from ADC [millivolts] */
int _battery_voltage(void)
{
return current_voltage;
}

View file

@ -1,59 +0,0 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2007 by Dave Chapman
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#ifndef SYSTEM_TARGET_H
#define SYSTEM_TARGET_H
#include "system-arm.h"
#define CPUFREQ_DEFAULT 98784000
#define CPUFREQ_NORMAL 98784000
#define CPUFREQ_MAX 120000000
#define inl(a) (*(volatile unsigned long *) (a))
#define outl(a,b) (*(volatile unsigned long *) (b) = (a))
#define inb(a) (*(volatile unsigned char *) (a))
#define outb(a,b) (*(volatile unsigned char *) (b) = (a))
#define inw(a) (*(volatile unsigned short *) (a))
#define outw(a,b) (*(volatile unsigned short *) (b) = (a))
/* TC32 is configured to 1MHz in clock_init() */
#define USEC_TIMER TC32MCNT
static inline void udelay(unsigned usecs)
{
unsigned stop = USEC_TIMER + usecs;
while (TIME_BEFORE(USEC_TIMER, stop));
}
#define TCC77X_CSCFG_BW8 0
#define TCC77X_CSCFG_BW16 1
/* Due to hardware bug or "feature" this hack is needed to set bus width bits */
static inline
unsigned long tcc77x_cscfg_bw(int bw) {
if (bw == TCC77X_CSCFG_BW8)
return (((MCFG >> 11) & 3) ^ 3) << 28;
else
return (((MCFG >> 11) & 3) ^ 2) << 28;
}
#endif /* SYSTEM_TARGET_H */

View file

@ -1,326 +0,0 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2007 by Dave Chapman
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#include "kernel.h"
#include "system.h"
#include "panic.h"
/* Externally defined interrupt handlers */
extern void TIMER(void);
extern void ADC(void);
extern void USB_DEVICE(void);
void irq(void)
{
int irq = IREQ & 0x7fffffff;
CREQ = irq; /* Clears the corresponding IRQ status */
if (irq & TIMER0_IRQ_MASK)
TIMER();
else if (irq & ADC_IRQ_MASK)
ADC();
#ifdef HAVE_USBSTACK
else if (irq & USBD_IRQ_MASK)
USB_DEVICE();
#endif
else
panicf("Unhandled IRQ 0x%08X", irq);
}
void fiq_handler(void) __attribute__((interrupt ("FIQ"), naked));
#ifdef BOOTLOADER
void fiq_handler(void)
{
/* TODO */
}
#endif
void system_reboot(void)
{
}
void system_exception_wait(void)
{
while (1);
}
/* TODO - these should live in the target-specific directories and
once we understand what all the GPIO pins do, move the init to the
specific driver for that hardware. For now, we just perform the
same GPIO init as the original firmware - this makes it easier to
investigate what the GPIO pins do.
*/
#ifdef LOGIK_DAX
static void gpio_init(void)
{
/* Do what the original firmware does */
GPIOD_FUNC = 0;
GPIOD_DIR = 0x3f0;
GPIOD = 0xe0;
GPIOE_FUNC = 0;
GPIOE_DIR = 0xe0;
GPIOE = 0;
GPIOA_FUNC = 0;
GPIOA_DIR = 0xffff1000; /* 0 - 0xf000 */
GPIOA = 0x1080;
GPIOB_FUNC = 0x16a3;
GPIOB_DIR = 0x6ffff;
GPIOB = 0;
GPIOC_FUNC = 1;
GPIOC_DIR = 0x03ffffff; /* mvn r2, 0xfc000000 */
GPIOC = 0;
}
#elif defined(IAUDIO_7)
static void gpio_init(void)
{
/* Do what the original firmware does */
GPIOA_FUNC = 0;
GPIOB_FUNC = 0x1623;
GPIOC_FUNC = 1;
GPIOD_FUNC = 0;
GPIOE_FUNC = 0;
GPIOA = 0x30;
GPIOB = 0x00c00;
GPIOC = 0;
GPIOD = 0x180;
GPIOE = 0x80;
GPIOA_DIR = 0x84b0;
GPIOB_DIR = 0x80c00;
GPIOC_DIR = 0x2000000;
GPIOD_DIR = 0x3e3;
GPIOE_DIR = 0x88;
}
#elif defined(SANSA_M200)
static void gpio_init(void)
{
/* TODO - Implement for M200 */
}
#elif defined(SANSA_C100)
static void gpio_init(void)
{
/* Do what the original firmware does */
GPIOA_FUNC = 0;
GPIOB_FUNC = 0x16A3;
GPIOC_FUNC = 1;
GPIOD_FUNC |= 2;
GPIOE_FUNC = 0;
GPIOA_DIR = 0xFFFF0E00;
GPIOB_DIR = 0x6FFFF;
GPIOC_DIR = 0x03FFFFFF;
GPIOD_DIR = 0x3F7;
GPIOE_DIR = 0x9B;
GPIOA = 0x80;
GPIOB = 0;
GPIOC = 0;
GPIOD |= 0xC0;
GPIOE = 0x9B;
}
#endif
/* Second function called in the original firmware's startup code - we just
set up the clocks in the same way as the original firmware for now. */
static void clock_init(void)
{
unsigned int i;
/* STP = 0x1, PW = 0x04 , HLD = 0x0 */
CSCFG3 = (CSCFG3 &~ 0x3fff) | 0x820;
/* XIN=External main, Fcpu=Fsys, BCKDIV=1 (Fbus = Fsys / 2) */
CLKCTRL = (CLKCTRL & ~0xff) | 0x14;
if (BMI & 0x20)
PCLKCFG0 = 0xc82d7000; /* EN1 = 1, XIN=Ext. main, DIV1 = 0x2d, P1 = 1 */
else
PCLKCFG0 = 0xc8ba7000; /* EN1 = 1, XIN=Ext. main, DIV1 = 0xba, P1 = 1 */
MCFG |= 0x2000;
#ifdef LOGIK_DAX
/* Only seen in the Logik DAX original firmware */
SDCFG = (SDCFG & ~0x7000) | 0x2000;
#endif
/* Disable PLL */
PLL0CFG |= 0x80000000;
/* Enable PLL, M=0xcf, P=0x13. m=M+8, p=P+2, S = 0
Fout = (215/21)*12MHz = 122857142Hz */
PLL0CFG = 0x0000cf13;
i = 8000;
while (--i) {};
/* Enable PLL0 */
CLKDIVC = 0x81000000;
/* Fsys = PLL0, Fcpu = Fsys, Fbus=Fsys / 2 */
CLKCTRL = 0x80000010;
asm volatile (
"nop \n\t"
"nop \n\t"
);
/* Enable Z-Clock */
PCLKCFG5 |= (1<<31) | (4<<28); /* Timer Z-Clock enable, XIN direct*/
/* Set TC32 timer to be our USEC_TIMER (Xin divided by 12 = 1MHz) */
TC32MCNT = 0;
TC32LDV = 0;
TC32EN = (1<<24) | 11;
}
static void cpu_init(void)
{
/* Memory protection - see page 48 of ARM946 TRM
http://infocenter.arm.com/help/topic/com.arm.doc.ddi0201d/DDI0201D_arm946es_r1p1_trm.pdf
*/
asm volatile (
/* Region 0 - addr=0, size=4GB, enabled */
"mov r0, #0x3f \n\t"
"mcr p15, 0, r0, c6, c0, 0 \n\t"
"mcr p15, 0, r0, c6, c0, 1 \n\t"
#if defined(LOGIK_DAX) || defined(SANSA_C100)
/* Address region 1 - addr 0x2fff0000, size=64KB, enabled*/
"ldr r0, =0x2fff001f \n\t"
#elif defined(IAUDIO_7)
/* Address region 1 - addr 0x20000000, size=8KB, enabled*/
"mov r0, #0x19 \n\t"
"add r0, r0, #0x20000000 \n\t"
#elif defined(SANSA_M200)
/* Address region 1 - addr 0x20000000, size=256MB, enabled*/
"mov r0, #0x37 \n\t"
"add r0, r0, #0x20000000 \n\t"
#endif
"mcr p15, 0, r0, c6, c1, 0 \n\t"
"mcr p15, 0, r0, c6, c1, 1 \n\t"
/* Address region 2 - addr 0x30000000, size=256MB, enabled*/
"mov r0, #0x37 \n\t"
"add r0, r0, #0x30000000 \n\t"
"mcr p15, 0, r0, c6, c2, 0 \n\t"
"mcr p15, 0, r0, c6, c2, 1 \n\t"
/* Address region 2 - addr 0x40000000, size=512MB, enabled*/
"mov r0, #0x39 \n\t"
"add r0, r0, #0x40000000 \n\t"
"mcr p15, 0, r0, c6, c3, 0 \n\t"
"mcr p15, 0, r0, c6, c3, 1 \n\t"
/* Address region 4 - addr 0x60000000, size=256MB, enabled*/
"mov r0, #0x37 \n\t"
"add r0, r0, #0x60000000 \n\t"
"mcr p15, 0, r0, c6, c4, 0 \n\t"
"mcr p15, 0, r0, c6, c4, 1 \n\t"
/* Address region 5 - addr 0x10000000, size=256MB, enabled*/
"mov r0, #0x37 \n\t"
"add r0, r0, #0x10000000 \n\t"
"mcr p15, 0, r0, c6, c5, 0 \n\t"
"mcr p15, 0, r0, c6, c5, 1 \n\t"
/* Address region 6 - addr 0x80000000, size=2GB, enabled*/
"mov r0, #0x37 \n\t"
"add r0, r0, #0x80000006 \n\t"
"mcr p15, 0, r0, c6, c6, 0 \n\t"
"mcr p15, 0, r0, c6, c6, 1 \n\t"
/* Address region 7 - addr 0x3000f000, size=4KB, enabled*/
"ldr r0, =0x3000f017 \n\t"
"mcr p15, 0, r0, c6, c7, 0 \n\t"
"mcr p15, 0, r0, c6, c7, 1 \n\t"
/* Register 5 - Access Permission Registers */
"ldr r0, =0xffff \n\t"
"mcr p15, 0, r0, c5, c0, 0 \n\t" /* write data access permission bits */
"mcr p15, 0, r0, c5, c0, 1 \n\t" /* write instruction access permission bits */
"mov r0, #0xa7 \n\t"
"mcr p15, 0, r0, c3, c0, 0 \n\t" /* set write buffer control register */
#if defined(LOGIK_DAX) || defined(SANSA_C100)
"mov r0, #0xa5 \n\t"
#elif defined(IAUDIO_7) || defined(SANSA_M200)
"mov r0, #0xa7 \n\t"
#else
#error NOT DEFINED FOR THIS TARGET!
#endif
"mcr p15, 0, r0, c2, c0, 0 \n\t"
"mcr p15, 0, r0, c2, c0, 1 \n\t"
"mov r0, #0xa0000006 \n\t"
"mcr p15, 0, r0, c9, c1, 0 \n\t"
"ldr r1, =0x1107d \n\t"
"mov r0, #0x0 \n\t"
"mcr p15, 0, r0, c7, c5, 0 \n\t" /* Flush instruction cache */
"mcr p15, 0, r0, c7, c6, 0 \n\t" /* Flush data cache */
"mcr p15, 0, r1, c1, c0, 0 \n\t" /* CPU control bits */
: : : "r0", "r1"
);
}
void system_init(void)
{
/* mask all interrupts */
IEN = 0;
/* Set all interrupts as IRQ for now - some may need to be FIQ in future */
IRQSEL = 0xffffffff;
/* Set master enable bit */
IEN = 0x80000000;
cpu_init();
clock_init();
gpio_init();
enable_irq();
}
int system_memory_guard(int newmode)
{
(void)newmode;
return 0;
}
#ifdef HAVE_ADJUSTABLE_CPU_FREQ
void set_cpu_frequency(long frequency)
{
}
#endif

View file

@ -1,69 +0,0 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2008 by Rob Purchase
*
* 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 "timer.h"
#include "logf.h"
/* Use the TC32 counter [sourced by Xin:12Mhz] for this timer, as it's the
only one that allows a 32-bit counter (Timer0-5 are 16/20 bit only). */
bool timer_set(long cycles, bool start)
{
#warning function not implemented
(void)cycles;
(void)start;
return false;
}
bool timer_start(void)
{
#warning function not implemented
return false;
}
void timer_stop(void)
{
#warning function not implemented
}
/* Timer interrupt processing - all timers (inc. tick) have a single IRQ */
void TIMER(void)
{
if (TIREQ & TF0) /* Timer0 reached ref value */
{
/* Run through the list of tick tasks */
call_tick_tasks();
/* reset Timer 0 IRQ & ref flags */
TIREQ |= TI0 | TF0;
}
if (TC32IRQ & (1<<3)) /* end of TC32 prescale */
{
/* dispatch timer */
}
}

View file

@ -34,8 +34,6 @@
#if defined(COWON_D2)
/* The D2's audio codec uses an I2C address of 0x34 */
#define I2C_AUDIO_ADDRESS 0x34
#elif defined (IAUDIO_7) || defined(LOGIK_DAX) || defined(SANSA_M200)
#define I2C_AUDIO_ADDRESS 0x34
#else
#error wmcodec not implemented for this target!
#endif