mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-09 13:15:18 -05:00
iPod Classic: use PMU interrupts to detect USB and FW
Change-Id: I9be733e1a943ddeb99335d362f81f74879eeb94b
This commit is contained in:
parent
f6ed4f8306
commit
daee722455
6 changed files with 44 additions and 22 deletions
|
|
@ -27,7 +27,6 @@
|
||||||
#ifdef HAVE_USBSTACK
|
#ifdef HAVE_USBSTACK
|
||||||
#include "usb_core.h"
|
#include "usb_core.h"
|
||||||
#include "usb_drv.h"
|
#include "usb_drv.h"
|
||||||
#include "power.h"
|
|
||||||
|
|
||||||
void usb_enable(bool on)
|
void usb_enable(bool on)
|
||||||
{
|
{
|
||||||
|
|
@ -35,6 +34,9 @@ void usb_enable(bool on)
|
||||||
else usb_core_exit();
|
else usb_core_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if CONFIG_CPU==S5L8701
|
||||||
|
#include "power.h"
|
||||||
|
|
||||||
int usb_detect(void)
|
int usb_detect(void)
|
||||||
{
|
{
|
||||||
if (power_input_status() & POWER_INPUT_USB)
|
if (power_input_status() & POWER_INPUT_USB)
|
||||||
|
|
@ -42,6 +44,31 @@ int usb_detect(void)
|
||||||
return USB_EXTRACTED;
|
return USB_EXTRACTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#elif CONFIG_CPU==S5L8702
|
||||||
|
static int usb_status = USB_EXTRACTED;
|
||||||
|
|
||||||
|
int usb_detect(void)
|
||||||
|
{
|
||||||
|
return usb_status;
|
||||||
|
}
|
||||||
|
|
||||||
|
void usb_insert_int(void)
|
||||||
|
{
|
||||||
|
usb_status = USB_INSERTED;
|
||||||
|
#ifdef USB_STATUS_BY_EVENT
|
||||||
|
usb_status_event(USB_INSERTED);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void usb_remove_int(void)
|
||||||
|
{
|
||||||
|
usb_status = USB_EXTRACTED;
|
||||||
|
#ifdef USB_STATUS_BY_EVENT
|
||||||
|
usb_status_event(USB_EXTRACTED);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif /* S5L8702 */
|
||||||
|
|
||||||
void usb_init_device(void)
|
void usb_init_device(void)
|
||||||
{
|
{
|
||||||
/* Power up the core clocks to allow writing
|
/* Power up the core clocks to allow writing
|
||||||
|
|
@ -59,7 +86,8 @@ void usb_init_device(void)
|
||||||
|
|
||||||
usb_drv_exit();
|
usb_drv_exit();
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
|
#else /* !HAVE_STACK */
|
||||||
void usb_enable(bool on)
|
void usb_enable(bool on)
|
||||||
{
|
{
|
||||||
(void)on;
|
(void)on;
|
||||||
|
|
|
||||||
|
|
@ -122,7 +122,7 @@ bool dbg_hw_info(void)
|
||||||
_DEBUG_PRINTF("brightness value: %d", pmu_read(0x28));
|
_DEBUG_PRINTF("brightness value: %d", pmu_read(0x28));
|
||||||
line++;
|
line++;
|
||||||
_DEBUG_PRINTF("USB present: %s",
|
_DEBUG_PRINTF("USB present: %s",
|
||||||
pmu_usb_present() ? "true" : "false");
|
(power_input_status() & POWER_INPUT_USB) ? "true" : "false");
|
||||||
#if CONFIG_CHARGING
|
#if CONFIG_CHARGING
|
||||||
_DEBUG_PRINTF("FW present: %s",
|
_DEBUG_PRINTF("FW present: %s",
|
||||||
pmu_firewire_present() ? "true" : "false");
|
pmu_firewire_present() ? "true" : "false");
|
||||||
|
|
|
||||||
|
|
@ -161,18 +161,12 @@ static struct eint_handler pmu_eint = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static int pmu_input_holdswitch;
|
static int pmu_input_holdswitch;
|
||||||
static int pmu_input_usb;
|
|
||||||
|
|
||||||
int pmu_holdswitch_locked(void)
|
int pmu_holdswitch_locked(void)
|
||||||
{
|
{
|
||||||
return pmu_input_holdswitch;
|
return pmu_input_holdswitch;
|
||||||
}
|
}
|
||||||
|
|
||||||
int pmu_usb_present(void)
|
|
||||||
{
|
|
||||||
return pmu_input_usb;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef IPOD_ACCESSORY_PROTOCOL
|
#ifdef IPOD_ACCESSORY_PROTOCOL
|
||||||
static int pmu_input_accessory;
|
static int pmu_input_accessory;
|
||||||
|
|
||||||
|
|
@ -206,7 +200,10 @@ static void pmu_read_inputs_gpio(void)
|
||||||
static void pmu_read_inputs_ooc(void)
|
static void pmu_read_inputs_ooc(void)
|
||||||
{
|
{
|
||||||
unsigned char oocstat = pmu_read(PCF5063X_REG_OOCSTAT);
|
unsigned char oocstat = pmu_read(PCF5063X_REG_OOCSTAT);
|
||||||
pmu_input_usb = !!(oocstat & PCF5063X_OOCSTAT_EXTON2);
|
if (oocstat & PCF5063X_OOCSTAT_EXTON2)
|
||||||
|
usb_insert_int();
|
||||||
|
else
|
||||||
|
usb_remove_int();
|
||||||
#ifdef IPOD_ACCESSORY_PROTOCOL
|
#ifdef IPOD_ACCESSORY_PROTOCOL
|
||||||
pmu_input_accessory = !(oocstat & PCF5063X_OOCSTAT_EXTON3);
|
pmu_input_accessory = !(oocstat & PCF5063X_OOCSTAT_EXTON3);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,6 @@ void pmu_write_rtc(unsigned char* buffer);
|
||||||
void pmu_hdd_power(bool on);
|
void pmu_hdd_power(bool on);
|
||||||
|
|
||||||
int pmu_holdswitch_locked(void);
|
int pmu_holdswitch_locked(void);
|
||||||
int pmu_usb_present(void);
|
|
||||||
#if CONFIG_CHARGING
|
#if CONFIG_CHARGING
|
||||||
int pmu_firewire_present(void);
|
int pmu_firewire_present(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -119,17 +119,12 @@ void usb_charging_maxcurrent_change(int maxcurrent)
|
||||||
|
|
||||||
unsigned int power_input_status(void)
|
unsigned int power_input_status(void)
|
||||||
{
|
{
|
||||||
/* This checks if USB Vbus is present. */
|
unsigned int status = POWER_INPUT_NONE;
|
||||||
if (!(PDAT(12) & 0x8)) return POWER_INPUT_USB_CHARGER;
|
if (usb_detect() == USB_INSERTED)
|
||||||
|
status |= POWER_INPUT_USB_CHARGER;
|
||||||
/* If USB Vbus is not present, check if we have a positive power balance
|
if (pmu_firewire_present())
|
||||||
regardless. This would indicate FireWire charging. Note that this will
|
status |= POWER_INPUT_MAIN_CHARGER;
|
||||||
drop to POWER_INPUT_NONE if FireWire isn't able to supply enough current
|
return status;
|
||||||
for device operation, e.g. during disk spinup. */
|
|
||||||
if (PDAT(11) & 0x20) return POWER_INPUT_NONE;
|
|
||||||
|
|
||||||
/* Looks like we have FireWire power. */
|
|
||||||
return POWER_INPUT_MAIN_CHARGER;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool charging_state(void)
|
bool charging_state(void)
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,9 @@ static inline void udelay(unsigned usecs)
|
||||||
while (TIME_BEFORE(USEC_TIMER, stop));
|
while (TIME_BEFORE(USEC_TIMER, stop));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void usb_insert_int(void);
|
||||||
|
void usb_remove_int(void);
|
||||||
|
|
||||||
#ifdef BOOTLOADER
|
#ifdef BOOTLOADER
|
||||||
void system_preinit(void);
|
void system_preinit(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue