From ebb612fbcc87a9547a3603ef6188a26b0760a9aa Mon Sep 17 00:00:00 2001 From: Maurus Cuelenaere Date: Tue, 15 Jul 2008 17:17:01 +0000 Subject: Onda VX747: 1) Improve touchscreen handling 2) Add RTC driver 4) Add NAND Flash ID scanning 3) Other minor fixes Nand_ID: Add a generic NAND ID database (currently only containg Samsung chips) git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18052 a1c6a512-1295-4272-9138-f99709370657 --- firmware/target/mips/ingenic_jz47xx/ata-jz4740.c | 40 ------------- .../target/mips/ingenic_jz47xx/ata-nand-jz4740.c | 68 ++++++++++++++++++++++ .../ingenic_jz47xx/onda_vx747/button-onda_vx747.c | 33 +++++++---- .../target/mips/ingenic_jz47xx/system-jz4740.c | 8 +-- 4 files changed, 92 insertions(+), 57 deletions(-) delete mode 100644 firmware/target/mips/ingenic_jz47xx/ata-jz4740.c create mode 100644 firmware/target/mips/ingenic_jz47xx/ata-nand-jz4740.c (limited to 'firmware/target') diff --git a/firmware/target/mips/ingenic_jz47xx/ata-jz4740.c b/firmware/target/mips/ingenic_jz47xx/ata-jz4740.c deleted file mode 100644 index b907bb86df..0000000000 --- a/firmware/target/mips/ingenic_jz47xx/ata-jz4740.c +++ /dev/null @@ -1,40 +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 "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/ata-nand-jz4740.c b/firmware/target/mips/ingenic_jz47xx/ata-nand-jz4740.c new file mode 100644 index 0000000000..ad053c7deb --- /dev/null +++ b/firmware/target/mips/ingenic_jz47xx/ata-nand-jz4740.c @@ -0,0 +1,68 @@ +/*************************************************************************** + * __________ __ ___. + * 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" + +#define NAND_CMD_READ1_00 0x00 +#define NAND_CMD_READ1_01 0x01 +#define NAND_CMD_READ2 0x50 +#define NAND_CMD_READ_ID1 0x90 +#define NAND_CMD_READ_ID2 0x91 +#define NAND_CMD_RESET 0xFF +#define NAND_CMD_PAGE_PROGRAM_START 0x80 +#define NAND_CMD_PAGE_PROGRAM_STOP 0x10 +#define NAND_CMD_BLOCK_ERASE_START 0x60 +#define NAND_CMD_BLOCK_ERASE_CONFIRM 0xD0 +#define NAND_CMD_READ_STATUS 0x70 + +#define NANDFLASH_CLE 0x00008000 //PA[15] +#define NANDFLASH_ALE 0x00010000 //PA[16] + +#define NANDFLASH_BASE 0xB8000000 +#define REG_NAND_DATA (*((volatile unsigned char *) NANDFLASH_BASE)) +#define REG_NAND_CMD (*((volatile unsigned char *) (NANDFLASH_BASE + NANDFLASH_CLE))) +#define REG_NAND_ADDR (*((volatile unsigned char *) (NANDFLASH_BASE + NANDFLASH_ALE))) + +#define JZ_NAND_SET_CLE (NANDFLASH_BASE |= NANDFLASH_CLE) +#define JZ_NAND_CLR_CLE (NANDFLASH_BASE &= ~NANDFLASH_CLE) +#define JZ_NAND_SET_ALE (NANDFLASH_BASE |= NANDFLASH_ALE) +#define JZ_NAND_CLR_ALE (NANDFLASH_BASE &= ~NANDFLASH_ALE) + +#define JZ_NAND_SELECT (REG_EMC_NFCSR |= EMC_NFCSR_NFCE1 ) +#define JZ_NAND_DESELECT (REG_EMC_NFCSR &= ~(EMC_NFCSR_NFCE1)) + +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/onda_vx747/button-onda_vx747.c b/firmware/target/mips/ingenic_jz47xx/onda_vx747/button-onda_vx747.c index 90dc0b83fb..950fc51d69 100644 --- a/firmware/target/mips/ingenic_jz47xx/onda_vx747/button-onda_vx747.c +++ b/firmware/target/mips/ingenic_jz47xx/onda_vx747/button-onda_vx747.c @@ -32,16 +32,16 @@ | 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 ) + (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); + return (~REG_GPIO_PXPIN(3) & BTN_HOLD ? 1 : 0); } void button_init_device(void) @@ -54,7 +54,7 @@ void button_init_device(void) REG_SADC_CFG = SADC_CFG_INIT; REG_SADC_SAMETIME = 1; - REG_SADC_WAITTIME = 1000; //per 100 HZ + 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; @@ -66,14 +66,21 @@ static int touch_to_pixels(short x, short y) x -= 300; y -= 300; - x /= 3200 / LCD_WIDTH; - y /= 3600 / LCD_HEIGHT; - - return (x << 16) | y; + /* X & Y are switched */ + x /= 3200 / LCD_HEIGHT; + y /= 3600 / LCD_WIDTH; + + x = LCD_HEIGHT - x; + y = LCD_WIDTH - y; + + return (y << 16) | x; } int button_read_device(int *data) { + if(button_hold()) + return 0; + unsigned int key = ~REG_GPIO_PXPIN(3); int ret = 0; if(key & BTN_MASK) @@ -114,6 +121,8 @@ int button_read_device(int *data) REG_SADC_STATE = 0; //__intc_unmask_irq(IRQ_SADC); } + else + *data = 0; return ret; } diff --git a/firmware/target/mips/ingenic_jz47xx/system-jz4740.c b/firmware/target/mips/ingenic_jz47xx/system-jz4740.c index 4963cac517..ee50520243 100644 --- a/firmware/target/mips/ingenic_jz47xx/system-jz4740.c +++ b/firmware/target/mips/ingenic_jz47xx/system-jz4740.c @@ -22,19 +22,17 @@ #include "config.h" #include "jz4740.h" #include "mipsregs.h" +#include "panic.h" void intr_handler(void) { + _printf("Interrupt!"); 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); + panicf("Exception occurred: [0x%x] at 0x%x (stack at 0x%x)", cause, epc, (unsigned int)stack_ptr); } void system_reboot(void) -- cgit v1.2.3