From 0709f0a5c60b5525ff98708887f5f1e5b0b570c2 Mon Sep 17 00:00:00 2001 From: Maurus Cuelenaere Date: Mon, 14 Jul 2008 15:03:10 +0000 Subject: Add preliminary support for the Onda VX747 (MIPS target) git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18032 a1c6a512-1295-4272-9138-f99709370657 --- .../mips/ingenic_jz47xx/onda_vx747/adc-target.h | 28 +++ .../onda_vx747/backlight-onda_vx747.c | 80 ++++++++ .../ingenic_jz47xx/onda_vx747/backlight-target.h | 37 ++++ .../ingenic_jz47xx/onda_vx747/button-onda_vx747.c | 123 +++++++++++++ .../mips/ingenic_jz47xx/onda_vx747/button-target.h | 69 +++++++ .../ingenic_jz47xx/onda_vx747/lcd-onda_vx747.c | 201 +++++++++++++++++++++ .../mips/ingenic_jz47xx/onda_vx747/lcd-target.h | 36 ++++ .../mips/ingenic_jz47xx/onda_vx747/usb-target.h | 26 +++ 8 files changed, 600 insertions(+) create mode 100755 firmware/target/mips/ingenic_jz47xx/onda_vx747/adc-target.h create mode 100755 firmware/target/mips/ingenic_jz47xx/onda_vx747/backlight-onda_vx747.c create mode 100755 firmware/target/mips/ingenic_jz47xx/onda_vx747/backlight-target.h create mode 100755 firmware/target/mips/ingenic_jz47xx/onda_vx747/button-onda_vx747.c create mode 100755 firmware/target/mips/ingenic_jz47xx/onda_vx747/button-target.h create mode 100755 firmware/target/mips/ingenic_jz47xx/onda_vx747/lcd-onda_vx747.c create mode 100755 firmware/target/mips/ingenic_jz47xx/onda_vx747/lcd-target.h create mode 100755 firmware/target/mips/ingenic_jz47xx/onda_vx747/usb-target.h (limited to 'firmware/target/mips/ingenic_jz47xx/onda_vx747') diff --git a/firmware/target/mips/ingenic_jz47xx/onda_vx747/adc-target.h b/firmware/target/mips/ingenic_jz47xx/onda_vx747/adc-target.h new file mode 100755 index 0000000000..e74f008a3e --- /dev/null +++ b/firmware/target/mips/ingenic_jz47xx/onda_vx747/adc-target.h @@ -0,0 +1,28 @@ +/*************************************************************************** + * __________ __ ___. + * 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. + * + ****************************************************************************/ +#ifndef _ADC_TARGET_H_ +#define _ADC_TARGET_H_ + +#define NUM_ADC_CHANNELS 4 + +#define ADC_BUTTONS 0 + +#endif /* _ADC_TARGET_H_ */ 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 new file mode 100755 index 0000000000..9deab7712a --- /dev/null +++ b/firmware/target/mips/ingenic_jz47xx/onda_vx747/backlight-onda_vx747.c @@ -0,0 +1,80 @@ +/*************************************************************************** + * __________ __ ___. + * 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_vx747/backlight-target.h b/firmware/target/mips/ingenic_jz47xx/onda_vx747/backlight-target.h new file mode 100755 index 0000000000..4170f96cc0 --- /dev/null +++ b/firmware/target/mips/ingenic_jz47xx/onda_vx747/backlight-target.h @@ -0,0 +1,37 @@ +/*************************************************************************** + * __________ __ ___. + * 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. + * + ****************************************************************************/ +#ifndef BACKLIGHT_TARGET_H +#define BACKLIGHT_TARGET_H + +#ifdef BOOTLOADER +#define BACKLIGHT_DRIVER_CLOSE +/* Force the whole driver to be built */ +#define BACKLIGHT_FULL_INIT +#endif + +#include + +bool _backlight_init(void); +void _backlight_on(void); +void _backlight_off(void); +void _backlight_set_brightness(int brightness); + +#endif /* BACKLIGHT_TARGET_H */ diff --git a/firmware/target/mips/ingenic_jz47xx/onda_vx747/button-onda_vx747.c b/firmware/target/mips/ingenic_jz47xx/onda_vx747/button-onda_vx747.c new file mode 100755 index 0000000000..e42325bcb3 --- /dev/null +++ b/firmware/target/mips/ingenic_jz47xx/onda_vx747/button-onda_vx747.c @@ -0,0 +1,123 @@ +/*************************************************************************** + * __________ __ ___. + * 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 "button-target.h" + +#define BTN_VOL_DOWN (1 << 27) +#define BTN_VOL_UP (1 << 0) +#define BTN_MENU (1 << 1) +#define BTN_OFF (1 << 29) +#define BTN_HOLD (1 << 16) +#define BTN_MASK (BTN_VOL_DOWN | BTN_VOL_UP \ + | BTN_MENU | BTN_OFF ) + +#define SADC_CFG_INIT ( \ + (2 << SADC_CFG_CLKOUT_NUM_BIT) | \ + SADC_CFG_XYZ1Z2 | \ + SADC_CFG_SNUM_5 | \ + (1 << SADC_CFG_CLKDIV_BIT) | \ + SADC_CFG_PBAT_HIGH | \ + SADC_CFG_CMD_INT_PEN ) + +bool button_hold(void) +{ + return (REG_GPIO_PXPIN(3) ^ BTN_HOLD ? 1 : 0); +} + +void button_init_device(void) +{ + REG_SADC_ENA = 0; + REG_SADC_STATE &= (~REG_SADC_STATE); + REG_SADC_CTRL = 0x1f; + + __cpm_start_sadc(); + REG_SADC_CFG = SADC_CFG_INIT; + + REG_SADC_SAMETIME = 1; + REG_SADC_WAITTIME = 1000; //per 100 HZ + REG_SADC_STATE &= (~REG_SADC_STATE); + REG_SADC_CTRL &= (~(SADC_CTRL_PENDM | SADC_CTRL_TSRDYM)); + REG_SADC_ENA = SADC_ENA_TSEN; // | REG_SADC_ENA;//SADC_ENA_TSEN | SADC_ENA_PBATEN | SADC_ENA_SADCINEN; +} + +static int touch_to_pixels(short x, short y) +{ + /* X:300 -> 3800 Y:300->3900 */ + x -= 300; + y -= 300; + + x /= 3200 / LCD_WIDTH; + y /= 3600 / LCD_HEIGHT; + + return (x << 16) | y; +} + +int button_read_device(int *data) +{ + unsigned int key = ~REG_GPIO_PXPIN(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_MENU) + ret |= BUTTON_MENU; + if(key & BTN_OFF) + ret |= BUTTON_POWER; + } + + if(REG_SADC_STATE & (SADC_CTRL_TSRDYM|SADC_STATE_PEND)) + { + if(REG_SADC_STATE & SADC_CTRL_PENDM) + { + REG_SADC_CTRL &= (~(SADC_CTRL_PENUM | SADC_CTRL_TSRDYM)); + REG_SADC_CTRL |= (SADC_CTRL_PENDM); + unsigned int dat; + unsigned short xData,yData; + short tsz1Data,tsz2Data; + + dat = REG_SADC_TSDAT; + + xData = (dat >> 0) & 0xfff; + yData = (dat >> 16) & 0xfff; + + dat = REG_SADC_TSDAT; + tsz1Data = (dat >> 0) & 0xfff; + tsz2Data = (dat >> 16) & 0xfff; + + *data = touch_to_pixels(xData, yData); + + tsz1Data = tsz2Data - tsz1Data; + } + REG_SADC_STATE = 0; + //__intc_unmask_irq(IRQ_SADC); + } + + return ret; +} +void button_set_touch_available(void) +{ + return; +} diff --git a/firmware/target/mips/ingenic_jz47xx/onda_vx747/button-target.h b/firmware/target/mips/ingenic_jz47xx/onda_vx747/button-target.h new file mode 100755 index 0000000000..23ce386cb1 --- /dev/null +++ b/firmware/target/mips/ingenic_jz47xx/onda_vx747/button-target.h @@ -0,0 +1,69 @@ +/*************************************************************************** + * __________ __ ___. + * 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. + * + ****************************************************************************/ +#ifndef BUTTON_TARGET_H +#define BUTTON_TARGET_H + + +#include +#include "config.h" + +#define HAS_BUTTON_HOLD + +bool button_hold(void); +void button_init_device(void); +int button_read_device(int *data); +void button_set_touch_available(void); + +/* Main unit's buttons */ +#define BUTTON_POWER 0x00000001 +#define BUTTON_VOL_UP 0x00000002 +#define BUTTON_VOL_DOWN 0x00000004 +#define BUTTON_MENU 0x00000008 + +/* Compatibility hacks for flipping. Needs a somewhat better fix. */ +#define BUTTON_LEFT BUTTON_MIDLEFT +#define BUTTON_RIGHT BUTTON_MIDRIGHT +#define BUTTON_UP BUTTON_TOPMIDDLE +#define BUTTON_DOWN BUTTON_BOTTOMMIDDLE + +/* Touchpad Screen Area Buttons */ +#define BUTTON_TOPLEFT 0x00000010 +#define BUTTON_TOPMIDDLE 0x00000020 +#define BUTTON_TOPRIGHT 0x00000040 +#define BUTTON_MIDLEFT 0x00000080 +#define BUTTON_CENTER 0x00000100 +#define BUTTON_MIDRIGHT 0x00000200 +#define BUTTON_BOTTOMLEFT 0x00000400 +#define BUTTON_BOTTOMMIDDLE 0x00000800 +#define BUTTON_BOTTOMRIGHT 0x00001000 + +#define BUTTON_TOUCH 0x00002000 + +#define BUTTON_MAIN 0x3FFF + +/* No remote */ +#define BUTTON_REMOTE 0 + +/* Software power-off */ +#define POWEROFF_BUTTON BUTTON_POWER +#define POWEROFF_COUNT 10 + +#endif /* BUTTON_TARGET_H */ diff --git a/firmware/target/mips/ingenic_jz47xx/onda_vx747/lcd-onda_vx747.c b/firmware/target/mips/ingenic_jz47xx/onda_vx747/lcd-onda_vx747.c new file mode 100755 index 0000000000..d46cee6884 --- /dev/null +++ b/firmware/target/mips/ingenic_jz47xx/onda_vx747/lcd-onda_vx747.c @@ -0,0 +1,201 @@ +/*************************************************************************** + * __________ __ ___. + * 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 my__gpio_as_lcd_16bit() \ +do { \ + REG_GPIO_PXFUNS(2) = 0x001cffff; \ + REG_GPIO_PXSELC(2) = 0x001cffff; \ + REG_GPIO_PXPES(2) = 0x001cffff; \ +} while (0) + + +#define SLEEP(x) for(i=0; i 0x1ff ) + { + //printf("CPM_LPCDR too large, set it to 0x1ff\n"); + val = 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_on(); +} + +void lcd_set_target(short x, short y, short width, short height) +{ + SLCD_SEND_COMMAND(0x210, y); /* y_start */ + SLCD_SEND_COMMAND(0x211, y+height); /* y_end */ + SLCD_SEND_COMMAND(0x212, x); /* x_start */ + SLCD_SEND_COMMAND(0x213, x+width); /* x_end */ + SLCD_SEND_COMMAND(0x200, x); /* set cursor at x_start */ + SLCD_SEND_COMMAND(0x201, y); /* set cursor at y_start */ + SLCD_SET_COMMAND(0x202); /* write data? */ +} + +void lcd_on(void) +{ + _display_on(); +} + +void lcd_off(void) +{ + return; +} diff --git a/firmware/target/mips/ingenic_jz47xx/onda_vx747/lcd-target.h b/firmware/target/mips/ingenic_jz47xx/onda_vx747/lcd-target.h new file mode 100755 index 0000000000..e643608d56 --- /dev/null +++ b/firmware/target/mips/ingenic_jz47xx/onda_vx747/lcd-target.h @@ -0,0 +1,36 @@ +/*************************************************************************** + * __________ __ ___. + * 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. + * + ****************************************************************************/ +#ifndef LCD_TARGET_H +#define LCD_TARGET_H + +#include + +void lcd_enable(bool state); +bool lcd_enabled(void); +void lcd_init_device(void); + + +void lcd_init_controller(void); +void lcd_set_target(short x, short y, short width, short height); +void lcd_on(void); +void lcd_off(void); + +#endif /* LCD_TARGET_H */ diff --git a/firmware/target/mips/ingenic_jz47xx/onda_vx747/usb-target.h b/firmware/target/mips/ingenic_jz47xx/onda_vx747/usb-target.h new file mode 100755 index 0000000000..30893aaaa3 --- /dev/null +++ b/firmware/target/mips/ingenic_jz47xx/onda_vx747/usb-target.h @@ -0,0 +1,26 @@ +/*************************************************************************** + * __________ __ ___. + * 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. + * + ****************************************************************************/ +#ifndef USB_TARGET_H +#define USB_TARGET_H + +void usb_init_device(void); + +#endif -- cgit v1.2.3