Blame view

arch/arm/plat-samsung/irq-vic-timer.c 2.43 KB
7162ba037   Ben Dooks   ARM: SAMSUNG: Mov...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
  /* arch/arm/plat-samsung/irq-vic-timer.c
   *	originally part of arch/arm/plat-s3c64xx/irq.c
   *
   * Copyright 2008 Openmoko, Inc.
   * Copyright 2008 Simtec Electronics
   *      Ben Dooks <ben@simtec.co.uk>
   *      http://armlinux.simtec.co.uk/
   *
   * S3C64XX - Interrupt handling
   *
   * This program is free software; you can redistribute it and/or modify
   * it under the terms of the GNU General Public License version 2 as
   * published by the Free Software Foundation.
   */
  
  #include <linux/kernel.h>
  #include <linux/interrupt.h>
  #include <linux/irq.h>
  #include <linux/io.h>
  
  #include <mach/map.h>
  #include <plat/irq-vic-timer.h>
  #include <plat/regs-timer.h>
995b528ad   Marek Szyprowski   ARM: SAMSUNG: Add...
24
  #include <asm/mach/irq.h>
7162ba037   Ben Dooks   ARM: SAMSUNG: Mov...
25
26
  static void s3c_irq_demux_vic_timer(unsigned int irq, struct irq_desc *desc)
  {
995b528ad   Marek Szyprowski   ARM: SAMSUNG: Add...
27
28
  	struct irq_chip *chip = irq_get_chip(irq);
  	chained_irq_enter(chip, desc);
04ea1cc8a   Lennert Buytenhek   ARM: SAMSUNG: som...
29
  	generic_handle_irq((int)desc->irq_data.handler_data);
995b528ad   Marek Szyprowski   ARM: SAMSUNG: Add...
30
  	chained_irq_exit(chip, desc);
7162ba037   Ben Dooks   ARM: SAMSUNG: Mov...
31
32
33
  }
  
  /* We assume the IRQ_TIMER0..IRQ_TIMER4 range is continuous. */
2d2e1d3c4   Thomas Gleixner   ARM: SAMSUNG: Con...
34
  static void s3c_irq_timer_ack(struct irq_data *d)
7162ba037   Ben Dooks   ARM: SAMSUNG: Mov...
35
  {
2d2e1d3c4   Thomas Gleixner   ARM: SAMSUNG: Con...
36
37
  	struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
  	u32 mask = (1 << 5) << (d->irq - gc->irq_base);
7162ba037   Ben Dooks   ARM: SAMSUNG: Mov...
38

2d2e1d3c4   Thomas Gleixner   ARM: SAMSUNG: Con...
39
  	irq_reg_writel(mask | gc->mask_cache, gc->reg_base);
7162ba037   Ben Dooks   ARM: SAMSUNG: Mov...
40
  }
7162ba037   Ben Dooks   ARM: SAMSUNG: Mov...
41
42
  /**
   * s3c_init_vic_timer_irq() - initialise timer irq chanined off VIC.\
2d2e1d3c4   Thomas Gleixner   ARM: SAMSUNG: Con...
43
44
   * @num: Number of timers to initialize
   * @timer_irq: Base IRQ number to be used for the timers.
7162ba037   Ben Dooks   ARM: SAMSUNG: Mov...
45
46
47
48
   *
   * Register the necessary IRQ chaining and support for the timer IRQs
   * chained of the VIC.
   */
2d2e1d3c4   Thomas Gleixner   ARM: SAMSUNG: Con...
49
  void __init s3c_init_vic_timer_irq(unsigned int num, unsigned int timer_irq)
7162ba037   Ben Dooks   ARM: SAMSUNG: Mov...
50
  {
2d2e1d3c4   Thomas Gleixner   ARM: SAMSUNG: Con...
51
52
53
54
55
  	unsigned int pirq[5] = { IRQ_TIMER0_VIC, IRQ_TIMER1_VIC, IRQ_TIMER2_VIC,
  				 IRQ_TIMER3_VIC, IRQ_TIMER4_VIC };
  	struct irq_chip_generic *s3c_tgc;
  	struct irq_chip_type *ct;
  	unsigned int i;
7162ba037   Ben Dooks   ARM: SAMSUNG: Mov...
56

2d2e1d3c4   Thomas Gleixner   ARM: SAMSUNG: Con...
57
58
  	s3c_tgc = irq_alloc_generic_chip("s3c-timer", 1, timer_irq,
  					 S3C64XX_TINT_CSTAT, handle_level_irq);
691abd0ab   Todd Poynor   ARM: SAMSUNG: Che...
59
60
61
62
63
64
65
  
  	if (!s3c_tgc) {
  		pr_err("%s: irq_alloc_generic_chip for IRQ %d failed
  ",
  		       __func__, timer_irq);
  		return;
  	}
2d2e1d3c4   Thomas Gleixner   ARM: SAMSUNG: Con...
66
67
68
69
70
71
72
73
  	ct = s3c_tgc->chip_types;
  	ct->chip.irq_mask = irq_gc_mask_clr_bit;
  	ct->chip.irq_unmask = irq_gc_mask_set_bit;
  	ct->chip.irq_ack = s3c_irq_timer_ack;
  	irq_setup_generic_chip(s3c_tgc, IRQ_MSK(num), IRQ_GC_INIT_MASK_CACHE,
  			       IRQ_NOREQUEST | IRQ_NOPROBE, 0);
  	/* Clear the upper bits of the mask_cache*/
  	s3c_tgc->mask_cache &= 0x1f;
7162ba037   Ben Dooks   ARM: SAMSUNG: Mov...
74

2d2e1d3c4   Thomas Gleixner   ARM: SAMSUNG: Con...
75
76
77
78
  	for (i = 0; i < num; i++, timer_irq++) {
  		irq_set_chained_handler(pirq[i], s3c_irq_demux_vic_timer);
  		irq_set_handler_data(pirq[i], (void *)timer_irq);
  	}
7162ba037   Ben Dooks   ARM: SAMSUNG: Mov...
79
  }