diff options
author | Jens Arnold <amiconn@rockbox.org> | 2004-10-10 19:51:11 +0000 |
---|---|---|
committer | Jens Arnold <amiconn@rockbox.org> | 2004-10-10 19:51:11 +0000 |
commit | 5789ee99286a487e1764bd9b52562e1a79b5d4e7 (patch) | |
tree | e4a9eb64f5b8f58def41faa2e123e553b2bdf5d8 /firmware/usb.c | |
parent | 120d863c68a6c4489357f1ae11db3e96a0124ded (diff) | |
download | rockbox-5789ee99286a487e1764bd9b52562e1a79b5d4e7.tar.gz rockbox-5789ee99286a487e1764bd9b52562e1a79b5d4e7.zip |
MMC hotswap handling in USB mode
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@5247 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/usb.c')
-rw-r--r-- | firmware/usb.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/firmware/usb.c b/firmware/usb.c index 8f3169e5df..65069c486a 100644 --- a/firmware/usb.c +++ b/firmware/usb.c | |||
@@ -32,6 +32,9 @@ | |||
32 | #include "button.h" | 32 | #include "button.h" |
33 | #include "sprintf.h" | 33 | #include "sprintf.h" |
34 | #include "hwcompat.h" | 34 | #include "hwcompat.h" |
35 | #ifdef HAVE_MMC | ||
36 | #include "ata_mmc.h" | ||
37 | #endif | ||
35 | 38 | ||
36 | extern void dbg_ports(void); /* NASTY! defined in apps/ */ | 39 | extern void dbg_ports(void); /* NASTY! defined in apps/ */ |
37 | 40 | ||
@@ -47,6 +50,9 @@ void screen_dump(void); /* Nasty again. Defined in apps/ too */ | |||
47 | /* Messages from usb_tick */ | 50 | /* Messages from usb_tick */ |
48 | #define USB_INSERTED 1 | 51 | #define USB_INSERTED 1 |
49 | #define USB_EXTRACTED 2 | 52 | #define USB_EXTRACTED 2 |
53 | #ifdef HAVE_MMC | ||
54 | #define USB_REENABLE 3 | ||
55 | #endif | ||
50 | 56 | ||
51 | /* Thread states */ | 57 | /* Thread states */ |
52 | #define EXTRACTING 1 | 58 | #define EXTRACTING 1 |
@@ -62,6 +68,10 @@ static int countdown; | |||
62 | 68 | ||
63 | static int usb_state; | 69 | static int usb_state; |
64 | 70 | ||
71 | #ifdef HAVE_MMC | ||
72 | static int usb_mmc_countdown = 0; | ||
73 | #endif | ||
74 | |||
65 | /* FIXME: The extra 0x400 is consumed by fat_mount() when the fsinfo | 75 | /* FIXME: The extra 0x400 is consumed by fat_mount() when the fsinfo |
66 | needs updating */ | 76 | needs updating */ |
67 | static char usb_stack[DEFAULT_STACK_SIZE + 0x400]; | 77 | static char usb_stack[DEFAULT_STACK_SIZE + 0x400]; |
@@ -75,6 +85,9 @@ static void usb_enable(bool on) | |||
75 | #ifdef USB_ENABLE_ONDIOSTYLE | 85 | #ifdef USB_ENABLE_ONDIOSTYLE |
76 | if(on) | 86 | if(on) |
77 | { | 87 | { |
88 | #ifdef HAVE_MMC | ||
89 | mmc_select_clock(mmc_detect() ? 1 : 0); | ||
90 | #endif | ||
78 | or_b(0x20, &PADRL); /* enable USB */ | 91 | or_b(0x20, &PADRL); /* enable USB */ |
79 | and_b(~0x08, &PADRL); /* assert card detect */ | 92 | and_b(~0x08, &PADRL); /* assert card detect */ |
80 | } | 93 | } |
@@ -255,6 +268,22 @@ static void usb_thread(void) | |||
255 | } | 268 | } |
256 | } | 269 | } |
257 | break; | 270 | break; |
271 | |||
272 | #ifdef HAVE_MMC | ||
273 | case SYS_MMC_INSERTED: | ||
274 | case SYS_MMC_EXTRACTED: | ||
275 | if(usb_state == USB_INSERTED) | ||
276 | { | ||
277 | usb_enable(false); | ||
278 | usb_mmc_countdown = HZ/2; /* re-enable after 0.5 sec */ | ||
279 | } | ||
280 | break; | ||
281 | |||
282 | case USB_REENABLE: | ||
283 | if(usb_state == USB_INSERTED) | ||
284 | usb_enable(true); /* reenable only if still inserted */ | ||
285 | break; | ||
286 | #endif | ||
258 | } | 287 | } |
259 | } | 288 | } |
260 | } | 289 | } |
@@ -308,6 +337,14 @@ static void usb_tick(void) | |||
308 | } | 337 | } |
309 | } | 338 | } |
310 | } | 339 | } |
340 | #ifdef HAVE_MMC | ||
341 | if(usb_mmc_countdown > 0) | ||
342 | { | ||
343 | usb_mmc_countdown--; | ||
344 | if (usb_mmc_countdown == 0) | ||
345 | queue_post(&usb_queue, USB_REENABLE, NULL); | ||
346 | } | ||
347 | #endif | ||
311 | } | 348 | } |
312 | 349 | ||
313 | void usb_acknowledge(int id) | 350 | void usb_acknowledge(int id) |