From 98a53f0287a9eba03247f44667d84f659299aeef Mon Sep 17 00:00:00 2001 From: Maurus Cuelenaere Date: Mon, 9 Mar 2009 21:26:39 +0000 Subject: * 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 --- firmware/target/mips/ingenic_jz47xx/debug-jz4740.c | 11 +- firmware/target/mips/ingenic_jz47xx/lcd-jz4740.c | 2 + .../onda_vx747/backlight-onda_vx747.c | 163 ---------------- .../onda_vx747/backlight-onda_vx7X7.c | 163 ++++++++++++++++ .../onda_vx767/backlight-ondavx767.c | 80 -------- .../ingenic_jz47xx/onda_vx767/button-onda_vx767.c | 85 ++++++++ .../ingenic_jz47xx/onda_vx767/button-ondavx767.c | 85 -------- .../ingenic_jz47xx/onda_vx767/lcd-onda_vx767.c | 215 +++++++++++++++++++++ .../mips/ingenic_jz47xx/onda_vx767/lcd-ondavx767.c | 210 -------------------- .../ingenic_jz47xx/onda_vx767/sadc-onda_vx767.c | 127 ++++++++++++ 10 files changed, 601 insertions(+), 540 deletions(-) delete mode 100644 firmware/target/mips/ingenic_jz47xx/onda_vx747/backlight-onda_vx747.c create mode 100644 firmware/target/mips/ingenic_jz47xx/onda_vx747/backlight-onda_vx7X7.c delete mode 100644 firmware/target/mips/ingenic_jz47xx/onda_vx767/backlight-ondavx767.c create mode 100644 firmware/target/mips/ingenic_jz47xx/onda_vx767/button-onda_vx767.c delete mode 100644 firmware/target/mips/ingenic_jz47xx/onda_vx767/button-ondavx767.c create mode 100644 firmware/target/mips/ingenic_jz47xx/onda_vx767/lcd-onda_vx767.c delete mode 100644 firmware/target/mips/ingenic_jz47xx/onda_vx767/lcd-ondavx767.c create mode 100644 firmware/target/mips/ingenic_jz47xx/onda_vx767/sadc-onda_vx767.c (limited to 'firmware/target/mips/ingenic_jz47xx') 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) 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 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) 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_vx747.c deleted file mode 100644 index eec48768b2..0000000000 --- a/firmware/target/mips/ingenic_jz47xx/onda_vx747/backlight-onda_vx747.c +++ /dev/null @@ -1,163 +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" - -/* PWM_CHN7 == GPIO(32*3 + 31) */ -#define BACKLIGHT_GPIO (32*3+31) -#define BACKLIGHT_PWM 7 - -#define SW_PWM 1 - -#if SW_PWM - -static bool backlight_on; - -static void set_backlight(int val) -{ - (void)val; -} - -bool _backlight_init(void) -{ - __gpio_as_output(BACKLIGHT_GPIO); - __gpio_set_pin(BACKLIGHT_GPIO); - - backlight_on = true; - - return true; -} - -bool backlight_enabled(void) -{ - return backlight_on; -} - -void _backlight_on(void) -{ - __gpio_set_pin(BACKLIGHT_GPIO); - backlight_on = true; -} - -void _backlight_off(void) -{ - __gpio_clear_pin(BACKLIGHT_GPIO); - backlight_on = false; -} - -#else - -static int old_val; -static void set_backlight(int val) -{ - if(val == old_val) - return; - - /* Taken from the OF */ - int tmp; - tmp = (val/2 + __cpm_get_rtcclk()) / val; - if(tmp > 0xFFFF) - tmp = 0xFFFF; - - __tcu_set_half_data(BACKLIGHT_PWM, (tmp * val * 1374389535) >> 5); - __tcu_set_full_data(BACKLIGHT_PWM, tmp); - - old_val = val; -} - -static void set_backlight_on(void) -{ - if(old_val == MAX_BRIGHTNESS_SETTING) - return; - - __tcu_start_timer_clock(BACKLIGHT_PWM); - - set_backlight(MAX_BRIGHTNESS_SETTING); - - __tcu_set_count(BACKLIGHT_PWM, 0); - __tcu_start_counter(BACKLIGHT_PWM); - - __tcu_enable_pwm_output(BACKLIGHT_PWM); -} - -static void set_backlight_off(void) -{ - __tcu_stop_counter(BACKLIGHT_PWM); - __tcu_disable_pwm_output(BACKLIGHT_PWM); - __tcu_stop_timer_clock(BACKLIGHT_PWM); - - old_val = -1; -} - -bool _backlight_init(void) -{ - __gpio_as_pwm(BACKLIGHT_PWM); - __tcu_start_timer_clock(BACKLIGHT_PWM); - - __tcu_stop_counter(BACKLIGHT_PWM); - __tcu_disable_pwm_output(BACKLIGHT_PWM); - - __tcu_init_pwm_output_low(BACKLIGHT_PWM); - __tcu_select_rtcclk(BACKLIGHT_PWM); - __tcu_select_clk_div1(BACKLIGHT_PWM); - - __tcu_mask_half_match_irq(BACKLIGHT_PWM); - __tcu_mask_full_match_irq(BACKLIGHT_PWM); - - old_val = -1; - - set_backlight_on(); - - return true; -} - -bool backlight_enabled(void) -{ - return old_val > -1 ? true : false; -} - -void _backlight_on(void) -{ - set_backlight_on(); -} - -void _backlight_off(void) -{ - set_backlight_off(); -} -#endif /* !SW_PWM */ - -#ifdef HAVE_BACKLIGHT_BRIGHTNESS -void _backlight_set_brightness(int brightness) -{ - set_backlight(brightness); -} -#endif - -#ifdef HAVE_LCD_SLEEP -/* Turn off LED supply */ -void _backlight_lcd_sleep(void) -{ - set_backlight_off(); -} -#endif diff --git a/firmware/target/mips/ingenic_jz47xx/onda_vx747/backlight-onda_vx7X7.c b/firmware/target/mips/ingenic_jz47xx/onda_vx747/backlight-onda_vx7X7.c new file mode 100644 index 0000000000..eec48768b2 --- /dev/null +++ b/firmware/target/mips/ingenic_jz47xx/onda_vx747/backlight-onda_vx7X7.c @@ -0,0 +1,163 @@ +/*************************************************************************** + * __________ __ ___. + * 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" + +/* PWM_CHN7 == GPIO(32*3 + 31) */ +#define BACKLIGHT_GPIO (32*3+31) +#define BACKLIGHT_PWM 7 + +#define SW_PWM 1 + +#if SW_PWM + +static bool backlight_on; + +static void set_backlight(int val) +{ + (void)val; +} + +bool _backlight_init(void) +{ + __gpio_as_output(BACKLIGHT_GPIO); + __gpio_set_pin(BACKLIGHT_GPIO); + + backlight_on = true; + + return true; +} + +bool backlight_enabled(void) +{ + return backlight_on; +} + +void _backlight_on(void) +{ + __gpio_set_pin(BACKLIGHT_GPIO); + backlight_on = true; +} + +void _backlight_off(void) +{ + __gpio_clear_pin(BACKLIGHT_GPIO); + backlight_on = false; +} + +#else + +static int old_val; +static void set_backlight(int val) +{ + if(val == old_val) + return; + + /* Taken from the OF */ + int tmp; + tmp = (val/2 + __cpm_get_rtcclk()) / val; + if(tmp > 0xFFFF) + tmp = 0xFFFF; + + __tcu_set_half_data(BACKLIGHT_PWM, (tmp * val * 1374389535) >> 5); + __tcu_set_full_data(BACKLIGHT_PWM, tmp); + + old_val = val; +} + +static void set_backlight_on(void) +{ + if(old_val == MAX_BRIGHTNESS_SETTING) + return; + + __tcu_start_timer_clock(BACKLIGHT_PWM); + + set_backlight(MAX_BRIGHTNESS_SETTING); + + __tcu_set_count(BACKLIGHT_PWM, 0); + __tcu_start_counter(BACKLIGHT_PWM); + + __tcu_enable_pwm_output(BACKLIGHT_PWM); +} + +static void set_backlight_off(void) +{ + __tcu_stop_counter(BACKLIGHT_PWM); + __tcu_disable_pwm_output(BACKLIGHT_PWM); + __tcu_stop_timer_clock(BACKLIGHT_PWM); + + old_val = -1; +} + +bool _backlight_init(void) +{ + __gpio_as_pwm(BACKLIGHT_PWM); + __tcu_start_timer_clock(BACKLIGHT_PWM); + + __tcu_stop_counter(BACKLIGHT_PWM); + __tcu_disable_pwm_output(BACKLIGHT_PWM); + + __tcu_init_pwm_output_low(BACKLIGHT_PWM); + __tcu_select_rtcclk(BACKLIGHT_PWM); + __tcu_select_clk_div1(BACKLIGHT_PWM); + + __tcu_mask_half_match_irq(BACKLIGHT_PWM); + __tcu_mask_full_match_irq(BACKLIGHT_PWM); + + old_val = -1; + + set_backlight_on(); + + return true; +} + +bool backlight_enabled(void) +{ + return old_val > -1 ? true : false; +} + +void _backlight_on(void) +{ + set_backlight_on(); +} + +void _backlight_off(void) +{ + set_backlight_off(); +} +#endif /* !SW_PWM */ + +#ifdef HAVE_BACKLIGHT_BRIGHTNESS +void _backlight_set_brightness(int brightness) +{ + set_backlight(brightness); +} +#endif + +#ifdef HAVE_LCD_SLEEP +/* Turn off LED supply */ +void _backlight_lcd_sleep(void) +{ + set_backlight_off(); +} +#endif 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-onda_vx767.c b/firmware/target/mips/ingenic_jz47xx/onda_vx767/button-onda_vx767.c new file mode 100644 index 0000000000..d98df9c42d --- /dev/null +++ b/firmware/target/mips/ingenic_jz47xx/onda_vx767/button-onda_vx767.c @@ -0,0 +1,85 @@ +/*************************************************************************** + * __________ __ ___. + * 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 "system.h" +#include "jz4740.h" +#include "button-target.h" + +#define BTN_VOL_DOWN ((1 << 27) | (1 << 21) | (1 << 30)) +#define BTN_VOL_UP (1 << 0) +#define BTN_MENU (1 << 3) +#define BTN_BACK (1 << 4) +#define BTN_SELECT (1 << 29) +#define BTN_REWIND (1 << 1) +#define BTN_FAST_FWD (1 << 2) +#define BTN_HOLD (1 << 31) /* Unknown currently */ +#define BTN_MASK (BTN_VOL_DOWN | BTN_VOL_UP | BTN_MENU \ + | BTN_BACK | BTN_SELECT | BTN_REWIND \ + | BTN_FAST_FWD) + +bool button_hold(void) +{ + return (~__gpio_get_port(3) & BTN_HOLD ? 1 : 0); +} + +void button_init_device(void) +{ + __gpio_port_as_input(3, 30); + __gpio_port_as_input(3, 21); + __gpio_port_as_input(3, 27); + __gpio_port_as_input(3, 0); + __gpio_port_as_input(3, 3); + __gpio_port_as_input(3, 4); + __gpio_port_as_input(3, 29); + __gpio_port_as_input(3, 1); + __gpio_port_as_input(3, 2); + /* __gpio_port_as_input(3, 31); */ +} + +int button_read_device(void) +{ + if(button_hold()) + return 0; + + unsigned int key = ~(__gpio_get_port(3)); + int ret = 0; + + if(key & BTN_MASK) + { + if(key & BTN_VOL_DOWN) + ret |= BUTTON_VOL_DOWN; + if(key & BTN_VOL_UP) + ret |= BUTTON_VOL_UP; + if(key & BTN_SELECT) + ret |= BUTTON_SELECT; + if(key & BTN_MENU) + ret |= BUTTON_MENU; + if(key & BTN_BACK) + ret |= BUTTON_BACK; + if(key & BTN_REWIND) + ret |= BUTTON_REWIND; + if(key & BTN_FAST_FWD) + ret |= BUTTON_FAST_FWD; + } + + return ret; +} diff --git a/firmware/target/mips/ingenic_jz47xx/onda_vx767/button-ondavx767.c b/firmware/target/mips/ingenic_jz47xx/onda_vx767/button-ondavx767.c deleted file mode 100644 index d98df9c42d..0000000000 --- a/firmware/target/mips/ingenic_jz47xx/onda_vx767/button-ondavx767.c +++ /dev/null @@ -1,85 +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 "system.h" -#include "jz4740.h" -#include "button-target.h" - -#define BTN_VOL_DOWN ((1 << 27) | (1 << 21) | (1 << 30)) -#define BTN_VOL_UP (1 << 0) -#define BTN_MENU (1 << 3) -#define BTN_BACK (1 << 4) -#define BTN_SELECT (1 << 29) -#define BTN_REWIND (1 << 1) -#define BTN_FAST_FWD (1 << 2) -#define BTN_HOLD (1 << 31) /* Unknown currently */ -#define BTN_MASK (BTN_VOL_DOWN | BTN_VOL_UP | BTN_MENU \ - | BTN_BACK | BTN_SELECT | BTN_REWIND \ - | BTN_FAST_FWD) - -bool button_hold(void) -{ - return (~__gpio_get_port(3) & BTN_HOLD ? 1 : 0); -} - -void button_init_device(void) -{ - __gpio_port_as_input(3, 30); - __gpio_port_as_input(3, 21); - __gpio_port_as_input(3, 27); - __gpio_port_as_input(3, 0); - __gpio_port_as_input(3, 3); - __gpio_port_as_input(3, 4); - __gpio_port_as_input(3, 29); - __gpio_port_as_input(3, 1); - __gpio_port_as_input(3, 2); - /* __gpio_port_as_input(3, 31); */ -} - -int button_read_device(void) -{ - if(button_hold()) - return 0; - - unsigned int key = ~(__gpio_get_port(3)); - int ret = 0; - - if(key & BTN_MASK) - { - if(key & BTN_VOL_DOWN) - ret |= BUTTON_VOL_DOWN; - if(key & BTN_VOL_UP) - ret |= BUTTON_VOL_UP; - if(key & BTN_SELECT) - ret |= BUTTON_SELECT; - if(key & BTN_MENU) - ret |= BUTTON_MENU; - if(key & BTN_BACK) - ret |= BUTTON_BACK; - if(key & BTN_REWIND) - ret |= BUTTON_REWIND; - if(key & BTN_FAST_FWD) - ret |= BUTTON_FAST_FWD; - } - - return ret; -} diff --git a/firmware/target/mips/ingenic_jz47xx/onda_vx767/lcd-onda_vx767.c b/firmware/target/mips/ingenic_jz47xx/onda_vx767/lcd-onda_vx767.c new file mode 100644 index 0000000000..3cf2586d46 --- /dev/null +++ b/firmware/target/mips/ingenic_jz47xx/onda_vx767/lcd-onda_vx767.c @@ -0,0 +1,215 @@ +/*************************************************************************** + * __________ __ ___. + * 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 "lcd-target.h" + +#define PIN_CS_N (32*1+17) /* Chip select */ +#define PIN_RESET_N (32*1+18) /* Reset */ +#define PIN_UNK_N (32*2+19) + +#define my__gpio_as_lcd_16bit() \ +do { \ + REG_GPIO_PXFUNS(2) = 0x0014ffff; \ + REG_GPIO_PXSELC(2) = 0x0014ffff; \ + REG_GPIO_PXPES(2) = 0x0014ffff; \ +} while (0) + + +#define SLEEP(x) for(i=0; i 0x1ff ) + val = 0x1ff; /* CPM_LPCDR is too large, set it to 0x1ff */ + __cpm_set_pixdiv(val); + __cpm_start_lcd(); +} + +void lcd_init_controller(void) +{ + int i; + _display_pin_init(); + _set_lcd_bus(); + _set_lcd_clock(); + SLEEP(1000); + _display_init(); +} + +void lcd_set_target(short x, short y, short width, short height) +{ + SLCD_SEND_COMMAND(0x50, y); + SLCD_SEND_COMMAND(0x51, y+height-1); + SLCD_SEND_COMMAND(0x52, x); + SLCD_SEND_COMMAND(0x53, x+width-1); + /* TODO */ + + __gpio_clear_pin(PIN_UNK_N); + SLCD_SET_COMMAND(0x22); + WAIT_ON_SLCD; + __gpio_set_pin(PIN_UNK_N); +} + +void lcd_on(void) +{ + _display_on(); +} + +void lcd_off(void) +{ + _display_off(); +} + +void lcd_set_contrast(int val) +{ + (void)val; +} diff --git a/firmware/target/mips/ingenic_jz47xx/onda_vx767/lcd-ondavx767.c b/firmware/target/mips/ingenic_jz47xx/onda_vx767/lcd-ondavx767.c deleted file mode 100644 index c8288a4450..0000000000 --- a/firmware/target/mips/ingenic_jz47xx/onda_vx767/lcd-ondavx767.c +++ /dev/null @@ -1,210 +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 "lcd-target.h" - -#define PIN_CS_N (32*1+17) /* Chip select */ -#define PIN_RESET_N (32*1+18) /* Reset */ -#define PIN_UNK_N (32*2+19) - -#define my__gpio_as_lcd_16bit() \ -do { \ - REG_GPIO_PXFUNS(2) = 0x0014ffff; \ - REG_GPIO_PXSELC(2) = 0x0014ffff; \ - REG_GPIO_PXPES(2) = 0x0014ffff; \ -} while (0) - - -#define SLEEP(x) for(i=0; i 0x1ff ) - val = 0x1ff; /* CPM_LPCDR is too large, set it to 0x1ff */ - __cpm_set_pixdiv(val); - __cpm_start_lcd(); -} - -void lcd_init_controller(void) -{ - int i; - _display_pin_init(); - _set_lcd_bus(); - _set_lcd_clock(); - SLEEP(1000); - _display_init(); -} - -void lcd_set_target(short x, short y, short width, short height) -{ - SLCD_SEND_COMMAND(0x50, y); - SLCD_SEND_COMMAND(0x51, y+height-1); - SLCD_SEND_COMMAND(0x52, x); - SLCD_SEND_COMMAND(0x53, x+width-1); - /* TODO */ - - __gpio_clear_pin(PIN_UNK_N); - SLCD_SET_COMMAND(0x22); - WAIT_ON_SLCD; - __gpio_set_pin(PIN_UNK_N); -} - -void lcd_on(void) -{ - _display_on(); -} - -void lcd_off(void) -{ - _display_off(); -} 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 */ + } +} -- cgit v1.2.3