1 // --------------------------------------------------------------------------
2 INTERFACE [arm && omap3]:
12 TIOCP_CFG = Kmem::Timer_base + 0x010, // config
13 TISTAT = Kmem::Timer_base + 0x014, // non-interrupt status
14 TISR = Kmem::Timer_base + 0x018, // pending interrupts
15 TIER = Kmem::Timer_base + 0x01c, // enable/disable of interrupt events
16 TWER = Kmem::Timer_base + 0x020, // wake-up features
17 TCLR = Kmem::Timer_base + 0x024, // optional features
18 TCRR = Kmem::Timer_base + 0x028, // internal counter
19 TLDR = Kmem::Timer_base + 0x02c, // timer load value
20 TTGR = Kmem::Timer_base + 0x030, // trigger reload by writing
21 TWPS = Kmem::Timer_base + 0x034, // write-posted pending
22 TMAR = Kmem::Timer_base + 0x038, // compare value
23 TCAR1 = Kmem::Timer_base + 0x03c, // first capture value of the counter
24 TCAR2 = Kmem::Timer_base + 0x044, // second capture value of the counter
25 TPIR = Kmem::Timer_base + 0x048, // positive inc, gpt1, 2 and 10 only
26 TNIR = Kmem::Timer_base + 0x04C, // negative inc, gpt1, 2 and 10 only
29 CM_CLKSEL_WKUP = Kmem::Wkup_cm_map_base + 0x40,
35 // -----------------------------------------------------------------------
36 IMPLEMENTATION [arm && omap3]:
51 Io::write<Mword>(1, TIOCP_CFG);
52 while (!Io::read<Mword>(TISTAT))
57 Io::write<Mword>(0x2, TIER);
59 Io::write<Mword>(0x0, TWER);
61 // select 32768 Hz input to GPTimer1 (timer1 only!)
62 Io::write<Mword>(~1 & Io::read<Mword>(CM_CLKSEL_WKUP), CM_CLKSEL_WKUP);
64 // program 1000 Hz timer frequency
65 Io::write<Mword>(232000, TPIR); // gpt1, gpt2 and gpt10 only
66 Io::write<Mword>(-768000, TNIR); // gpt1, gpt2 and gpt10 only
67 Io::write<Mword>(0xffffffe0, TCRR);
68 Io::write<Mword>(0xffffffe0, TLDR);
71 Io::write<Mword>(1 | 2, TCLR);
73 Irq_chip::hw_chip->reserve(Config::Scheduling_irq);
76 Irq_chip::hw_chip->setup(&ib, Config::Scheduling_irq);
82 Timer::timer_to_us(Unsigned32 /*cr*/)
87 Timer::us_to_timer(Unsigned64 us)
88 { (void)us; return 0; }
90 IMPLEMENT inline NEEDS["config.h", "io.h"]
91 void Timer::acknowledge()
93 // XXX: there's a update_system_clock function !?!?!?!
94 //if (!Config::scheduler_one_shot)
95 // Kip::k()->clock += Config::scheduler_granularity;
97 Io::write<Mword>(2, TISR);
104 irq->pin()->unmask();
108 void Timer::disable()
113 IMPLEMENT inline NEEDS["kip.h", "io.h", Timer::timer_to_us, Timer::us_to_timer]
115 Timer::update_one_shot(Unsigned64 wakeup)
118 //Kip::k()->clock += timer_to_us(Io::read<Unsigned32>(OSCR));
119 Unsigned64 now = Kip::k()->clock;
121 if (EXPECT_FALSE (wakeup <= now) )
126 apic = us_to_timer(wakeup - now);
127 if (EXPECT_FALSE(apic > 0x0ffffffff))
129 if (EXPECT_FALSE (apic < 1) )
135 IMPLEMENT inline NEEDS["config.h", "kip.h"]
137 Timer::system_clock()
139 if (Config::scheduler_one_shot)
142 return Kip::k()->clock;