summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaurus Cuelenaere <mcuelenaere@gmail.com>2009-03-09 21:26:39 +0000
committerMaurus Cuelenaere <mcuelenaere@gmail.com>2009-03-09 21:26:39 +0000
commit98a53f0287a9eba03247f44667d84f659299aeef (patch)
treee57b6ad7cb6bc80c4a15f43081e95d4fcd073943
parent7fc6bbb304425287b50e7a423ecdebd26e164948 (diff)
downloadrockbox-98a53f0287a9eba03247f44667d84f659299aeef.tar.gz
rockbox-98a53f0287a9eba03247f44667d84f659299aeef.zip
* Onda VX767: fix some redundant files + add some missing functions for apps/ compilation (still needs keymap though).
* Add Onda VX767 SADC driver * Unify Onda VX747(+) and Onda VX767 backlight driver * Also be more consistent wrt file naming. * Add speaker-onda_vx747.c to SOURCES (forgot to commit this) git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20259 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/SOURCES10
-rw-r--r--firmware/export/config-ondavx747.h2
-rw-r--r--firmware/export/config-ondavx767.h19
-rw-r--r--firmware/target/mips/ingenic_jz47xx/debug-jz4740.c11
-rw-r--r--firmware/target/mips/ingenic_jz47xx/lcd-jz4740.c2
-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.c80
-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.c127
10 files changed, 163 insertions, 95 deletions
diff --git a/firmware/SOURCES b/firmware/SOURCES
index 1ee2979f22..05de8582cd 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -1242,14 +1242,16 @@ drivers/nand_id.c
1242#endif 1242#endif
1243 1243
1244#if defined(ONDA_VX747) || defined(ONDA_VX747P) 1244#if defined(ONDA_VX747) || defined(ONDA_VX747P)
1245target/mips/ingenic_jz47xx/onda_vx747/backlight-onda_vx747.c 1245target/mips/ingenic_jz47xx/onda_vx747/backlight-onda_vx7X7.c
1246target/mips/ingenic_jz47xx/onda_vx747/lcd-onda_vx747.c 1246target/mips/ingenic_jz47xx/onda_vx747/lcd-onda_vx747.c
1247target/mips/ingenic_jz47xx/onda_vx747/sadc-onda_vx747.c 1247target/mips/ingenic_jz47xx/onda_vx747/sadc-onda_vx747.c
1248target/mips/ingenic_jz47xx/onda_vx747/power-onda_vx747.c 1248target/mips/ingenic_jz47xx/onda_vx747/power-onda_vx747.c
1249target/mips/ingenic_jz47xx/onda_vx747/speaker-onda_vx747.c
1249#endif 1250#endif
1250 1251
1251#ifdef ONDA_VX767 1252#ifdef ONDA_VX767
1252target/mips/ingenic_jz47xx/onda_vx767/backlight-ondavx767.c 1253target/mips/ingenic_jz47xx/onda_vx747/backlight-onda_vx7X7.c
1253target/mips/ingenic_jz47xx/onda_vx767/button-ondavx767.c 1254target/mips/ingenic_jz47xx/onda_vx767/button-onda_vx767.c
1254target/mips/ingenic_jz47xx/onda_vx767/lcd-ondavx767.c 1255target/mips/ingenic_jz47xx/onda_vx767/lcd-onda_vx767.c
1256target/mips/ingenic_jz47xx/onda_vx767/sadc-onda_vx767.c
1255#endif 1257#endif
diff --git a/firmware/export/config-ondavx747.h b/firmware/export/config-ondavx747.h
index 491dab4f60..1849064251 100644
--- a/firmware/export/config-ondavx747.h
+++ b/firmware/export/config-ondavx747.h
@@ -61,7 +61,7 @@
61#define HAVE_TAGCACHE 61#define HAVE_TAGCACHE
62 62
63/* define this if the target has volume keys which can be used in the lists */ 63/* define this if the target has volume keys which can be used in the lists */
64#define HAVE_VOLUME_IN_LIST 64//#define HAVE_VOLUME_IN_LIST
65 65
66/* LCD dimensions */ 66/* LCD dimensions */
67#define CONFIG_LCD LCD_ONDAVX747 67#define CONFIG_LCD LCD_ONDAVX747
diff --git a/firmware/export/config-ondavx767.h b/firmware/export/config-ondavx767.h
index 1f481432f2..a0500a7aa5 100644
--- a/firmware/export/config-ondavx767.h
+++ b/firmware/export/config-ondavx767.h
@@ -37,7 +37,7 @@
37//#define HAVE_HOTSWAP 37//#define HAVE_HOTSWAP
38 38
39//#define CONFIG_STORAGE (STORAGE_NAND | STORAGE_SD) 39//#define CONFIG_STORAGE (STORAGE_NAND | STORAGE_SD)
40#define CONFIG_STORAGE STORAGE_RAMDISK /* Multivolume currently handled at firmware/target/ level */ 40#define CONFIG_STORAGE STORAGE_SD /* Multivolume currently handled at firmware/target/ level */
41 41
42#define CONFIG_NAND NAND_CC 42#define CONFIG_NAND NAND_CC
43 43
@@ -93,7 +93,7 @@
93#define DEFAULT_DIMNESS_SETTING 22 93#define DEFAULT_DIMNESS_SETTING 22
94 94
95/* Define this if you have a software controlled poweroff */ 95/* Define this if you have a software controlled poweroff */
96//#define HAVE_SW_POWEROFF 96#define HAVE_SW_POWEROFF
97 97
98/* The number of bytes reserved for loadable codecs */ 98/* The number of bytes reserved for loadable codecs */
99#define CODEC_SIZE 0x100000 99#define CODEC_SIZE 0x100000
@@ -101,8 +101,11 @@
101/* The number of bytes reserved for loadable plugins */ 101/* The number of bytes reserved for loadable plugins */
102#define PLUGIN_BUFFER_SIZE 0x100000 102#define PLUGIN_BUFFER_SIZE 0x100000
103 103
104/* Define this if you have the */ 104/* Define this if you have the Jz4740 internal codec */
105//#define HAVE_INGENIC_CODEC 105#define HAVE_JZ4740_CODEC
106
107/* Define this if you have a speaker */
108//#define HAVE_SPEAKER
106 109
107#define CONFIG_I2C I2C_JZ47XX 110#define CONFIG_I2C I2C_JZ47XX
108 111
@@ -123,7 +126,7 @@
123 126
124#ifndef SIMULATOR 127#ifndef SIMULATOR
125 128
126/* Define this if you have a Ingenic JZ4732 */ 129/* Define this if you have a Ingenic JZ4740 */
127#define CONFIG_CPU JZ4732 130#define CONFIG_CPU JZ4732
128 131
129/* define this if the hardware can be powered off while charging */ 132/* define this if the hardware can be powered off while charging */
@@ -150,6 +153,7 @@
150 153
151/* Define this if you have adjustable CPU frequency */ 154/* Define this if you have adjustable CPU frequency */
152/* #define HAVE_ADJUSTABLE_CPU_FREQ */ 155/* #define HAVE_ADJUSTABLE_CPU_FREQ */
156#define CPUFREQ_NORMAL 336000000 /* CPU clock: 336 MHz */
153 157
154#define BOOTFILE_EXT "vx767" 158#define BOOTFILE_EXT "vx767"
155#define BOOTFILE "rockbox." BOOTFILE_EXT 159#define BOOTFILE "rockbox." BOOTFILE_EXT
@@ -157,8 +161,9 @@
157 161
158#define CONFIG_USBOTG USBOTG_JZ4740 162#define CONFIG_USBOTG USBOTG_JZ4740
159#define HAVE_USBSTACK 163#define HAVE_USBSTACK
160#define USB_VENDOR_ID 0x07C4 164#define USE_ROCKBOX_USB
161#define USB_PRODUCT_ID 0xA4A5 165#define USB_VENDOR_ID 0x07C4
166#define USB_PRODUCT_ID 0xA4A5
162#define USB_NUM_ENDPOINTS 3 167#define USB_NUM_ENDPOINTS 3
163/* This needs to be 2048 byte aligned, but USB_QHARRAY_ATTR should take care 168/* This needs to be 2048 byte aligned, but USB_QHARRAY_ATTR should take care
164 * of that */ 169 * of that */
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
151bool __dbg_hw_info(void) 151bool __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
30static 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
54bool _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}
65void _backlight_on(void)
66{
67 set_backlight(300, 7);
68}
69void _backlight_off(void)
70{
71 set_backlight(300, 0);
72}
73
74#ifdef HAVE_BACKLIGHT_BRIGHTNESS
75void _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
212void 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
36static volatile unsigned short bat_val;
37static struct mutex battery_mtx;
38
39const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] =
40{
41 /* TODO */
42 1000
43};
44
45const 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 */
52const 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 */
59const 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] */
69unsigned 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
92void 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 */
113void 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}