summaryrefslogtreecommitdiff
path: root/arch/sh/boards/se/7722/irq.c
blob: 099e5deb77f8d1d110b567b1920e93811b8a1126 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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
/*
 * linux/arch/sh/boards/se/7722/irq.c
 *
 * Copyright (C) 2007  Nobuhiro Iwamatsu
 *
 * Hitachi UL SolutionEngine 7722 Support.
 *
 * This file is subject to the terms and conditions of the GNU General Public
 * License.  See the file "COPYING" in the main directory of this archive
 * for more details.
 */
#include <linux/init.h>
#include <linux/irq.h>
#include <linux/interrupt.h>
#include <asm/irq.h>
#include <asm/io.h>
#include <asm/se7722.h>

#define INTC_INTMSK0             0xFFD00044
#define INTC_INTMSKCLR0          0xFFD00064

static void disable_se7722_irq(unsigned int irq)
{
	struct ipr_data *p = get_irq_chip_data(irq);
	ctrl_outw( ctrl_inw( p->addr ) | p->priority , p->addr );
}

static void enable_se7722_irq(unsigned int irq)
{
	struct ipr_data *p = get_irq_chip_data(irq);
	ctrl_outw( ctrl_inw( p->addr ) & ~p->priority , p->addr );
}

static struct irq_chip se7722_irq_chip __read_mostly = {
	.name           = "SE7722",
	.mask           = disable_se7722_irq,
	.unmask         = enable_se7722_irq,
	.mask_ack       = disable_se7722_irq,
};

static struct ipr_data ipr_irq_table[] = {
	/* irq        ,idx,sft, priority     , addr   */
	{ MRSHPC_IRQ0 , 0 , 0 , MRSHPC_BIT0 , IRQ01_MASK } ,
	{ MRSHPC_IRQ1 , 0 , 0 , MRSHPC_BIT1 , IRQ01_MASK } ,
	{ MRSHPC_IRQ2 , 0 , 0 , MRSHPC_BIT2 , IRQ01_MASK } ,
	{ MRSHPC_IRQ3 , 0 , 0 , MRSHPC_BIT3 , IRQ01_MASK } ,
	{ SMC_IRQ     , 0 , 0 , SMC_BIT     , IRQ01_MASK } ,
	{ EXT_IRQ     , 0 , 0 , EXT_BIT     , IRQ01_MASK } ,
};

int se7722_irq_demux(int irq)
{

	if ((irq == IRQ0_IRQ)||(irq == IRQ1_IRQ)) {
		volatile unsigned short intv =
			*(volatile unsigned short *)IRQ01_STS;
		if (irq == IRQ0_IRQ){
			if(intv & SMC_BIT ) {
				return SMC_IRQ;
			} else if(intv & USB_BIT) {
				return USB_IRQ;
			} else {
				printk("intv =%04x\n", intv);
				return SMC_IRQ;
			}
		} else if(irq == IRQ1_IRQ){
			if(intv & MRSHPC_BIT0) {
				return MRSHPC_IRQ0;
			} else if(intv & MRSHPC_BIT1) {
				return MRSHPC_IRQ1;
			} else if(intv & MRSHPC_BIT2) {
				return MRSHPC_IRQ2;
			} else if(intv & MRSHPC_BIT3) {
				return MRSHPC_IRQ3;
			} else {
				printk("BIT_EXTENTION =%04x\n", intv);
				return EXT_IRQ;
			}
		}
	}
	return irq;

}
/*
 * Initialize IRQ setting
 */
void __init init_se7722_IRQ(void)
{
	int i = 0;
	ctrl_outw(0x2000, 0xb03fffec);  /* mrshpc irq enable */
	ctrl_outl((3 << ((7 - 0) * 4))|(3 << ((7 - 1) * 4)), INTC_INTPRI0);     /* irq0 pri=3,irq1,pri=3 */
	ctrl_outw((2 << ((7 - 0) * 2))|(2 << ((7 - 1) * 2)), INTC_ICR1);        /* irq0,1 low-level irq */

	for (i = 0; i < ARRAY_SIZE(ipr_irq_table); i++) {
		disable_irq_nosync(ipr_irq_table[i].irq);
		set_irq_chip_and_handler_name( ipr_irq_table[i].irq, &se7722_irq_chip,
			handle_level_irq, "level");
		set_irq_chip_data( ipr_irq_table[i].irq, &ipr_irq_table[i] );
		disable_se7722_irq(ipr_irq_table[i].irq);
	}
}