diff options
Diffstat (limited to 'firmware/target/mips/ingenic_x1000/usb-x1000.c')
-rw-r--r-- | firmware/target/mips/ingenic_x1000/usb-x1000.c | 26 |
1 files changed, 8 insertions, 18 deletions
diff --git a/firmware/target/mips/ingenic_x1000/usb-x1000.c b/firmware/target/mips/ingenic_x1000/usb-x1000.c index 32413b0b94..1cedac4fa7 100644 --- a/firmware/target/mips/ingenic_x1000/usb-x1000.c +++ b/firmware/target/mips/ingenic_x1000/usb-x1000.c | |||
@@ -29,20 +29,9 @@ | |||
29 | #include "x1000/cpm.h" | 29 | #include "x1000/cpm.h" |
30 | 30 | ||
31 | #ifdef FIIO_M3K | 31 | #ifdef FIIO_M3K |
32 | # define USB_DETECT_PORT GPIO_B | 32 | # define USB_DETECT_PIN_INT GPIOB11 // TODO remove me |
33 | # define USB_DETECT_PIN (1 << 11) | ||
34 | # define USB_DETECT_PIN_INT GPIOB11 | ||
35 | # define USB_ID_PORT GPIO_B | ||
36 | # define USB_ID_PIN (1 << 7) | ||
37 | #else | ||
38 | # ifndef USB_NONE | ||
39 | # error "please add USB GPIO pins" | ||
40 | # endif | ||
41 | #endif | 33 | #endif |
42 | 34 | ||
43 | #define USB_DRVVBUS_PORT GPIO_B | ||
44 | #define USB_DRVVBUS_PIN (1 << 25) | ||
45 | |||
46 | /* | 35 | /* |
47 | * USB-Designware driver API | 36 | * USB-Designware driver API |
48 | */ | 37 | */ |
@@ -165,7 +154,8 @@ static volatile int usb_status = USB_EXTRACTED; | |||
165 | 154 | ||
166 | static int __usb_detect(void) | 155 | static int __usb_detect(void) |
167 | { | 156 | { |
168 | if(REG_GPIO_PIN(USB_DETECT_PORT) & USB_DETECT_PIN) | 157 | /* XXX: Do we need an active level define for this? */ |
158 | if(gpio_get_level(GPIO_USB_DETECT)) | ||
169 | return USB_INSERTED; | 159 | return USB_INSERTED; |
170 | else | 160 | else |
171 | return USB_EXTRACTED; | 161 | return USB_EXTRACTED; |
@@ -183,7 +173,7 @@ void usb_init_device(void) | |||
183 | { | 173 | { |
184 | /* Disable drvvbus pin -- it is only used when acting as a host, | 174 | /* Disable drvvbus pin -- it is only used when acting as a host, |
185 | * which Rockbox does not support */ | 175 | * which Rockbox does not support */ |
186 | gpio_config(USB_DRVVBUS_PORT, USB_DRVVBUS_PIN, GPIO_OUTPUT(0)); | 176 | gpio_set_function(GPIO_USB_DRVVBUS, GPIOF_OUTPUT(0)); |
187 | 177 | ||
188 | /* Power up the core clocks to allow writing | 178 | /* Power up the core clocks to allow writing |
189 | to some registers needed to power it down */ | 179 | to some registers needed to power it down */ |
@@ -194,9 +184,9 @@ void usb_init_device(void) | |||
194 | #ifdef USB_STATUS_BY_EVENT | 184 | #ifdef USB_STATUS_BY_EVENT |
195 | /* Setup USB detect pin IRQ */ | 185 | /* Setup USB detect pin IRQ */ |
196 | usb_status = __usb_detect(); | 186 | usb_status = __usb_detect(); |
197 | int level = (REG_GPIO_PIN(USB_DETECT_PORT) & USB_DETECT_PIN) ? 1 : 0; | 187 | gpio_set_function(GPIO_USB_DETECT, GPIOF_IRQ_EDGE(1)); |
198 | gpio_config(USB_DETECT_PORT, USB_DETECT_PIN, GPIO_IRQ_EDGE(level ? 0 : 1)); | 188 | gpio_flip_edge_irq(GPIO_USB_DETECT); |
199 | gpio_enable_irq(USB_DETECT_PORT, USB_DETECT_PIN); | 189 | gpio_enable_irq(GPIO_USB_DETECT); |
200 | #endif | 190 | #endif |
201 | } | 191 | } |
202 | 192 | ||
@@ -215,7 +205,7 @@ void USB_DETECT_PIN_INT(void) | |||
215 | { | 205 | { |
216 | /* Update status and flip the IRQ trigger edge */ | 206 | /* Update status and flip the IRQ trigger edge */ |
217 | usb_status = __usb_detect(); | 207 | usb_status = __usb_detect(); |
218 | REG_GPIO_PAT0(USB_DETECT_PORT) ^= USB_DETECT_PIN; | 208 | gpio_flip_edge_irq(GPIO_USB_DETECT); |
219 | 209 | ||
220 | /* Notify Rockbox of event */ | 210 | /* Notify Rockbox of event */ |
221 | usb_status_event(usb_status); | 211 | usb_status_event(usb_status); |