diff options
Diffstat (limited to 'firmware/target/mips')
3 files changed, 17 insertions, 87 deletions
diff --git a/firmware/target/mips/ingenic_jz47xx/onda_vx747/usb-target.h b/firmware/target/mips/ingenic_jz47xx/onda_vx747/usb-target.h index 12210dfbaa..392de9d1f0 100644 --- a/firmware/target/mips/ingenic_jz47xx/onda_vx747/usb-target.h +++ b/firmware/target/mips/ingenic_jz47xx/onda_vx747/usb-target.h | |||
@@ -1,42 +1,2 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2008 by Maurus Cuelenaere | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #ifndef __USB_TARGET_H | ||
23 | #define __USB_TARGET_H | ||
24 | |||
25 | #include "config.h" | ||
26 | |||
27 | #define GPIO_UDC_DETE (32 * 3 + 28) /* A18 = ADP_CHK */ | ||
28 | #define IRQ_GPIO_UDC_DETE (IRQ_GPIO_0 + GPIO_UDC_DETE) | ||
29 | #define USB_GPIO_IRQ GPIO124 | ||
30 | |||
31 | #define USB_INIT_GPIO() \ | ||
32 | { \ | ||
33 | REG_GPIO_PXPES(3) = 0x10000000; \ | ||
34 | __gpio_as_irq_rise_edge(GPIO_UDC_DETE); \ | ||
35 | } | ||
36 | |||
37 | #define USB_DRV_CONNECTED() (__gpio_get_pin(GPIO_UDC_DETE) == 1) | ||
38 | |||
39 | /* Connect by events, not by tick polling */ | 1 | /* Connect by events, not by tick polling */ |
40 | #define USB_STATUS_BY_EVENT | 2 | #define USB_STATUS_BY_EVENT |
41 | |||
42 | #endif | ||
diff --git a/firmware/target/mips/ingenic_jz47xx/onda_vx767/usb-target.h b/firmware/target/mips/ingenic_jz47xx/onda_vx767/usb-target.h index 44793f0dae..e69de29bb2 100644 --- a/firmware/target/mips/ingenic_jz47xx/onda_vx767/usb-target.h +++ b/firmware/target/mips/ingenic_jz47xx/onda_vx767/usb-target.h | |||
@@ -1,40 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2008 by Maurus Cuelenaere | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #ifndef __USB_TARGET_H | ||
23 | #define __USB_TARGET_H | ||
24 | |||
25 | #include "config.h" | ||
26 | |||
27 | #define GPIO_UDC_DETE (32 * 3 + 28) | ||
28 | #define IRQ_GPIO_UDC_DETE (IRQ_GPIO_0 + GPIO_UDC_DETE) | ||
29 | |||
30 | #define USB_INIT_GPIO() \ | ||
31 | { \ | ||
32 | REG_GPIO_PXFUNS(3) = 0x10000000; \ | ||
33 | REG_GPIO_PXSELS(3) = 0x10000000; \ | ||
34 | REG_GPIO_PXPES(3) = 0x10000000; \ | ||
35 | __gpio_as_input(GPIO_UDC_DETE); \ | ||
36 | } | ||
37 | |||
38 | #define USB_DRV_CONNECTED() (__gpio_get_pin(GPIO_UDC_DETE) == 1) | ||
39 | |||
40 | #endif | ||
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 | ||