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 --- firmware/target/mips/ingenic_jz47xx/ata-jz4740.c | 40 ++++ firmware/target/mips/ingenic_jz47xx/boot.lds | 107 +++++++++ firmware/target/mips/ingenic_jz47xx/crt0.S | 246 +++++++++++++++++++++ firmware/target/mips/ingenic_jz47xx/lcd-jz4740.c | 94 ++++++++ .../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 +++ .../target/mips/ingenic_jz47xx/system-jz4740.c | 71 ++++++ .../target/mips/ingenic_jz47xx/system-target.h | 103 +++++++++ 14 files changed, 1261 insertions(+) create mode 100755 firmware/target/mips/ingenic_jz47xx/ata-jz4740.c create mode 100755 firmware/target/mips/ingenic_jz47xx/boot.lds create mode 100755 firmware/target/mips/ingenic_jz47xx/crt0.S create mode 100755 firmware/target/mips/ingenic_jz47xx/lcd-jz4740.c 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 create mode 100755 firmware/target/mips/ingenic_jz47xx/system-jz4740.c create mode 100755 firmware/target/mips/ingenic_jz47xx/system-target.h (limited to 'firmware/target/mips/ingenic_jz47xx') diff --git a/firmware/target/mips/ingenic_jz47xx/ata-jz4740.c b/firmware/target/mips/ingenic_jz47xx/ata-jz4740.c new file mode 100755 index 0000000000..b907bb86df --- /dev/null +++ b/firmware/target/mips/ingenic_jz47xx/ata-jz4740.c @@ -0,0 +1,40 @@ +/*************************************************************************** + * __________ __ ___. + * 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 "ata.h" + +int ata_read_sectors(IF_MV2(int drive,) unsigned long start, int count, void* buf) +{ + (void)start; + (void)count; + (void)buf; + return 0; +} + +int ata_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const void* buf) +{ + (void)start; + (void)count; + (void)buf; + return 0; +} diff --git a/firmware/target/mips/ingenic_jz47xx/boot.lds b/firmware/target/mips/ingenic_jz47xx/boot.lds new file mode 100755 index 0000000000..9bc635afad --- /dev/null +++ b/firmware/target/mips/ingenic_jz47xx/boot.lds @@ -0,0 +1,107 @@ +#include "config.h" +#undef mips + +OUTPUT_FORMAT("elf32-tradlittlemips") +OUTPUT_ARCH(MIPS) +ENTRY(_start) +STARTUP(target/mips/ingenic_jz47xx/crt0.o) + +#define DRAMSIZE (MEMORYSIZE * 0x100000) + +#define DRAMORIG 0x80E00000 /* HACK */ +#define IRAMORIG 0x80000000 +#define IRAMSIZE 16K + +MEMORY +{ + DRAM : ORIGIN = DRAMORIG, LENGTH = DRAMSIZE + IRAM : ORIGIN = IRAMORIG, LENGTH = IRAMSIZE +} + +SECTIONS +{ + . = DRAMORIG; + + .text : { + loadaddress = .; + _loadaddress = .; + *(.init.text); + *(.text*); + *(.glue_7); + *(.glue_7t); + . = ALIGN(0x4); + } > DRAM + + . = ALIGN(4); + + .rodata : + { + *(.rodata); /* problems without this, dunno why */ + *(.rodata*); + *(.rodata.str1.1); + *(.rodata.str1.4); + . = ALIGN(0x4); + + /* Pseudo-allocate the copies of the data sections */ + _datacopy = .; + } > DRAM + + . = ALIGN(4); + + .data : { + *(.icode); + *(.irodata); + *(.idata); + *(.data*); + *(.scommon*); + *(.sdata*); + . = ALIGN(0x4); + _dataend = . ; + } > DRAM + + . = ALIGN(4); + + _gp = ALIGN(16); + .got : { + *(.got*) + }> DRAM + + . = ALIGN(4); + + .stack : + { + *(.stack) + _stackbegin = .; + stackbegin = .; + . += 0x2000; + _stackend = .; + stackend = .; + } > DRAM + + . = ALIGN(4); + + .bss : + { + _edata = .; + *(.sbss*); + *(.bss*); + *(.ibss); + *(COMMON) + _end = .; + } > DRAM + + . = ALIGN(4); + + .vectors IRAMORIG : + { + _vectorsstart = .; + KEEP(*(.resetvectors)); + *(.resetvectors); + KEEP(*(.vectors)); + *(.vectors); + _vectorsend = .; + } AT > DRAM + _vectorscopy = LOADADDR(.vectors); + + . = ALIGN(4); +} diff --git a/firmware/target/mips/ingenic_jz47xx/crt0.S b/firmware/target/mips/ingenic_jz47xx/crt0.S new file mode 100755 index 0000000000..6ac9ad71ab --- /dev/null +++ b/firmware/target/mips/ingenic_jz47xx/crt0.S @@ -0,0 +1,246 @@ +/* + * init.S + * + * Initialization code for JzRISC. + * + * Author: Seeger Chin + * e-mail: seeger.chin@gmail.com + * + * Copyright (C) 2006 Ingenic Semiconductor Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + */ + +#include "config.h" +#include "mips.h" + + .text + + .set mips3 + + .extern main + + .global _start +#ifdef BOOTLOADER + .section .init.text,"ax",%progbits +#else + .section .resetvectors,"ax",%progbits +#endif + .set noreorder + .set noat + +#ifdef BOOTLOADER + .word 0 /* HACK */ + .word 0 /* HACK */ +#endif +_start: + la ra, _start + //---------------------------------------------------- + // init cp0 registers. + //---------------------------------------------------- + mtc0 zero, C0_WATCHLO + mtc0 zero, C0_WATCHHI + + li t0, (M_StatusBEV | M_StatusIM7 | M_StatusIM6 \ + | M_StatusIM5 | M_StatusIM4 | M_StatusIM3 \ + | M_StatusIM2 | M_StatusERL) + // BEV = Enable Boot Exception Vectors + // IMx = Interrupt mask + // ERL = Denotes error level + mtc0 t0, C0_STATUS + + li t1, M_CauseIV + mtc0 t1, C0_CAUSE + + //---------------------------------------------------- + // init caches, assumes a 4way*128set*32byte i/d cache + //---------------------------------------------------- + li t0, 3 // enable cache for kseg0 accesses + mtc0 t0, C0_CONFIG // CONFIG reg + la t0, 0x80000000 // an idx op should use a unmappable address + ori t1, t0, 0x4000 // 16kB cache + mtc0 zero, C0_TAGLO // TAGLO reg + mtc0 zero, C0_TAGHI // TAGHI reg + +_init_cache_loop: + cache 0x8, 0(t0) // index store icache tag + cache 0x9, 0(t0) // index store dcache tag + bne t0, t1, _init_cache_loop + addiu t0, t0, 0x20 // 32 bytes per cache line + nop + + //---------------------------------------------------- + // Invalidate BTB + //---------------------------------------------------- + mfc0 t0, C0_CONFIG + nop + ori t0, 2 + mtc0 t0, C0_CONFIG + nop + + //---------------------------------------------------- + // setup stack, jump to C code + //---------------------------------------------------- + la sp, stackend + la t0, stackbegin + li t1, 0xDEADBEEF + +_init_stack_loop: + sw t1, 0(t0) + bne t0, sp, _init_stack_loop + addiu t0, t0, 4 + + la t0, main + jr t0 + nop + + +#ifndef BOOTLOADER + .section .vectors,"ax",%progbits +#endif + .extern exception_handler + .global except_common_entry + .type except_common_entry,@function +except_common_entry: + la k0, exception_handler + jr k0 + nop + nop + nop + + .extern _int + .extern _exception + .global exception_handler + .type exception_handler,@function + .set noreorder +exception_handler: + + + addiu sp, -0x80 # Add Immediate Unsigned + sw ra, 0(sp) # Store Word + sw fp, 4(sp) # Store Word + sw gp, 8(sp) # Store Word + sw t9, 0xC(sp) # Store Word + sw t8, 0x10(sp) # Store Word + sw s7, 0x14(sp) # Store Word + sw s6, 0x18(sp) # Store Word + sw s5, 0x1C(sp) # Store Word + sw s4, 0x20(sp) # Store Word + sw s3, 0x24(sp) # Store Word + sw s2, 0x28(sp) # Store Word + sw s1, 0x2C(sp) # Store Word + sw s0, 0x30(sp) # Store Word + sw t7, 0x34(sp) # Store Word + sw t6, 0x38(sp) # Store Word + sw t5, 0x3C(sp) # Store Word + sw t4, 0x40(sp) # Store Word + sw t3, 0x44(sp) # Store Word + sw t2, 0x48(sp) # Store Word + sw t1, 0x4C(sp) # Store Word + sw t0, 0x50(sp) # Store Word + sw a3, 0x54(sp) # Store Word + sw a2, 0x58(sp) # Store Word + sw a1, 0x5C(sp) # Store Word + sw a0, 0x60(sp) # Store Word + sw v1, 0x64(sp) # Store Word + sw v0, 0x68(sp) # Store Word + sw $1, 0x6C(sp) # Store Word + mflo t0 # Move F LO + nop + sw t0, 0x70(sp) # Store Word + mfhi t0 # Move F HI + nop + sw t0, 0x74(sp) # Store Word + mfc0 t0, C0_STATUS # Status register + sll zero, 1 # Shift Left Logical + sll zero, 1 # Shift Left Logical + sll zero, 1 # Shift Left Logical + sll zero, 1 # Shift Left Logical + sw t0, 0x78(sp) # Store Word + mfc0 t0, C0_EPC # Exception Program Counter + sll zero, 1 # Shift Left Logical + sll zero, 1 # Shift Left Logical + sll zero, 1 # Shift Left Logical + sll zero, 1 # Shift Left Logical + sw t0, 0x7C(sp) # Store Word + li k1, 0x7C # Load Immediate + mfc0 k0, C0_CAUSE # C0_CAUSE of last exception + and k0, k1 # AND + beq zero, k0, _int # Branch on Equal + nop + la k0, _exception + jr k0 + nop + + .global _int + .type _int,@function +_int: + jal intr_handler # Jump And Link + nop + lw ra, 0(sp) # Load Word + lw fp, 4(sp) # Load Word + sw gp, 8(sp) # Store Word + lw t9, 0xC(sp) # Load Word + lw t8, 0x10(sp) # Load Word + lw s7, 0x14(sp) # Load Word + lw s6, 0x18(sp) # Load Word + lw s5, 0x1C(sp) # Load Word + lw s4, 0x20(sp) # Load Word + lw s3, 0x24(sp) # Load Word + lw s2, 0x28(sp) # Load Word + lw s1, 0x2C(sp) # Load Word + lw s0, 0x30(sp) # Load Word + lw t7, 0x34(sp) # Load Word + lw t6, 0x38(sp) # Load Word + lw t5, 0x3C(sp) # Load Word + lw t4, 0x40(sp) # Load Word + lw t3, 0x44(sp) # Load Word + lw t2, 0x48(sp) # Load Word + lw t1, 0x4C(sp) # Load Word + lw t0, 0x50(sp) # Load Word + lw a3, 0x54(sp) # Load Word + lw a2, 0x58(sp) # Load Word + lw a1, 0x5C(sp) # Load Word + lw a0, 0x60(sp) # Load Word + lw v1, 0x64(sp) # Load Word + lw v0, 0x68(sp) # Load Word + lw v1, 0x6C(sp) # Load Word + lw k0, 0x70(sp) # Load Word + mtlo k0 # Move To LO + nop + lw k0, 0x74(sp) # Load Word + mthi k0 # Move To HI + nop + lw k0, 0x78(sp) # Load Word + nop + mtc0 k0, C0_STATUS # Status register + sll zero, 1 # Shift Left Logical + sll zero, 1 # Shift Left Logical + sll zero, 1 # Shift Left Logical + sll zero, 1 # Shift Left Logical + lw k0, 0x7C(sp) # Load Word + nop + mtc0 k0, C0_EPC # Exception Program Counter + sll zero, 1 # Shift Left Logical + sll zero, 1 # Shift Left Logical + sll zero, 1 # Shift Left Logical + sll zero, 1 # Shift Left Logical + addiu sp, 0x80 # Add Immediate Unsigned + eret # Exception Return + nop + + .extern _except_handler + .global _exception + .type _exception,@function +_exception: + move a0, sp + mfc0 a1, C0_CAUSE # C0_CAUSE of last exception + mfc0 a2, C0_EPC # Exception Program Counter + la k0, except_handler # Load Address + jr k0 # Jump Register + nop + + .set reorder diff --git a/firmware/target/mips/ingenic_jz47xx/lcd-jz4740.c b/firmware/target/mips/ingenic_jz47xx/lcd-jz4740.c new file mode 100755 index 0000000000..429178aeee --- /dev/null +++ b/firmware/target/mips/ingenic_jz47xx/lcd-jz4740.c @@ -0,0 +1,94 @@ +/*************************************************************************** + * __________ __ ___. + * 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.h" +#include "lcd-target.h" + +static volatile bool _lcd_on = false; +static volatile bool lcd_poweroff = false; + +/* LCD init */ +void lcd_init_device(void) +{ + lcd_init_controller(); + _lcd_on = true; +} + +void lcd_enable(bool state) +{ + if(state) + lcd_on(); + else + lcd_off(); + + _lcd_on = state; +} + +bool lcd_enabled(void) +{ + return _lcd_on; +} + +#define LCDADDR(x, y) ((unsigned int)&lcd_framebuffer[(y)][(x)]) +#define LCD_UNCACHED(addr) ((unsigned int)(addr) | 0xA0000000) + +/* Update a fraction of the display. */ +void lcd_update_rect(int x, int y, int width, int height) +{ + /* HACKY... */ + x=0; y=0; width=400; height=240; + lcd_set_target(x, y, width-1, height-1); + + REG_DMAC_DCCSR(0) = 0; + REG_DMAC_DRSR(0) = DMAC_DRSR_RS_SLCD; /* source = SLCD */ + REG_DMAC_DSAR(0) = LCDADDR(x,y) & 0x1FFFFFFF; +#if 0 + REG_DMAC_DTAR(0) = LCD_UNCACHED(SLCD_FIFO); +#else + REG_DMAC_DTAR(0) = 0x130500B0; /* SLCD_FIFO */ +#endif + REG_DMAC_DTCR(0) = (width*height); + + REG_DMAC_DCMD(0) = (DMAC_DCMD_SAI | DMAC_DCMD_RDIL_IGN | DMAC_DCMD_SWDH_32 /* (1 << 23) | (0 << 16) | (0 << 14) */ + | DMAC_DCMD_DWDH_16 | DMAC_DCMD_DS_16BIT); /* | (2 << 12) | (3 << 8) */ + REG_DMAC_DCCSR(0) = (DMAC_DCCSR_NDES | DMAC_DCCSR_EN); /* (1 << 31) | (1 << 0) */ + + jz_flush_icache(); + + REG_DMAC_DMACR = DMAC_DMACR_DMAE; + + while( !(REG_DMAC_DCCSR(0) & DMAC_DCCSR_TT) ) + asm("nop"); + + //REG_DMAC_DCCSR(0) &= ~DMAC_DCCSR_TT; +} + +/* Update the display. + This must be called after all other LCD functions that change the display. */ +void lcd_update(void) +{ + if (!_lcd_on) + return; + + lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT); +} 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 diff --git a/firmware/target/mips/ingenic_jz47xx/system-jz4740.c b/firmware/target/mips/ingenic_jz47xx/system-jz4740.c new file mode 100755 index 0000000000..4963cac517 --- /dev/null +++ b/firmware/target/mips/ingenic_jz47xx/system-jz4740.c @@ -0,0 +1,71 @@ +/*************************************************************************** + * __________ __ ___. + * 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 "mipsregs.h" + +void intr_handler(void) +{ + return; +} + +void except_handler(void* stack_ptr, unsigned int cause, unsigned int epc) +{ + (void)stack_ptr; + (void)cause; + (void)epc; + REG8(USB_REG_POWER) &= ~USB_POWER_SOFTCONN; + while(1); +} + +void system_reboot(void) +{ + while(1); +} + +void cli(void) +{ + register unsigned int t; + t = read_c0_status(); + t &= ~1; + write_c0_status(t); +} + +unsigned int mips_get_sr(void) +{ + unsigned int t = read_c0_status(); + return t; +} + +void sti(void) +{ + register unsigned int t; + t = read_c0_status(); + t |= 1; + t &= ~2; + write_c0_status(t); +} + +void tick_start(unsigned int interval_in_ms) +{ + (void)interval_in_ms; +} diff --git a/firmware/target/mips/ingenic_jz47xx/system-target.h b/firmware/target/mips/ingenic_jz47xx/system-target.h new file mode 100755 index 0000000000..2fff6423b9 --- /dev/null +++ b/firmware/target/mips/ingenic_jz47xx/system-target.h @@ -0,0 +1,103 @@ +/*************************************************************************** + * __________ __ ___. + * 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 "mipsregs.h" + +/* Core-level interrupt masking */ + +/* This one returns the old status */ +#define HIGHEST_IRQ_LEVEL 0 + +#define set_irq_level(status) \ + set_interrupt_status((status), ST0_IE) +#define set_fiq_status(status) \ + set_interrupt_status((status), ST0_IE) + +static inline int set_interrupt_status(int status, int mask) +{ + unsigned int res, oldstatus; + + res = oldstatus = read_c0_status(); + res &= ~mask; + res |= (status & mask); + write_c0_status(res); + + return oldstatus; +} + +static inline void enable_interrupt(void) +{ + /* Set IE bit */ + set_c0_status(ST0_IE); +} + +static inline void disable_interrupt(void) +{ + /* Clear IE bit */ + clear_c0_status(ST0_IE); +} + +#define disable_irq() \ + disable_interrupt() + +#define enable_irq() \ + enable_interrupt() + +#define disable_fiq() \ + disable_interrupt() + +#define enable_fiq() \ + enable_interrupt() + +static inline int disable_interrupt_save(int mask) +{ + unsigned int oldstatus; + + oldstatus = read_c0_status(); + write_c0_status(oldstatus | mask); + + return oldstatus; +} + +#define disable_irq_save() \ + disable_interrupt_save(ST0_IE) + +#define disable_fiq_save() \ + disable_interrupt_save(ST0_IE) + +static inline void restore_interrupt(int status) +{ + write_c0_status(status); +} + +#define restore_irq(cpsr) \ + restore_interrupt(cpsr) + +#define restore_fiq(cpsr) \ + restore_interrupt(cpsr) + +#define swap16(x) (((x) & 0xff) << 8 | ((x) >> 8) & 0xff) +#define swap32(x) (((x) & 0xff) << 24 | ((x) & 0xff00) << 8 | ((x) & 0xff0000) >> 8 | ((x) >> 24) & 0xff) + +void sti(void); +void cli(void); -- cgit v1.2.3