HD200 - power_init() rework based on latest power consumption measurements

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26767 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Marcin Bukat 2010-06-11 11:41:29 +00:00
parent b45a2d433b
commit 2f7bd4d993

View file

@ -30,15 +30,10 @@
#if CONFIG_TUNER
bool tuner_power(bool status)
{
(void)status;
if (status)
{
and_l(~(1<<17), &GPIO1_OUT);
}
else
{
or_l((1<<17), &GPIO1_OUT);
}
return status;
}
@ -46,20 +41,39 @@ bool tuner_power(bool status)
void power_init(void)
{
/* GPIO53 has to be high - low resets device */
/* GPIO49 is FM related */
or_l((1<<21)|(1<<17), &GPIO1_OUT);
or_l((1<<21)|(1<<17), &GPIO1_ENABLE);
or_l((1<<21)|(1<<17)|(1<<14), &GPIO1_FUNCTION);
/* GPIO53 has to be high - low resets device
* it is setup in crt0.S
*/
and_l(~(1<<15), &GPIO_OUT);
or_l((1<<15),&GPIO_ENABLE);
or_l((1<<15),&GPIO_FUNCTION);
/* GPIO50 is ATA power (default OFF) */
or_l((1<<18), &GPIO1_OUT);
or_l((1<<18), &GPIO1_ENABLE);
or_l((1<<18), &GPIO1_FUNCTION);
/* GPIO49 is FM power (default OFF) */
or_l((1<<17), &GPIO1_OUT);
or_l((1<<17), &GPIO1_ENABLE);
or_l((1<<17), &GPIO1_FUNCTION);
/* GPIO46 is wall charger detect (input) */
and_l(~(1<<14), &GPIO1_ENABLE);
or_l((1<<14), &GPIO1_FUNCTION);
/* GPIO31 needs to be low */
and_l(~(1<<31), &GPIO_OUT);
or_l((1<<31),&GPIO_ENABLE);
or_l((1<<31),&GPIO_FUNCTION);
/* turn off charger by default*/
or_l((1<<23), &GPIO_OUT);
and_l(~(1<<23), &GPIO_ENABLE);
or_l((1<<23), &GPIO_FUNCTION);
/* high current charge mode */
or_l((1<<15), &GPIO_OUT);
or_l((1<<15),&GPIO_ENABLE);
or_l((1<<15),&GPIO_FUNCTION);
#ifndef BOOTLOADER
/* The boot loader controls the power */
ide_power_enable(true);
@ -71,8 +85,16 @@ unsigned int power_input_status(void)
unsigned int status = POWER_INPUT_NONE;
/* GPIO46 is AC plug detect (low = AC plugged) */
if (!(GPIO1_READ & (1<<14)))
status |= POWER_INPUT_MAIN_CHARGER;
{
status |= POWER_INPUT_MAIN_CHARGER;
/* tristate GPIO23 to start charging cycle */
and_l(~(1<<23), &GPIO_ENABLE);
}
else
{
/* drive GPIO23 high to enter LTC1733 shutdown mode */
or_l((1<<23), &GPIO_ENABLE);
}
return status;
}
@ -87,20 +109,15 @@ bool charging_state(void)
void ide_power_enable(bool on)
{
(void)on;
if (on)
and_l(~(1<<31),&GPIO_OUT);
if (on)
and_l(~(1<<18),&GPIO1_OUT);
else
or_l((1<<31),&GPIO_OUT);
or_l((1<<31),&GPIO_ENABLE);
or_l((1<<31),&GPIO_FUNCTION);
or_l((1<<18),&GPIO1_OUT);
}
bool ide_powered(void)
{
return true;
return (GPIO1_OUT & (1<<18))?false:true;
}
void power_off(void)