diff options
Diffstat (limited to 'firmware/target/mips/ingenic_jz47xx/usb-jz4740.c')
-rw-r--r-- | firmware/target/mips/ingenic_jz47xx/usb-jz4740.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/firmware/target/mips/ingenic_jz47xx/usb-jz4740.c b/firmware/target/mips/ingenic_jz47xx/usb-jz4740.c index a615d3d4da..fcc14706f3 100644 --- a/firmware/target/mips/ingenic_jz47xx/usb-jz4740.c +++ b/firmware/target/mips/ingenic_jz47xx/usb-jz4740.c | |||
@@ -577,19 +577,29 @@ void usb_drv_stall(int endpoint, bool stall, bool in) | |||
577 | } | 577 | } |
578 | } | 578 | } |
579 | 579 | ||
580 | bool usb_drv_connected(void) | 580 | #define GPIO_UDC_DETE (32 * 3 + 28) /* A18 = ADP_CHK */ |
581 | { | 581 | #define IRQ_GPIO_UDC_DETE (IRQ_GPIO_0 + GPIO_UDC_DETE) |
582 | return USB_DRV_CONNECTED(); | 582 | #ifndef ONDA_VX767 |
583 | } | 583 | # define USB_GPIO_IRQ GPIO124 |
584 | #endif | ||
584 | 585 | ||
585 | int usb_detect(void) | 586 | int usb_detect(void) |
586 | { | 587 | { |
587 | return usb_drv_connected() ? USB_INSERTED : USB_EXTRACTED; | 588 | return (__gpio_get_pin(GPIO_UDC_DETE) == 1) |
589 | ? USB_INSERTED : USB_EXTRACTED; | ||
588 | } | 590 | } |
589 | 591 | ||
590 | void usb_init_device(void) | 592 | void usb_init_device(void) |
591 | { | 593 | { |
592 | unsigned int i; | 594 | #ifdef ONDA_VX767 |
595 | REG_GPIO_PXFUNS(3) = 0x10000000; | ||
596 | REG_GPIO_PXSELS(3) = 0x10000000; | ||
597 | REG_GPIO_PXPES(3) = 0x10000000; | ||
598 | __gpio_as_input(GPIO_UDC_DETE); | ||
599 | #else | ||
600 | REG_GPIO_PXPES(3) = 0x10000000; | ||
601 | __gpio_as_irq_rise_edge(GPIO_UDC_DETE); | ||
602 | #endif | ||
593 | 603 | ||
594 | USB_INIT_GPIO(); | 604 | USB_INIT_GPIO(); |
595 | #ifdef USB_GPIO_IRQ | 605 | #ifdef USB_GPIO_IRQ |
@@ -597,7 +607,7 @@ void usb_init_device(void) | |||
597 | #endif | 607 | #endif |
598 | system_enable_irq(IRQ_UDC); | 608 | system_enable_irq(IRQ_UDC); |
599 | 609 | ||
600 | for(i=0; i<TOTAL_EP(); i++) | 610 | for(unsigned i=0; i<TOTAL_EP(); i++) |
601 | semaphore_init(&endpoints[i].complete, 1, 0); | 611 | semaphore_init(&endpoints[i].complete, 1, 0); |
602 | } | 612 | } |
603 | 613 | ||