blob: f714d060370d6f1647e29e2367591dafa242b4b6 [file] [log] [blame]
Ben Dooks7162ba02010-01-06 10:14:51 +09001/* arch/arm/plat-samsung/irq-vic-timer.c
2 * originally part of arch/arm/plat-s3c64xx/irq.c
3 *
4 * Copyright 2008 Openmoko, Inc.
5 * Copyright 2008 Simtec Electronics
6 * Ben Dooks <ben@simtec.co.uk>
7 * http://armlinux.simtec.co.uk/
8 *
9 * S3C64XX - Interrupt handling
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
14 */
15
16#include <linux/kernel.h>
17#include <linux/interrupt.h>
18#include <linux/irq.h>
19#include <linux/io.h>
20
21#include <mach/map.h>
22#include <plat/irq-vic-timer.h>
23#include <plat/regs-timer.h>
24
25static void s3c_irq_demux_vic_timer(unsigned int irq, struct irq_desc *desc)
26{
Lennert Buytenhek04ea1cc2010-12-14 22:55:57 +010027 generic_handle_irq((int)desc->irq_data.handler_data);
Ben Dooks7162ba02010-01-06 10:14:51 +090028}
29
30/* We assume the IRQ_TIMER0..IRQ_TIMER4 range is continuous. */
Thomas Gleixner2d2e1d32011-05-09 10:09:26 +020031static void s3c_irq_timer_ack(struct irq_data *d)
Ben Dooks7162ba02010-01-06 10:14:51 +090032{
Thomas Gleixner2d2e1d32011-05-09 10:09:26 +020033 struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
34 u32 mask = (1 << 5) << (d->irq - gc->irq_base);
Ben Dooks7162ba02010-01-06 10:14:51 +090035
Thomas Gleixner2d2e1d32011-05-09 10:09:26 +020036 irq_reg_writel(mask | gc->mask_cache, gc->reg_base);
Ben Dooks7162ba02010-01-06 10:14:51 +090037}
38
Ben Dooks7162ba02010-01-06 10:14:51 +090039/**
40 * s3c_init_vic_timer_irq() - initialise timer irq chanined off VIC.\
Thomas Gleixner2d2e1d32011-05-09 10:09:26 +020041 * @num: Number of timers to initialize
42 * @timer_irq: Base IRQ number to be used for the timers.
Ben Dooks7162ba02010-01-06 10:14:51 +090043 *
44 * Register the necessary IRQ chaining and support for the timer IRQs
45 * chained of the VIC.
46 */
Thomas Gleixner2d2e1d32011-05-09 10:09:26 +020047void __init s3c_init_vic_timer_irq(unsigned int num, unsigned int timer_irq)
Ben Dooks7162ba02010-01-06 10:14:51 +090048{
Thomas Gleixner2d2e1d32011-05-09 10:09:26 +020049 unsigned int pirq[5] = { IRQ_TIMER0_VIC, IRQ_TIMER1_VIC, IRQ_TIMER2_VIC,
50 IRQ_TIMER3_VIC, IRQ_TIMER4_VIC };
51 struct irq_chip_generic *s3c_tgc;
52 struct irq_chip_type *ct;
53 unsigned int i;
Ben Dooks7162ba02010-01-06 10:14:51 +090054
Thomas Gleixner2d2e1d32011-05-09 10:09:26 +020055 s3c_tgc = irq_alloc_generic_chip("s3c-timer", 1, timer_irq,
56 S3C64XX_TINT_CSTAT, handle_level_irq);
Todd Poynor691abd02011-07-16 11:13:47 +090057
58 if (!s3c_tgc) {
59 pr_err("%s: irq_alloc_generic_chip for IRQ %d failed\n",
60 __func__, timer_irq);
61 return;
62 }
63
Thomas Gleixner2d2e1d32011-05-09 10:09:26 +020064 ct = s3c_tgc->chip_types;
65 ct->chip.irq_mask = irq_gc_mask_clr_bit;
66 ct->chip.irq_unmask = irq_gc_mask_set_bit;
67 ct->chip.irq_ack = s3c_irq_timer_ack;
68 irq_setup_generic_chip(s3c_tgc, IRQ_MSK(num), IRQ_GC_INIT_MASK_CACHE,
69 IRQ_NOREQUEST | IRQ_NOPROBE, 0);
70 /* Clear the upper bits of the mask_cache*/
71 s3c_tgc->mask_cache &= 0x1f;
Ben Dooks7162ba02010-01-06 10:14:51 +090072
Thomas Gleixner2d2e1d32011-05-09 10:09:26 +020073 for (i = 0; i < num; i++, timer_irq++) {
74 irq_set_chained_handler(pirq[i], s3c_irq_demux_vic_timer);
75 irq_set_handler_data(pirq[i], (void *)timer_irq);
76 }
Ben Dooks7162ba02010-01-06 10:14:51 +090077}