Blame view

arch/h8300/platform/h8s/irq.c 3.11 KB
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1
2
3
4
5
6
7
  /*
   * linux/arch/h8300/platform/h8s/ints_h8s.c
   * Interrupt handling CPU variants
   *
   * Yoshinori Sato <ysato@users.sourceforge.jp>
   *
   */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
8
9
10
11
12
13
14
15
  #include <linux/init.h>
  #include <linux/errno.h>
  #include <linux/kernel.h>
  
  #include <asm/ptrace.h>
  #include <asm/traps.h>
  #include <asm/irq.h>
  #include <asm/io.h>
d92ef29a6   Mark Brown   h8300: Move gpio....
16
  #include <asm/gpio-internal.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
17
18
19
20
21
22
23
24
25
26
27
28
  #include <asm/regs267x.h>
  
  /* saved vector list */
  const int __initdata h8300_saved_vectors[]={
  #if defined(CONFIG_GDB_DEBUG)
  	TRACE_VEC,
  	TRAP3_VEC,
  #endif
  	-1
  };
  
  /* trap entry table */
5cc265a5d   Yoshinori Sato   h8300: IRQ handli...
29
  const H8300_VECTOR __initdata h8300_trap_table[] = {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
30
  	0,0,0,0,0,
5cc265a5d   Yoshinori Sato   h8300: IRQ handli...
31
  	trace_break,  /* TRACE */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
32
  	0,0,
5cc265a5d   Yoshinori Sato   h8300: IRQ handli...
33
  	system_call,  /* TRAPA #0 */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
34
35
36
37
38
39
40
41
42
  	0,0,0,0,0,0,0
  };
  
  /* IRQ pin assignment */
  struct irq_pins {
  	unsigned char port_no;
  	unsigned char bit_no;
  } __attribute__((aligned(1),packed));
  /* ISTR = 0 */
3c6bee1d4   Jesper Juhl   [PATCH] turn "con...
43
  static const struct irq_pins irq_assign_table0[16]={
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
44
45
46
47
48
49
50
51
          {H8300_GPIO_P5,H8300_GPIO_B0},{H8300_GPIO_P5,H8300_GPIO_B1},
  	{H8300_GPIO_P5,H8300_GPIO_B2},{H8300_GPIO_P5,H8300_GPIO_B3},
  	{H8300_GPIO_P5,H8300_GPIO_B4},{H8300_GPIO_P5,H8300_GPIO_B5},
  	{H8300_GPIO_P5,H8300_GPIO_B6},{H8300_GPIO_P5,H8300_GPIO_B7},
  	{H8300_GPIO_P6,H8300_GPIO_B0},{H8300_GPIO_P6,H8300_GPIO_B1},
  	{H8300_GPIO_P6,H8300_GPIO_B2},{H8300_GPIO_P6,H8300_GPIO_B3},
  	{H8300_GPIO_P6,H8300_GPIO_B4},{H8300_GPIO_P6,H8300_GPIO_B5},
  	{H8300_GPIO_PF,H8300_GPIO_B1},{H8300_GPIO_PF,H8300_GPIO_B2},
5cc265a5d   Yoshinori Sato   h8300: IRQ handli...
52
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
53
  /* ISTR = 1 */
3c6bee1d4   Jesper Juhl   [PATCH] turn "con...
54
  static const struct irq_pins irq_assign_table1[16]={
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
55
56
57
58
59
60
61
62
63
  	{H8300_GPIO_P8,H8300_GPIO_B0},{H8300_GPIO_P8,H8300_GPIO_B1},
  	{H8300_GPIO_P8,H8300_GPIO_B2},{H8300_GPIO_P8,H8300_GPIO_B3},
  	{H8300_GPIO_P8,H8300_GPIO_B4},{H8300_GPIO_P8,H8300_GPIO_B5},
  	{H8300_GPIO_PH,H8300_GPIO_B2},{H8300_GPIO_PH,H8300_GPIO_B3},
  	{H8300_GPIO_P2,H8300_GPIO_B0},{H8300_GPIO_P2,H8300_GPIO_B1},
  	{H8300_GPIO_P2,H8300_GPIO_B2},{H8300_GPIO_P2,H8300_GPIO_B3},
  	{H8300_GPIO_P2,H8300_GPIO_B4},{H8300_GPIO_P2,H8300_GPIO_B5},
  	{H8300_GPIO_P2,H8300_GPIO_B6},{H8300_GPIO_P2,H8300_GPIO_B7},
  };
5e71c6051   Simon Arlott   spelling fixes: a...
64
  /* IRQ to GPIO pin translation */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
  #define IRQ_GPIO_MAP(irqbit,irq,port,bit)			  \
  do {								  \
  	if (*(volatile unsigned short *)ITSR & irqbit) {	  \
  		port = irq_assign_table1[irq - EXT_IRQ0].port_no; \
  		bit  = irq_assign_table1[irq - EXT_IRQ0].bit_no;  \
  	} else {						  \
  		port = irq_assign_table0[irq - EXT_IRQ0].port_no; \
  		bit  = irq_assign_table0[irq - EXT_IRQ0].bit_no;  \
  	}							  \
  } while(0)
  
  int h8300_enable_irq_pin(unsigned int irq)
  {
  	if (irq >= EXT_IRQ0 && irq <= EXT_IRQ15) {
  		unsigned short ptn = 1 << (irq - EXT_IRQ0);
  		unsigned int port_no,bit_no;
  		IRQ_GPIO_MAP(ptn, irq, port_no, bit_no);
  		if (H8300_GPIO_RESERVE(port_no, bit_no) == 0)
  			return -EBUSY;                   /* pin already use */
  		H8300_GPIO_DDR(port_no, bit_no, H8300_GPIO_INPUT);
  		*(volatile unsigned short *)ISR &= ~ptn; /* ISR clear */
  	}
  
  	return 0;
  }
  
  void h8300_disable_irq_pin(unsigned int irq)
  {
  	if (irq >= EXT_IRQ0 && irq <= EXT_IRQ15) {
  		/* disable interrupt & release IRQ pin */
  		unsigned short ptn = 1 << (irq - EXT_IRQ0);
  		unsigned short port_no,bit_no;
  		*(volatile unsigned short *)ISR &= ~ptn;
  		*(volatile unsigned short *)IER &= ~ptn;
  		IRQ_GPIO_MAP(ptn, irq, port_no, bit_no);
  		H8300_GPIO_FREE(port_no, bit_no);
  	}
  }