diff options
Diffstat (limited to 'firmware/target/mips/ingenic_jz47xx')
-rw-r--r-- | firmware/target/mips/ingenic_jz47xx/debug-jz4740.c | 11 | ||||
-rw-r--r-- | firmware/target/mips/ingenic_jz47xx/lcd-jz4740.c | 2 | ||||
-rw-r--r-- | firmware/target/mips/ingenic_jz47xx/onda_vx747/backlight-onda_vx7X7.c (renamed from firmware/target/mips/ingenic_jz47xx/onda_vx747/backlight-onda_vx747.c) | 0 | ||||
-rw-r--r-- | firmware/target/mips/ingenic_jz47xx/onda_vx767/backlight-ondavx767.c | 80 | ||||
-rw-r--r-- | firmware/target/mips/ingenic_jz47xx/onda_vx767/button-onda_vx767.c (renamed from firmware/target/mips/ingenic_jz47xx/onda_vx767/button-ondavx767.c) | 0 | ||||
-rw-r--r-- | firmware/target/mips/ingenic_jz47xx/onda_vx767/lcd-onda_vx767.c (renamed from firmware/target/mips/ingenic_jz47xx/onda_vx767/lcd-ondavx767.c) | 7 | ||||
-rw-r--r-- | firmware/target/mips/ingenic_jz47xx/onda_vx767/sadc-onda_vx767.c | 127 |
7 files changed, 144 insertions, 83 deletions
diff --git a/firmware/target/mips/ingenic_jz47xx/debug-jz4740.c b/firmware/target/mips/ingenic_jz47xx/debug-jz4740.c index 7b0b74ed0d..9d61c0931b 100644 --- a/firmware/target/mips/ingenic_jz47xx/debug-jz4740.c +++ b/firmware/target/mips/ingenic_jz47xx/debug-jz4740.c | |||
@@ -150,7 +150,10 @@ bool __dbg_ports(void) | |||
150 | 150 | ||
151 | bool __dbg_hw_info(void) | 151 | bool __dbg_hw_info(void) |
152 | { | 152 | { |
153 | int btn = 0, touch; | 153 | int btn = 0; |
154 | #ifdef HAVE_TOUCHSCREEN | ||
155 | int touch; | ||
156 | #endif | ||
154 | struct tm *cur_time; | 157 | struct tm *cur_time; |
155 | 158 | ||
156 | lcd_setfont(FONT_SYSFIXED); | 159 | lcd_setfont(FONT_SYSFIXED); |
@@ -160,9 +163,13 @@ bool __dbg_hw_info(void) | |||
160 | line = 0; | 163 | line = 0; |
161 | display_clocks(); | 164 | display_clocks(); |
162 | display_enabled_clocks(); | 165 | display_enabled_clocks(); |
166 | #ifdef HAVE_TOUCHSCREEN | ||
163 | btn = button_read_device(&touch); | 167 | btn = button_read_device(&touch); |
164 | cur_time = get_time(); | ||
165 | printf("X: %d Y: %d BTN: 0x%X", touch>>16, touch&0xFFFF, btn); | 168 | printf("X: %d Y: %d BTN: 0x%X", touch>>16, touch&0xFFFF, btn); |
169 | #else | ||
170 | btn = button_read_device(); | ||
171 | #endif | ||
172 | cur_time = get_time(); | ||
166 | printf("%02d/%02d/%04d %02d:%02d:%02d", cur_time->tm_mday, | 173 | printf("%02d/%02d/%04d %02d:%02d:%02d", cur_time->tm_mday, |
167 | cur_time->tm_mon, cur_time->tm_year, cur_time->tm_hour, | 174 | cur_time->tm_mon, cur_time->tm_year, cur_time->tm_hour, |
168 | cur_time->tm_min, cur_time->tm_sec); | 175 | cur_time->tm_min, cur_time->tm_sec); |
diff --git a/firmware/target/mips/ingenic_jz47xx/lcd-jz4740.c b/firmware/target/mips/ingenic_jz47xx/lcd-jz4740.c index 071adbd63e..3d93feac04 100644 --- a/firmware/target/mips/ingenic_jz47xx/lcd-jz4740.c +++ b/firmware/target/mips/ingenic_jz47xx/lcd-jz4740.c | |||
@@ -53,7 +53,9 @@ void lcd_enable(bool state) | |||
53 | if(state) | 53 | if(state) |
54 | { | 54 | { |
55 | lcd_on(); | 55 | lcd_on(); |
56 | #ifdef HAVE_LCD_ENABLE | ||
56 | lcd_call_enable_hook(); | 57 | lcd_call_enable_hook(); |
58 | #endif | ||
57 | } | 59 | } |
58 | else | 60 | else |
59 | lcd_off(); | 61 | lcd_off(); |
diff --git a/firmware/target/mips/ingenic_jz47xx/onda_vx747/backlight-onda_vx747.c b/firmware/target/mips/ingenic_jz47xx/onda_vx747/backlight-onda_vx7X7.c index eec48768b2..eec48768b2 100644 --- a/firmware/target/mips/ingenic_jz47xx/onda_vx747/backlight-onda_vx747.c +++ b/firmware/target/mips/ingenic_jz47xx/onda_vx747/backlight-onda_vx7X7.c | |||
diff --git a/firmware/target/mips/ingenic_jz47xx/onda_vx767/backlight-ondavx767.c b/firmware/target/mips/ingenic_jz47xx/onda_vx767/backlight-ondavx767.c deleted file mode 100644 index 9deab7712a..0000000000 --- a/firmware/target/mips/ingenic_jz47xx/onda_vx767/backlight-ondavx767.c +++ /dev/null | |||
@@ -1,80 +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 | #include "config.h" | ||
23 | #include "jz4740.h" | ||
24 | #include "backlight-target.h" | ||
25 | |||
26 | #define GPIO_PWM 123 | ||
27 | #define PWM_CHN 7 | ||
28 | #define PWM_FULL 101 | ||
29 | |||
30 | static void set_backlight(int unk, int val) | ||
31 | { | ||
32 | if(val == 0) | ||
33 | __gpio_as_pwm7(); | ||
34 | else | ||
35 | { | ||
36 | REG_TCU_TCSR(7) |= 2; | ||
37 | REG_TCU_TCSR(7) &= ~0x100; | ||
38 | int tmp; | ||
39 | tmp = (unk/2 + __cpm_get_rtcclk()) / unk; | ||
40 | if(tmp > 0xFFFF) | ||
41 | tmp = 0xFFFF; | ||
42 | |||
43 | __tcu_set_half_data(7, (tmp * unk * 1374389535) >> 5); | ||
44 | __tcu_set_full_data(7, tmp); | ||
45 | |||
46 | REG_TCU_TSCR = (1 << 7); | ||
47 | REG_TCU_TESR = (1 << 7); | ||
48 | |||
49 | __tcu_enable_pwm_output(7); | ||
50 | } | ||
51 | __tcu_set_count(7, 0); | ||
52 | } | ||
53 | |||
54 | bool _backlight_init(void) | ||
55 | { | ||
56 | __gpio_as_pwm7(); | ||
57 | |||
58 | __tcu_stop_counter(7); | ||
59 | __tcu_disable_pwm_output(7); | ||
60 | |||
61 | set_backlight(300, 7); | ||
62 | |||
63 | return true; | ||
64 | } | ||
65 | void _backlight_on(void) | ||
66 | { | ||
67 | set_backlight(300, 7); | ||
68 | } | ||
69 | void _backlight_off(void) | ||
70 | { | ||
71 | set_backlight(300, 0); | ||
72 | } | ||
73 | |||
74 | #ifdef HAVE_BACKLIGHT_BRIGHTNESS | ||
75 | void _backlight_set_brightness(int brightness) | ||
76 | { | ||
77 | (void)brightness; | ||
78 | return; | ||
79 | } | ||
80 | #endif | ||
diff --git a/firmware/target/mips/ingenic_jz47xx/onda_vx767/button-ondavx767.c b/firmware/target/mips/ingenic_jz47xx/onda_vx767/button-onda_vx767.c index d98df9c42d..d98df9c42d 100644 --- a/firmware/target/mips/ingenic_jz47xx/onda_vx767/button-ondavx767.c +++ b/firmware/target/mips/ingenic_jz47xx/onda_vx767/button-onda_vx767.c | |||
diff --git a/firmware/target/mips/ingenic_jz47xx/onda_vx767/lcd-ondavx767.c b/firmware/target/mips/ingenic_jz47xx/onda_vx767/lcd-onda_vx767.c index c8288a4450..3cf2586d46 100644 --- a/firmware/target/mips/ingenic_jz47xx/onda_vx767/lcd-ondavx767.c +++ b/firmware/target/mips/ingenic_jz47xx/onda_vx767/lcd-onda_vx767.c | |||
@@ -23,7 +23,7 @@ | |||
23 | #include "jz4740.h" | 23 | #include "jz4740.h" |
24 | #include "lcd-target.h" | 24 | #include "lcd-target.h" |
25 | 25 | ||
26 | #define PIN_CS_N (32*1+17) /* Chip select */ | 26 | #define PIN_CS_N (32*1+17) /* Chip select */ |
27 | #define PIN_RESET_N (32*1+18) /* Reset */ | 27 | #define PIN_RESET_N (32*1+18) /* Reset */ |
28 | #define PIN_UNK_N (32*2+19) | 28 | #define PIN_UNK_N (32*2+19) |
29 | 29 | ||
@@ -208,3 +208,8 @@ void lcd_off(void) | |||
208 | { | 208 | { |
209 | _display_off(); | 209 | _display_off(); |
210 | } | 210 | } |
211 | |||
212 | void lcd_set_contrast(int val) | ||
213 | { | ||
214 | (void)val; | ||
215 | } | ||
diff --git a/firmware/target/mips/ingenic_jz47xx/onda_vx767/sadc-onda_vx767.c b/firmware/target/mips/ingenic_jz47xx/onda_vx767/sadc-onda_vx767.c new file mode 100644 index 0000000000..67c6a90631 --- /dev/null +++ b/firmware/target/mips/ingenic_jz47xx/onda_vx767/sadc-onda_vx767.c | |||
@@ -0,0 +1,127 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2009 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 | #include "config.h" | ||
23 | #include "system.h" | ||
24 | #include "jz4740.h" | ||
25 | #include "powermgmt.h" | ||
26 | #include "kernel.h" | ||
27 | #include "logf.h" | ||
28 | |||
29 | #define SADC_CFG_INIT ( \ | ||
30 | (2 << SADC_CFG_CLKOUT_NUM_BIT) | \ | ||
31 | (1 << SADC_CFG_CLKDIV_BIT) | \ | ||
32 | SADC_CFG_PBAT_HIGH | \ | ||
33 | SADC_CFG_CMD_INT_PEN \ | ||
34 | ) | ||
35 | |||
36 | static volatile unsigned short bat_val; | ||
37 | static struct mutex battery_mtx; | ||
38 | |||
39 | const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] = | ||
40 | { | ||
41 | /* TODO */ | ||
42 | 1000 | ||
43 | }; | ||
44 | |||
45 | const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] = | ||
46 | { | ||
47 | /* TODO */ | ||
48 | 900 | ||
49 | }; | ||
50 | |||
51 | /* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */ | ||
52 | const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] = | ||
53 | { | ||
54 | /* TODO */ | ||
55 | { 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000 }, | ||
56 | }; | ||
57 | |||
58 | /* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */ | ||
59 | const unsigned short percent_to_volt_charge[11] = | ||
60 | { | ||
61 | /* TODO */ | ||
62 | 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000 | ||
63 | }; | ||
64 | |||
65 | /* VBAT = (BDATA/4096) * 7.5V */ | ||
66 | #define BATTERY_SCALE_FACTOR 1875 | ||
67 | |||
68 | /* Returns battery voltage from ADC [millivolts] */ | ||
69 | unsigned int battery_adc_voltage(void) | ||
70 | { | ||
71 | unsigned int dummy, timeout=HZ/4; | ||
72 | |||
73 | mutex_lock(&battery_mtx); | ||
74 | |||
75 | dummy = REG_SADC_BATDAT; | ||
76 | dummy = REG_SADC_BATDAT; | ||
77 | |||
78 | REG_SADC_ENA |= SADC_ENA_PBATEN; | ||
79 | bat_val = 0; | ||
80 | |||
81 | /* primitive wakeup event */ | ||
82 | while(bat_val == 0 && timeout--) | ||
83 | sleep(0); | ||
84 | |||
85 | logf("%d %d", bat_val, (bat_val*BATTERY_SCALE_FACTOR)>>10); | ||
86 | |||
87 | mutex_unlock(&battery_mtx); | ||
88 | |||
89 | return (bat_val*BATTERY_SCALE_FACTOR)>>10; | ||
90 | } | ||
91 | |||
92 | void adc_init(void) | ||
93 | { | ||
94 | __cpm_start_sadc(); | ||
95 | REG_SADC_ENA = 0; | ||
96 | REG_SADC_STATE &= ~REG_SADC_STATE; | ||
97 | REG_SADC_CTRL = 0x1F; | ||
98 | |||
99 | REG_SADC_CFG = SADC_CFG_INIT; | ||
100 | |||
101 | system_enable_irq(IRQ_SADC); | ||
102 | |||
103 | REG_SADC_SAMETIME = 10; | ||
104 | REG_SADC_WAITTIME = 100; | ||
105 | REG_SADC_STATE &= ~REG_SADC_STATE; | ||
106 | REG_SADC_CTRL = ~SADC_CTRL_PBATRDYM; | ||
107 | REG_SADC_ENA = 0; | ||
108 | |||
109 | mutex_init(&battery_mtx); | ||
110 | } | ||
111 | |||
112 | /* Interrupt handler */ | ||
113 | void SADC(void) | ||
114 | { | ||
115 | unsigned char state; | ||
116 | unsigned char sadcstate; | ||
117 | |||
118 | sadcstate = REG_SADC_STATE; | ||
119 | state = REG_SADC_STATE & (~REG_SADC_CTRL); | ||
120 | REG_SADC_STATE &= sadcstate; | ||
121 | |||
122 | if(state & SADC_CTRL_PBATRDYM) | ||
123 | { | ||
124 | bat_val = REG_SADC_BATDAT; | ||
125 | /* Battery AD IRQ */ | ||
126 | } | ||
127 | } | ||