1
0
Fork 0
forked from len0rd/rockbox

* 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
This commit is contained in:
Maurus Cuelenaere 2009-03-09 21:26:39 +00:00
parent 7fc6bbb304
commit 98a53f0287
10 changed files with 163 additions and 95 deletions

View file

@ -1242,14 +1242,16 @@ drivers/nand_id.c
#endif #endif
#if defined(ONDA_VX747) || defined(ONDA_VX747P) #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/lcd-onda_vx747.c
target/mips/ingenic_jz47xx/onda_vx747/sadc-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/power-onda_vx747.c
target/mips/ingenic_jz47xx/onda_vx747/speaker-onda_vx747.c
#endif #endif
#ifdef ONDA_VX767 #ifdef ONDA_VX767
target/mips/ingenic_jz47xx/onda_vx767/backlight-ondavx767.c target/mips/ingenic_jz47xx/onda_vx747/backlight-onda_vx7X7.c
target/mips/ingenic_jz47xx/onda_vx767/button-ondavx767.c target/mips/ingenic_jz47xx/onda_vx767/button-onda_vx767.c
target/mips/ingenic_jz47xx/onda_vx767/lcd-ondavx767.c target/mips/ingenic_jz47xx/onda_vx767/lcd-onda_vx767.c
target/mips/ingenic_jz47xx/onda_vx767/sadc-onda_vx767.c
#endif #endif

View file

@ -61,7 +61,7 @@
#define HAVE_TAGCACHE #define HAVE_TAGCACHE
/* define this if the target has volume keys which can be used in the lists */ /* 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 */ /* LCD dimensions */
#define CONFIG_LCD LCD_ONDAVX747 #define CONFIG_LCD LCD_ONDAVX747

View file

@ -37,7 +37,7 @@
//#define HAVE_HOTSWAP //#define HAVE_HOTSWAP
//#define CONFIG_STORAGE (STORAGE_NAND | STORAGE_SD) //#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 #define CONFIG_NAND NAND_CC
@ -93,7 +93,7 @@
#define DEFAULT_DIMNESS_SETTING 22 #define DEFAULT_DIMNESS_SETTING 22
/* Define this if you have a software controlled poweroff */ /* 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 */ /* The number of bytes reserved for loadable codecs */
#define CODEC_SIZE 0x100000 #define CODEC_SIZE 0x100000
@ -101,8 +101,11 @@
/* The number of bytes reserved for loadable plugins */ /* The number of bytes reserved for loadable plugins */
#define PLUGIN_BUFFER_SIZE 0x100000 #define PLUGIN_BUFFER_SIZE 0x100000
/* Define this if you have the */ /* Define this if you have the Jz4740 internal codec */
//#define HAVE_INGENIC_CODEC #define HAVE_JZ4740_CODEC
/* Define this if you have a speaker */
//#define HAVE_SPEAKER
#define CONFIG_I2C I2C_JZ47XX #define CONFIG_I2C I2C_JZ47XX
@ -123,7 +126,7 @@
#ifndef SIMULATOR #ifndef SIMULATOR
/* Define this if you have a Ingenic JZ4732 */ /* Define this if you have a Ingenic JZ4740 */
#define CONFIG_CPU JZ4732 #define CONFIG_CPU JZ4732
/* define this if the hardware can be powered off while charging */ /* define this if the hardware can be powered off while charging */
@ -150,6 +153,7 @@
/* Define this if you have adjustable CPU frequency */ /* Define this if you have adjustable CPU frequency */
/* #define HAVE_ADJUSTABLE_CPU_FREQ */ /* #define HAVE_ADJUSTABLE_CPU_FREQ */
#define CPUFREQ_NORMAL 336000000 /* CPU clock: 336 MHz */
#define BOOTFILE_EXT "vx767" #define BOOTFILE_EXT "vx767"
#define BOOTFILE "rockbox." BOOTFILE_EXT #define BOOTFILE "rockbox." BOOTFILE_EXT
@ -157,8 +161,9 @@
#define CONFIG_USBOTG USBOTG_JZ4740 #define CONFIG_USBOTG USBOTG_JZ4740
#define HAVE_USBSTACK #define HAVE_USBSTACK
#define USB_VENDOR_ID 0x07C4 #define USE_ROCKBOX_USB
#define USB_PRODUCT_ID 0xA4A5 #define USB_VENDOR_ID 0x07C4
#define USB_PRODUCT_ID 0xA4A5
#define USB_NUM_ENDPOINTS 3 #define USB_NUM_ENDPOINTS 3
/* This needs to be 2048 byte aligned, but USB_QHARRAY_ATTR should take care /* This needs to be 2048 byte aligned, but USB_QHARRAY_ATTR should take care
* of that */ * of that */

View file

@ -150,7 +150,10 @@ bool __dbg_ports(void)
bool __dbg_hw_info(void) bool __dbg_hw_info(void)
{ {
int btn = 0, touch; int btn = 0;
#ifdef HAVE_TOUCHSCREEN
int touch;
#endif
struct tm *cur_time; struct tm *cur_time;
lcd_setfont(FONT_SYSFIXED); lcd_setfont(FONT_SYSFIXED);
@ -160,9 +163,13 @@ bool __dbg_hw_info(void)
line = 0; line = 0;
display_clocks(); display_clocks();
display_enabled_clocks(); display_enabled_clocks();
#ifdef HAVE_TOUCHSCREEN
btn = button_read_device(&touch); btn = button_read_device(&touch);
cur_time = get_time();
printf("X: %d Y: %d BTN: 0x%X", touch>>16, touch&0xFFFF, btn); 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, 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_mon, cur_time->tm_year, cur_time->tm_hour,
cur_time->tm_min, cur_time->tm_sec); cur_time->tm_min, cur_time->tm_sec);

View file

@ -53,7 +53,9 @@ void lcd_enable(bool state)
if(state) if(state)
{ {
lcd_on(); lcd_on();
#ifdef HAVE_LCD_ENABLE
lcd_call_enable_hook(); lcd_call_enable_hook();
#endif
} }
else else
lcd_off(); lcd_off();

View file

@ -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

View file

@ -23,7 +23,7 @@
#include "jz4740.h" #include "jz4740.h"
#include "lcd-target.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_RESET_N (32*1+18) /* Reset */
#define PIN_UNK_N (32*2+19) #define PIN_UNK_N (32*2+19)
@ -208,3 +208,8 @@ void lcd_off(void)
{ {
_display_off(); _display_off();
} }
void lcd_set_contrast(int val)
{
(void)val;
}

View file

@ -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 */
}
}