Fix a pile of yellow in the bootloader
Change-Id: Ia89a33bbb13683566e421ac2a002baa20cdb07de
This commit is contained in:
parent
b4865b05b0
commit
4a3d046545
9 changed files with 87 additions and 58 deletions
|
@ -7,7 +7,7 @@
|
|||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2002 by Linus Nielsen Feltzing, Uwe Freese, Laurent Baum,
|
||||
* Copyright (C) 2002 by Linus Nielsen Feltzing, Uwe Freese, Laurent Baum,
|
||||
* Przemyslaw Holubowski
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
|
@ -59,13 +59,14 @@ void rtc_init(void)
|
|||
{
|
||||
unsigned char tmp;
|
||||
int rv;
|
||||
|
||||
|
||||
/* initialize Control 1 register */
|
||||
tmp = 0;
|
||||
pp_i2c_send(RTC_ADDR, RTC_CTRL1, tmp);
|
||||
|
||||
|
||||
/* read value of the Control 2 register - we'll need it to preserve alarm and timer interrupt assertion flags */
|
||||
rv = i2c_readbytes(RTC_ADDR, RTC_CTRL2, 1, &tmp);
|
||||
(void)rv;
|
||||
/* preserve alarm and timer interrupt flags */
|
||||
tmp &= (RTC_TF | RTC_AF | RTC_TIE | RTC_AIE);
|
||||
pp_i2c_send(RTC_ADDR, RTC_CTRL2, tmp);
|
||||
|
@ -119,6 +120,7 @@ void rtc_set_alarm(int h, int m)
|
|||
|
||||
/* clear alarm interrupt */
|
||||
rv = i2c_readbytes(RTC_ADDR, RTC_CTRL2, 1, buf);
|
||||
(void)rv;
|
||||
buf[0] &= RTC_AF;
|
||||
pp_i2c_send(RTC_ADDR, RTC_CTRL2, buf[0]);
|
||||
|
||||
|
@ -128,7 +130,7 @@ void rtc_set_alarm(int h, int m)
|
|||
else
|
||||
/* ignore minutes comparison query */
|
||||
buf[0] = RTC_AE;
|
||||
|
||||
|
||||
if( h >= 0 )
|
||||
buf[1] = DEC2BCD(h);
|
||||
else
|
||||
|
@ -172,7 +174,7 @@ void rtc_enable_alarm(bool enable)
|
|||
}
|
||||
else
|
||||
{
|
||||
/* disable alarm interrupt */
|
||||
/* disable alarm interrupt */
|
||||
if(rtc_lock_alarm_clear)
|
||||
/* lock disabling alarm before it was checked whether or not the unit was started by RTC alarm */
|
||||
return;
|
||||
|
@ -180,6 +182,7 @@ void rtc_enable_alarm(bool enable)
|
|||
tmp &= ~(RTC_AIE | RTC_AF);
|
||||
pp_i2c_send(RTC_ADDR, RTC_CTRL2, tmp);
|
||||
}
|
||||
(void)rv;
|
||||
}
|
||||
|
||||
bool rtc_check_alarm_started(bool release_alarm)
|
||||
|
@ -193,14 +196,14 @@ bool rtc_check_alarm_started(bool release_alarm)
|
|||
{
|
||||
started = alarm_state;
|
||||
alarm_state &= ~release_alarm;
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
/* read Control 2 register which contains alarm flag */
|
||||
rv = i2c_readbytes(RTC_ADDR, RTC_CTRL2, 1, &tmp);
|
||||
|
||||
alarm_state = started = ( (tmp & RTC_AF) && (tmp & RTC_AIE) );
|
||||
|
||||
|
||||
if(release_alarm && started)
|
||||
{
|
||||
rv = i2c_readbytes(RTC_ADDR, RTC_CTRL2, 1, &tmp);
|
||||
|
@ -211,7 +214,8 @@ bool rtc_check_alarm_started(bool release_alarm)
|
|||
run_before = true;
|
||||
rtc_lock_alarm_clear = false;
|
||||
}
|
||||
|
||||
(void)rv;
|
||||
|
||||
return started;
|
||||
}
|
||||
|
||||
|
@ -219,11 +223,10 @@ bool rtc_check_alarm_flag(void)
|
|||
{
|
||||
unsigned char tmp=0;
|
||||
int rv=0;
|
||||
|
||||
|
||||
/* read Control 2 register which contains alarm flag */
|
||||
rv = i2c_readbytes(RTC_ADDR, RTC_CTRL2, 1, &tmp);
|
||||
|
||||
return (tmp & RTC_AF);
|
||||
}
|
||||
#endif /* HAVE_RTC_ALARM */
|
||||
|
||||
|
|
|
@ -36,10 +36,10 @@ void button_init_device(void)
|
|||
{
|
||||
/* Enable REW, FF, Play, Left, Right, Hold buttons */
|
||||
GPIO_SET_BITWISE(GPIOA_ENABLE, 0xfc);
|
||||
|
||||
|
||||
/* Enable POWER button */
|
||||
GPIO_SET_BITWISE(GPIOB_ENABLE, 0x01);
|
||||
|
||||
|
||||
/* We need to output to pin 6 of GPIOD when reading the scroll pad value */
|
||||
GPIO_SET_BITWISE(GPIOD_ENABLE, 0x40);
|
||||
GPIO_SET_BITWISE(GPIOD_OUTPUT_EN, 0x40);
|
||||
|
@ -64,13 +64,18 @@ int button_read_device(void)
|
|||
int btn = BUTTON_NONE;
|
||||
int data;
|
||||
unsigned char state;
|
||||
|
||||
static bool hold_button = false;
|
||||
static bool remote_hold_button = false;
|
||||
#ifndef BOOTLOADER
|
||||
bool hold_button_old;
|
||||
bool remote_hold_button_old;
|
||||
#endif
|
||||
|
||||
/* Hold */
|
||||
#ifndef BOOTLOADER
|
||||
hold_button_old = hold_button;
|
||||
#endif
|
||||
hold_button = button_hold();
|
||||
|
||||
#ifndef BOOTLOADER
|
||||
|
@ -91,10 +96,10 @@ int button_read_device(void)
|
|||
if ((state & 0x20) == 0) btn |= BUTTON_REW;
|
||||
if ((state & 0x40) == 0) btn |= BUTTON_RIGHT;
|
||||
if ((state & 0x80) == 0) btn |= BUTTON_LEFT;
|
||||
|
||||
|
||||
/* Read power button */
|
||||
if (GPIOB_INPUT_VAL & 0x1) btn |= BUTTON_POWER;
|
||||
|
||||
|
||||
/* Read scroller */
|
||||
if ( GPIOD_INPUT_VAL & 0x20 )
|
||||
{
|
||||
|
@ -102,7 +107,7 @@ int button_read_device(void)
|
|||
udelay(250);
|
||||
data = adc_scan(ADC_SCROLLPAD);
|
||||
GPIO_SET_BITWISE(GPIOD_OUTPUT_VAL, 0x40);
|
||||
|
||||
|
||||
if(data < 0x224)
|
||||
{
|
||||
btn |= BUTTON_SCROLL_DOWN;
|
||||
|
@ -111,9 +116,11 @@ int button_read_device(void)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifndef BOOTLOADER
|
||||
/* remote buttons */
|
||||
remote_hold_button_old = remote_hold_button;
|
||||
#endif
|
||||
|
||||
data = adc_scan(ADC_REMOTE);
|
||||
remote_hold_button = data < 0x2B;
|
||||
|
@ -143,6 +150,6 @@ int button_read_device(void)
|
|||
/* remote play button should be dead if hold */
|
||||
if (!remote_hold_button && !(GPIOA_INPUT_VAL & 0x1))
|
||||
btn |= BUTTON_RC_PLAY;
|
||||
|
||||
|
||||
return btn;
|
||||
}
|
||||
|
|
|
@ -77,10 +77,14 @@ int button_read_device(void)
|
|||
static int lastbutton;
|
||||
unsigned short remote_adc;
|
||||
int btn = BUTTON_NONE;
|
||||
#ifndef BOOTLOADER
|
||||
bool hold_button_old;
|
||||
#endif
|
||||
|
||||
/* normal buttons */
|
||||
#ifndef BOOTLOADER
|
||||
hold_button_old = hold_button;
|
||||
#endif
|
||||
hold_button = button_hold();
|
||||
|
||||
#ifndef BOOTLOADER
|
||||
|
@ -121,7 +125,7 @@ int button_read_device(void)
|
|||
{
|
||||
btn |= buttons;
|
||||
}
|
||||
|
||||
|
||||
/* the touchpad - only watch the lines we actually read */
|
||||
touchpad = GPJDAT & touchpad_mask;
|
||||
|
||||
|
@ -151,7 +155,7 @@ int button_read_device(void)
|
|||
btn |= BUTTON_LEFT;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* the cradle buttons */
|
||||
buttons = ~GPFDAT & 0xc0;
|
||||
if (buttons)
|
||||
|
@ -163,7 +167,7 @@ int button_read_device(void)
|
|||
btn |= BUTTON_POWER;
|
||||
buttonlight_on();
|
||||
}
|
||||
|
||||
|
||||
return btn;
|
||||
}
|
||||
|
||||
|
|
|
@ -159,6 +159,7 @@ void irq_handler(void)
|
|||
|
||||
void* dummy = VIC0ADDRESS;
|
||||
dummy = VIC1ADDRESS;
|
||||
(void)dummy;
|
||||
uint32_t irqs0 = VIC0IRQSTATUS;
|
||||
uint32_t irqs1 = VIC1IRQSTATUS;
|
||||
for (current_irq = 0; irqs0; current_irq++, irqs0 >>= 1)
|
||||
|
|
|
@ -50,11 +50,15 @@ int button_read_device(int *data)
|
|||
static int old_data = 0;
|
||||
|
||||
static bool hold_button = false;
|
||||
#ifndef BOOTLOADER
|
||||
bool hold_button_old;
|
||||
#endif
|
||||
|
||||
*data = old_data;
|
||||
|
||||
#ifndef BOOTLOADER
|
||||
hold_button_old = hold_button;
|
||||
#endif
|
||||
hold_button = button_hold();
|
||||
|
||||
#ifndef BOOTLOADER
|
||||
|
|
|
@ -58,33 +58,32 @@ const unsigned short percent_to_volt_charge[11] =
|
|||
{
|
||||
4000, 4105, 4210, 4315, 4420, 4525, 4630, 4735, 4840, 4945, 5050,
|
||||
};
|
||||
|
||||
|
||||
/* Returns battery voltage from ADC [millivolts] */
|
||||
int _battery_voltage(void)
|
||||
{
|
||||
short bat1, bat2, aux;
|
||||
static unsigned last_tick = 0;
|
||||
// static unsigned last_tick = 0;
|
||||
short tsadc;
|
||||
|
||||
|
||||
tsadc=tsc2100_readreg(TSADC_PAGE, TSADC_ADDRESS);
|
||||
|
||||
|
||||
/* Set the TSC2100 to read voltages if not busy with pen */
|
||||
if(!(tsadc & TSADC_PSTCM))
|
||||
{
|
||||
tsc2100_set_mode(true, 0x0B);
|
||||
last_tick = current_tick;
|
||||
// last_tick = current_tick;
|
||||
}
|
||||
|
||||
|
||||
if(tsc2100_read_volt(&bat1, &bat2, &aux))
|
||||
{
|
||||
{
|
||||
/* Calculation was:
|
||||
* (val << 10) / 4096 * 6 * 2.5
|
||||
* (val << 10) / 4096 * 6 * 2.5
|
||||
*/
|
||||
current_voltage = (short)( (int) (bat1 * 15) >> 2 );
|
||||
current_bat2 = (short)( (bat2 * 15) >> 2 );
|
||||
current_aux = (short)( (aux * 15) >> 2 );
|
||||
}
|
||||
|
||||
|
||||
return current_voltage;
|
||||
}
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ default_interrupt(RESERVED);
|
|||
* change the offset for the interrupt in the entry table.
|
||||
*/
|
||||
|
||||
static const unsigned short const irqpriority[] =
|
||||
static const unsigned short const irqpriority[] =
|
||||
{
|
||||
IRQ_TIMER0,IRQ_TIMER1,IRQ_TIMER2,IRQ_TIMER3,IRQ_CCD_VD0,IRQ_CCD_VD1,
|
||||
IRQ_CCD_WEN,IRQ_VENC,IRQ_SERIAL0,IRQ_SERIAL1,IRQ_EXT_HOST,IRQ_DSPHINT,
|
||||
|
@ -165,7 +165,7 @@ void fiq_handler(void)
|
|||
void system_reboot(void)
|
||||
{
|
||||
/* Code taken from linux/include/asm-arm/arch-itdm320-20/system.h at NeuroSVN */
|
||||
__asm__ __volatile__(
|
||||
__asm__ __volatile__(
|
||||
"mov ip, #0 \n"
|
||||
"mcr p15, 0, ip, c7, c7, 0 @ invalidate cache \n"
|
||||
"mcr p15, 0, ip, c7, c10,4 @ drain WB \n"
|
||||
|
@ -175,7 +175,7 @@ void system_reboot(void)
|
|||
"bic ip, ip, #0x2100 @ ..v....s........ \n"
|
||||
"mcr p15, 0, ip, c1, c0, 0 @ ctrl register \n"
|
||||
"mov ip, #0xFF000000 \n"
|
||||
"orr pc, ip, #0xFF0000 @ ip = 0xFFFF0000 \n"
|
||||
"orr pc, ip, #0xFF0000 @ ip = 0xFFFF0000 \n"
|
||||
:
|
||||
:
|
||||
: "cc"
|
||||
|
@ -198,8 +198,8 @@ void system_exception_wait(void)
|
|||
|
||||
void system_init(void)
|
||||
{
|
||||
unsigned int vector_addr;
|
||||
/* Pin 33 is connected to a buzzer, for an annoying sound set
|
||||
// unsigned int vector_addr;
|
||||
/* Pin 33 is connected to a buzzer, for an annoying sound set
|
||||
* PWM0C == 0x3264
|
||||
* PWM0H == 0x1932
|
||||
* Function to 1
|
||||
|
@ -228,8 +228,8 @@ void system_init(void)
|
|||
IO_INTC_FISEL2 = 0;
|
||||
|
||||
/* Only initially needed clocks should be turned on */
|
||||
IO_CLK_MOD0 = CLK_MOD0_HPIB | CLK_MOD0_DSP | CLK_MOD0_SDRAMC |
|
||||
CLK_MOD0_EMIF | CLK_MOD0_INTC | CLK_MOD0_AIM |
|
||||
IO_CLK_MOD0 = CLK_MOD0_HPIB | CLK_MOD0_DSP | CLK_MOD0_SDRAMC |
|
||||
CLK_MOD0_EMIF | CLK_MOD0_INTC | CLK_MOD0_AIM |
|
||||
CLK_MOD0_AHB | CLK_MOD0_BUSC | CLK_MOD0_ARM;
|
||||
IO_CLK_MOD1 = CLK_MOD1_CPBUS;
|
||||
IO_CLK_MOD2 = CLK_MOD2_GIO;
|
||||
|
@ -258,17 +258,17 @@ void system_init(void)
|
|||
* IO_EMIF_CS4CTRL2 = 0x4220;
|
||||
*
|
||||
* More agressive numbers may be possible, but it depends on the clocking
|
||||
* setup.
|
||||
* setup.
|
||||
*/
|
||||
IO_EMIF_CS4CTRL1 = 0x66AB;
|
||||
IO_EMIF_CS4CTRL2 = 0x4220;
|
||||
IO_EMIF_CS4CTRL2 = 0x4220;
|
||||
|
||||
/* 27 MHz input clock:
|
||||
* PLLA: 27 * 15 / 2 = 202.5 MHz
|
||||
* PLLB: 27 * 9 / 2 = 121.5 MHz (off: bit 12)
|
||||
*/
|
||||
IO_CLK_PLLA = (14 << 4) | 1;
|
||||
IO_CLK_PLLB = ( 1 << 12) | ( 8 << 4) | 1;
|
||||
IO_CLK_PLLB = ( 1 << 12) | ( 8 << 4) | 1;
|
||||
|
||||
/* Set the slow and fast clock speeds used for boosting
|
||||
* Slow Setup:
|
||||
|
@ -282,31 +282,31 @@ void system_init(void)
|
|||
clock_arm_fast = (1 << 8) | 0;
|
||||
|
||||
IO_CLK_DIV0 = clock_arm_slow;
|
||||
|
||||
|
||||
/* SDRAM div= 2 ( 101.25 MHz )
|
||||
* AXL div = 1 ( 202.5 MHz )
|
||||
*/
|
||||
IO_CLK_DIV1 = (0 << 8) | 1;
|
||||
|
||||
|
||||
/* MS div = 15 ( 13.5 MHz )
|
||||
* DSP div = 4 ( 50.625 MHz - could be double, but this saves power)
|
||||
*/
|
||||
*/
|
||||
IO_CLK_DIV2 = (3 << 8) | 14;
|
||||
|
||||
|
||||
/* MMC div = 256 ( slow )
|
||||
* VENC div = 32 ( 843.75 KHz )
|
||||
*/
|
||||
IO_CLK_DIV3 = (31 << 8) | 255;
|
||||
|
||||
|
||||
/* I2C div = 1 ( 48 MHz if M48XI is running )
|
||||
* VLNQ div = 32
|
||||
*/
|
||||
IO_CLK_DIV4 = (31 << 8) | 0;
|
||||
|
||||
|
||||
/* Feed everything from PLLA */
|
||||
IO_CLK_SEL0=0x007E;
|
||||
IO_CLK_SEL1=0x1000;
|
||||
IO_CLK_SEL2=0x0000;
|
||||
IO_CLK_SEL2=0x0000;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
|
@ -335,16 +335,16 @@ void system_init(void)
|
|||
/* IRQENTRY only reflects enabled interrupts */
|
||||
IO_INTC_RAW = 0;
|
||||
|
||||
vector_addr = (unsigned int) irqvector;
|
||||
// vector_addr = (unsigned int) irqvector;
|
||||
IO_INTC_ENTRY_TBA0 = 0;//(short) vector_addr & ~0x000F;
|
||||
IO_INTC_ENTRY_TBA1 = 0;//(short) (vector_addr >> 16);
|
||||
|
||||
int i;
|
||||
/* Set interrupt priorities to predefined values */
|
||||
for(i = 0; i < 23; i++)
|
||||
DM320_REG(0x0540+i*2) = ((irqpriority[i*2+1] & 0x3F) << 8) |
|
||||
DM320_REG(0x0540+i*2) = ((irqpriority[i*2+1] & 0x3F) << 8) |
|
||||
(irqpriority[i*2] & 0x3F); /* IO_INTC_PRIORITYx */
|
||||
|
||||
|
||||
/* Turn off all timers */
|
||||
IO_TIMER0_TMMD = CONFIG_TIMER0_TMMD_STOP;
|
||||
IO_TIMER1_TMMD = CONFIG_TIMER1_TMMD_STOP;
|
||||
|
@ -410,12 +410,12 @@ void set_cpu_frequency(long frequency)
|
|||
return;
|
||||
}
|
||||
|
||||
if (frequency == CPUFREQ_MAX)
|
||||
if (frequency == CPUFREQ_MAX)
|
||||
{
|
||||
IO_CLK_DIV0 = clock_arm_fast;
|
||||
FREQ = CPUFREQ_MAX;
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
IO_CLK_DIV0 = clock_arm_slow;
|
||||
FREQ = CPUFREQ_NORMAL;
|
||||
|
@ -477,7 +477,7 @@ void udelay(int usec) {
|
|||
* can lead to lockup.
|
||||
* Interrupt status bit check below is used to prevent this lockup.
|
||||
*/
|
||||
|
||||
|
||||
if (stop < count)
|
||||
{
|
||||
/* udelay will end after counter reset (tick) */
|
||||
|
@ -503,4 +503,3 @@ void system_prepare_fw_start(void)
|
|||
IO_INTC_EINT2 = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -49,12 +49,16 @@ bool remote_button_hold(void)
|
|||
int button_read_device(void)
|
||||
{
|
||||
int btn = BUTTON_NONE;
|
||||
#ifndef BOOTLOADER
|
||||
bool hold_button_old;
|
||||
bool remote_hold_button_old;
|
||||
#endif
|
||||
int data;
|
||||
|
||||
/* normal buttons */
|
||||
#ifndef BOOTLOADER
|
||||
hold_button_old = hold_button;
|
||||
#endif
|
||||
hold_button = button_hold();
|
||||
|
||||
if (!hold_button)
|
||||
|
@ -87,7 +91,9 @@ int button_read_device(void)
|
|||
/* remote buttons */
|
||||
data = remote_detect() ? adc_read(ADC_REMOTE) : 0xff;
|
||||
|
||||
#ifndef BOOTLOADER
|
||||
remote_hold_button_old = remote_hold_button;
|
||||
#endif
|
||||
remote_hold_button = data < 0x14;
|
||||
|
||||
#ifndef BOOTLOADER
|
||||
|
|
|
@ -60,14 +60,18 @@ bool remote_button_hold(void)
|
|||
int button_read_device(void)
|
||||
{
|
||||
int btn = BUTTON_NONE;
|
||||
#ifndef BOOTLOADER
|
||||
bool hold_button_old;
|
||||
bool remote_hold_button_old;
|
||||
#endif
|
||||
static int prev_data = 0xff;
|
||||
static int last_valid = 0xff;
|
||||
int data;
|
||||
|
||||
/* normal buttons */
|
||||
#ifndef BOOTLOADER
|
||||
hold_button_old = hold_button;
|
||||
#endif
|
||||
hold_button = button_hold();
|
||||
|
||||
#ifndef BOOTLOADER
|
||||
|
@ -86,7 +90,7 @@ int button_read_device(void)
|
|||
last_valid = data;
|
||||
prev_data = data;
|
||||
data = last_valid;
|
||||
|
||||
|
||||
if (data < 0xf0)
|
||||
{
|
||||
if(data < 0x7c)
|
||||
|
@ -114,7 +118,9 @@ int button_read_device(void)
|
|||
/* remote buttons */
|
||||
data = remote_detect() ? adc_scan(ADC_REMOTE) : 0xff;
|
||||
|
||||
#ifndef BOOTLOADER
|
||||
remote_hold_button_old = remote_hold_button;
|
||||
#endif
|
||||
remote_hold_button = data < 0x17;
|
||||
|
||||
#ifndef BOOTLOADER
|
||||
|
|
Loading…
Reference in a new issue