summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafaël Carré <rafael.carre@gmail.com>2011-12-31 18:43:59 +0000
committerRafaël Carré <rafael.carre@gmail.com>2011-12-31 18:43:59 +0000
commit2115eac7bb599ccc321f43c3bfa1a11672fd4b3a (patch)
tree1cd19570528528898483ccb2e62044f17693872a
parentdf09274768f020fe403cbe9475f5ba192247826d (diff)
usb_plugged() is PP only
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31489 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--bootloader/gigabeat-s.c4
-rw-r--r--bootloader/imx233.c4
-rw-r--r--firmware/target/arm/imx233/power-imx233.c3
-rw-r--r--firmware/target/arm/imx233/powermgmt-imx233.c4
-rw-r--r--firmware/target/arm/imx233/usb-imx233.c7
-rw-r--r--firmware/target/arm/imx233/usb-target.h1
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/usb-gigabeat-s.c10
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/usb-target.h2
-rw-r--r--firmware/target/arm/iriver/usb-target.h2
-rw-r--r--firmware/target/arm/rk27xx/usb-rk27xx.c5
-rw-r--r--firmware/target/arm/system-target.h2
-rw-r--r--firmware/target/arm/usb-fw-pp5002.c2
-rw-r--r--firmware/target/arm/usb-target.h1
13 files changed, 14 insertions, 33 deletions
diff --git a/bootloader/gigabeat-s.c b/bootloader/gigabeat-s.c
index 8483170522..7e28f55f09 100644
--- a/bootloader/gigabeat-s.c
+++ b/bootloader/gigabeat-s.c
@@ -110,7 +110,7 @@ static void handle_usb(int connect_timeout)
break;
}
- if (!usb_plugged())
+ if (usb_detect() == USB_EXTRACTED)
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
* at the time and we can untar or move after unplugging. */
- if (usb_plugged())
+ if (usb_detect() == USB_INSERTED)
handle_usb(HZ*2);
handle_untar();
diff --git a/bootloader/imx233.c b/bootloader/imx233.c
index 276a334c56..3d66403cc0 100644
--- a/bootloader/imx233.c
+++ b/bootloader/imx233.c
@@ -73,7 +73,7 @@ static void usb_mode(int connect_timeout)
break;
}
- if(!usb_plugged())
+ if(usb_detect() == USB_EXTRACTED)
break; /* Cable pulled */
}
@@ -149,7 +149,7 @@ void main(uint32_t arg, uint32_t addr)
if((ret = disk_mount_all()) <= 0)
error(EDISK, ret, false);
- if(usb_plugged())
+ if(usb_detect() == USB_INSERTED)
usb_mode(HZ);
printf("Loading firmware");
diff --git a/firmware/target/arm/imx233/power-imx233.c b/firmware/target/arm/imx233/power-imx233.c
index ac1a407ba0..f532f3303f 100644
--- a/firmware/target/arm/imx233/power-imx233.c
+++ b/firmware/target/arm/imx233/power-imx233.c
@@ -112,7 +112,8 @@ void power_off(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)
diff --git a/firmware/target/arm/imx233/powermgmt-imx233.c b/firmware/target/arm/imx233/powermgmt-imx233.c
index 97f6e08e12..87c48e7655 100644
--- a/firmware/target/arm/imx233/powermgmt-imx233.c
+++ b/firmware/target/arm/imx233/powermgmt-imx233.c
@@ -21,7 +21,7 @@
#include "powermgmt.h"
#include "power-imx233.h"
-#include "usb-target.h"
+#include "usb.h"
#include "string.h"
//#define LOGF_ENABLE
#include "logf.h"
@@ -60,7 +60,7 @@ void powermgmt_init_target(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 */
if(!is_5v_present && charge_state != DISCHARGING)
diff --git a/firmware/target/arm/imx233/usb-imx233.c b/firmware/target/arm/imx233/usb-imx233.c
index 91fb770190..8aaa90c46b 100644
--- a/firmware/target/arm/imx233/usb-imx233.c
+++ b/firmware/target/arm/imx233/usb-imx233.c
@@ -68,12 +68,7 @@ void usb_init_device(void)
int usb_detect(void)
{
- return usb_plugged() ? USB_INSERTED : USB_EXTRACTED;
-}
-
-bool usb_plugged(void)
-{
- return !!(HW_POWER_STS & HW_POWER_STS__VBUSVALID);
+ return (HW_POWER_STS & HW_POWER_STS__VBUSVALID) ? USB_INSERTED : USB_EXTRACTED;
}
void usb_enable(bool on)
diff --git a/firmware/target/arm/imx233/usb-target.h b/firmware/target/arm/imx233/usb-target.h
index 976d954038..600fc990ed 100644
--- a/firmware/target/arm/imx233/usb-target.h
+++ b/firmware/target/arm/imx233/usb-target.h
@@ -29,6 +29,5 @@
void usb_insert_int(void);
void usb_remove_int(void);
-bool usb_plugged(void);
#endif /* USB_TARGET_H */
diff --git a/firmware/target/arm/imx31/gigabeat-s/usb-gigabeat-s.c b/firmware/target/arm/imx31/gigabeat-s/usb-gigabeat-s.c
index 19c3b3173f..9ee1a47fd6 100644
--- a/firmware/target/arm/imx31/gigabeat-s/usb-gigabeat-s.c
+++ b/firmware/target/arm/imx31/gigabeat-s/usb-gigabeat-s.c
@@ -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)
{
- 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;
/* Notify power that USB charging is potentially available */
charger_usb_detect_event(status);
diff --git a/firmware/target/arm/imx31/gigabeat-s/usb-target.h b/firmware/target/arm/imx31/gigabeat-s/usb-target.h
index 961b947e14..60a9abd04c 100644
--- a/firmware/target/arm/imx31/gigabeat-s/usb-target.h
+++ b/firmware/target/arm/imx31/gigabeat-s/usb-target.h
@@ -26,8 +26,6 @@
#endif
void usb_connect_event(void);
-/* Read the immediate state of the cable from the PMIC */
-bool usb_plugged(void);
/** Sector read/write filters **/
diff --git a/firmware/target/arm/iriver/usb-target.h b/firmware/target/arm/iriver/usb-target.h
index 1b0dc7e194..7415308594 100644
--- a/firmware/target/arm/iriver/usb-target.h
+++ b/firmware/target/arm/iriver/usb-target.h
@@ -28,6 +28,4 @@
#define USB_DRIVER_CLOSE
#endif
-bool usb_plugged(void); /* Returns instantaneous state - always */
-
#endif
diff --git a/firmware/target/arm/rk27xx/usb-rk27xx.c b/firmware/target/arm/rk27xx/usb-rk27xx.c
index 2eb6bed480..60a82bed88 100644
--- a/firmware/target/arm/rk27xx/usb-rk27xx.c
+++ b/firmware/target/arm/rk27xx/usb-rk27xx.c
@@ -45,11 +45,6 @@ void usb_attach(void)
usb_enable(true);
}
-bool usb_plugged(void)
-{
- return true;
-}
-
void usb_enable(bool on)
{
if(on)
diff --git a/firmware/target/arm/system-target.h b/firmware/target/arm/system-target.h
index 91e6beb868..022baa1466 100644
--- a/firmware/target/arm/system-target.h
+++ b/firmware/target/arm/system-target.h
@@ -24,6 +24,7 @@
#include "config.h"
#include "system-arm.h"
+#include <stdbool.h>
#ifdef CPU_PP
/* TODO: This header is actually portalplayer specific, and should be
@@ -50,6 +51,7 @@
#define outw(a,b) (*(volatile unsigned short *) (b) = (a))
void usb_pin_init(void);
+bool usb_plugged(void);
static inline void udelay(unsigned usecs)
{
diff --git a/firmware/target/arm/usb-fw-pp5002.c b/firmware/target/arm/usb-fw-pp5002.c
index d1664c3607..a8e76eade0 100644
--- a/firmware/target/arm/usb-fw-pp5002.c
+++ b/firmware/target/arm/usb-fw-pp5002.c
@@ -73,6 +73,4 @@ int usb_detect(void)
return USB_EXTRACTED;
}
-
-/* No different for now */
bool usb_plugged(void) __attribute__((alias("usb_detect")));
diff --git a/firmware/target/arm/usb-target.h b/firmware/target/arm/usb-target.h
index 802b8e1445..34e7a54262 100644
--- a/firmware/target/arm/usb-target.h
+++ b/firmware/target/arm/usb-target.h
@@ -23,7 +23,6 @@
void usb_insert_int(void);
void firewire_insert_int(void);
-bool usb_plugged(void); /* Returns instantaneous state - always */
#ifdef HAVE_BOOTLOADER_USB_MODE
#define USB_DRIVER_CLOSE