usb_plugged() is PP only

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31489 a1c6a512-1295-4272-9138-f99709370657
diff --git a/bootloader/gigabeat-s.c b/bootloader/gigabeat-s.c
index 8483170..7e28f55 100644
--- a/bootloader/gigabeat-s.c
+++ b/bootloader/gigabeat-s.c
@@ -110,7 +110,7 @@
             break;
         }
 
-        if (!usb_plugged())
+        if (usb_detect() == USB_EXTRACTED)
             break; /* Cable pulled */
     }
 
@@ -377,7 +377,7 @@
 
     /* 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 276a334..3d66403 100644
--- a/bootloader/imx233.c
+++ b/bootloader/imx233.c
@@ -73,7 +73,7 @@
             break;
         }
 
-        if(!usb_plugged())
+        if(usb_detect() == USB_EXTRACTED)
             break; /* Cable pulled */
     }
 
@@ -149,7 +149,7 @@
     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 ac1a407..f532f33 100644
--- a/firmware/target/arm/imx233/power-imx233.c
+++ b/firmware/target/arm/imx233/power-imx233.c
@@ -112,7 +112,8 @@
 
 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 97f6e08..87c48e7 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 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 91fb770..8aaa90c 100644
--- a/firmware/target/arm/imx233/usb-imx233.c
+++ b/firmware/target/arm/imx233/usb-imx233.c
@@ -68,12 +68,7 @@
 
 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 976d954..600fc99 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 19c3b31..9ee1a47 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 @@
     }
 }
 
-/* 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 961b947..60a9abd 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 1b0dc7e..7415308 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 2eb6bed..60a82be 100644
--- a/firmware/target/arm/rk27xx/usb-rk27xx.c
+++ b/firmware/target/arm/rk27xx/usb-rk27xx.c
@@ -45,11 +45,6 @@
     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 91e6beb..022baa1 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 d1664c3..a8e76ea 100644
--- a/firmware/target/arm/usb-fw-pp5002.c
+++ b/firmware/target/arm/usb-fw-pp5002.c
@@ -73,6 +73,4 @@
 
     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 802b8e1..34e7a54 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