mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-14 02:27:39 -04:00
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:
parent
0d0cc039f8
commit
58eb784a5d
41 changed files with 284 additions and 403 deletions
|
@ -8321,7 +8321,7 @@
|
||||||
</phrase>
|
</phrase>
|
||||||
<phrase>
|
<phrase>
|
||||||
id: LANG_USB_CHARGING
|
id: LANG_USB_CHARGING
|
||||||
desc: in Battery menu
|
desc: in Battery menu, TODO: cleanup unless HAVE_USB_CHARGING_ENABLE defined
|
||||||
user:
|
user:
|
||||||
<source>
|
<source>
|
||||||
*: none
|
*: none
|
||||||
|
|
|
@ -144,8 +144,7 @@ MENUITEM_SETTING(battery_capacity, &global_settings.battery_capacity, NULL);
|
||||||
#if BATTERY_TYPES_COUNT > 1
|
#if BATTERY_TYPES_COUNT > 1
|
||||||
MENUITEM_SETTING(battery_type, &global_settings.battery_type, NULL);
|
MENUITEM_SETTING(battery_type, &global_settings.battery_type, NULL);
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_USB_POWER
|
#ifdef HAVE_USB_CHARGING_ENABLE
|
||||||
#if CONFIG_CHARGING
|
|
||||||
static int usbcharging_callback(int action,const struct menu_item_ex *this_item)
|
static int usbcharging_callback(int action,const struct menu_item_ex *this_item)
|
||||||
{
|
{
|
||||||
(void)this_item;
|
(void)this_item;
|
||||||
|
@ -158,8 +157,7 @@ static int usbcharging_callback(int action,const struct menu_item_ex *this_item)
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
MENUITEM_SETTING(usb_charging, &global_settings.usb_charging, usbcharging_callback);
|
MENUITEM_SETTING(usb_charging, &global_settings.usb_charging, usbcharging_callback);
|
||||||
#endif
|
#endif /* HAVE_USB_CHARGING_ENABLE */
|
||||||
#endif
|
|
||||||
MAKE_MENU(battery_menu, ID2P(LANG_BATTERY_MENU), 0, Icon_NOICON,
|
MAKE_MENU(battery_menu, ID2P(LANG_BATTERY_MENU), 0, Icon_NOICON,
|
||||||
#if BATTERY_CAPACITY_INC > 0
|
#if BATTERY_CAPACITY_INC > 0
|
||||||
&battery_capacity,
|
&battery_capacity,
|
||||||
|
@ -167,10 +165,8 @@ MAKE_MENU(battery_menu, ID2P(LANG_BATTERY_MENU), 0, Icon_NOICON,
|
||||||
#if BATTERY_TYPES_COUNT > 1
|
#if BATTERY_TYPES_COUNT > 1
|
||||||
&battery_type,
|
&battery_type,
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_USB_POWER
|
#ifdef HAVE_USB_CHARGING_ENABLE
|
||||||
#if CONFIG_CHARGING
|
|
||||||
&usb_charging,
|
&usb_charging,
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
/* Disk */
|
/* Disk */
|
||||||
|
|
|
@ -131,12 +131,12 @@ void* plugin_get_buffer(size_t *buffer_size);
|
||||||
#define PLUGIN_MAGIC 0x526F634B /* RocK */
|
#define PLUGIN_MAGIC 0x526F634B /* RocK */
|
||||||
|
|
||||||
/* increase this every time the api struct changes */
|
/* increase this every time the api struct changes */
|
||||||
#define PLUGIN_API_VERSION 126
|
#define PLUGIN_API_VERSION 127
|
||||||
|
|
||||||
/* update this to latest version if a change to the api struct breaks
|
/* update this to latest version if a change to the api struct breaks
|
||||||
backwards compatibility (and please take the opportunity to sort in any
|
backwards compatibility (and please take the opportunity to sort in any
|
||||||
new function which are "waiting" at the end of the function table) */
|
new function which are "waiting" at the end of the function table) */
|
||||||
#define PLUGIN_MIN_API_VERSION 125
|
#define PLUGIN_MIN_API_VERSION 127
|
||||||
|
|
||||||
/* plugin return codes */
|
/* plugin return codes */
|
||||||
enum plugin_status {
|
enum plugin_status {
|
||||||
|
|
|
@ -906,11 +906,7 @@ bool view_runtime(void)
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
#if CONFIG_CHARGING
|
#if CONFIG_CHARGING
|
||||||
if (charger_inserted()
|
if (charger_inserted())
|
||||||
#ifdef HAVE_USB_POWER
|
|
||||||
|| usb_powered()
|
|
||||||
#endif
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
global_status.runtime = 0;
|
global_status.runtime = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -717,11 +717,9 @@ void sound_settings_apply(void)
|
||||||
sound_set(SOUND_TREBLE_CUTOFF, global_settings.treble_cutoff);
|
sound_set(SOUND_TREBLE_CUTOFF, global_settings.treble_cutoff);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_USB_POWER
|
#ifdef HAVE_USB_CHARGING_ENABLE
|
||||||
#if CONFIG_CHARGING
|
|
||||||
usb_charging_enable(global_settings.usb_charging);
|
usb_charging_enable(global_settings.usb_charging);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void settings_apply(bool read_disk)
|
void settings_apply(bool read_disk)
|
||||||
|
|
|
@ -684,10 +684,8 @@ struct user_settings
|
||||||
unsigned char kbd_file[MAX_FILENAME+1]; /* last keyboard */
|
unsigned char kbd_file[MAX_FILENAME+1]; /* last keyboard */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_USB_POWER
|
#ifdef HAVE_USB_CHARGING_ENABLE
|
||||||
#if CONFIG_CHARGING
|
|
||||||
bool usb_charging;
|
bool usb_charging;
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool hold_lr_for_scroll_in_list; /* hold L/R scrolls the list left/right */
|
bool hold_lr_for_scroll_in_list; /* hold L/R scrolls the list left/right */
|
||||||
|
|
|
@ -1310,10 +1310,8 @@ const struct settings_list settings[] = {
|
||||||
#ifdef HAVE_LCD_BITMAP
|
#ifdef HAVE_LCD_BITMAP
|
||||||
TEXT_SETTING(0,kbd_file,"kbd","",ROCKBOX_DIR "/",".kbd"),
|
TEXT_SETTING(0,kbd_file,"kbd","",ROCKBOX_DIR "/",".kbd"),
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_USB_POWER
|
#ifdef HAVE_USB_CHARGING_ENABLE
|
||||||
#if CONFIG_CHARGING
|
|
||||||
OFFON_SETTING(0,usb_charging,LANG_USB_CHARGING,false,"usb charging",NULL),
|
OFFON_SETTING(0,usb_charging,LANG_USB_CHARGING,false,"usb charging",NULL),
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
OFFON_SETTING(F_BANFROMQS,cuesheet,LANG_CUESHEET_ENABLE,false,"cuesheet support",
|
OFFON_SETTING(F_BANFROMQS,cuesheet,LANG_CUESHEET_ENABLE,false,"cuesheet support",
|
||||||
NULL),
|
NULL),
|
||||||
|
|
|
@ -488,11 +488,7 @@ static void backlight_update_state(void)
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
#if CONFIG_CHARGING
|
#if CONFIG_CHARGING
|
||||||
if (charger_inserted()
|
if (power_input_present())
|
||||||
#ifdef HAVE_USB_POWER
|
|
||||||
|| usb_powered()
|
|
||||||
#endif
|
|
||||||
)
|
|
||||||
backlight_timeout = backlight_timeout_plugged;
|
backlight_timeout = backlight_timeout_plugged;
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
|
@ -532,11 +528,7 @@ static void remote_backlight_update_state(void)
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
#if CONFIG_CHARGING
|
#if CONFIG_CHARGING
|
||||||
if (charger_inserted()
|
if (power_input_present())
|
||||||
#ifdef HAVE_USB_POWER
|
|
||||||
|| usb_powered()
|
|
||||||
#endif
|
|
||||||
)
|
|
||||||
remote_backlight_timeout = remote_backlight_timeout_plugged;
|
remote_backlight_timeout = remote_backlight_timeout_plugged;
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -134,6 +134,11 @@
|
||||||
|
|
||||||
/* define this if the unit can be powered or charged via USB */
|
/* define this if the unit can be powered or charged via USB */
|
||||||
//#define HAVE_USB_POWER /* Disable for now */
|
//#define HAVE_USB_POWER /* Disable for now */
|
||||||
|
//#define HAVE_USB_CHARGING_ENABLE
|
||||||
|
|
||||||
|
/* define this if the unit has a battery switch or battery can be removed
|
||||||
|
* when running */
|
||||||
|
#define HAVE_BATTERY_SWITCH
|
||||||
|
|
||||||
/* USB On-the-go */
|
/* USB On-the-go */
|
||||||
#define CONFIG_USBOTG USBOTG_ARC
|
#define CONFIG_USBOTG USBOTG_ARC
|
||||||
|
|
|
@ -114,6 +114,10 @@
|
||||||
/* define this if the unit can be powered or charged via USB */
|
/* define this if the unit can be powered or charged via USB */
|
||||||
#define HAVE_USB_POWER
|
#define HAVE_USB_POWER
|
||||||
|
|
||||||
|
/* define this if the unit has a battery switch or battery can be removed
|
||||||
|
* when running */
|
||||||
|
#define HAVE_BATTERY_SWITCH
|
||||||
|
|
||||||
#ifndef SIMULATOR
|
#ifndef SIMULATOR
|
||||||
|
|
||||||
/* The LCD on a Gigabeat is 240x320 - it is portrait */
|
/* The LCD on a Gigabeat is 240x320 - it is portrait */
|
||||||
|
|
|
@ -112,6 +112,10 @@
|
||||||
/* define this if the unit can be powered or charged via USB */
|
/* define this if the unit can be powered or charged via USB */
|
||||||
#define HAVE_USB_POWER
|
#define HAVE_USB_POWER
|
||||||
|
|
||||||
|
/* define this if the unit can have USB charging disabled by user -
|
||||||
|
* if USB/MAIN power is discernable and hardware doesn't compel charging */
|
||||||
|
#define HAVE_USB_CHARGING_ENABLE
|
||||||
|
|
||||||
#ifndef SIMULATOR
|
#ifndef SIMULATOR
|
||||||
|
|
||||||
/* define this if the backlight thread is used for fade, not for sim, needs
|
/* define this if the backlight thread is used for fade, not for sim, needs
|
||||||
|
|
|
@ -27,8 +27,57 @@ void charger_enable(bool on);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if CONFIG_CHARGING
|
#if CONFIG_CHARGING
|
||||||
bool charger_inserted(void);
|
enum power_input_flags {
|
||||||
|
/* No external power source? Default. */
|
||||||
|
POWER_INPUT_NONE = 0x00,
|
||||||
|
|
||||||
|
/* Main power source is available (AC?), the default other than
|
||||||
|
* battery if for instance USB and others cannot be distinguished or
|
||||||
|
* USB is the only possibility. */
|
||||||
|
POWER_INPUT_MAIN = 0x01,
|
||||||
|
|
||||||
|
/* USB power source is available (and is discernable from MAIN). */
|
||||||
|
POWER_INPUT_USB = 0x02,
|
||||||
|
|
||||||
|
/* Something is plugged. */
|
||||||
|
POWER_INPUT = 0x0f,
|
||||||
|
|
||||||
|
/* POWER_INPUT_*_CHARGER of course implies presence of the respective
|
||||||
|
* power source. */
|
||||||
|
|
||||||
|
/* Battery not included in CHARGER (it can't charge itself) */
|
||||||
|
|
||||||
|
/* Charging is possible on main. */
|
||||||
|
POWER_INPUT_MAIN_CHARGER = 0x10 | POWER_INPUT_MAIN,
|
||||||
|
|
||||||
|
/* Charging is possible on USB. */
|
||||||
|
POWER_INPUT_USB_CHARGER = 0x20 | POWER_INPUT_USB,
|
||||||
|
|
||||||
|
/* Charging is possible from something. */
|
||||||
|
POWER_INPUT_CHARGER = 0xf0,
|
||||||
|
|
||||||
|
#ifdef HAVE_BATTERY_SWITCH
|
||||||
|
/* Battery is powering device or is available to power device. It
|
||||||
|
* could also be used if the battery is hot-swappable to indicate if
|
||||||
|
* it is present ("switch" as verb vs. noun). */
|
||||||
|
POWER_INPUT_BATTERY = 0x100,
|
||||||
#endif
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Returns detailed power input status information from device. */
|
||||||
|
unsigned int power_input_status(void);
|
||||||
|
|
||||||
|
/* Shortcuts */
|
||||||
|
/* Returns true if any power source that is connected is capable of
|
||||||
|
* charging the batteries.
|
||||||
|
* > (power_input_status() & POWER_INPUT_CHARGER) != 0 */
|
||||||
|
bool charger_inserted(void);
|
||||||
|
|
||||||
|
/* Returns true if any power input is connected - charging-capable
|
||||||
|
* or not.
|
||||||
|
* > (power_input_status() & POWER_INPUT) != 0 */
|
||||||
|
bool power_input_present(void);
|
||||||
|
#endif /* CONFIG_CHARGING */
|
||||||
|
|
||||||
void power_off(void);
|
void power_off(void);
|
||||||
void ide_power_enable(bool on);
|
void ide_power_enable(bool on);
|
||||||
|
|
|
@ -935,6 +935,23 @@ static inline void charging_algorithm_close(void)
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_CHARGING == CHARGING_CONTROL */
|
#endif /* CONFIG_CHARGING == CHARGING_CONTROL */
|
||||||
|
|
||||||
|
#if CONFIG_CHARGING
|
||||||
|
/* Shortcut function calls - compatibility, simplicity. */
|
||||||
|
|
||||||
|
/* Returns true if any power input is capable of charging. */
|
||||||
|
bool charger_inserted(void)
|
||||||
|
{
|
||||||
|
return power_input_status() & POWER_INPUT_CHARGER;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Returns true if any power input is connected - charging-capable
|
||||||
|
* or not. */
|
||||||
|
bool power_input_present(void)
|
||||||
|
{
|
||||||
|
return power_input_status() & POWER_INPUT;
|
||||||
|
}
|
||||||
|
#endif /* CONFIG_CHARGING */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This function is called to do the relativly long sleep waits from within the
|
* This function is called to do the relativly long sleep waits from within the
|
||||||
* main power_thread loop while at the same time servicing any other periodic
|
* main power_thread loop while at the same time servicing any other periodic
|
||||||
|
@ -957,12 +974,7 @@ static void power_thread_sleep(int ticks)
|
||||||
* loop (including the subroutines), and end up back here where we
|
* loop (including the subroutines), and end up back here where we
|
||||||
* transition to the appropriate steady state charger on/off state.
|
* transition to the appropriate steady state charger on/off state.
|
||||||
*/
|
*/
|
||||||
if(charger_inserted()
|
if(power_input_status() & POWER_INPUT_CHARGER) {
|
||||||
#ifdef HAVE_USB_POWER /* USB powered or USB inserted both provide power */
|
|
||||||
|| usb_powered()
|
|
||||||
|| (usb_inserted() && usb_charging_enabled())
|
|
||||||
#endif
|
|
||||||
) {
|
|
||||||
switch(charger_input_state) {
|
switch(charger_input_state) {
|
||||||
case NO_CHARGER:
|
case NO_CHARGER:
|
||||||
case CHARGER_UNPLUGGED:
|
case CHARGER_UNPLUGGED:
|
||||||
|
|
|
@ -32,16 +32,14 @@
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
#include "power.h"
|
#include "power.h"
|
||||||
|
|
||||||
#ifndef SIMULATOR
|
|
||||||
|
|
||||||
void power_init(void)
|
void power_init(void)
|
||||||
{
|
{
|
||||||
/* Charger detect */
|
/* Charger detect */
|
||||||
}
|
}
|
||||||
|
|
||||||
bool charger_inserted(void)
|
unsigned int power_input_status(void)
|
||||||
{
|
{
|
||||||
return false;
|
return POWER_INPUT_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ide_power_enable(bool on)
|
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)
|
bool tuner_power(bool status)
|
||||||
{
|
{
|
||||||
(void)status;
|
(void)status;
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
* KIND, either express or implied.
|
* KIND, either express or implied.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "ascodec-target.h"
|
#include "ascodec-target.h"
|
||||||
|
@ -40,14 +39,14 @@ void power_init(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
#if CONFIG_CHARGING
|
#if CONFIG_CHARGING
|
||||||
bool charger_inserted(void)
|
unsigned int power_input_status(void)
|
||||||
{
|
{
|
||||||
if(ascodec_read(AS3514_IRQ_ENRD0) & (1<<5))
|
return (ascodec_read(AS3514_IRQ_ENRD0) & (1<<5)) ?
|
||||||
return true;
|
POWER_INPUT_MAIN_CHARGER : POWER_INPUT_NONE;
|
||||||
else
|
|
||||||
return false;
|
/* TODO: Handle USB and other sources properly */
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* CONFIG_CHARGING */
|
||||||
|
|
||||||
void ide_power_enable(bool on)
|
void ide_power_enable(bool on)
|
||||||
{
|
{
|
||||||
|
|
|
@ -27,8 +27,6 @@
|
||||||
#include "avic-imx31.h"
|
#include "avic-imx31.h"
|
||||||
#include "mc13783.h"
|
#include "mc13783.h"
|
||||||
|
|
||||||
#ifndef SIMULATOR
|
|
||||||
|
|
||||||
static bool charger_detect = false;
|
static bool charger_detect = false;
|
||||||
|
|
||||||
/* This is called from the mc13783 interrupt thread */
|
/* This is called from the mc13783 interrupt thread */
|
||||||
|
@ -38,9 +36,17 @@ void charger_detect_event(void)
|
||||||
mc13783_read(MC13783_INTERRUPT_SENSE0) & MC13783_CHGDETS;
|
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. */
|
/* Returns true if the unit is charging the batteries. */
|
||||||
|
@ -90,26 +96,3 @@ void power_init(void)
|
||||||
mc13783_enable_event(MC13783_CHGDET_EVENT);
|
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 */
|
|
||||||
|
|
||||||
|
|
|
@ -43,18 +43,28 @@ void power_init(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
#if CONFIG_CHARGING
|
#if CONFIG_CHARGING
|
||||||
bool charger_inserted(void)
|
unsigned int power_input_status(void)
|
||||||
{
|
{
|
||||||
#if defined(IPOD_VIDEO)
|
unsigned int status = POWER_INPUT_NONE;
|
||||||
return (GPIOL_INPUT_VAL & 0x08)?false:true;
|
|
||||||
|
#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) \
|
#elif defined(IPOD_4G) || defined(IPOD_COLOR) \
|
||||||
|| defined(IPOD_MINI) || defined(IPOD_MINI2G)
|
|| defined(IPOD_MINI) || defined(IPOD_MINI2G)
|
||||||
/* C2 is firewire power */
|
/* C2 is firewire power */
|
||||||
return (GPIOC_INPUT_VAL & 0x04)?false:true;
|
if ((GPIOC_INPUT_VAL & 0x04) == 0)
|
||||||
|
status = POWER_INPUT_MAIN_CHARGER;
|
||||||
|
/* */
|
||||||
#else
|
#else
|
||||||
/* This needs filling in for other ipods. */
|
/* This needs filling in for other ipods. */
|
||||||
return false;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Returns true if the unit is charging the batteries. */
|
/* Returns true if the unit is charging the batteries. */
|
||||||
|
|
|
@ -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)
|
void ide_power_enable(bool on)
|
||||||
|
|
|
@ -41,9 +41,10 @@ void power_init(void)
|
||||||
GPIOB_OUTPUT_EN |= 0x80;
|
GPIOB_OUTPUT_EN |= 0x80;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool charger_inserted(void)
|
unsigned int power_input_status(void)
|
||||||
{
|
{
|
||||||
return (GPIOL_INPUT_VAL & 0x24) ? true : false ;
|
return (GPIOL_INPUT_VAL & 0x24) ?
|
||||||
|
POWER_INPUT_MAIN_CHARGER : POWER_INPUT_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ide_power_enable(bool on)
|
void ide_power_enable(bool on)
|
||||||
|
|
|
@ -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)
|
void ide_power_enable(bool on)
|
||||||
|
|
|
@ -54,15 +54,9 @@ void power_off(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool charger_inserted(void)
|
unsigned int power_input_status(void)
|
||||||
{
|
{
|
||||||
#ifdef SANSA_E200
|
return POWER_INPUT_NONE;
|
||||||
if(GPIOB_INPUT_VAL & 0x10)
|
|
||||||
#else /* SANSA_C200 */
|
|
||||||
if(GPIOH_INPUT_VAL & 0x2)
|
|
||||||
#endif
|
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ide_power_enable(bool on)
|
void ide_power_enable(bool on)
|
||||||
|
|
|
@ -27,8 +27,7 @@
|
||||||
#include "pcf50606.h"
|
#include "pcf50606.h"
|
||||||
#include "backlight.h"
|
#include "backlight.h"
|
||||||
#include "backlight-target.h"
|
#include "backlight-target.h"
|
||||||
|
#include "usb.h"
|
||||||
#ifndef SIMULATOR
|
|
||||||
|
|
||||||
void power_init(void)
|
void power_init(void)
|
||||||
{
|
{
|
||||||
|
@ -39,13 +38,28 @@ void power_init(void)
|
||||||
/* Charger detect */
|
/* 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. */
|
/* Returns true if the unit is charging the batteries. */
|
||||||
bool charging_state(void) {
|
bool charging_state(void)
|
||||||
|
{
|
||||||
return (GPGDAT & (1 << 8)) ? false : true;
|
return (GPGDAT & (1 << 8)) ? false : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,27 +101,3 @@ void power_off(void)
|
||||||
|
|
||||||
reboot_point();
|
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 */
|
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include "tuner.h"
|
#include "tuner.h"
|
||||||
#include "as3514.h"
|
#include "as3514.h"
|
||||||
#include "power.h"
|
#include "power.h"
|
||||||
|
#include "usb.h"
|
||||||
|
|
||||||
void power_init(void)
|
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
|
unsigned int status = POWER_INPUT_NONE;
|
||||||
if(GPIOB_INPUT_VAL & 0x10)
|
|
||||||
#else /* SANSA_C200 */
|
#if defined(SANSA_E200)
|
||||||
if(GPIOH_INPUT_VAL & 0x2)
|
#define _charger_present() (GPIOB_INPUT_VAL & 0x10)
|
||||||
|
#elif defined(SANSA_C200)
|
||||||
|
#define _charger_present() (GPIOH_INPUT_VAL & 0x2)
|
||||||
|
#else
|
||||||
|
#define _charger_present() 0
|
||||||
#endif
|
#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)
|
void ide_power_enable(bool on)
|
||||||
|
|
|
@ -41,9 +41,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)
|
void ide_power_enable(bool on)
|
||||||
|
|
|
@ -25,8 +25,6 @@
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
#include "power.h"
|
#include "power.h"
|
||||||
|
|
||||||
#ifndef SIMULATOR
|
|
||||||
|
|
||||||
void power_init(void)
|
void power_init(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -43,22 +41,3 @@ bool ide_powered(void)
|
||||||
void power_off(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 */
|
|
||||||
|
|
|
@ -141,7 +141,8 @@ bool tuner_power(bool status)
|
||||||
|
|
||||||
#endif /* CONFIG_TUNER */
|
#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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,8 +25,6 @@
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
#include "power.h"
|
#include "power.h"
|
||||||
|
|
||||||
#ifndef SIMULATOR
|
|
||||||
|
|
||||||
void power_init(void)
|
void power_init(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -43,26 +41,3 @@ bool ide_powered(void)
|
||||||
void power_off(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 */
|
|
||||||
|
|
|
@ -25,8 +25,6 @@
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
#include "power.h"
|
#include "power.h"
|
||||||
|
|
||||||
#ifndef SIMULATOR
|
|
||||||
|
|
||||||
void power_init(void)
|
void power_init(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -43,26 +41,3 @@ bool ide_powered(void)
|
||||||
void power_off(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 */
|
|
||||||
|
|
|
@ -26,8 +26,6 @@
|
||||||
#include "button-target.h"
|
#include "button-target.h"
|
||||||
#include "tuner.h"
|
#include "tuner.h"
|
||||||
|
|
||||||
#ifndef SIMULATOR
|
|
||||||
|
|
||||||
void power_init(void)
|
void power_init(void)
|
||||||
{
|
{
|
||||||
unsigned char data[3]; /* 0 = INT1, 1 = INT2, 2 = INT3 */
|
unsigned char data[3]; /* 0 = INT1, 1 = INT2, 2 = INT3 */
|
||||||
|
@ -93,9 +91,10 @@ void EXT3(void)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if CONFIG_CHARGING
|
#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
|
#endif
|
||||||
|
|
||||||
|
@ -147,26 +146,3 @@ bool tuner_power(bool status)
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* CONFIG_TUNER */
|
#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 */
|
|
||||||
|
|
|
@ -28,8 +28,6 @@
|
||||||
#include "backlight.h"
|
#include "backlight.h"
|
||||||
#include "backlight-target.h"
|
#include "backlight-target.h"
|
||||||
|
|
||||||
#ifndef SIMULATOR
|
|
||||||
|
|
||||||
void power_init(void)
|
void power_init(void)
|
||||||
{
|
{
|
||||||
/* Initialize IDE power pin */
|
/* Initialize IDE power pin */
|
||||||
|
@ -37,34 +35,17 @@ void power_init(void)
|
||||||
/* Charger detect */
|
/* 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. */
|
/* Returns true if the unit is charging the batteries. */
|
||||||
bool charging_state(void) {
|
bool charging_state(void)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void power_off(void)
|
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 */
|
|
||||||
|
|
|
@ -29,8 +29,6 @@
|
||||||
#include "backlight.h"
|
#include "backlight.h"
|
||||||
#include "backlight-target.h"
|
#include "backlight-target.h"
|
||||||
|
|
||||||
#ifndef SIMULATOR
|
|
||||||
|
|
||||||
void power_init(void)
|
void power_init(void)
|
||||||
{
|
{
|
||||||
/* Initialize IDE power pin */
|
/* Initialize IDE power pin */
|
||||||
|
@ -40,9 +38,9 @@ void power_init(void)
|
||||||
/* Charger detect */
|
/* 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. */
|
/* Returns true if the unit is charging the batteries. */
|
||||||
|
@ -71,27 +69,3 @@ void power_off(void)
|
||||||
/* Hard shutdown */
|
/* Hard shutdown */
|
||||||
IO_GIO_BITSET1|=1<<10;
|
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 */
|
|
||||||
|
|
||||||
|
|
|
@ -27,8 +27,6 @@
|
||||||
#include "power.h"
|
#include "power.h"
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
|
|
||||||
#ifndef SIMULATOR
|
|
||||||
|
|
||||||
void power_init(void)
|
void power_init(void)
|
||||||
{
|
{
|
||||||
/* Set KEEPACT */
|
/* Set KEEPACT */
|
||||||
|
@ -47,9 +45,10 @@ void power_init(void)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool charger_inserted(void)
|
unsigned int power_input_status(void)
|
||||||
{
|
{
|
||||||
return (GPIO1_READ & 0x00000020) == 0;
|
return ((GPIO1_READ & 0x00000020) == 0) ?
|
||||||
|
POWER_INPUT_MAIN_CHARGER : POWER_INPUT_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ide_power_enable(bool on)
|
void ide_power_enable(bool on)
|
||||||
|
@ -77,8 +76,6 @@ void power_off(void)
|
||||||
asm("halt");
|
asm("halt");
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* SIMULATOR */
|
|
||||||
|
|
||||||
bool tuner_power(bool status)
|
bool tuner_power(bool status)
|
||||||
{
|
{
|
||||||
(void)status;
|
(void)status;
|
||||||
|
|
|
@ -27,8 +27,6 @@
|
||||||
#include "pcf50606.h"
|
#include "pcf50606.h"
|
||||||
#include "lcd-remote-target.h"
|
#include "lcd-remote-target.h"
|
||||||
|
|
||||||
#ifndef SIMULATOR
|
|
||||||
|
|
||||||
void power_init(void)
|
void power_init(void)
|
||||||
{
|
{
|
||||||
/* Charger detect */
|
/* Charger detect */
|
||||||
|
@ -38,9 +36,10 @@ void power_init(void)
|
||||||
pcf50606_init();
|
pcf50606_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool charger_inserted(void)
|
unsigned int power_input_status(void)
|
||||||
{
|
{
|
||||||
return (GPIO1_READ & 0x01000000) != 0;
|
return (GPIO1_READ & 0x01000000) ?
|
||||||
|
POWER_INPUT_MAIN_CHARGER : POWER_INPUT_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ide_power_enable(bool on)
|
void ide_power_enable(bool on)
|
||||||
|
@ -66,5 +65,3 @@ void power_off(void)
|
||||||
and_l(~0x00000008, &GPIO_OUT); /* Set KEEPACT low */
|
and_l(~0x00000008, &GPIO_OUT); /* Set KEEPACT low */
|
||||||
asm("halt");
|
asm("halt");
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* SIMULATOR */
|
|
||||||
|
|
|
@ -27,8 +27,6 @@
|
||||||
#include "pcf50606.h"
|
#include "pcf50606.h"
|
||||||
#include "lcd-remote-target.h"
|
#include "lcd-remote-target.h"
|
||||||
|
|
||||||
#ifndef SIMULATOR
|
|
||||||
|
|
||||||
void power_init(void)
|
void power_init(void)
|
||||||
{
|
{
|
||||||
/* Charger detect */
|
/* Charger detect */
|
||||||
|
@ -38,9 +36,10 @@ void power_init(void)
|
||||||
pcf50606_init();
|
pcf50606_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool charger_inserted(void)
|
unsigned int power_input_status(void)
|
||||||
{
|
{
|
||||||
return (GPIO1_READ & 0x01000000) != 0;
|
return (GPIO1_READ & 0x01000000) ?
|
||||||
|
POWER_INPUT_MAIN_CHARGER : POWER_INPUT_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ide_power_enable(bool on)
|
void ide_power_enable(bool on)
|
||||||
|
@ -67,8 +66,6 @@ void power_off(void)
|
||||||
asm("halt");
|
asm("halt");
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* SIMULATOR */
|
|
||||||
|
|
||||||
bool tuner_power(bool status)
|
bool tuner_power(bool status)
|
||||||
{
|
{
|
||||||
(void)status;
|
(void)status;
|
||||||
|
|
|
@ -26,19 +26,14 @@
|
||||||
#include "power.h"
|
#include "power.h"
|
||||||
#include "spdif.h"
|
#include "spdif.h"
|
||||||
|
|
||||||
|
|
||||||
#if CONFIG_TUNER
|
#if CONFIG_TUNER
|
||||||
|
|
||||||
bool tuner_power(bool status)
|
bool tuner_power(bool status)
|
||||||
{
|
{
|
||||||
(void)status;
|
(void)status;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* #if CONFIG_TUNER */
|
#endif /* #if CONFIG_TUNER */
|
||||||
|
|
||||||
#ifndef SIMULATOR
|
|
||||||
|
|
||||||
void power_init(void)
|
void power_init(void)
|
||||||
{
|
{
|
||||||
or_l(0x00080000, &GPIO1_OUT);
|
or_l(0x00080000, &GPIO1_OUT);
|
||||||
|
@ -56,14 +51,16 @@ void power_init(void)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned int power_input_status(void)
|
||||||
bool charger_inserted(void)
|
{
|
||||||
{
|
return (GPIO1_READ & 0x00400000) ?
|
||||||
return (GPIO1_READ & 0x00400000)?true:false;
|
POWER_INPUT_MAIN_CHARGER : POWER_INPUT_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Returns true if the unit is charging the batteries. */
|
/* Returns true if the unit is charging the batteries. */
|
||||||
bool charging_state(void) {
|
bool charging_state(void)
|
||||||
return charger_inserted();
|
{
|
||||||
|
return (power_input_status() & POWER_INPUT_CHARGER) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_SPDIF_POWER
|
#ifdef HAVE_SPDIF_POWER
|
||||||
|
@ -119,5 +116,3 @@ void power_off(void)
|
||||||
asm("halt");
|
asm("halt");
|
||||||
while(1);
|
while(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* SIMULATOR */
|
|
||||||
|
|
|
@ -25,20 +25,18 @@
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
#include "power.h"
|
#include "power.h"
|
||||||
#include "pcf50606.h"
|
#include "pcf50606.h"
|
||||||
|
#include "usb.h"
|
||||||
|
#include "logf.h"
|
||||||
|
|
||||||
|
|
||||||
#if CONFIG_TUNER
|
#if CONFIG_TUNER
|
||||||
|
|
||||||
bool tuner_power(bool status)
|
bool tuner_power(bool status)
|
||||||
{
|
{
|
||||||
(void)status;
|
(void)status;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* #if CONFIG_TUNER */
|
#endif /* #if CONFIG_TUNER */
|
||||||
|
|
||||||
#ifndef SIMULATOR
|
|
||||||
|
|
||||||
void power_init(void)
|
void power_init(void)
|
||||||
{
|
{
|
||||||
or_l(0x00080000, &GPIO1_OUT);
|
or_l(0x00080000, &GPIO1_OUT);
|
||||||
|
@ -56,17 +54,54 @@ void power_init(void)
|
||||||
|
|
||||||
|
|
||||||
#if CONFIG_CHARGING
|
#if CONFIG_CHARGING
|
||||||
bool charger_inserted(void)
|
unsigned int power_input_status(void)
|
||||||
{
|
{
|
||||||
return (GPIO1_READ & 0x00400000)?true:false;
|
unsigned int status = POWER_INPUT_NONE;
|
||||||
|
|
||||||
|
if (GPIO1_READ & 0x00400000)
|
||||||
|
status |= POWER_INPUT_MAIN_CHARGER;
|
||||||
|
|
||||||
|
#ifdef HAVE_USB_POWER
|
||||||
|
if (usb_detect() == USB_INSERTED && pcf50606_usb_charging_enabled())
|
||||||
|
status |= POWER_INPUT_USB_CHARGER;
|
||||||
|
/* CHECK: Can the device be powered from USB w/o charging it? */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_USB_POWER
|
||||||
|
bool usb_charging_enable(bool on)
|
||||||
|
{
|
||||||
|
bool rc = false;
|
||||||
|
int irqlevel;
|
||||||
|
logf("usb_charging_enable(%s)\n", on ? "on" : "off" );
|
||||||
|
irqlevel = disable_irq_save();
|
||||||
|
pcf50606_set_usb_charging(on);
|
||||||
|
rc = on;
|
||||||
|
restore_irq(irqlevel);
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
#endif /* HAVE_USB_POWER */
|
||||||
|
|
||||||
#endif /* CONFIG_CHARGING */
|
#endif /* CONFIG_CHARGING */
|
||||||
|
|
||||||
/* Returns true if the unit is charging the batteries. */
|
/* Returns true if the unit is charging the batteries. */
|
||||||
bool charging_state(void) {
|
bool charging_state(void)
|
||||||
|
{
|
||||||
return (GPIO_READ & 0x00800000)?true:false;
|
return (GPIO_READ & 0x00800000)?true:false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool usb_charging_enabled(void)
|
||||||
|
{
|
||||||
|
bool rc = false;
|
||||||
|
/* TODO: read the state of the GPOOD2 register...
|
||||||
|
* (this also means to set the irq level here) */
|
||||||
|
rc = pcf50606_usb_charging_enabled();
|
||||||
|
|
||||||
|
logf("usb charging %s", rc ? "enabled" : "disabled" );
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
void ide_power_enable(bool on)
|
void ide_power_enable(bool on)
|
||||||
{
|
{
|
||||||
|
@ -90,5 +125,3 @@ void power_off(void)
|
||||||
asm("halt");
|
asm("halt");
|
||||||
while(1);
|
while(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* SIMULATOR */
|
|
||||||
|
|
|
@ -28,7 +28,6 @@
|
||||||
#include "usb.h"
|
#include "usb.h"
|
||||||
|
|
||||||
#if CONFIG_TUNER
|
#if CONFIG_TUNER
|
||||||
|
|
||||||
bool tuner_power(bool status)
|
bool tuner_power(bool status)
|
||||||
{
|
{
|
||||||
(void)status;
|
(void)status;
|
||||||
|
@ -44,10 +43,20 @@ void power_init(void)
|
||||||
or_b(0x20, &PBDRL); /* hold power */
|
or_b(0x20, &PBDRL); /* hold power */
|
||||||
}
|
}
|
||||||
|
|
||||||
bool charger_inserted(void)
|
unsigned int power_input_status(void)
|
||||||
{
|
{
|
||||||
|
unsigned int status = POWER_INPUT_NONE;
|
||||||
|
|
||||||
/* FM or V2 can also charge from the USB port */
|
/* FM or V2 can also charge from the USB port */
|
||||||
return (adc_read(ADC_CHARGE_REGULATOR) < 0x1FF);
|
if (adc_read(ADC_CHARGE_REGULATOR) < 0x1FF)
|
||||||
|
status = POWER_INPUT_MAIN_CHARGER;
|
||||||
|
|
||||||
|
#ifdef HAVE_USB_POWER
|
||||||
|
if (usb_detect() == USB_INSERTED)
|
||||||
|
status |= POWER_INPUT_USB_CHARGER;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Returns true if the unit is charging the batteries. */
|
/* Returns true if the unit is charging the batteries. */
|
||||||
|
|
|
@ -31,10 +31,11 @@ void power_init(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool charger_inserted(void)
|
unsigned int power_input_status(void)
|
||||||
{
|
{
|
||||||
/* Player */
|
/* Player */
|
||||||
return (PADR & 1) == 0;
|
return ((PADR & 1) == 0) ?
|
||||||
|
POWER_INPUT_MAIN_CHARGER : POWER_INPUT_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ide_power_enable(bool on)
|
void ide_power_enable(bool on)
|
||||||
|
|
|
@ -36,10 +36,11 @@ void power_init(void)
|
||||||
charger_enable(false); /* Default to charger OFF */
|
charger_enable(false); /* Default to charger OFF */
|
||||||
}
|
}
|
||||||
|
|
||||||
bool charger_inserted(void)
|
unsigned int power_input_status(void)
|
||||||
{
|
{
|
||||||
/* Recorder */
|
/* Recorder */
|
||||||
return adc_read(ADC_EXT_POWER) > 0x100;
|
return (adc_read(ADC_EXT_POWER) > 0x100) ?
|
||||||
|
POWER_INPUT_MAIN_CHARGER : POWER_INPUT_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void charger_enable(bool on)
|
void charger_enable(bool on)
|
||||||
|
|
|
@ -42,9 +42,6 @@
|
||||||
#ifdef HAVE_USBSTACK
|
#ifdef HAVE_USBSTACK
|
||||||
#include "usb_core.h"
|
#include "usb_core.h"
|
||||||
#endif
|
#endif
|
||||||
#ifdef IRIVER_H300_SERIES
|
|
||||||
#include "pcf50606.h" /* for pcf50606_usb_charging_... */
|
|
||||||
#endif
|
|
||||||
#include "logf.h"
|
#include "logf.h"
|
||||||
|
|
||||||
/* Conditions under which we want the entire driver */
|
/* Conditions under which we want the entire driver */
|
||||||
|
@ -588,40 +585,6 @@ bool usb_powered(void)
|
||||||
{
|
{
|
||||||
return usb_state == USB_POWERED;
|
return usb_state == USB_POWERED;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if CONFIG_CHARGING
|
|
||||||
bool usb_charging_enable(bool on)
|
|
||||||
{
|
|
||||||
bool rc = false;
|
|
||||||
#ifdef IRIVER_H300_SERIES
|
|
||||||
int irqlevel;
|
|
||||||
logf("usb_charging_enable(%s)\n", on ? "on" : "off" );
|
|
||||||
irqlevel = disable_irq_save();
|
|
||||||
pcf50606_set_usb_charging(on);
|
|
||||||
rc = on;
|
|
||||||
restore_irq(irqlevel);
|
|
||||||
#else
|
|
||||||
/* TODO: implement it for other targets... */
|
|
||||||
(void)on;
|
|
||||||
#endif
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool usb_charging_enabled(void)
|
|
||||||
{
|
|
||||||
bool rc = false;
|
|
||||||
#ifdef IRIVER_H300_SERIES
|
|
||||||
/* TODO: read the state of the GPOOD2 register...
|
|
||||||
* (this also means to set the irq level here) */
|
|
||||||
rc = pcf50606_usb_charging_enabled();
|
|
||||||
#else
|
|
||||||
/* TODO: implement it for other targets... */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
logf("usb charging %s", rc ? "enabled" : "disabled" );
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -30,6 +30,8 @@
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
#include "lcd.h"
|
#include "lcd.h"
|
||||||
|
|
||||||
|
#include "power.h"
|
||||||
|
|
||||||
#include "ata.h" /* for volume definitions */
|
#include "ata.h" /* for volume definitions */
|
||||||
|
|
||||||
extern char having_new_lcd;
|
extern char having_new_lcd;
|
||||||
|
@ -212,9 +214,13 @@ bool charging_state(void)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool charger_inserted(void)
|
unsigned int power_input_status(void)
|
||||||
{
|
{
|
||||||
return false;
|
#ifdef HAVE_BATTERY_SWITCH
|
||||||
|
return POWER_INPUT_BATTERY;
|
||||||
|
#else
|
||||||
|
return POWER_INPUT_NONE;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_SPDIF_POWER
|
#ifdef HAVE_SPDIF_POWER
|
||||||
|
@ -241,6 +247,11 @@ bool usb_powered(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
#if CONFIG_CHARGING
|
#if CONFIG_CHARGING
|
||||||
|
bool charger_inserted(void)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool usb_charging_enable(bool on)
|
bool usb_charging_enable(bool on)
|
||||||
{
|
{
|
||||||
(void)on;
|
(void)on;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue