diff options
author | Jens Arnold <amiconn@rockbox.org> | 2007-04-11 20:44:32 +0000 |
---|---|---|
committer | Jens Arnold <amiconn@rockbox.org> | 2007-04-11 20:44:32 +0000 |
commit | fad79dc6364e1e0d42216f4636a4fc504a594307 (patch) | |
tree | 37e17308c021f63c69f63fa8658c572d879dcce2 /firmware/usb.c | |
parent | dfa9f440349d7532423373b2bac5993ee5e958a9 (diff) | |
download | rockbox-fad79dc6364e1e0d42216f4636a4fc504a594307.tar.gz rockbox-fad79dc6364e1e0d42216f4636a4fc504a594307.zip |
Moved archos USB handling to target tree. Minor simplification for coldfire (only one usb-target.h).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13110 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/usb.c')
-rw-r--r-- | firmware/usb.c | 78 |
1 files changed, 1 insertions, 77 deletions
diff --git a/firmware/usb.c b/firmware/usb.c index 13adc3b391..217aaf8b84 100644 --- a/firmware/usb.c +++ b/firmware/usb.c | |||
@@ -32,18 +32,11 @@ | |||
32 | #include "disk.h" | 32 | #include "disk.h" |
33 | #include "panic.h" | 33 | #include "panic.h" |
34 | #include "lcd.h" | 34 | #include "lcd.h" |
35 | #include "adc.h" | ||
36 | #include "usb.h" | 35 | #include "usb.h" |
37 | #include "button.h" | 36 | #include "button.h" |
38 | #include "sprintf.h" | 37 | #include "sprintf.h" |
39 | #include "string.h" | 38 | #include "string.h" |
40 | #include "hwcompat.h" | ||
41 | #ifdef HAVE_MMC | ||
42 | #include "ata_mmc.h" | ||
43 | #endif | ||
44 | #ifdef TARGET_TREE | ||
45 | #include "usb-target.h" | 39 | #include "usb-target.h" |
46 | #endif | ||
47 | #ifdef IRIVER_H300_SERIES | 40 | #ifdef IRIVER_H300_SERIES |
48 | #include "pcf50606.h" /* for pcf50606_usb_charging_... */ | 41 | #include "pcf50606.h" /* for pcf50606_usb_charging_... */ |
49 | #endif | 42 | #endif |
@@ -56,8 +49,6 @@ bool do_screendump_instead_of_usb = false; | |||
56 | void screen_dump(void); /* Nasty again. Defined in apps/ too */ | 49 | void screen_dump(void); /* Nasty again. Defined in apps/ too */ |
57 | #endif | 50 | #endif |
58 | 51 | ||
59 | #define USB_REALLY_BRAVE | ||
60 | |||
61 | #if !defined(SIMULATOR) && !defined(USB_NONE) | 52 | #if !defined(SIMULATOR) && !defined(USB_NONE) |
62 | 53 | ||
63 | /* Messages from usb_tick and thread states */ | 54 | /* Messages from usb_tick and thread states */ |
@@ -93,10 +84,7 @@ void screen_dump(void); /* Nasty again. Defined in apps/ too */ | |||
93 | #endif | 84 | #endif |
94 | #endif /* HAVE_USB_POWER */ | 85 | #endif /* HAVE_USB_POWER */ |
95 | 86 | ||
96 | /* The ADC tick reads one channel per tick, and we want to check 3 successive | 87 | #define NUM_POLL_READINGS (HZ/5) |
97 | readings on the USB voltage channel. This doesn't apply to the Player, but | ||
98 | debouncing the USB detection port won't hurt us either. */ | ||
99 | #define NUM_POLL_READINGS (NUM_ADC_CHANNELS * 3) | ||
100 | static int countdown; | 88 | static int countdown; |
101 | 89 | ||
102 | static int usb_state; | 90 | static int usb_state; |
@@ -115,46 +103,6 @@ static struct event_queue usb_queue; | |||
115 | static bool last_usb_status; | 103 | static bool last_usb_status; |
116 | static bool usb_monitor_enabled; | 104 | static bool usb_monitor_enabled; |
117 | 105 | ||
118 | #ifndef TARGET_TREE | ||
119 | void usb_enable(bool on) | ||
120 | { | ||
121 | #ifdef USB_ENABLE_ONDIOSTYLE | ||
122 | PACR2 &= ~0x04C0; /* use PA3, PA5 as GPIO */ | ||
123 | if(on) | ||
124 | { | ||
125 | #ifdef HAVE_MMC | ||
126 | mmc_enable_int_flash_clock(!mmc_detect()); | ||
127 | #endif | ||
128 | if (!(read_hw_mask() & MMC_CLOCK_POLARITY)) | ||
129 | and_b(~0x20, &PBDRH); /* old circuit needs SCK1 = low while on USB */ | ||
130 | or_b(0x20, &PADRL); /* enable USB */ | ||
131 | and_b(~0x08, &PADRL); /* assert card detect */ | ||
132 | } | ||
133 | else | ||
134 | { | ||
135 | if (!(read_hw_mask() & MMC_CLOCK_POLARITY)) | ||
136 | or_b(0x20, &PBDRH); /* reset SCK1 = high for old circuit */ | ||
137 | and_b(~0x20, &PADRL); /* disable USB */ | ||
138 | or_b(0x08, &PADRL); /* deassert card detect */ | ||
139 | } | ||
140 | or_b(0x28, &PAIORL); /* output for USB enable and card detect */ | ||
141 | #else | ||
142 | #ifdef HAVE_LCD_BITMAP | ||
143 | if(read_hw_mask() & USB_ACTIVE_HIGH) | ||
144 | on = !on; | ||
145 | #endif | ||
146 | if(on) | ||
147 | { | ||
148 | and_b(~0x04, &PADRH); /* enable USB */ | ||
149 | } | ||
150 | else | ||
151 | { | ||
152 | or_b(0x04, &PADRH); | ||
153 | } | ||
154 | or_b(0x04, &PAIORH); | ||
155 | #endif | ||
156 | } | ||
157 | #endif | ||
158 | 106 | ||
159 | #ifndef BOOTLOADER | 107 | #ifndef BOOTLOADER |
160 | static void usb_slave_mode(bool on) | 108 | static void usb_slave_mode(bool on) |
@@ -246,13 +194,9 @@ static void usb_thread(void) | |||
246 | if(num_acks_to_expect == 0) | 194 | if(num_acks_to_expect == 0) |
247 | { | 195 | { |
248 | DEBUGF("All threads have acknowledged the connect.\n"); | 196 | DEBUGF("All threads have acknowledged the connect.\n"); |
249 | #ifdef USB_REALLY_BRAVE | ||
250 | usb_slave_mode(true); | 197 | usb_slave_mode(true); |
251 | usb_state = USB_INSERTED; | 198 | usb_state = USB_INSERTED; |
252 | cpu_idle_mode(true); | 199 | cpu_idle_mode(true); |
253 | #else | ||
254 | system_reboot(); | ||
255 | #endif | ||
256 | } | 200 | } |
257 | else | 201 | else |
258 | { | 202 | { |
@@ -330,23 +274,6 @@ static void usb_thread(void) | |||
330 | } | 274 | } |
331 | #endif | 275 | #endif |
332 | 276 | ||
333 | #ifndef TARGET_TREE | ||
334 | bool usb_detect(void) | ||
335 | { | ||
336 | bool current_status; | ||
337 | |||
338 | #ifdef USB_RECORDERSTYLE | ||
339 | current_status = (adc_read(ADC_USB_POWER) > 500)?true:false; | ||
340 | #endif | ||
341 | #ifdef USB_FMRECORDERSTYLE | ||
342 | current_status = (adc_read(ADC_USB_POWER) <= 512)?true:false; | ||
343 | #endif | ||
344 | #ifdef USB_PLAYERSTYLE | ||
345 | current_status = (PADR & 0x8000)?false:true; | ||
346 | #endif | ||
347 | return current_status; | ||
348 | } | ||
349 | #endif | ||
350 | 277 | ||
351 | #ifndef BOOTLOADER | 278 | #ifndef BOOTLOADER |
352 | static void usb_tick(void) | 279 | static void usb_tick(void) |
@@ -402,10 +329,7 @@ void usb_init(void) | |||
402 | usb_monitor_enabled = false; | 329 | usb_monitor_enabled = false; |
403 | countdown = -1; | 330 | countdown = -1; |
404 | 331 | ||
405 | #ifdef TARGET_TREE | ||
406 | usb_init_device(); | 332 | usb_init_device(); |
407 | #endif | ||
408 | |||
409 | usb_enable(false); | 333 | usb_enable(false); |
410 | 334 | ||
411 | /* We assume that the USB cable is extracted */ | 335 | /* We assume that the USB cable is extracted */ |