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.zip
rockbox-98a53f0287a9eba03247f44667d84f659299aeef.tar.gz
rockbox-98a53f0287a9eba03247f44667d84f659299aeef.tar.bz2
rockbox-98a53f0287a9eba03247f44667d84f659299aeef.tar.xz
* 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 1ee2979..05de858 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -1242,14 +1242,16 @@ drivers/nand_id.c
#endif
#if defined(ONDA_VX747) || defined(ONDA_VX747P)
-target/mips/ingenic_jz47xx/onda_vx747/backlight-onda_vx747.c
+target/mips/ingenic_jz47xx/onda_vx747/backlight-onda_vx7X7.c
target/mips/ingenic_jz47xx/onda_vx747/lcd-onda_vx747.c
target/mips/ingenic_jz47xx/onda_vx747/sadc-onda_vx747.c
target/mips/ingenic_jz47xx/onda_vx747/power-onda_vx747.c
+target/mips/ingenic_jz47xx/onda_vx747/speaker-onda_vx747.c
#endif
#ifdef ONDA_VX767
-target/mips/ingenic_jz47xx/onda_vx767/backlight-ondavx767.c
-target/mips/ingenic_jz47xx/onda_vx767/button-ondavx767.c
-target/mips/ingenic_jz47xx/onda_vx767/lcd-ondavx767.c
+target/mips/ingenic_jz47xx/onda_vx747/backlight-onda_vx7X7.c
+target/mips/ingenic_jz47xx/onda_vx767/button-onda_vx767.c
+target/mips/ingenic_jz47xx/onda_vx767/lcd-onda_vx767.c
+target/mips/ingenic_jz47xx/onda_vx767/sadc-onda_vx767.c
#endif
diff --git a/firmware/export/config-ondavx747.h b/firmware/export/config-ondavx747.h
index 491dab4..1849064 100644
--- a/firmware/export/config-ondavx747.h
+++ b/firmware/export/config-ondavx747.h
@@ -61,7 +61,7 @@
#define HAVE_TAGCACHE
/* define this if the target has volume keys which can be used in the lists */
-#define HAVE_VOLUME_IN_LIST
+//#define HAVE_VOLUME_IN_LIST
/* LCD dimensions */
#define CONFIG_LCD LCD_ONDAVX747
diff --git a/firmware/export/config-ondavx767.h b/firmware/export/config-ondavx767.h
index 1f48143..a0500a7 100644
--- a/firmware/export/config-ondavx767.h
+++ b/firmware/export/config-ondavx767.h
@@ -37,7 +37,7 @@
//#define HAVE_HOTSWAP
//#define CONFIG_STORAGE (STORAGE_NAND | STORAGE_SD)
-#define CONFIG_STORAGE STORAGE_RAMDISK /* Multivolume currently handled at firmware/target/ level */
+#define CONFIG_STORAGE STORAGE_SD /* Multivolume currently handled at firmware/target/ level */
#define CONFIG_NAND NAND_CC
@@ -93,7 +93,7 @@
#define DEFAULT_DIMNESS_SETTING 22
/* Define this if you have a software controlled poweroff */
-//#define HAVE_SW_POWEROFF
+#define HAVE_SW_POWEROFF
/* The number of bytes reserved for loadable codecs */
#define CODEC_SIZE 0x100000
@@ -101,8 +101,11 @@
/* The number of bytes reserved for loadable plugins */
#define PLUGIN_BUFFER_SIZE 0x100000
-/* Define this if you have the */
-//#define HAVE_INGENIC_CODEC
+/* Define this if you have the Jz4740 internal codec */
+#define HAVE_JZ4740_CODEC
+
+/* Define this if you have a speaker */
+//#define HAVE_SPEAKER
#define CONFIG_I2C I2C_JZ47XX
@@ -123,7 +126,7 @@
#ifndef SIMULATOR
-/* Define this if you have a Ingenic JZ4732 */
+/* Define this if you have a Ingenic JZ4740 */
#define CONFIG_CPU JZ4732
/* define this if the hardware can be powered off while charging */
@@ -150,6 +153,7 @@
/* Define this if you have adjustable CPU frequency */
/* #define HAVE_ADJUSTABLE_CPU_FREQ */
+#define CPUFREQ_NORMAL 336000000 /* CPU clock: 336 MHz */
#define BOOTFILE_EXT "vx767"
#define BOOTFILE "rockbox." BOOTFILE_EXT
@@ -157,8 +161,9 @@
#define CONFIG_USBOTG USBOTG_JZ4740
#define HAVE_USBSTACK
-#define USB_VENDOR_ID 0x07C4
-#define USB_PRODUCT_ID 0xA4A5
+#define USE_ROCKBOX_USB
+#define USB_VENDOR_ID 0x07C4
+#define USB_PRODUCT_ID 0xA4A5
#define USB_NUM_ENDPOINTS 3
/* This needs to be 2048 byte aligned, but USB_QHARRAY_ATTR should take care
* of that */
diff --git a/firmware/target/mips/ingenic_jz47xx/debug-jz4740.c b/firmware/target/mips/ingenic_jz47xx/debug-jz4740.c
index 7b0b74e..9d61c09 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)
bool __dbg_hw_info(void)
{
- int btn = 0, touch;
+ int btn = 0;
+#ifdef HAVE_TOUCHSCREEN
+ int touch;
+#endif
struct tm *cur_time;
lcd_setfont(FONT_SYSFIXED);
@@ -160,9 +163,13 @@ bool __dbg_hw_info(void)
line = 0;
display_clocks();
display_enabled_clocks();
+#ifdef HAVE_TOUCHSCREEN
btn = button_read_device(&touch);
- cur_time = get_time();
printf("X: %d Y: %d BTN: 0x%X", touch>>16, touch&0xFFFF, btn);
+#else
+ btn = button_read_device();
+#endif
+ cur_time = get_time();
printf("%02d/%02d/%04d %02d:%02d:%02d", cur_time->tm_mday,
cur_time->tm_mon, cur_time->tm_year, cur_time->tm_hour,
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 071adbd..3d93fea 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)
if(state)
{
lcd_on();
+#ifdef HAVE_LCD_ENABLE
lcd_call_enable_hook();
+#endif
}
else
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 eec4876..eec4876 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 9deab77..0000000
--- a/firmware/target/mips/ingenic_jz47xx/onda_vx767/backlight-ondavx767.c
+++ /dev/null
@@ -1,80 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2008 by Maurus Cuelenaere
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- ****************************************************************************/
-
-#include "config.h"
-#include "jz4740.h"
-#include "backlight-target.h"
-
-#define GPIO_PWM 123
-#define PWM_CHN 7
-#define PWM_FULL 101
-
-static void set_backlight(int unk, int val)
-{
- if(val == 0)
- __gpio_as_pwm7();
- else
- {
- REG_TCU_TCSR(7) |= 2;
- REG_TCU_TCSR(7) &= ~0x100;
- int tmp;
- tmp = (unk/2 + __cpm_get_rtcclk()) / unk;
- if(tmp > 0xFFFF)
- tmp = 0xFFFF;
-
- __tcu_set_half_data(7, (tmp * unk * 1374389535) >> 5);
- __tcu_set_full_data(7, tmp);
-
- REG_TCU_TSCR = (1 << 7);
- REG_TCU_TESR = (1 << 7);
-
- __tcu_enable_pwm_output(7);
- }
- __tcu_set_count(7, 0);
-}
-
-bool _backlight_init(void)
-{
- __gpio_as_pwm7();
-
- __tcu_stop_counter(7);
- __tcu_disable_pwm_output(7);
-
- set_backlight(300, 7);
-
- return true;
-}
-void _backlight_on(void)
-{
- set_backlight(300, 7);
-}
-void _backlight_off(void)
-{
- set_backlight(300, 0);
-}
-
-#ifdef HAVE_BACKLIGHT_BRIGHTNESS
-void _backlight_set_brightness(int brightness)
-{
- (void)brightness;
- return;
-}
-#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 d98df9c..d98df9c 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 c8288a4..3cf2586 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 @@
#include "jz4740.h"
#include "lcd-target.h"
-#define PIN_CS_N (32*1+17) /* Chip select */
+#define PIN_CS_N (32*1+17) /* Chip select */
#define PIN_RESET_N (32*1+18) /* Reset */
#define PIN_UNK_N (32*2+19)
@@ -208,3 +208,8 @@ void lcd_off(void)
{
_display_off();
}
+
+void lcd_set_contrast(int val)
+{
+ (void)val;
+}
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 0000000..67c6a90
--- /dev/null
+++ b/firmware/target/mips/ingenic_jz47xx/onda_vx767/sadc-onda_vx767.c
@@ -0,0 +1,127 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2009 by Maurus Cuelenaere
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#include "config.h"
+#include "system.h"
+#include "jz4740.h"
+#include "powermgmt.h"
+#include "kernel.h"
+#include "logf.h"
+
+#define SADC_CFG_INIT ( \
+ (2 << SADC_CFG_CLKOUT_NUM_BIT) | \
+ (1 << SADC_CFG_CLKDIV_BIT) | \
+ SADC_CFG_PBAT_HIGH | \
+ SADC_CFG_CMD_INT_PEN \
+ )
+
+static volatile unsigned short bat_val;
+static struct mutex battery_mtx;
+
+const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] =
+{
+ /* TODO */
+ 1000
+};
+
+const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
+{
+ /* TODO */
+ 900
+};
+
+/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
+const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
+{
+ /* TODO */
+ { 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000 },
+};
+
+/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */
+const unsigned short percent_to_volt_charge[11] =
+{
+ /* TODO */
+ 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000
+};
+
+/* VBAT = (BDATA/4096) * 7.5V */
+#define BATTERY_SCALE_FACTOR 1875
+
+/* Returns battery voltage from ADC [millivolts] */
+unsigned int battery_adc_voltage(void)
+{
+ unsigned int dummy, timeout=HZ/4;
+
+ mutex_lock(&battery_mtx);
+
+ dummy = REG_SADC_BATDAT;
+ dummy = REG_SADC_BATDAT;
+
+ REG_SADC_ENA |= SADC_ENA_PBATEN;
+ bat_val = 0;
+
+ /* primitive wakeup event */
+ while(bat_val == 0 && timeout--)
+ sleep(0);
+
+ logf("%d %d", bat_val, (bat_val*BATTERY_SCALE_FACTOR)>>10);
+
+ mutex_unlock(&battery_mtx);
+
+ return (bat_val*BATTERY_SCALE_FACTOR)>>10;
+}
+
+void adc_init(void)
+{
+ __cpm_start_sadc();
+ REG_SADC_ENA = 0;
+ REG_SADC_STATE &= ~REG_SADC_STATE;
+ REG_SADC_CTRL = 0x1F;
+
+ REG_SADC_CFG = SADC_CFG_INIT;
+
+ system_enable_irq(IRQ_SADC);
+
+ REG_SADC_SAMETIME = 10;
+ REG_SADC_WAITTIME = 100;
+ REG_SADC_STATE &= ~REG_SADC_STATE;
+ REG_SADC_CTRL = ~SADC_CTRL_PBATRDYM;
+ REG_SADC_ENA = 0;
+
+ mutex_init(&battery_mtx);
+}
+
+/* Interrupt handler */
+void SADC(void)
+{
+ unsigned char state;
+ unsigned char sadcstate;
+
+ sadcstate = REG_SADC_STATE;
+ state = REG_SADC_STATE & (~REG_SADC_CTRL);
+ REG_SADC_STATE &= sadcstate;
+
+ if(state & SADC_CTRL_PBATRDYM)
+ {
+ bat_val = REG_SADC_BATDAT;
+ /* Battery AD IRQ */
+ }
+}