14 #include <linux/kernel.h>
26 #define PIT_CPIV(x) ((x) & AT91_PIT_CPIV)
27 #define PIT_PICNT(x) (((x) & AT91_PIT_PICNT) >> 20)
33 static inline unsigned int pit_read(
unsigned int reg_offset)
38 static inline void pit_write(
unsigned int reg_offset,
unsigned long value)
75 pit_clkevt_mode(
enum clock_event_mode
mode,
struct clock_event_device *
dev)
78 case CLOCK_EVT_MODE_PERIODIC:
84 case CLOCK_EVT_MODE_ONESHOT:
87 case CLOCK_EVT_MODE_SHUTDOWN:
88 case CLOCK_EVT_MODE_UNUSED:
92 case CLOCK_EVT_MODE_RESUME:
97 static struct clock_event_device pit_clkevt = {
99 .features = CLOCK_EVT_FEAT_PERIODIC,
102 .set_mode = pit_clkevt_mode,
118 if ((pit_clkevt.mode == CLOCK_EVT_MODE_PERIODIC)
125 pit_cnt += pit_cycle;
126 pit_clkevt.event_handler(&pit_clkevt);
136 static struct irqaction at91sam926x_pit_irq = {
139 .handler = at91sam926x_pit_interrupt,
143 static void at91sam926x_pit_reset(
void)
162 static int __init of_at91sam926x_pit_init(
void)
178 pr_crit(
"AT91: PIT: Unable to get IRQ from DT\n");
181 at91sam926x_pit_irq.
irq =
ret;
195 static int __init of_at91sam926x_pit_init(
void)
204 static void __init at91sam926x_pit_init(
void)
206 unsigned long pit_rate;
211 of_at91sam926x_pit_init();
218 pit_cycle = (pit_rate +
HZ/2) /
HZ;
222 at91sam926x_pit_reset();
228 bits = 12 +
ilog2(pit_cycle) ;
230 clocksource_register_hz(&pit_clk, pit_rate);
233 ret =
setup_irq(at91sam926x_pit_irq.
irq, &at91sam926x_pit_irq);
235 pr_crit(
"AT91: PIT: Unable to setup IRQ\n");
238 pit_clkevt.mult = div_sc(pit_rate,
NSEC_PER_SEC, pit_clkevt.shift);
243 static void at91sam926x_pit_suspend(
void)
251 #if defined(CONFIG_OF)
260 pit_base_addr =
ioremap(addr, 16);
263 panic(
"Impossible to ioremap PIT\n");
267 .init = at91sam926x_pit_init,
268 .suspend = at91sam926x_pit_suspend,
269 .resume = at91sam926x_pit_reset,