Straighten out some powermanagement stuff. Give target complete control over how power inputs are sensed. Clean SIMULATOR stuff out of target files. Get rid of USB charging option on targets that don't support it or don't implement it yet. Menu string remains to avoid language incompatibility but should be removed on next cleanup for targets not using it (notice in english.lang). global_settings becomes incompatible for some builds and so plugin API version is incremented.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19315 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Michael Sevakis 2008-12-03 19:54:25 +00:00
parent 0d0cc039f8
commit 58eb784a5d
41 changed files with 284 additions and 403 deletions

View file

@ -32,16 +32,14 @@
#include "system.h"
#include "power.h"
#ifndef SIMULATOR
void power_init(void)
{
/* Charger detect */
}
bool charger_inserted(void)
{
return false;
unsigned int power_input_status(void)
{
return POWER_INPUT_NONE;
}
void ide_power_enable(bool on)
@ -61,29 +59,6 @@ void power_off(void)
{
}
#else
bool charger_inserted(void)
{
return false;
}
void charger_enable(bool on)
{
(void)on;
}
void power_off(void)
{
}
void ide_power_enable(bool on)
{
(void)on;
}
#endif /* SIMULATOR */
bool tuner_power(bool status)
{
(void)status;

View file

@ -18,7 +18,6 @@
* KIND, either express or implied.
*
****************************************************************************/
#include <stdbool.h>
#include "config.h"
#include "ascodec-target.h"
@ -40,14 +39,14 @@ void power_init(void)
}
#if CONFIG_CHARGING
bool charger_inserted(void)
unsigned int power_input_status(void)
{
if(ascodec_read(AS3514_IRQ_ENRD0) & (1<<5))
return true;
else
return false;
return (ascodec_read(AS3514_IRQ_ENRD0) & (1<<5)) ?
POWER_INPUT_MAIN_CHARGER : POWER_INPUT_NONE;
/* TODO: Handle USB and other sources properly */
}
#endif
#endif /* CONFIG_CHARGING */
void ide_power_enable(bool on)
{

View file

@ -27,8 +27,6 @@
#include "avic-imx31.h"
#include "mc13783.h"
#ifndef SIMULATOR
static bool charger_detect = false;
/* This is called from the mc13783 interrupt thread */
@ -38,9 +36,17 @@ void charger_detect_event(void)
mc13783_read(MC13783_INTERRUPT_SENSE0) & MC13783_CHGDETS;
}
bool charger_inserted(void)
unsigned int power_input_status(void)
{
return charger_detect;
unsigned int status = POWER_INPUT_NONE;
if ((GPIO3_DR & (1 << 20)) != 0)
status |= POWER_INPUT_BATTERY;
if (charger_detect)
status |= POWER_INPUT_MAIN_CHARGER;
return status;
}
/* Returns true if the unit is charging the batteries. */
@ -90,26 +96,3 @@ void power_init(void)
mc13783_enable_event(MC13783_CHGDET_EVENT);
}
#else /* SIMULATOR */
bool charger_inserted(void)
{
return false;
}
void charger_enable(bool on)
{
(void)on;
}
void power_off(void)
{
}
void ide_power_enable(bool on)
{
(void)on;
}
#endif /* SIMULATOR */

View file

@ -43,18 +43,28 @@ void power_init(void)
}
#if CONFIG_CHARGING
bool charger_inserted(void)
unsigned int power_input_status(void)
{
#if defined(IPOD_VIDEO)
return (GPIOL_INPUT_VAL & 0x08)?false:true;
unsigned int status = POWER_INPUT_NONE;
#if defined(IPOD_NANO) || defined(IPOD_VIDEO)
if ((GPIOL_INPUT_VAL & 0x08) == 0)
status = POWER_INPUT_MAIN_CHARGER;
if ((GPIOL_INPUT_VAL & 0x10) != 0)
status |= POWER_INPUT_USB_CHARGER;
/* */
#elif defined(IPOD_4G) || defined(IPOD_COLOR) \
|| defined(IPOD_MINI) || defined(IPOD_MINI2G)
/* C2 is firewire power */
return (GPIOC_INPUT_VAL & 0x04)?false:true;
if ((GPIOC_INPUT_VAL & 0x04) == 0)
status = POWER_INPUT_MAIN_CHARGER;
/* */
#else
/* This needs filling in for other ipods. */
return false;
#endif
return status;
}
/* Returns true if the unit is charging the batteries. */

View file

@ -52,9 +52,11 @@ void power_init(void)
{
}
bool charger_inserted(void)
unsigned int power_input_status(void)
{
return (GPIOF_INPUT_VAL & 0x08)?true:false;
/* No separate source for USB and charges from USB on its own */
return (GPIOF_INPUT_VAL & 0x08) ?
POWER_INPUT_MAIN_CHARGER : POWER_INPUT_NONE;
}
void ide_power_enable(bool on)

View file

@ -41,9 +41,10 @@ void power_init(void)
GPIOB_OUTPUT_EN |= 0x80;
}
bool charger_inserted(void)
{
return (GPIOL_INPUT_VAL & 0x24) ? true : false ;
unsigned int power_input_status(void)
{
return (GPIOL_INPUT_VAL & 0x24) ?
POWER_INPUT_MAIN_CHARGER : POWER_INPUT_NONE;
}
void ide_power_enable(bool on)

View file

@ -37,9 +37,9 @@ void power_init(void)
{
}
bool charger_inserted(void)
unsigned int power_input_status(void)
{
return false ;
return POWER_INPUT_NONE;
}
void ide_power_enable(bool on)

View file

@ -54,15 +54,9 @@ void power_off(void)
}
}
bool charger_inserted(void)
unsigned int power_input_status(void)
{
#ifdef SANSA_E200
if(GPIOB_INPUT_VAL & 0x10)
#else /* SANSA_C200 */
if(GPIOH_INPUT_VAL & 0x2)
#endif
return true;
return false;
return POWER_INPUT_NONE;
}
void ide_power_enable(bool on)

View file

@ -27,8 +27,7 @@
#include "pcf50606.h"
#include "backlight.h"
#include "backlight-target.h"
#ifndef SIMULATOR
#include "usb.h"
void power_init(void)
{
@ -39,13 +38,28 @@ void power_init(void)
/* Charger detect */
}
bool charger_inserted(void)
unsigned int power_input_status(void)
{
return (GPFDAT & (1 << 4)) ? false : true;
unsigned int status = POWER_INPUT_NONE;
/* Is the battery switch ON? */
if ((GPGDAT & (1 << 9)) == 0)
status |= POWER_INPUT_BATTERY;
/* Main or cradle power available? */
if ((GPFDAT & (1 << 4)) == 0)
status |= POWER_INPUT_MAIN_CHARGER;
/* Is the USB cable inserted? */
if (usb_detect() == USB_INSERTED)
status |= POWER_INPUT_USB_CHARGER;
return status;
}
/* Returns true if the unit is charging the batteries. */
bool charging_state(void) {
bool charging_state(void)
{
return (GPGDAT & (1 << 8)) ? false : true;
}
@ -87,27 +101,3 @@ void power_off(void)
reboot_point();
}
#else /* SIMULATOR */
bool charger_inserted(void)
{
return false;
}
void charger_enable(bool on)
{
(void)on;
}
void power_off(void)
{
}
void ide_power_enable(bool on)
{
(void)on;
}
#endif /* SIMULATOR */

View file

@ -26,6 +26,7 @@
#include "tuner.h"
#include "as3514.h"
#include "power.h"
#include "usb.h"
void power_init(void)
{
@ -53,15 +54,24 @@ void power_off(void)
}
}
bool charger_inserted(void)
unsigned int power_input_status(void)
{
#ifdef SANSA_E200
if(GPIOB_INPUT_VAL & 0x10)
#else /* SANSA_C200 */
if(GPIOH_INPUT_VAL & 0x2)
unsigned int status = POWER_INPUT_NONE;
#if defined(SANSA_E200)
#define _charger_present() (GPIOB_INPUT_VAL & 0x10)
#elif defined(SANSA_C200)
#define _charger_present() (GPIOH_INPUT_VAL & 0x2)
#else
#define _charger_present() 0
#endif
return true;
return false;
if (_charger_present())
status = POWER_INPUT_MAIN_CHARGER;
/* No separate source for USB */
return status;
}
void ide_power_enable(bool on)

View file

@ -41,9 +41,9 @@ void power_init(void)
{
}
bool charger_inserted(void)
{
return false;
unsigned int power_input_status(void)
{
return POWER_INPUT_NONE;
}
void ide_power_enable(bool on)

View file

@ -25,8 +25,6 @@
#include "system.h"
#include "power.h"
#ifndef SIMULATOR
void power_init(void)
{
}
@ -43,22 +41,3 @@ bool ide_powered(void)
void power_off(void)
{
}
#else /* SIMULATOR */
bool charger_inserted(void)
{
return false;
}
void charger_enable(bool on)
{
(void)on;
}
void ide_power_enable(bool on)
{
(void)on;
}
#endif /* SIMULATOR */

View file

@ -141,7 +141,8 @@ bool tuner_power(bool status)
#endif /* CONFIG_TUNER */
bool charger_inserted(void)
unsigned int power_input_status(void)
{
return (GPIOA & 0x1) ? true : false;
return (GPIOA & 0x1) ?
POWER_INPUT_MAIN_CHARGER : POWER_INPUT_NONE;
}

View file

@ -25,8 +25,6 @@
#include "system.h"
#include "power.h"
#ifndef SIMULATOR
void power_init(void)
{
}
@ -43,26 +41,3 @@ bool ide_powered(void)
void power_off(void)
{
}
#else /* SIMULATOR */
bool charger_inserted(void)
{
return false;
}
void charger_enable(bool on)
{
(void)on;
}
void power_off(void)
{
}
void ide_power_enable(bool on)
{
(void)on;
}
#endif /* SIMULATOR */

View file

@ -25,8 +25,6 @@
#include "system.h"
#include "power.h"
#ifndef SIMULATOR
void power_init(void)
{
}
@ -43,26 +41,3 @@ bool ide_powered(void)
void power_off(void)
{
}
#else /* SIMULATOR */
bool charger_inserted(void)
{
return false;
}
void charger_enable(bool on)
{
(void)on;
}
void power_off(void)
{
}
void ide_power_enable(bool on)
{
(void)on;
}
#endif /* SIMULATOR */

View file

@ -26,8 +26,6 @@
#include "button-target.h"
#include "tuner.h"
#ifndef SIMULATOR
void power_init(void)
{
unsigned char data[3]; /* 0 = INT1, 1 = INT2, 2 = INT3 */
@ -93,9 +91,10 @@ void EXT3(void)
#endif
#if CONFIG_CHARGING
bool charger_inserted(void)
unsigned int power_input_status(void)
{
return (GPIOC & (1<<26)) ? false:true;
return ((GPIOC & (1<<26)) == 0) ?
POWER_INPUT_MAIN_CHARGER : POWER_INPUT_NONE;
}
#endif
@ -147,26 +146,3 @@ bool tuner_power(bool status)
}
#endif /* CONFIG_TUNER */
#else /* SIMULATOR */
bool charger_inserted(void)
{
return false;
}
void charger_enable(bool on)
{
(void)on;
}
void power_off(void)
{
}
void ide_power_enable(bool on)
{
(void)on;
}
#endif /* SIMULATOR */

View file

@ -28,8 +28,6 @@
#include "backlight.h"
#include "backlight-target.h"
#ifndef SIMULATOR
void power_init(void)
{
/* Initialize IDE power pin */
@ -37,34 +35,17 @@ void power_init(void)
/* Charger detect */
}
bool charger_inserted(void)
unsigned int power_input_status(void)
{
return false;
return POWER_INPUT_NONE;
}
/* Returns true if the unit is charging the batteries. */
bool charging_state(void) {
bool charging_state(void)
{
return false;
}
void power_off(void)
{
}
#else /* SIMULATOR */
bool charger_inserted(void)
{
return false;
}
void charger_enable(bool on)
{
(void)on;
}
void power_off(void)
{
}
#endif /* SIMULATOR */

View file

@ -29,8 +29,6 @@
#include "backlight.h"
#include "backlight-target.h"
#ifndef SIMULATOR
void power_init(void)
{
/* Initialize IDE power pin */
@ -40,9 +38,9 @@ void power_init(void)
/* Charger detect */
}
bool charger_inserted(void)
unsigned int power_input_status(void)
{
return false;
return POWER_INPUT_NONE;
}
/* Returns true if the unit is charging the batteries. */
@ -71,27 +69,3 @@ void power_off(void)
/* Hard shutdown */
IO_GIO_BITSET1|=1<<10;
}
#else /* SIMULATOR */
bool charger_inserted(void)
{
return false;
}
void charger_enable(bool on)
{
(void)on;
}
void power_off(void)
{
}
void ide_power_enable(bool on)
{
(void)on;
}
#endif /* SIMULATOR */