PageRenderTime 24ms CodeModel.GetById 19ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 1ms

/arch/h8300/platform/h8300h/ints_h8300h.c

https://bitbucket.org/evzijst/gittest
C | 86 lines | 66 code | 9 blank | 11 comment | 8 complexity | 188ffd2968eaaad59df02288535c654c MD5 | raw file
 1/*
 2 * linux/arch/h8300/platform/h8300h/ints_h8300h.c
 3 * Interrupt handling CPU variants
 4 *
 5 * Yoshinori Sato <ysato@users.sourceforge.jp>
 6 *
 7 */
 8
 9#include <linux/config.h>
10#include <linux/init.h>
11#include <linux/errno.h>
12
13#include <asm/ptrace.h>
14#include <asm/traps.h>
15#include <asm/irq.h>
16#include <asm/io.h>
17#include <asm/gpio.h>
18#include <asm/regs306x.h>
19
20/* saved vector list */
21const int __initdata h8300_saved_vectors[]={
22#if defined(CONFIG_GDB_DEBUG)
23	TRAP3_VEC,
24#endif
25	-1
26};
27
28/* trap entry table */
29const unsigned long __initdata h8300_trap_table[NR_TRAPS]={
30	0,0,0,0,0,0,0,0,
31	(unsigned long)system_call,  /* TRAPA #0 */
32	0,0,
33	(unsigned long)trace_break,  /* TRAPA #3 */
34};
35
36int h8300_enable_irq_pin(unsigned int irq)
37{
38	int bitmask;
39	if (irq < EXT_IRQ0 || irq > EXT_IRQ5)
40		return 0;
41
42	/* initialize IRQ pin */
43	bitmask = 1 << (irq - EXT_IRQ0);
44	switch(irq) {
45	case EXT_IRQ0:
46	case EXT_IRQ1:
47	case EXT_IRQ2:
48	case EXT_IRQ3:
49		if (H8300_GPIO_RESERVE(H8300_GPIO_P8, bitmask) == 0)
50			return -EBUSY;
51		H8300_GPIO_DDR(H8300_GPIO_P8, bitmask, H8300_GPIO_INPUT);
52		break;
53	case EXT_IRQ4:
54	case EXT_IRQ5:
55		if (H8300_GPIO_RESERVE(H8300_GPIO_P9, bitmask) == 0)
56			return -EBUSY;
57		H8300_GPIO_DDR(H8300_GPIO_P9, bitmask, H8300_GPIO_INPUT);
58		break;
59	}
60
61	return 0;
62}
63
64void h8300_disable_irq_pin(unsigned int irq)
65{
66	int bitmask;
67	if (irq < EXT_IRQ0 || irq > EXT_IRQ5)
68		return;
69
70	/* disable interrupt & release IRQ pin */
71	bitmask = 1 << (irq - EXT_IRQ0);
72	switch(irq) {
73	case EXT_IRQ0:
74	case EXT_IRQ1:
75	case EXT_IRQ2:
76	case EXT_IRQ3:
77		*(volatile unsigned char *)IER &= ~bitmask;
78		H8300_GPIO_FREE(H8300_GPIO_P8, bitmask);
79		break ;
80	case EXT_IRQ4:
81	case EXT_IRQ5:
82		*(volatile unsigned char *)IER &= ~bitmask;
83		H8300_GPIO_FREE(H8300_GPIO_P9, bitmask);
84		break;
85	}
86}