36dbb569dca5792e4abc57eed050815c9d203e5f
[tpg/acess2.git] / KernelLand / Kernel / arch / armv7 / platform_tegra2.c
1 /*
2  * Acess2 Kernel ARMv7 Port
3  * - By John Hodge (thePowersGang)
4  *
5  * platform_tegra2.c
6  * - Tegra2 Core code
7  */
8 #include <acess.h>
9 #include "platform_tegra2.h"
10
11 // === CONSTANTS ===
12 #define TIMER0_INT      (0*32+0)        // Pri #0
13 #define TIMER1_INT      (0*32+1)        // Pri #1
14 #define TIMER2_INT      (1*32+9)        // Sec #9
15 #define TIMER3_INT      (1*32+10)       // Sec #10
16
17 // === Imports ===
18 extern volatile Sint64  giTimestamp;
19 extern volatile Uint64  giTicks;
20 extern volatile Uint64  giPartMiliseconds;
21 extern void     Timer_CallTimers(void);
22
23 // === PROTORTYPES ===
24 void    Timer_IRQHandler_SysClock(int IRQ, void *_unused);
25 void    Time_Setup(void);
26
27 // === GLOBALS ===
28 // - Addresses for the GIC to use
29 tPAddr  gGIC_InterfaceAddr = 0x50040000;
30 tPAddr  gGIC_DistributorAddr = 0x50041000;
31 // - Map of timer registers
32 struct sTimersMap *gpTimersMap;
33 // - Interrupt controller code commented out, because the Tegra2 also has a GIC
34 #if 0
35 struct sIRQMap  gpIRQMap;
36 #endif
37
38 // === CODE ===
39
40 // -- Timers --
41 void Timer_IRQHandler_SysClock(int IRQ, void *_unused)
42 {
43         giTimestamp += 100;
44         gpTimersMap->TMR0.PCR_0 = (1<<31);
45 }
46
47 void Time_Setup(void)
48 {
49         gpTimersMap = (void*)MM_MapHWPages(0x60005000, 1);
50         // Timer 1 (used for system timekeeping)
51         IRQ_AddHandler(0*32+0, Timer_IRQHandler_SysClock, NULL);
52         gpTimersMap->TMR0.PTV_0 = (1<31)|(1<30)|(100*1000);     // enable, periodic, 100 ms
53 }
54
55 #if 0
56 // -- Interrupt Controller --
57 void IRQ_CtrlrHandler(struct sIRQRegs *Ctrlr, int Ofs)
58 {
59         // Primary CPU only?
60         // TODO: 
61 }
62
63 void IRQ_RootHandler(void)
64 {
65         IRQ_CtrlrHandler(&gpIRQMap->Pri, 0*32);
66         IRQ_CtrlrHandler(&gpIRQMap->Sec, 1*32);
67         IRQ_CtrlrHandler(&gpIRQMap->Tri, 2*32);
68         IRQ_CtrlrHandler(&gpIRQMap->Quad, 3*32);
69 }
70
71 void IRQ_Setup(void)
72 {
73         gpIRQMap = (void*)MM_MapHWPages(0x60004000, 1);
74         
75         gpIRQHandler = IRQ_RootHandler;
76 }
77 #endif

UCC git Repository :: git.ucc.asn.au