summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--firmware/export/system.h22
-rw-r--r--firmware/system.c97
2 files changed, 109 insertions, 10 deletions
diff --git a/firmware/export/system.h b/firmware/export/system.h
index 74074d543f..a3944296a0 100644
--- a/firmware/export/system.h
+++ b/firmware/export/system.h
@@ -179,21 +179,25 @@ static inline unsigned long SWAB32(unsigned long value)
179 179
180#elif CONFIG_CPU == TCC730 180#elif CONFIG_CPU == TCC730
181 181
182extern void* interrupt_vector[16] __attribute__ ((section(".idata"))); 182extern void* volatile interrupt_vector[16] __attribute__ ((section(".idata")));
183 183
184extern void ddma_transfer(int dir, int mem, long intAddr, void* extAddr, 184extern void ddma_transfer(int dir, int mem, long intAddr, long extAddr,
185 int num); 185 int num);
186 186
187static inline void clear_watchdog(void)
188{
189 WDTCON = 0x0A;
190}
191
192 187
193#define HIGHEST_IRQ_LEVEL (1<<15) 188#define HIGHEST_IRQ_LEVEL (1)
194static inline int set_irq_level(int level) 189static inline int set_irq_level(int level)
195{ 190{
196 return 0; 191 int result;
192 __asm__ ("ld %0, 0\n\t"
193 "tstsr ie\n\t"
194 "incc %0" : "=r"(result));
195 if (level > 0)
196 __asm__ volatile ("clrsr ie");
197 else
198 __asm__ volatile ("setsr ie");
199
200 return result;
197} 201}
198 202
199static inline unsigned short SWAB16(unsigned short value) 203static inline unsigned short SWAB16(unsigned short value)
diff --git a/firmware/system.c b/firmware/system.c
index 726d7fd6cc..2c0f03b7ad 100644
--- a/firmware/system.c
+++ b/firmware/system.c
@@ -21,8 +21,103 @@
21#include <stdbool.h> 21#include <stdbool.h>
22#include "lcd.h" 22#include "lcd.h"
23#include "font.h" 23#include "font.h"
24#include "system.h"
25
26#if CONFIG_CPU == TCC730
27
28void* volatile interrupt_vector[16] __attribute__ ((section(".idata")));
29
30void ddma_wait_idle(void)
31{
32 do {
33 } while ((DDMACOM & 3) != 0);
34}
35
36void ddma_transfer(int dir, int mem, long intAddr, long extAddr, int num) {
37 int irq = set_irq_level(1);
38 ddma_wait_idle();
39 long externalAddress = (long) extAddr;
40 long internalAddress = (long) intAddr;
41 /* HW wants those two in word units. */
42 num /= 2;
43 externalAddress /= 2;
44
45 DDMACFG = (dir << 1) | (mem << 2);
46 DDMAIADR = internalAddress;
47 DDMAEADR = externalAddress;
48 DDMANUM = num;
49 DDMACOM |= 0x4; /* start */
50
51 ddma_wait_idle(); /* wait for completion */
52 set_irq_level(irq);
53}
54
55/* Some linker-defined symbols */
56extern int icodecopy;
57extern int icodesize;
58extern int icodestart;
59
60/* called by crt0 */
61void system_init(void)
62{
63 /* Disable watchdog */
64 WDTEN = 0xA5;
65
66 /* Setup the CPU */
67
68
69 /* PLL0 (cpu osc. frequency) */
70
71#if 0
72 PLL0DATA = 0xf98;
73 PLL0CON = 0x1; /* activate */
74 do {
75 asm "nop";
76 } while ((PLL0CON & 0x2) == 0); /* wait for stabilization */
77
78 PLL0CON = 0x5; /* use as CPU clock */
79
80#endif
81
82 /*******************
83 * configure S(D)RAM
84 */
85
86 /************************
87 * Copy .icode section to icram
88 */
89 ddma_transfer(0, 0, 0x40, (long)&icodecopy, (int)&icodesize);
90
91
92 /***************************
93 * Interrupt mask
94 */
95
96 /* interrupt priorities ? */
97
98 IMR0 = 0;
99 IMR1 = 0;
100
101
102/* IRQ0 BT INT */
103/* IRQ1 RTC INT */
104/* IRQ2 TA INT */
105/* IRQ3 TAOV INT */
106/* IRQ4 TB INT */
107/* IRQ5 TBOV INT */
108/* IRQ6 TC INT */
109/* IRQ7 TCOV INT */
110/* IRQ8 USB INT */
111/* IRQ9 PPIC INT */
112/* IRQ10 UART_Rx/UART_Err/ UART_tx INT */
113/* IRQ11 IIC INT */
114/* IRQ12 SIO INT */
115/* IRQ13 IIS0 INT */
116/* IRQ14 IIS1 INT */
117/* IRQ15 ­ */
118}
24 119
25#if CONFIG_CPU == MCF5249 120#elif CONFIG_CPU == MCF5249
26 121
27#define default_interrupt(name) \ 122#define default_interrupt(name) \
28 extern __attribute__((weak,alias("UIE"))) void name (void); 123 extern __attribute__((weak,alias("UIE"))) void name (void);