summaryrefslogtreecommitdiff
path: root/firmware/usb.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/usb.c')
-rw-r--r--firmware/usb.c30
1 files changed, 7 insertions, 23 deletions
diff --git a/firmware/usb.c b/firmware/usb.c
index 8bb320c49d..1400805c33 100644
--- a/firmware/usb.c
+++ b/firmware/usb.c
@@ -80,19 +80,6 @@ static struct event_queue usb_queue;
80static bool last_usb_status; 80static bool last_usb_status;
81static bool usb_monitor_enabled; 81static bool usb_monitor_enabled;
82 82
83#ifdef USB_GMINISTYLE
84static int getSMSCVer(void) {
85 int v;
86 int* smscVerAddr = (int*)0x4C20;
87 __asm__ ("ldc %0, @%1" : "=r"(v) : "a"(smscVerAddr));
88 v &= 0xFF;
89 if (v < 4 || v == 0xFF) {
90 return 3;
91 }
92 return v;
93}
94
95#endif
96 83
97static void usb_enable(bool on) 84static void usb_enable(bool on)
98{ 85{
@@ -118,26 +105,23 @@ static void usb_enable(bool on)
118 or_b(0x28, &PAIORL); /* output for USB enable and card detect */ 105 or_b(0x28, &PAIORL); /* output for USB enable and card detect */
119#elif defined(USB_GMINISTYLE) 106#elif defined(USB_GMINISTYLE)
120 { 107 {
121 int i; 108 int smsc_ver = smsc_version();
122 int smscVer = getSMSCVer();
123 if (on) { 109 if (on) {
124 if (smscVer < 4) { 110 if (smsc_ver < 4) {
125 P6 &= ~0x04; 111 P6 &= ~0x04;
126 P10 &= ~0x20; 112 P10 &= ~0x20;
127 113
128 for (i=0; i < 20; i++) 114 smsc_delay();
129 ;
130 115
131 P6 |= 0x08; 116 P6 |= 0x08;
132 P10 |= 0x20; 117 P10 |= 0x20;
133 118
134 for (i=0; i < 20; i++) 119 smsc_delay();
135 ;
136 } 120 }
137 P6 |= 0x10; 121 P6 |= 0x10;
138 } else { 122 } else {
139 P6 &= ~0x10; 123 P6 &= ~0x10;
140 if (smscVer < 4) { 124 if (smsc_ver < 4) {
141 P6 &= ~0x04; 125 P6 &= ~0x04;
142 P10 &= ~0x20; 126 P10 &= ~0x20;
143 } 127 }
@@ -355,7 +339,7 @@ bool usb_detect(void)
355 current_status = (GPIO1_READ & 0x80)?true:false; 339 current_status = (GPIO1_READ & 0x80)?true:false;
356#endif 340#endif
357#ifdef USB_GMINISTYLE 341#ifdef USB_GMINISTYLE
358 current_status = (P5 & 0x80)?true:false; 342 current_status = (P5 & 0x10)?true:false;
359#endif 343#endif
360 return current_status; 344 return current_status;
361} 345}