diff options
Diffstat (limited to 'firmware/kernel.c')
-rw-r--r-- | firmware/kernel.c | 49 |
1 files changed, 47 insertions, 2 deletions
diff --git a/firmware/kernel.c b/firmware/kernel.c index bb67ced64d..11b10e287e 100644 --- a/firmware/kernel.c +++ b/firmware/kernel.c | |||
@@ -24,8 +24,11 @@ | |||
24 | #include "cpu.h" | 24 | #include "cpu.h" |
25 | #include "system.h" | 25 | #include "system.h" |
26 | #include "panic.h" | 26 | #include "panic.h" |
27 | #if CONFIG_CPU == IMX31L | ||
28 | #include "avic-imx31.h" | ||
29 | #endif | ||
27 | 30 | ||
28 | #if !defined(CPU_PP) || !defined(BOOTLOADER) | 31 | #if (!defined(CPU_PP) && (CONFIG_CPU != IMX31L)) || !defined(BOOTLOADER) |
29 | volatile long current_tick NOCACHEDATA_ATTR = 0; | 32 | volatile long current_tick NOCACHEDATA_ATTR = 0; |
30 | #endif | 33 | #endif |
31 | 34 | ||
@@ -83,7 +86,7 @@ void sleep(int ticks) | |||
83 | 86 | ||
84 | void yield(void) | 87 | void yield(void) |
85 | { | 88 | { |
86 | #if ((CONFIG_CPU == S3C2440 || defined(ELIO_TPJ1022)) && defined(BOOTLOADER)) | 89 | #if ((CONFIG_CPU == S3C2440 || defined(ELIO_TPJ1022) || CONFIG_CPU == IMX31L) && defined(BOOTLOADER)) |
87 | /* Some targets don't like yielding in the bootloader */ | 90 | /* Some targets don't like yielding in the bootloader */ |
88 | #else | 91 | #else |
89 | switch_thread(true, NULL); | 92 | switch_thread(true, NULL); |
@@ -708,6 +711,48 @@ void tick_start(unsigned int interval_in_ms) | |||
708 | 711 | ||
709 | TIMER0.ctrl |= 0x80; /* Enable the counter */ | 712 | TIMER0.ctrl |= 0x80; /* Enable the counter */ |
710 | } | 713 | } |
714 | #elif CONFIG_CPU == IMX31L | ||
715 | void tick_start(unsigned int interval_in_ms) | ||
716 | { | ||
717 | EPITCR1 &= ~0x1; /* Disable the counter */ | ||
718 | |||
719 | EPITCR1 &= ~0xE; /* Disable interrupt, count down from 0xFFFFFFFF */ | ||
720 | EPITCR1 &= ~0xFFF0; /* Clear prescaler */ | ||
721 | #ifdef BOOTLOADER | ||
722 | EPITCR1 |= (2700 << 2); /* Prescaler = 2700 */ | ||
723 | #endif | ||
724 | EPITCR1 &= ~(0x3 << 24); | ||
725 | EPITCR1 |= (0x2 << 24); /* Set clock source to external clock (27mhz) */ | ||
726 | EPITSR1 = 1; /* Clear the interrupt request */ | ||
727 | #ifndef BOOTLOADER | ||
728 | EPITLR1 = 27000000 * interval_in_ms / 1000; | ||
729 | EPITCMPR1 = 27000000 * interval_in_ms / 1000; | ||
730 | #else | ||
731 | (void)interval_in_ms; | ||
732 | #endif | ||
733 | |||
734 | //avic_enable_int(EPIT1, IRQ, EPIT_HANDLER); | ||
735 | |||
736 | EPITCR1 |= 0x1; /* Enable the counter */ | ||
737 | } | ||
738 | |||
739 | #ifndef BOOTLOADER | ||
740 | void EPIT_HANDLER(void) __attribute__((interrupt("IRQ"))); | ||
741 | void EPIT_HANDLER(void) { | ||
742 | int i; | ||
743 | |||
744 | /* Run through the list of tick tasks */ | ||
745 | for(i = 0;i < MAX_NUM_TICK_TASKS;i++) | ||
746 | { | ||
747 | if(tick_funcs[i]) | ||
748 | tick_funcs[i](); | ||
749 | } | ||
750 | |||
751 | current_tick++; | ||
752 | |||
753 | EPITSR1 = 1; /* Clear the interrupt request */ | ||
754 | } | ||
755 | #endif | ||
711 | #endif | 756 | #endif |
712 | 757 | ||
713 | int tick_add_task(void (*f)(void)) | 758 | int tick_add_task(void (*f)(void)) |