hd64461.c 2.5 KB
Newer Older
L
Linus Torvalds 已提交
1 2 3 4 5 6 7 8 9 10 11 12
/*
 *	Copyright (C) 2000 YAEGASHI Takeshi
 *	Hitachi HD64461 companion chip support
 */

#include <linux/sched.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/param.h>
#include <linux/interrupt.h>
#include <linux/init.h>
#include <linux/irq.h>
13
#include <linux/io.h>
L
Linus Torvalds 已提交
14
#include <asm/irq.h>
15
#include <asm/hd64461.h>
L
Linus Torvalds 已提交
16

17 18 19
/* This belongs in cpu specific */
#define INTC_ICR1 0xA4140010UL

20
static void hd64461_mask_irq(unsigned int irq)
L
Linus Torvalds 已提交
21 22 23 24
{
	unsigned short nimr;
	unsigned short mask = 1 << (irq - HD64461_IRQBASE);

25
	nimr = __raw_readw(HD64461_NIMR);
L
Linus Torvalds 已提交
26
	nimr |= mask;
27
	__raw_writew(nimr, HD64461_NIMR);
L
Linus Torvalds 已提交
28 29
}

30
static void hd64461_unmask_irq(unsigned int irq)
L
Linus Torvalds 已提交
31 32 33 34
{
	unsigned short nimr;
	unsigned short mask = 1 << (irq - HD64461_IRQBASE);

35
	nimr = __raw_readw(HD64461_NIMR);
L
Linus Torvalds 已提交
36
	nimr &= ~mask;
37
	__raw_writew(nimr, HD64461_NIMR);
L
Linus Torvalds 已提交
38 39
}

40
static void hd64461_mask_and_ack_irq(unsigned int irq)
L
Linus Torvalds 已提交
41
{
42
	hd64461_mask_irq(irq);
L
Linus Torvalds 已提交
43 44
#ifdef CONFIG_HD64461_ENABLER
	if (irq == HD64461_IRQBASE + 13)
45
		__raw_writeb(0x00, HD64461_PCC1CSCR);
L
Linus Torvalds 已提交
46 47 48
#endif
}

49 50 51 52 53
static struct irq_chip hd64461_irq_chip = {
	.name		= "HD64461-IRQ",
	.mask		= hd64461_mask_irq,
	.mask_ack	= hd64461_mask_and_ack_irq,
	.unmask		= hd64461_unmask_irq,
L
Linus Torvalds 已提交
54 55
};

56
static void hd64461_irq_demux(unsigned int irq, struct irq_desc *desc)
L
Linus Torvalds 已提交
57
{
58 59 60 61 62 63 64 65 66 67 68 69 70
	unsigned short intv = ctrl_inw(HD64461_NIRR);
	struct irq_desc *ext_desc;
	unsigned int ext_irq = HD64461_IRQBASE;

	intv &= (1 << HD64461_IRQ_NUM) - 1;

	while (intv) {
		if (intv & 1) {
			ext_desc = irq_desc + ext_irq;
			handle_level_irq(ext_irq, ext_desc);
		}
		intv >>= 1;
		ext_irq++;
L
Linus Torvalds 已提交
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
	}
}

int __init setup_hd64461(void)
{
	int i;

	if (!MACH_HD64461)
		return 0;

	printk(KERN_INFO
	       "HD64461 configured at 0x%x on irq %d(mapped into %d to %d)\n",
	       CONFIG_HD64461_IOBASE, CONFIG_HD64461_IRQ, HD64461_IRQBASE,
	       HD64461_IRQBASE + 15);

86 87 88
/* Should be at processor specific part.. */
#if defined(CONFIG_CPU_SUBTYPE_SH7709)
	__raw_writew(0x2240, INTC_ICR1);
L
Linus Torvalds 已提交
89
#endif
90
	__raw_writew(0xffff, HD64461_NIMR);
L
Linus Torvalds 已提交
91

92
	/*  IRQ 80 -> 95 belongs to HD64461  */
93 94 95
	for (i = HD64461_IRQBASE; i < HD64461_IRQBASE + 16; i++)
		set_irq_chip_and_handler(i, &hd64461_irq_chip,
					 handle_level_irq);
L
Linus Torvalds 已提交
96

97 98 99
	set_irq_chained_handler(CONFIG_HD64461_IRQ, hd64461_irq_demux);
	set_irq_type(CONFIG_HD64461_IRQ, IRQ_TYPE_LEVEL_LOW);

L
Linus Torvalds 已提交
100 101
#ifdef CONFIG_HD64461_ENABLER
	printk(KERN_INFO "HD64461: enabling PCMCIA devices\n");
102 103
	__raw_writeb(0x4c, HD64461_PCC1CSCIER);
	__raw_writeb(0x00, HD64461_PCC1CSCR);
L
Linus Torvalds 已提交
104 105 106 107 108 109
#endif

	return 0;
}

module_init(setup_hd64461);