usb_plugged() is PP only

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31489 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Rafaël Carré 2011-12-31 18:43:59 +00:00
parent df09274768
commit 2115eac7bb
13 changed files with 14 additions and 33 deletions

View file

@ -110,7 +110,7 @@ static void handle_usb(int connect_timeout)
break; break;
} }
if (!usb_plugged()) if (usb_detect() == USB_EXTRACTED)
break; /* Cable pulled */ break; /* Cable pulled */
} }
@ -377,7 +377,7 @@ void main(void)
/* Do USB first since a tar or binary could be added to the MTP directory /* Do USB first since a tar or binary could be added to the MTP directory
* at the time and we can untar or move after unplugging. */ * at the time and we can untar or move after unplugging. */
if (usb_plugged()) if (usb_detect() == USB_INSERTED)
handle_usb(HZ*2); handle_usb(HZ*2);
handle_untar(); handle_untar();

View file

@ -73,7 +73,7 @@ static void usb_mode(int connect_timeout)
break; break;
} }
if(!usb_plugged()) if(usb_detect() == USB_EXTRACTED)
break; /* Cable pulled */ break; /* Cable pulled */
} }
@ -149,7 +149,7 @@ void main(uint32_t arg, uint32_t addr)
if((ret = disk_mount_all()) <= 0) if((ret = disk_mount_all()) <= 0)
error(EDISK, ret, false); error(EDISK, ret, false);
if(usb_plugged()) if(usb_detect() == USB_INSERTED)
usb_mode(HZ); usb_mode(HZ);
printf("Loading firmware"); printf("Loading firmware");

View file

@ -112,7 +112,8 @@ void power_off(void)
unsigned int power_input_status(void) unsigned int power_input_status(void)
{ {
return usb_plugged() ? POWER_INPUT_MAIN_CHARGER : POWER_INPUT_NONE; return (usb_detect == USB_INSERTED)
? POWER_INPUT_MAIN_CHARGER : POWER_INPUT_NONE;
} }
bool charging_state(void) bool charging_state(void)

View file

@ -21,7 +21,7 @@
#include "powermgmt.h" #include "powermgmt.h"
#include "power-imx233.h" #include "power-imx233.h"
#include "usb-target.h" #include "usb.h"
#include "string.h" #include "string.h"
//#define LOGF_ENABLE //#define LOGF_ENABLE
#include "logf.h" #include "logf.h"
@ -60,7 +60,7 @@ void powermgmt_init_target(void)
void charging_algorithm_step(void) void charging_algorithm_step(void)
{ {
bool is_5v_present = usb_plugged(); bool is_5v_present = usb_detect() == USB_INSERTED;
/* initial state & 5v -> battery transition */ /* initial state & 5v -> battery transition */
if(!is_5v_present && charge_state != DISCHARGING) if(!is_5v_present && charge_state != DISCHARGING)

View file

@ -68,12 +68,7 @@ void usb_init_device(void)
int usb_detect(void) int usb_detect(void)
{ {
return usb_plugged() ? USB_INSERTED : USB_EXTRACTED; return (HW_POWER_STS & HW_POWER_STS__VBUSVALID) ? USB_INSERTED : USB_EXTRACTED;
}
bool usb_plugged(void)
{
return !!(HW_POWER_STS & HW_POWER_STS__VBUSVALID);
} }
void usb_enable(bool on) void usb_enable(bool on)

View file

@ -29,6 +29,5 @@
void usb_insert_int(void); void usb_insert_int(void);
void usb_remove_int(void); void usb_remove_int(void);
bool usb_plugged(void);
#endif /* USB_TARGET_H */ #endif /* USB_TARGET_H */

View file

@ -54,15 +54,11 @@ static void enable_transceiver(bool enable)
} }
} }
/* Read the immediate state of the cable from the PMIC */
bool usb_plugged(void)
{
return mc13783_read(MC13783_INTERRUPT_SENSE0) & MC13783_USB4V4S;
}
void usb_connect_event(void) void usb_connect_event(void)
{ {
int status = usb_plugged() ? USB_INSERTED : USB_EXTRACTED; /* Read the immediate state of the cable from the PMIC */
int status = (mc13783_read(MC13783_INTERRUPT_SENSE0) & MC13783_USB4V4S)
? USB_INSERTED : USB_EXTRACTED;
usb_status = status; usb_status = status;
/* Notify power that USB charging is potentially available */ /* Notify power that USB charging is potentially available */
charger_usb_detect_event(status); charger_usb_detect_event(status);

View file

@ -26,8 +26,6 @@
#endif #endif
void usb_connect_event(void); void usb_connect_event(void);
/* Read the immediate state of the cable from the PMIC */
bool usb_plugged(void);
/** Sector read/write filters **/ /** Sector read/write filters **/

View file

@ -28,6 +28,4 @@
#define USB_DRIVER_CLOSE #define USB_DRIVER_CLOSE
#endif #endif
bool usb_plugged(void); /* Returns instantaneous state - always */
#endif #endif

View file

@ -45,11 +45,6 @@ void usb_attach(void)
usb_enable(true); usb_enable(true);
} }
bool usb_plugged(void)
{
return true;
}
void usb_enable(bool on) void usb_enable(bool on)
{ {
if(on) if(on)

View file

@ -24,6 +24,7 @@
#include "config.h" #include "config.h"
#include "system-arm.h" #include "system-arm.h"
#include <stdbool.h>
#ifdef CPU_PP #ifdef CPU_PP
/* TODO: This header is actually portalplayer specific, and should be /* TODO: This header is actually portalplayer specific, and should be
@ -50,6 +51,7 @@
#define outw(a,b) (*(volatile unsigned short *) (b) = (a)) #define outw(a,b) (*(volatile unsigned short *) (b) = (a))
void usb_pin_init(void); void usb_pin_init(void);
bool usb_plugged(void);
static inline void udelay(unsigned usecs) static inline void udelay(unsigned usecs)
{ {

View file

@ -73,6 +73,4 @@ int usb_detect(void)
return USB_EXTRACTED; return USB_EXTRACTED;
} }
/* No different for now */
bool usb_plugged(void) __attribute__((alias("usb_detect"))); bool usb_plugged(void) __attribute__((alias("usb_detect")));

View file

@ -23,7 +23,6 @@
void usb_insert_int(void); void usb_insert_int(void);
void firewire_insert_int(void); void firewire_insert_int(void);
bool usb_plugged(void); /* Returns instantaneous state - always */
#ifdef HAVE_BOOTLOADER_USB_MODE #ifdef HAVE_BOOTLOADER_USB_MODE
#define USB_DRIVER_CLOSE #define USB_DRIVER_CLOSE