diff options
author | Amaury Pouly <pamaury@rockbox.org> | 2011-09-06 00:27:38 +0000 |
---|---|---|
committer | Amaury Pouly <pamaury@rockbox.org> | 2011-09-06 00:27:38 +0000 |
commit | 2ac668e44cec12616a4d675f8eade8049ed10af9 (patch) | |
tree | 946451d3ef42a2e1f7c3259b81344ffb82ce041b /firmware | |
parent | 333b9ed2c330bb005456444de0eb16ad422496fa (diff) |
imx233/fuze+: implement user time api, implement a stub function, protect timrot against irq
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30437 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/SOURCES | 4 | ||||
-rw-r--r-- | firmware/export/imx233.h | 10 | ||||
-rw-r--r-- | firmware/target/arm/imx233/kernel-imx233.c | 2 | ||||
-rw-r--r-- | firmware/target/arm/imx233/system-imx233.c | 6 | ||||
-rw-r--r-- | firmware/target/arm/imx233/timer-imx233.c | 60 | ||||
-rw-r--r-- | firmware/target/arm/imx233/timrot-imx233.c | 4 | ||||
-rw-r--r-- | firmware/target/arm/imx233/timrot-imx233.h | 1 |
7 files changed, 86 insertions, 1 deletions
diff --git a/firmware/SOURCES b/firmware/SOURCES index 4517c37e7f..cd6d77a9ac 100644 --- a/firmware/SOURCES +++ b/firmware/SOURCES @@ -513,6 +513,10 @@ target/arm/imx233/debug-imx233.c #if !defined(BOOTLOADER) || defined(HAVE_BOOTLOADER_USB_MODE) target/arm/imx233/usb-imx233.c #endif +#ifndef BOOTLOADER +target/arm/imx233/pcm-imx233.c +target/arm/imx233/timer-imx233.c +#endif #endif /* IMX233 */ #if CONFIG_CPU == AS3525 || CONFIG_CPU == AS3525v2 diff --git a/firmware/export/imx233.h b/firmware/export/imx233.h index 2a2097b5d7..d6c84ef6f5 100644 --- a/firmware/export/imx233.h +++ b/firmware/export/imx233.h @@ -57,6 +57,16 @@ #define FRAME_PHYS_ADDR (DRAM_ORIG + DRAM_SIZE - TTB_SIZE - FRAME_SIZE) #define FRAME ((void *)(FRAME_PHYS_ADDR - UNCACHED_DRAM_ADDR + BUFFERED_DRAM_ADDR)) +/* Timer runs at APBX speed which is derived from ref_xtal@24MHz */ +#define TIMER_FREQ 24000000 + +#ifdef SANSA_FUZEPLUS +#define TICK_TIMER_NR 0 +#define USER_TIMER_NR 1 +#else +#error Select timers ! +#endif + /* USBOTG */ #define USB_QHARRAY_ATTR __attribute__((section(".qharray"),nocommon,aligned(2048))) #define USB_NUM_ENDPOINTS 5 diff --git a/firmware/target/arm/imx233/kernel-imx233.c b/firmware/target/arm/imx233/kernel-imx233.c index 367f359dc0..edb9b8366c 100644 --- a/firmware/target/arm/imx233/kernel-imx233.c +++ b/firmware/target/arm/imx233/kernel-imx233.c @@ -31,7 +31,7 @@ static void tick_timer(void) void tick_start(unsigned int interval_in_ms) { /* use the 1-kHz XTAL clock source */ - imx233_setup_timer(0, true, interval_in_ms, + imx233_setup_timer(TICK_TIMER_NR, true, interval_in_ms, HW_TIMROT_TIMCTRL__SELECT_1KHZ_XTAL, HW_TIMROT_TIMCTRL__PRESCALE_1, false, &tick_timer); } diff --git a/firmware/target/arm/imx233/system-imx233.c b/firmware/target/arm/imx233/system-imx233.c index 68f16bf860..8e742c0822 100644 --- a/firmware/target/arm/imx233/system-imx233.c +++ b/firmware/target/arm/imx233/system-imx233.c @@ -127,6 +127,12 @@ void system_exception_wait(void) while(!button_read_device()); } +int system_memory_guard(int newmode) +{ + (void)newmode; + return 0; +} + void imx233_enable_interrupt(int src, bool enable) { if(enable) diff --git a/firmware/target/arm/imx233/timer-imx233.c b/firmware/target/arm/imx233/timer-imx233.c new file mode 100644 index 0000000000..9721de5cd3 --- /dev/null +++ b/firmware/target/arm/imx233/timer-imx233.c @@ -0,0 +1,60 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2011 by Amaury Pouly + * + * 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 "kernel.h" +#include "timrot-imx233.h" +#include "timer.h" + +static long timer_cycles = 0; + +static void timer_fn() +{ + if(pfn_timer) + pfn_timer(); +} + +bool timer_set(long cycles, bool start) +{ + timer_stop(); + + if(start && pfn_unregister) + { + pfn_unregister(); + pfn_unregister = NULL; + } + + timer_cycles = cycles; + + return true; +} + +bool timer_start(IF_COP_VOID(int core)) +{ + imx233_setup_timer(USER_TIMER_NR, true, timer_cycles, + HW_TIMROT_TIMCTRL__SELECT_TICK_ALWAYS, HW_TIMROT_TIMCTRL__PRESCALE_1, + false, &timer_fn); + return true; +} + +void timer_stop(void) +{ + imx233_setup_timer(USER_TIMER_NR, false, 0, HW_TIMROT_TIMCTRL__SELECT_NEVER_TICK, + HW_TIMROT_TIMCTRL__PRESCALE_1, false, NULL); +} diff --git a/firmware/target/arm/imx233/timrot-imx233.c b/firmware/target/arm/imx233/timrot-imx233.c index 64a7c63f24..b2a1181ece 100644 --- a/firmware/target/arm/imx233/timrot-imx233.c +++ b/firmware/target/arm/imx233/timrot-imx233.c @@ -39,6 +39,8 @@ define_timer_irq(3) void imx233_setup_timer(unsigned timer_nr, bool reload, unsigned count, unsigned src, unsigned prescale, bool polarity, imx233_timer_fn_t fn) { + int oldstatus = disable_interrupt_save(IRQ_FIQ_STATUS); + timer_fns[timer_nr] = fn; HW_TIMROT_TIMCTRL(timer_nr) = src | prescale; @@ -65,6 +67,8 @@ void imx233_setup_timer(unsigned timer_nr, bool reload, unsigned count, imx233_enable_interrupt(INT_SRC_TIMER(timer_nr), false); /* finally update */ __REG_SET(HW_TIMROT_TIMCTRL(timer_nr)) = HW_TIMROT_TIMCTRL__UPDATE; + + restore_interrupt(oldstatus); } void imx233_timrot_init(void) diff --git a/firmware/target/arm/imx233/timrot-imx233.h b/firmware/target/arm/imx233/timrot-imx233.h index 792ab767ac..c79023da51 100644 --- a/firmware/target/arm/imx233/timrot-imx233.h +++ b/firmware/target/arm/imx233/timrot-imx233.h @@ -40,6 +40,7 @@ #define HW_TIMROT_TIMCTRL__PRESCALE_2 (1 << 4) #define HW_TIMROT_TIMCTRL__PRESCALE_4 (2 << 4) #define HW_TIMROT_TIMCTRL__PRESCALE_8 (3 << 4) +#define HW_TIMROT_TIMCTRL__SELECT_NEVER_TICK 0 #define HW_TIMROT_TIMCTRL__SELECT_32KHZ_XTAL 8 #define HW_TIMROT_TIMCTRL__SELECT_8KHZ_XTAL 9 #define HW_TIMROT_TIMCTRL__SELECT_4KHZ_XTAL 10 |