summaryrefslogtreecommitdiffstats
path: root/firmware/target/mips/ingenic_jz47xx/onda_vx767
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 /firmware/target/mips/ingenic_jz47xx/onda_vx767
parent7fc6bbb304425287b50e7a423ecdebd26e164948 (diff)
downloadrockbox-98a53f0287a9eba03247f44667d84f659299aeef.tar.gz
rockbox-98a53f0287a9eba03247f44667d84f659299aeef.tar.bz2
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
Diffstat (limited to 'firmware/target/mips/ingenic_jz47xx/onda_vx767')
-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
4 files changed, 133 insertions, 81 deletions
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 @@
-/***************************************************************************
- * __________ __ ___.
- * 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 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 @@
#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 0000000000..67c6a90631
--- /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 */
+ }
+}