]> rtime.felk.cvut.cz Git - zynq/linux.git/blobdiff - drivers/clocksource/timer-atmel-st.c
Apply preempt_rt patch-4.9-rt1.patch.xz
[zynq/linux.git] / drivers / clocksource / timer-atmel-st.c
index e90ab5b63a9068ec3901b85cab9b230db67a837c..9e124087c55fe9e133bbc744caa0b05157478e87 100644 (file)
@@ -115,18 +115,29 @@ static void clkdev32k_disable_and_flush_irq(void)
        last_crtr = read_CRTR();
 }
 
+static int atmel_st_irq;
+
 static int clkevt32k_shutdown(struct clock_event_device *evt)
 {
        clkdev32k_disable_and_flush_irq();
        irqmask = 0;
        regmap_write(regmap_st, AT91_ST_IER, irqmask);
+       free_irq(atmel_st_irq, regmap_st);
        return 0;
 }
 
 static int clkevt32k_set_oneshot(struct clock_event_device *dev)
 {
+       int ret;
+
        clkdev32k_disable_and_flush_irq();
 
+       ret = request_irq(atmel_st_irq, at91rm9200_timer_interrupt,
+                         IRQF_SHARED | IRQF_TIMER | IRQF_IRQPOLL,
+                         "at91_tick", regmap_st);
+       if (ret)
+               panic(pr_fmt("Unable to setup IRQ\n"));
+
        /*
         * ALM for oneshot irqs, set by next_event()
         * before 32 seconds have passed.
@@ -139,8 +150,16 @@ static int clkevt32k_set_oneshot(struct clock_event_device *dev)
 
 static int clkevt32k_set_periodic(struct clock_event_device *dev)
 {
+       int ret;
+
        clkdev32k_disable_and_flush_irq();
 
+       ret = request_irq(atmel_st_irq, at91rm9200_timer_interrupt,
+                         IRQF_SHARED | IRQF_TIMER | IRQF_IRQPOLL,
+                         "at91_tick", regmap_st);
+       if (ret)
+               panic(pr_fmt("Unable to setup IRQ\n"));
+
        /* PIT for periodic irqs; fixed rate of 1/HZ */
        irqmask = AT91_ST_PITS;
        regmap_write(regmap_st, AT91_ST_PIMR, timer_latch);
@@ -198,7 +217,7 @@ static int __init atmel_st_timer_init(struct device_node *node)
 {
        struct clk *sclk;
        unsigned int sclk_rate, val;
-       int irq, ret;
+       int ret;
 
        regmap_st = syscon_node_to_regmap(node);
        if (IS_ERR(regmap_st)) {
@@ -212,21 +231,12 @@ static int __init atmel_st_timer_init(struct device_node *node)
        regmap_read(regmap_st, AT91_ST_SR, &val);
 
        /* Get the interrupts property */
-       irq  = irq_of_parse_and_map(node, 0);
-       if (!irq) {
+       atmel_st_irq  = irq_of_parse_and_map(node, 0);
+       if (!atmel_st_irq) {
                pr_err("Unable to get IRQ from DT\n");
                return -EINVAL;
        }
 
-       /* Make IRQs happen for the system timer */
-       ret = request_irq(irq, at91rm9200_timer_interrupt,
-                         IRQF_SHARED | IRQF_TIMER | IRQF_IRQPOLL,
-                         "at91_tick", regmap_st);
-       if (ret) {
-               pr_err("Unable to setup IRQ\n");
-               return ret;
-       }
-
        sclk = of_clk_get(node, 0);
        if (IS_ERR(sclk)) {
                pr_err("Unable to get slow clock\n");