summaryrefslogtreecommitdiff
path: root/firmware/target/mips/ingenic_jz47xx
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/mips/ingenic_jz47xx')
-rwxr-xr-x[-rw-r--r--]firmware/target/mips/ingenic_jz47xx/onda_vx747/sadc-onda_vx747.c27
-rwxr-xr-x[-rw-r--r--]firmware/target/mips/ingenic_jz47xx/onda_vx767/usb-target.h20
2 files changed, 34 insertions, 13 deletions
diff --git a/firmware/target/mips/ingenic_jz47xx/onda_vx747/sadc-onda_vx747.c b/firmware/target/mips/ingenic_jz47xx/onda_vx747/sadc-onda_vx747.c
index 2624eb3d82..1aa98819fe 100644..100755
--- a/firmware/target/mips/ingenic_jz47xx/onda_vx747/sadc-onda_vx747.c
+++ b/firmware/target/mips/ingenic_jz47xx/onda_vx747/sadc-onda_vx747.c
@@ -27,11 +27,22 @@
27#include "powermgmt.h" 27#include "powermgmt.h"
28#include "kernel.h" 28#include "kernel.h"
29 29
30#ifdef ONDA_VX747
30#define BTN_OFF (1 << 29) 31#define BTN_OFF (1 << 29)
31#define BTN_VOL_DOWN (1 << 27) 32#define BTN_VOL_DOWN (1 << 27)
32#define BTN_HOLD (1 << 16) 33#define BTN_HOLD (1 << 16)
33#define BTN_MENU (1 << 1) 34#define BTN_MENU (1 << 1)
34#define BTN_VOL_UP (1 << 0) 35#define BTN_VOL_UP (1 << 0)
36#elif defined(ONDA_VX747P)
37#define BTN_OFF (1 << 29)
38#define BTN_VOL_DOWN (1 << 27)
39#define BTN_HOLD (1 << 22) /* on REG_GPIO_PXPIN(2) */
40#define BTN_MENU (1 << 20)
41#define BTN_VOL_UP (1 << 19)
42#else
43#error No buttons defined!
44#endif
45
35#define BTN_MASK (BTN_OFF | BTN_VOL_DOWN | \ 46#define BTN_MASK (BTN_OFF | BTN_VOL_DOWN | \
36 BTN_MENU | BTN_VOL_UP) 47 BTN_MENU | BTN_VOL_UP)
37 48
@@ -130,11 +141,19 @@ void button_init_device(void)
130 REG_SADC_CTRL = (~(SADC_CTRL_PENDM | SADC_CTRL_PENUM | SADC_CTRL_TSRDYM | SADC_CTRL_PBATRDYM)); 141 REG_SADC_CTRL = (~(SADC_CTRL_PENDM | SADC_CTRL_PENUM | SADC_CTRL_TSRDYM | SADC_CTRL_PBATRDYM));
131 REG_SADC_ENA = (SADC_ENA_TSEN | SADC_ENA_PBATEN); 142 REG_SADC_ENA = (SADC_ENA_TSEN | SADC_ENA_PBATEN);
132 143
144#ifdef ONDA_VX747
133 __gpio_as_input(32*3 + 29); 145 __gpio_as_input(32*3 + 29);
134 __gpio_as_input(32*3 + 27); 146 __gpio_as_input(32*3 + 27);
135 __gpio_as_input(32*3 + 16); 147 __gpio_as_input(32*3 + 16);
136 __gpio_as_input(32*3 + 1); 148 __gpio_as_input(32*3 + 1);
137 __gpio_as_input(32*3 + 0); 149 __gpio_as_input(32*3 + 0);
150#elif defined(ONDA_VX747P)
151 __gpio_as_input(32*3 + 29);
152 __gpio_as_input(32*3 + 27);
153 __gpio_as_input(32*3 + 20);
154 __gpio_as_input(32*3 + 19);
155 __gpio_as_input(32*2 + 22);
156#endif
138 157
139 mutex_init(&battery_mtx); 158 mutex_init(&battery_mtx);
140} 159}
@@ -173,7 +192,13 @@ int button_read_device(int *data)
173 int ret = 0, tmp; 192 int ret = 0, tmp;
174 193
175 /* Filter button events out if HOLD button is pressed at firmware/ level */ 194 /* Filter button events out if HOLD button is pressed at firmware/ level */
176 if((~REG_GPIO_PXPIN(3)) & BTN_HOLD) 195 if(
196#ifdef ONDA_VX747
197 (~REG_GPIO_PXPIN(3)) & BTN_HOLD
198#elif defined(ONDA_VX747P)
199 (~REG_GPIO_PXPIN(2)) & BTN_HOLD
200#endif
201 )
177 return 0; 202 return 0;
178 203
179 tmp = (~REG_GPIO_PXPIN(3)) & BTN_MASK; 204 tmp = (~REG_GPIO_PXPIN(3)) & BTN_MASK;
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 c681bdaa12..887d7415d0 100644..100755
--- a/firmware/target/mips/ingenic_jz47xx/onda_vx767/usb-target.h
+++ b/firmware/target/mips/ingenic_jz47xx/onda_vx767/usb-target.h
@@ -24,23 +24,19 @@
24 24
25#include "config.h" 25#include "config.h"
26 26
27#define __gpio_as_usb_detect() \
28do { \
29 REG_GPIO_PXFUNS(3) = 0x10000000; \
30 REG_GPIO_PXSELS(3) = 0x10000000; \
31 REG_GPIO_PXPES(3) = 0x10000000; \
32} while (0)
33
34#define GPIO_UDC_DETE (32 * 3 + 28) 27#define GPIO_UDC_DETE (32 * 3 + 28)
35#define IRQ_GPIO_UDC_DETE (IRQ_GPIO_0 + GPIO_UDC_DETE) 28#define IRQ_GPIO_UDC_DETE (IRQ_GPIO_0 + GPIO_UDC_DETE)
36 29
37static inline void usb_init_gpio(void) 30#define USB_INIT_GPIO() \
38{ 31{ \
39 __gpio_as_usb_detect(); 32 REG_GPIO_PXFUNS(3) = 0x10000000; \
40 system_enable_irq(IRQ_UDC); 33 REG_GPIO_PXSELS(3) = 0x10000000; \
41 __gpio_as_input(GPIO_UDC_DETE); 34 REG_GPIO_PXPES(3) = 0x10000000; \
35 __gpio_as_input(GPIO_UDC_DETE); \
42} 36}
43 37
38#define USB_DRV_CONNECTED() (__gpio_get_pin(GPIO_UDC_DETE) == 1)
39
44int usb_detect(void); 40int usb_detect(void);
45void usb_init_device(void); 41void usb_init_device(void);
46bool usb_drv_connected(void); 42bool usb_drv_connected(void);