aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sh/boards/cqreek
diff options
context:
space:
mode:
Diffstat (limited to 'arch/sh/boards/cqreek')
-rw-r--r--arch/sh/boards/cqreek/Makefile6
-rw-r--r--arch/sh/boards/cqreek/irq.c128
-rw-r--r--arch/sh/boards/cqreek/setup.c101
3 files changed, 235 insertions, 0 deletions
diff --git a/arch/sh/boards/cqreek/Makefile b/arch/sh/boards/cqreek/Makefile
new file mode 100644
index 000000000000..1a788a85eba3
--- /dev/null
+++ b/arch/sh/boards/cqreek/Makefile
@@ -0,0 +1,6 @@
1#
2# Makefile for the CqREEK specific parts of the kernel
3#
4
5obj-y := setup.o irq.o
6
diff --git a/arch/sh/boards/cqreek/irq.c b/arch/sh/boards/cqreek/irq.c
new file mode 100644
index 000000000000..fa6cfe5a20a7
--- /dev/null
+++ b/arch/sh/boards/cqreek/irq.c
@@ -0,0 +1,128 @@
1/* $Id: irq.c,v 1.1.2.4 2002/11/04 20:33:56 lethal Exp $
2 *
3 * arch/sh/boards/cqreek/irq.c
4 *
5 * Copyright (C) 2000 Niibe Yutaka
6 *
7 * CqREEK IDE/ISA Bridge Support.
8 *
9 */
10
11#include <linux/irq.h>
12#include <linux/init.h>
13
14#include <asm/cqreek/cqreek.h>
15#include <asm/io.h>
16#include <asm/io_generic.h>
17#include <asm/irq.h>
18#include <asm/machvec.h>
19#include <asm/machvec_init.h>
20#include <asm/rtc.h>
21
22struct cqreek_irq_data {
23 unsigned short mask_port; /* Port of Interrupt Mask Register */
24 unsigned short stat_port; /* Port of Interrupt Status Register */
25 unsigned short bit; /* Value of the bit */
26};
27static struct cqreek_irq_data cqreek_irq_data[NR_IRQS];
28
29static void disable_cqreek_irq(unsigned int irq)
30{
31 unsigned long flags;
32 unsigned short mask;
33 unsigned short mask_port = cqreek_irq_data[irq].mask_port;
34 unsigned short bit = cqreek_irq_data[irq].bit;
35
36 local_irq_save(flags);
37 /* Disable IRQ */
38 mask = inw(mask_port) & ~bit;
39 outw_p(mask, mask_port);
40 local_irq_restore(flags);
41}
42
43static void enable_cqreek_irq(unsigned int irq)
44{
45 unsigned long flags;
46 unsigned short mask;
47 unsigned short mask_port = cqreek_irq_data[irq].mask_port;
48 unsigned short bit = cqreek_irq_data[irq].bit;
49
50 local_irq_save(flags);
51 /* Enable IRQ */
52 mask = inw(mask_port) | bit;
53 outw_p(mask, mask_port);
54 local_irq_restore(flags);
55}
56
57static void mask_and_ack_cqreek(unsigned int irq)
58{
59 unsigned short stat_port = cqreek_irq_data[irq].stat_port;
60 unsigned short bit = cqreek_irq_data[irq].bit;
61
62 disable_cqreek_irq(irq);
63 /* Clear IRQ (it might be edge IRQ) */
64 inw(stat_port);
65 outw_p(bit, stat_port);
66}
67
68static void end_cqreek_irq(unsigned int irq)
69{
70 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
71 enable_cqreek_irq(irq);
72}
73
74static unsigned int startup_cqreek_irq(unsigned int irq)
75{
76 enable_cqreek_irq(irq);
77 return 0;
78}
79
80static void shutdown_cqreek_irq(unsigned int irq)
81{
82 disable_cqreek_irq(irq);
83}
84
85static struct hw_interrupt_type cqreek_irq_type = {
86 "CqREEK-IRQ",
87 startup_cqreek_irq,
88 shutdown_cqreek_irq,
89 enable_cqreek_irq,
90 disable_cqreek_irq,
91 mask_and_ack_cqreek,
92 end_cqreek_irq
93};
94
95int cqreek_has_ide, cqreek_has_isa;
96
97/* XXX: This is just for test for my NE2000 ISA board
98 What we really need is virtualized IRQ and demultiplexer like HP600 port */
99void __init init_cqreek_IRQ(void)
100{
101 if (cqreek_has_ide) {
102 cqreek_irq_data[14].mask_port = BRIDGE_IDE_INTR_MASK;
103 cqreek_irq_data[14].stat_port = BRIDGE_IDE_INTR_STAT;
104 cqreek_irq_data[14].bit = 1;
105
106 irq_desc[14].handler = &cqreek_irq_type;
107 irq_desc[14].status = IRQ_DISABLED;
108 irq_desc[14].action = 0;
109 irq_desc[14].depth = 1;
110
111 disable_cqreek_irq(14);
112 }
113
114 if (cqreek_has_isa) {
115 cqreek_irq_data[10].mask_port = BRIDGE_ISA_INTR_MASK;
116 cqreek_irq_data[10].stat_port = BRIDGE_ISA_INTR_STAT;
117 cqreek_irq_data[10].bit = (1 << 10);
118
119 /* XXX: Err... we may need demultiplexer for ISA irq... */
120 irq_desc[10].handler = &cqreek_irq_type;
121 irq_desc[10].status = IRQ_DISABLED;
122 irq_desc[10].action = 0;
123 irq_desc[10].depth = 1;
124
125 disable_cqreek_irq(10);
126 }
127}
128
diff --git a/arch/sh/boards/cqreek/setup.c b/arch/sh/boards/cqreek/setup.c
new file mode 100644
index 000000000000..29b537cd6546
--- /dev/null
+++ b/arch/sh/boards/cqreek/setup.c
@@ -0,0 +1,101 @@
1/* $Id: setup.c,v 1.5 2003/08/04 01:51:58 lethal Exp $
2 *
3 * arch/sh/kernel/setup_cqreek.c
4 *
5 * Copyright (C) 2000 Niibe Yutaka
6 *
7 * CqREEK IDE/ISA Bridge Support.
8 *
9 */
10
11#include <linux/config.h>
12#include <linux/kernel.h>
13#include <linux/init.h>
14#include <linux/irq.h>
15
16#include <asm/mach/cqreek.h>
17#include <asm/machvec.h>
18#include <asm/io.h>
19#include <asm/io_generic.h>
20#include <asm/irq.h>
21#include <asm/rtc.h>
22
23#define IDE_OFFSET 0xA4000000UL
24#define ISA_OFFSET 0xA4A00000UL
25
26const char *get_system_type(void)
27{
28 return "CqREEK";
29}
30
31static unsigned long cqreek_port2addr(unsigned long port)
32{
33 if (0x0000<=port && port<=0x0040)
34 return IDE_OFFSET + port;
35 if ((0x01f0<=port && port<=0x01f7) || port == 0x03f6)
36 return IDE_OFFSET + port;
37
38 return ISA_OFFSET + port;
39}
40
41/*
42 * The Machine Vector
43 */
44struct sh_machine_vector mv_cqreek __initmv = {
45#if defined(CONFIG_CPU_SH4)
46 .mv_nr_irqs = 48,
47#elif defined(CONFIG_CPU_SUBTYPE_SH7708)
48 .mv_nr_irqs = 32,
49#elif defined(CONFIG_CPU_SUBTYPE_SH7709)
50 .mv_nr_irqs = 61,
51#endif
52
53 .mv_init_irq = init_cqreek_IRQ,
54
55 .mv_isa_port2addr = cqreek_port2addr,
56};
57ALIAS_MV(cqreek)
58
59/*
60 * Initialize the board
61 */
62void __init platform_setup(void)
63{
64 int i;
65/* udelay is not available at setup time yet... */
66#define DELAY() do {for (i=0; i<10000; i++) ctrl_inw(0xa0000000);} while(0)
67
68 if ((inw (BRIDGE_FEATURE) & 1)) { /* We have IDE interface */
69 outw_p(0, BRIDGE_IDE_INTR_LVL);
70 outw_p(0, BRIDGE_IDE_INTR_MASK);
71
72 outw_p(0, BRIDGE_IDE_CTRL);
73 DELAY();
74
75 outw_p(0x8000, BRIDGE_IDE_CTRL);
76 DELAY();
77
78 outw_p(0xffff, BRIDGE_IDE_INTR_STAT); /* Clear interrupt status */
79 outw_p(0x0f-14, BRIDGE_IDE_INTR_LVL); /* Use 14 IPR */
80 outw_p(1, BRIDGE_IDE_INTR_MASK); /* Enable interrupt */
81 cqreek_has_ide=1;
82 }
83
84 if ((inw (BRIDGE_FEATURE) & 2)) { /* We have ISA interface */
85 outw_p(0, BRIDGE_ISA_INTR_LVL);
86 outw_p(0, BRIDGE_ISA_INTR_MASK);
87
88 outw_p(0, BRIDGE_ISA_CTRL);
89 DELAY();
90 outw_p(0x8000, BRIDGE_ISA_CTRL);
91 DELAY();
92
93 outw_p(0xffff, BRIDGE_ISA_INTR_STAT); /* Clear interrupt status */
94 outw_p(0x0f-10, BRIDGE_ISA_INTR_LVL); /* Use 10 IPR */
95 outw_p(0xfff8, BRIDGE_ISA_INTR_MASK); /* Enable interrupt */
96 cqreek_has_isa=1;
97 }
98
99 printk(KERN_INFO "CqREEK Setup (IDE=%d, ISA=%d)...done\n", cqreek_has_ide, cqreek_has_isa);
100}
101