From 745266d309e9434e67bdb81cfe93482bd2b26f86 Mon Sep 17 00:00:00 2001 From: Dave Chapman Date: Tue, 13 Oct 2009 09:23:32 +0000 Subject: [PATCH] Re-commit r23070 - reboot to disk mode on the Nano2G when USB is inserted. This was accidentally reverted in r23099 git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23148 a1c6a512-1295-4272-9138-f99709370657 --- firmware/target/arm/s5l8700/usb-s5l8700.c | 35 ++++++++++++++--------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/firmware/target/arm/s5l8700/usb-s5l8700.c b/firmware/target/arm/s5l8700/usb-s5l8700.c index 6ad4dcea95..c0bf7a951b 100644 --- a/firmware/target/arm/s5l8700/usb-s5l8700.c +++ b/firmware/target/arm/s5l8700/usb-s5l8700.c @@ -20,6 +20,9 @@ ****************************************************************************/ #include "config.h" #include "usb.h" +#include "cpu.h" +#include "system.h" +#include "string.h" void usb_init_device(void) { @@ -27,21 +30,27 @@ void usb_init_device(void) void usb_enable(bool on) { - (void)on; + /* This device specific code will eventually give way to proper USB + handling, which should be the same for all S5L870x targets. */ + if (on) + { +#ifdef IPOD_ARCH + /* For iPod, we can only do one thing with USB mode atm - reboot + into the flash-based disk-mode. This does not return. */ + + memcpy((void *)0x0002bf00, "diskmodehotstuff\1\0\0\0", 20); + + system_reboot(); /* Reboot */ +#endif + } } -void usb_attach(void) -{ - -} - -static bool usb_pin_state(void) -{ - return false; -} - -/* detect host or charger (INSERTED or EXTRACTED) */ int usb_detect(void) { - return usb_pin_state() ? USB_INSERTED : USB_EXTRACTED; +#if defined(IPOD_NANO2G) + if ((PDAT14 & 0x8) == 0x0) + return USB_INSERTED; +#endif + + return USB_EXTRACTED; }