18 #include <asm/special_insns.h>
37 #define TCR_TSTATLO 0x001
38 #define TCR_INVOUTPLO 0x002
39 #define TCR_INVINPLO 0x004
40 #define TCR_CPLO 0x008
41 #define TCR_ENAMODELO_ONCE 0x040
42 #define TCR_ENAMODELO_CONT 0x080
43 #define TCR_ENAMODELO_MASK 0x0c0
44 #define TCR_PWIDLO_MASK 0x030
45 #define TCR_CLKSRCLO 0x100
46 #define TCR_TIENLO 0x200
47 #define TCR_TSTATHI (0x001 << 16)
48 #define TCR_INVOUTPHI (0x002 << 16)
49 #define TCR_CPHI (0x008 << 16)
50 #define TCR_PWIDHI_MASK (0x030 << 16)
51 #define TCR_ENAMODEHI_ONCE (0x040 << 16)
52 #define TCR_ENAMODEHI_CONT (0x080 << 16)
53 #define TCR_ENAMODEHI_MASK (0x0c0 << 16)
55 #define TGCR_TIMLORS 0x001
56 #define TGCR_TIMHIRS 0x002
57 #define TGCR_TIMMODE_UD32 0x004
58 #define TGCR_TIMMODE_WDT64 0x008
59 #define TGCR_TIMMODE_CD32 0x00c
60 #define TGCR_TIMMODE_MASK 0x00c
61 #define TGCR_PSCHI_MASK (0x00f << 8)
62 #define TGCR_TDDRHI_MASK (0x00f << 12)
68 #define TIMER_DIVISOR \
69 ((soc_readl(&timer->emumgt) & (0xf << 16)) >> 16)
71 #define TIMER64_RATE (c6x_core_freq / TIMER_DIVISOR)
73 #define TIMER64_MODE_DISABLED 0
74 #define TIMER64_MODE_ONE_SHOT TCR_ENAMODELO_ONCE
75 #define TIMER64_MODE_PERIODIC TCR_ENAMODELO_CONT
77 static int timer64_mode;
78 static int timer64_devstate_id = -1;
80 static void timer64_config(
unsigned long period)
91 static void timer64_enable(
void)
95 if (timer64_devstate_id >= 0)
112 static void timer64_disable(
void)
118 if (timer64_devstate_id >= 0)
122 static int next_event(
unsigned long delta,
123 struct clock_event_device *
evt)
125 timer64_config(delta);
129 static void set_clock_mode(
enum clock_event_mode
mode,
130 struct clock_event_device *
evt)
133 case CLOCK_EVT_MODE_PERIODIC:
138 case CLOCK_EVT_MODE_ONESHOT:
142 case CLOCK_EVT_MODE_UNUSED:
143 case CLOCK_EVT_MODE_SHUTDOWN:
147 case CLOCK_EVT_MODE_RESUME:
152 static struct clock_event_device t64_clockevent_device = {
153 .name =
"TIMER64_EVT32_TIMER",
154 .features = CLOCK_EVT_FEAT_ONESHOT | CLOCK_EVT_FEAT_PERIODIC,
156 .set_mode = set_clock_mode,
157 .set_next_event = next_event,
162 struct clock_event_device *
cd = &t64_clockevent_device;
164 cd->event_handler(cd);
173 .dev_id = &t64_clockevent_device,
178 struct clock_event_device *cd = &t64_clockevent_device;
183 for_each_compatible_node(np,
NULL,
"ti,c64x+timer64") {
184 err = of_property_read_u32(np,
"ti,core-mask", &val);
196 np = of_node_get(first);
198 pr_debug(
"Cannot find ti,c64x+timer64 timer.\n");
218 err = of_property_read_u32(np,
"ti,dscr-dev-enable", &val);
220 timer64_devstate_id =
val;