aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sh/boards/bigsur
diff options
context:
space:
mode:
Diffstat (limited to 'arch/sh/boards/bigsur')
-rw-r--r--arch/sh/boards/bigsur/Makefile6
-rw-r--r--arch/sh/boards/bigsur/io.c125
-rw-r--r--arch/sh/boards/bigsur/irq.c348
-rw-r--r--arch/sh/boards/bigsur/led.c55
-rw-r--r--arch/sh/boards/bigsur/setup.c96
5 files changed, 630 insertions, 0 deletions
diff --git a/arch/sh/boards/bigsur/Makefile b/arch/sh/boards/bigsur/Makefile
new file mode 100644
index 000000000000..0ff9497ac58e
--- /dev/null
+++ b/arch/sh/boards/bigsur/Makefile
@@ -0,0 +1,6 @@
1#
2# Makefile for the BigSur specific parts of the kernel
3#
4
5obj-y := setup.o io.o irq.o led.o
6
diff --git a/arch/sh/boards/bigsur/io.c b/arch/sh/boards/bigsur/io.c
new file mode 100644
index 000000000000..697144de7419
--- /dev/null
+++ b/arch/sh/boards/bigsur/io.c
@@ -0,0 +1,125 @@
1/*
2 * include/asm-sh/io_bigsur.c
3 *
4 * By Dustin McIntire (dustin@sensoria.com) (c)2001
5 * Derived from io_hd64465.h, which bore the message:
6 * By Greg Banks <gbanks@pocketpenguins.com>
7 * (c) 2000 PocketPenguins Inc.
8 * and from io_hd64461.h, which bore the message:
9 * Copyright 2000 Stuart Menefy (stuart.menefy@st.com)
10 *
11 * May be copied or modified under the terms of the GNU General Public
12 * License. See linux/COPYING for more information.
13 *
14 * IO functions for a Hitachi Big Sur Evaluation Board.
15 */
16
17#include <linux/config.h>
18#include <linux/kernel.h>
19#include <linux/module.h>
20#include <asm/machvec.h>
21#include <asm/io.h>
22#include <asm/bigsur/bigsur.h>
23
24/* Low iomap maps port 0-1K to addresses in 8byte chunks */
25#define BIGSUR_IOMAP_LO_THRESH 0x400
26#define BIGSUR_IOMAP_LO_SHIFT 3
27#define BIGSUR_IOMAP_LO_MASK ((1<<BIGSUR_IOMAP_LO_SHIFT)-1)
28#define BIGSUR_IOMAP_LO_NMAP (BIGSUR_IOMAP_LO_THRESH>>BIGSUR_IOMAP_LO_SHIFT)
29static u32 bigsur_iomap_lo[BIGSUR_IOMAP_LO_NMAP];
30static u8 bigsur_iomap_lo_shift[BIGSUR_IOMAP_LO_NMAP];
31
32/* High iomap maps port 1K-64K to addresses in 1K chunks */
33#define BIGSUR_IOMAP_HI_THRESH 0x10000
34#define BIGSUR_IOMAP_HI_SHIFT 10
35#define BIGSUR_IOMAP_HI_MASK ((1<<BIGSUR_IOMAP_HI_SHIFT)-1)
36#define BIGSUR_IOMAP_HI_NMAP (BIGSUR_IOMAP_HI_THRESH>>BIGSUR_IOMAP_HI_SHIFT)
37static u32 bigsur_iomap_hi[BIGSUR_IOMAP_HI_NMAP];
38static u8 bigsur_iomap_hi_shift[BIGSUR_IOMAP_HI_NMAP];
39
40#ifndef MAX
41#define MAX(a,b) ((a)>(b)?(a):(b))
42#endif
43
44void bigsur_port_map(u32 baseport, u32 nports, u32 addr, u8 shift)
45{
46 u32 port, endport = baseport + nports;
47
48 pr_debug("bigsur_port_map(base=0x%0x, n=0x%0x, addr=0x%08x)\n",
49 baseport, nports, addr);
50
51 for (port = baseport ;
52 port < endport && port < BIGSUR_IOMAP_LO_THRESH ;
53 port += (1<<BIGSUR_IOMAP_LO_SHIFT)) {
54 pr_debug(" maplo[0x%x] = 0x%08x\n", port, addr);
55 bigsur_iomap_lo[port>>BIGSUR_IOMAP_LO_SHIFT] = addr;
56 bigsur_iomap_lo_shift[port>>BIGSUR_IOMAP_LO_SHIFT] = shift;
57 addr += (1<<(BIGSUR_IOMAP_LO_SHIFT));
58 }
59
60 for (port = MAX(baseport, BIGSUR_IOMAP_LO_THRESH) ;
61 port < endport && port < BIGSUR_IOMAP_HI_THRESH ;
62 port += (1<<BIGSUR_IOMAP_HI_SHIFT)) {
63 pr_debug(" maphi[0x%x] = 0x%08x\n", port, addr);
64 bigsur_iomap_hi[port>>BIGSUR_IOMAP_HI_SHIFT] = addr;
65 bigsur_iomap_hi_shift[port>>BIGSUR_IOMAP_HI_SHIFT] = shift;
66 addr += (1<<(BIGSUR_IOMAP_HI_SHIFT));
67 }
68}
69EXPORT_SYMBOL(bigsur_port_map);
70
71void bigsur_port_unmap(u32 baseport, u32 nports)
72{
73 u32 port, endport = baseport + nports;
74
75 pr_debug("bigsur_port_unmap(base=0x%0x, n=0x%0x)\n", baseport, nports);
76
77 for (port = baseport ;
78 port < endport && port < BIGSUR_IOMAP_LO_THRESH ;
79 port += (1<<BIGSUR_IOMAP_LO_SHIFT)) {
80 bigsur_iomap_lo[port>>BIGSUR_IOMAP_LO_SHIFT] = 0;
81 }
82
83 for (port = MAX(baseport, BIGSUR_IOMAP_LO_THRESH) ;
84 port < endport && port < BIGSUR_IOMAP_HI_THRESH ;
85 port += (1<<BIGSUR_IOMAP_HI_SHIFT)) {
86 bigsur_iomap_hi[port>>BIGSUR_IOMAP_HI_SHIFT] = 0;
87 }
88}
89EXPORT_SYMBOL(bigsur_port_unmap);
90
91unsigned long bigsur_isa_port2addr(unsigned long port)
92{
93 unsigned long addr = 0;
94 unsigned char shift;
95
96 /* Physical address not in P0, do nothing */
97 if (PXSEG(port)) {
98 addr = port;
99 /* physical address in P0, map to P2 */
100 } else if (port >= 0x30000) {
101 addr = P2SEGADDR(port);
102 /* Big Sur I/O + HD64465 registers 0x10000-0x30000 */
103 } else if (port >= BIGSUR_IOMAP_HI_THRESH) {
104 addr = BIGSUR_INTERNAL_BASE + (port - BIGSUR_IOMAP_HI_THRESH);
105 /* Handle remapping of high IO/PCI IO ports */
106 } else if (port >= BIGSUR_IOMAP_LO_THRESH) {
107 addr = bigsur_iomap_hi[port >> BIGSUR_IOMAP_HI_SHIFT];
108 shift = bigsur_iomap_hi_shift[port >> BIGSUR_IOMAP_HI_SHIFT];
109
110 if (addr != 0)
111 addr += (port & BIGSUR_IOMAP_HI_MASK) << shift;
112 } else {
113 /* Handle remapping of low IO ports */
114 addr = bigsur_iomap_lo[port >> BIGSUR_IOMAP_LO_SHIFT];
115 shift = bigsur_iomap_lo_shift[port >> BIGSUR_IOMAP_LO_SHIFT];
116
117 if (addr != 0)
118 addr += (port & BIGSUR_IOMAP_LO_MASK) << shift;
119 }
120
121 pr_debug("%s(0x%08lx) = 0x%08lx\n", __FUNCTION__, port, addr);
122
123 return addr;
124}
125
diff --git a/arch/sh/boards/bigsur/irq.c b/arch/sh/boards/bigsur/irq.c
new file mode 100644
index 000000000000..c188fc32dc9a
--- /dev/null
+++ b/arch/sh/boards/bigsur/irq.c
@@ -0,0 +1,348 @@
1/*
2 *
3 * By Dustin McIntire (dustin@sensoria.com) (c)2001
4 *
5 * Setup and IRQ handling code for the HD64465 companion chip.
6 * by Greg Banks <gbanks@pocketpenguins.com>
7 * Copyright (c) 2000 PocketPenguins Inc
8 *
9 * Derived from setup_hd64465.c which bore the message:
10 * Greg Banks <gbanks@pocketpenguins.com>
11 * Copyright (c) 2000 PocketPenguins Inc and
12 * Copyright (C) 2000 YAEGASHI Takeshi
13 * and setup_cqreek.c which bore message:
14 * Copyright (C) 2000 Niibe Yutaka
15 *
16 * May be copied or modified under the terms of the GNU General Public
17 * License. See linux/COPYING for more information.
18 *
19 * IRQ functions for a Hitachi Big Sur Evaluation Board.
20 *
21 */
22
23#include <linux/config.h>
24#include <linux/sched.h>
25#include <linux/module.h>
26#include <linux/kernel.h>
27#include <linux/param.h>
28#include <linux/ioport.h>
29#include <linux/interrupt.h>
30#include <linux/init.h>
31#include <linux/irq.h>
32#include <linux/bitops.h>
33
34#include <asm/io.h>
35#include <asm/irq.h>
36
37#include <asm/bigsur/io.h>
38#include <asm/hd64465/hd64465.h>
39#include <asm/bigsur/bigsur.h>
40
41//#define BIGSUR_DEBUG 3
42#undef BIGSUR_DEBUG
43
44#ifdef BIGSUR_DEBUG
45#define DPRINTK(args...) printk(args)
46#define DIPRINTK(n, args...) if (BIGSUR_DEBUG>(n)) printk(args)
47#else
48#define DPRINTK(args...)
49#define DIPRINTK(n, args...)
50#endif /* BIGSUR_DEBUG */
51
52#ifdef CONFIG_HD64465
53extern int hd64465_irq_demux(int irq);
54#endif /* CONFIG_HD64465 */
55
56
57/*===========================================================*/
58// Big Sur CPLD IRQ Routines
59/*===========================================================*/
60
61/* Level 1 IRQ routines */
62static void disable_bigsur_l1irq(unsigned int irq)
63{
64 unsigned long flags;
65 unsigned char mask;
66 unsigned int mask_port = ((irq - BIGSUR_IRQ_LOW)/8) ? BIGSUR_IRLMR1 : BIGSUR_IRLMR0;
67 unsigned char bit = (1 << ((irq - MGATE_IRQ_LOW)%8) );
68
69 if(irq >= BIGSUR_IRQ_LOW && irq < BIGSUR_IRQ_HIGH) {
70 DPRINTK("Disable L1 IRQ %d\n", irq);
71 DIPRINTK(2,"disable_bigsur_l1irq: IMR=0x%08x mask=0x%x\n",
72 mask_port, bit);
73 local_irq_save(flags);
74
75 /* Disable IRQ - set mask bit */
76 mask = inb(mask_port) | bit;
77 outb(mask, mask_port);
78 local_irq_restore(flags);
79 return;
80 }
81 DPRINTK("disable_bigsur_l1irq: Invalid IRQ %d\n", irq);
82}
83
84static void enable_bigsur_l1irq(unsigned int irq)
85{
86 unsigned long flags;
87 unsigned char mask;
88 unsigned int mask_port = ((irq - BIGSUR_IRQ_LOW)/8) ? BIGSUR_IRLMR1 : BIGSUR_IRLMR0;
89 unsigned char bit = (1 << ((irq - MGATE_IRQ_LOW)%8) );
90
91 if(irq >= BIGSUR_IRQ_LOW && irq < BIGSUR_IRQ_HIGH) {
92 DPRINTK("Enable L1 IRQ %d\n", irq);
93 DIPRINTK(2,"enable_bigsur_l1irq: IMR=0x%08x mask=0x%x\n",
94 mask_port, bit);
95 local_irq_save(flags);
96 /* Enable L1 IRQ - clear mask bit */
97 mask = inb(mask_port) & ~bit;
98 outb(mask, mask_port);
99 local_irq_restore(flags);
100 return;
101 }
102 DPRINTK("enable_bigsur_l1irq: Invalid IRQ %d\n", irq);
103}
104
105
106/* Level 2 irq masks and registers for L2 decoding */
107/* Level2 bitmasks for each level 1 IRQ */
108const u32 bigsur_l2irq_mask[] =
109 {0x40,0x80,0x08,0x01,0x01,0x3C,0x3E,0xFF,0x40,0x80,0x06,0x03};
110/* Level2 to ISR[n] map for each level 1 IRQ */
111const u32 bigsur_l2irq_reg[] =
112 { 2, 2, 3, 3, 1, 2, 1, 0, 1, 1, 3, 2};
113/* Level2 to Level 1 IRQ map */
114const u32 bigsur_l2_l1_map[] =
115 {7,7,7,7,7,7,7,7, 4,6,6,6,6,6,8,9, 11,11,5,5,5,5,0,1, 3,10,10,2,-1,-1,-1,-1};
116/* IRQ inactive level (high or low) */
117const u32 bigsur_l2_inactv_state[] = {0x00, 0xBE, 0xFC, 0xF7};
118
119/* CPLD external status and mask registers base and offsets */
120static const u32 isr_base = BIGSUR_IRQ0;
121static const u32 isr_offset = BIGSUR_IRQ0 - BIGSUR_IRQ1;
122static const u32 imr_base = BIGSUR_IMR0;
123static const u32 imr_offset = BIGSUR_IMR0 - BIGSUR_IMR1;
124
125#define REG_NUM(irq) ((irq-BIGSUR_2NDLVL_IRQ_LOW)/8 )
126
127/* Level 2 IRQ routines */
128static void disable_bigsur_l2irq(unsigned int irq)
129{
130 unsigned long flags;
131 unsigned char mask;
132 unsigned char bit = 1 << ((irq-BIGSUR_2NDLVL_IRQ_LOW)%8);
133 unsigned int mask_port = imr_base - REG_NUM(irq)*imr_offset;
134
135 if(irq >= BIGSUR_2NDLVL_IRQ_LOW && irq < BIGSUR_2NDLVL_IRQ_HIGH) {
136 DPRINTK("Disable L2 IRQ %d\n", irq);
137 DIPRINTK(2,"disable_bigsur_l2irq: IMR=0x%08x mask=0x%x\n",
138 mask_port, bit);
139 local_irq_save(flags);
140
141 /* Disable L2 IRQ - set mask bit */
142 mask = inb(mask_port) | bit;
143 outb(mask, mask_port);
144 local_irq_restore(flags);
145 return;
146 }
147 DPRINTK("disable_bigsur_l2irq: Invalid IRQ %d\n", irq);
148}
149
150static void enable_bigsur_l2irq(unsigned int irq)
151{
152 unsigned long flags;
153 unsigned char mask;
154 unsigned char bit = 1 << ((irq-BIGSUR_2NDLVL_IRQ_LOW)%8);
155 unsigned int mask_port = imr_base - REG_NUM(irq)*imr_offset;
156
157 if(irq >= BIGSUR_2NDLVL_IRQ_LOW && irq < BIGSUR_2NDLVL_IRQ_HIGH) {
158 DPRINTK("Enable L2 IRQ %d\n", irq);
159 DIPRINTK(2,"enable_bigsur_l2irq: IMR=0x%08x mask=0x%x\n",
160 mask_port, bit);
161 local_irq_save(flags);
162
163 /* Enable L2 IRQ - clear mask bit */
164 mask = inb(mask_port) & ~bit;
165 outb(mask, mask_port);
166 local_irq_restore(flags);
167 return;
168 }
169 DPRINTK("enable_bigsur_l2irq: Invalid IRQ %d\n", irq);
170}
171
172static void mask_and_ack_bigsur(unsigned int irq)
173{
174 DPRINTK("mask_and_ack_bigsur IRQ %d\n", irq);
175 if(irq >= BIGSUR_IRQ_LOW && irq < BIGSUR_IRQ_HIGH)
176 disable_bigsur_l1irq(irq);
177 else
178 disable_bigsur_l2irq(irq);
179}
180
181static void end_bigsur_irq(unsigned int irq)
182{
183 DPRINTK("end_bigsur_irq IRQ %d\n", irq);
184 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS))) {
185 if(irq >= BIGSUR_IRQ_LOW && irq < BIGSUR_IRQ_HIGH)
186 enable_bigsur_l1irq(irq);
187 else
188 enable_bigsur_l2irq(irq);
189 }
190}
191
192static unsigned int startup_bigsur_irq(unsigned int irq)
193{
194 u8 mask;
195 u32 reg;
196
197 DPRINTK("startup_bigsur_irq IRQ %d\n", irq);
198
199 if(irq >= BIGSUR_IRQ_LOW && irq < BIGSUR_IRQ_HIGH) {
200 /* Enable the L1 IRQ */
201 enable_bigsur_l1irq(irq);
202 /* Enable all L2 IRQs in this L1 IRQ */
203 mask = ~(bigsur_l2irq_mask[irq-BIGSUR_IRQ_LOW]);
204 reg = imr_base - bigsur_l2irq_reg[irq-BIGSUR_IRQ_LOW] * imr_offset;
205 mask &= inb(reg);
206 outb(mask,reg);
207 DIPRINTK(2,"startup_bigsur_irq: IMR=0x%08x mask=0x%x\n",reg,inb(reg));
208 }
209 else {
210 /* Enable the L2 IRQ - clear mask bit */
211 enable_bigsur_l2irq(irq);
212 /* Enable the L1 bit masking this L2 IRQ */
213 enable_bigsur_l1irq(bigsur_l2_l1_map[irq-BIGSUR_2NDLVL_IRQ_LOW]);
214 DIPRINTK(2,"startup_bigsur_irq: L1=%d L2=%d\n",
215 bigsur_l2_l1_map[irq-BIGSUR_2NDLVL_IRQ_LOW],irq);
216 }
217 return 0;
218}
219
220static void shutdown_bigsur_irq(unsigned int irq)
221{
222 DPRINTK("shutdown_bigsur_irq IRQ %d\n", irq);
223 if(irq >= BIGSUR_IRQ_LOW && irq < BIGSUR_IRQ_HIGH)
224 disable_bigsur_l1irq(irq);
225 else
226 disable_bigsur_l2irq(irq);
227}
228
229/* Define the IRQ structures for the L1 and L2 IRQ types */
230static struct hw_interrupt_type bigsur_l1irq_type = {
231 "BigSur-CPLD-Level1-IRQ",
232 startup_bigsur_irq,
233 shutdown_bigsur_irq,
234 enable_bigsur_l1irq,
235 disable_bigsur_l1irq,
236 mask_and_ack_bigsur,
237 end_bigsur_irq
238};
239
240static struct hw_interrupt_type bigsur_l2irq_type = {
241 "BigSur-CPLD-Level2-IRQ",
242 startup_bigsur_irq,
243 shutdown_bigsur_irq,
244 enable_bigsur_l2irq,
245 disable_bigsur_l2irq,
246 mask_and_ack_bigsur,
247 end_bigsur_irq
248};
249
250
251static void make_bigsur_l1isr(unsigned int irq) {
252
253 /* sanity check first */
254 if(irq >= BIGSUR_IRQ_LOW && irq < BIGSUR_IRQ_HIGH) {
255 /* save the handler in the main description table */
256 irq_desc[irq].handler = &bigsur_l1irq_type;
257 irq_desc[irq].status = IRQ_DISABLED;
258 irq_desc[irq].action = 0;
259 irq_desc[irq].depth = 1;
260
261 disable_bigsur_l1irq(irq);
262 return;
263 }
264 DPRINTK("make_bigsur_l1isr: bad irq, %d\n", irq);
265 return;
266}
267
268static void make_bigsur_l2isr(unsigned int irq) {
269
270 /* sanity check first */
271 if(irq >= BIGSUR_2NDLVL_IRQ_LOW && irq < BIGSUR_2NDLVL_IRQ_HIGH) {
272 /* save the handler in the main description table */
273 irq_desc[irq].handler = &bigsur_l2irq_type;
274 irq_desc[irq].status = IRQ_DISABLED;
275 irq_desc[irq].action = 0;
276 irq_desc[irq].depth = 1;
277
278 disable_bigsur_l2irq(irq);
279 return;
280 }
281 DPRINTK("make_bigsur_l2isr: bad irq, %d\n", irq);
282 return;
283}
284
285/* The IRQ's will be decoded as follows:
286 * If a level 2 handler exists and there is an unmasked active
287 * IRQ, the 2nd level handler will be called.
288 * If a level 2 handler does not exist for the active IRQ
289 * the 1st level handler will be called.
290 */
291
292int bigsur_irq_demux(int irq)
293{
294 int dmux_irq = irq;
295 u8 mask, actv_irqs;
296 u32 reg_num;
297
298 DIPRINTK(3,"bigsur_irq_demux, irq=%d\n", irq);
299 /* decode the 1st level IRQ */
300 if(irq >= BIGSUR_IRQ_LOW && irq < BIGSUR_IRQ_HIGH) {
301 /* Get corresponding L2 ISR bitmask and ISR number */
302 mask = bigsur_l2irq_mask[irq-BIGSUR_IRQ_LOW];
303 reg_num = bigsur_l2irq_reg[irq-BIGSUR_IRQ_LOW];
304 /* find the active IRQ's (XOR with inactive level)*/
305 actv_irqs = inb(isr_base-reg_num*isr_offset) ^
306 bigsur_l2_inactv_state[reg_num];
307 /* decode active IRQ's */
308 actv_irqs = actv_irqs & mask & ~(inb(imr_base-reg_num*imr_offset));
309 /* if NEZ then we have an active L2 IRQ */
310 if(actv_irqs) dmux_irq = ffz(~actv_irqs) + reg_num*8+BIGSUR_2NDLVL_IRQ_LOW;
311 /* if no 2nd level IRQ action, but has 1st level, use 1st level handler */
312 if(!irq_desc[dmux_irq].action && irq_desc[irq].action)
313 dmux_irq = irq;
314 DIPRINTK(1,"bigsur_irq_demux: irq=%d dmux_irq=%d mask=0x%04x reg=%d\n",
315 irq, dmux_irq, mask, reg_num);
316 }
317#ifdef CONFIG_HD64465
318 dmux_irq = hd64465_irq_demux(dmux_irq);
319#endif /* CONFIG_HD64465 */
320 DIPRINTK(3,"bigsur_irq_demux, demux_irq=%d\n", dmux_irq);
321
322 return dmux_irq;
323}
324
325/*===========================================================*/
326// Big Sur Init Routines
327/*===========================================================*/
328void __init init_bigsur_IRQ(void)
329{
330 int i;
331
332 if (!MACH_BIGSUR) return;
333
334 /* Create ISR's for Big Sur CPLD IRQ's */
335 /*==============================================================*/
336 for(i=BIGSUR_IRQ_LOW;i<BIGSUR_IRQ_HIGH;i++)
337 make_bigsur_l1isr(i);
338
339 printk(KERN_INFO "Big Sur CPLD L1 interrupts %d to %d.\n",
340 BIGSUR_IRQ_LOW,BIGSUR_IRQ_HIGH);
341
342 for(i=BIGSUR_2NDLVL_IRQ_LOW;i<BIGSUR_2NDLVL_IRQ_HIGH;i++)
343 make_bigsur_l2isr(i);
344
345 printk(KERN_INFO "Big Sur CPLD L2 interrupts %d to %d.\n",
346 BIGSUR_2NDLVL_IRQ_LOW,BIGSUR_2NDLVL_IRQ_HIGH);
347
348}
diff --git a/arch/sh/boards/bigsur/led.c b/arch/sh/boards/bigsur/led.c
new file mode 100644
index 000000000000..0a2339c69440
--- /dev/null
+++ b/arch/sh/boards/bigsur/led.c
@@ -0,0 +1,55 @@
1/*
2 * linux/arch/sh/kernel/led_bigsur.c
3 *
4 * By Dustin McIntire (dustin@sensoria.com) (c)2001
5 * Derived from led_se.c and led.c, which bore the message:
6 * Copyright (C) 2000 Stuart Menefy <stuart.menefy@st.com>
7 *
8 * May be copied or modified under the terms of the GNU General Public
9 * License. See linux/COPYING for more information.
10 *
11 * This file contains Big Sur specific LED code.
12 */
13
14#include <linux/config.h>
15#include <asm/io.h>
16#include <asm/bigsur/bigsur.h>
17
18static void mach_led(int position, int value)
19{
20 int word;
21
22 word = bigsur_inl(BIGSUR_CSLR);
23 if (value) {
24 bigsur_outl(word & ~BIGSUR_LED, BIGSUR_CSLR);
25 } else {
26 bigsur_outl(word | BIGSUR_LED, BIGSUR_CSLR);
27 }
28}
29
30#ifdef CONFIG_HEARTBEAT
31
32#include <linux/sched.h>
33
34/* Cycle the LED on/off */
35void heartbeat_bigsur(void)
36{
37 static unsigned cnt = 0, period = 0, dist = 0;
38
39 if (cnt == 0 || cnt == dist)
40 mach_led( -1, 1);
41 else if (cnt == 7 || cnt == dist+7)
42 mach_led( -1, 0);
43
44 if (++cnt > period) {
45 cnt = 0;
46 /* The hyperbolic function below modifies the heartbeat period
47 * length in dependency of the current (5min) load. It goes
48 * through the points f(0)=126, f(1)=86, f(5)=51,
49 * f(inf)->30. */
50 period = ((672<<FSHIFT)/(5*avenrun[0]+(7<<FSHIFT))) + 30;
51 dist = period / 4;
52 }
53}
54#endif /* CONFIG_HEARTBEAT */
55
diff --git a/arch/sh/boards/bigsur/setup.c b/arch/sh/boards/bigsur/setup.c
new file mode 100644
index 000000000000..e69be05195f5
--- /dev/null
+++ b/arch/sh/boards/bigsur/setup.c
@@ -0,0 +1,96 @@
1/*
2 *
3 * By Dustin McIntire (dustin@sensoria.com) (c)2001
4 *
5 * Setup and IRQ handling code for the HD64465 companion chip.
6 * by Greg Banks <gbanks@pocketpenguins.com>
7 * Copyright (c) 2000 PocketPenguins Inc
8 *
9 * Derived from setup_hd64465.c which bore the message:
10 * Greg Banks <gbanks@pocketpenguins.com>
11 * Copyright (c) 2000 PocketPenguins Inc and
12 * Copyright (C) 2000 YAEGASHI Takeshi
13 * and setup_cqreek.c which bore message:
14 * Copyright (C) 2000 Niibe Yutaka
15 *
16 * May be copied or modified under the terms of the GNU General Public
17 * License. See linux/COPYING for more information.
18 *
19 * Setup functions for a Hitachi Big Sur Evaluation Board.
20 *
21 */
22
23#include <linux/config.h>
24#include <linux/sched.h>
25#include <linux/module.h>
26#include <linux/kernel.h>
27#include <linux/param.h>
28#include <linux/ioport.h>
29#include <linux/interrupt.h>
30#include <linux/init.h>
31#include <linux/irq.h>
32#include <linux/bitops.h>
33
34#include <asm/io.h>
35#include <asm/irq.h>
36#include <asm/machvec.h>
37#include <asm/bigsur/io.h>
38#include <asm/hd64465/hd64465.h>
39#include <asm/bigsur/bigsur.h>
40
41/*===========================================================*/
42// Big Sur Init Routines
43/*===========================================================*/
44
45const char *get_system_type(void)
46{
47 return "Big Sur";
48}
49
50/*
51 * The Machine Vector
52 */
53extern void heartbeat_bigsur(void);
54extern void init_bigsur_IRQ(void);
55
56struct sh_machine_vector mv_bigsur __initmv = {
57 .mv_nr_irqs = NR_IRQS, // Defined in <asm/irq.h>
58
59 .mv_isa_port2addr = bigsur_isa_port2addr,
60 .mv_irq_demux = bigsur_irq_demux,
61
62 .mv_init_irq = init_bigsur_IRQ,
63#ifdef CONFIG_HEARTBEAT
64 .mv_heartbeat = heartbeat_bigsur,
65#endif
66};
67ALIAS_MV(bigsur)
68
69int __init platform_setup(void)
70{
71 /* Mask all 2nd level IRQ's */
72 outb(-1,BIGSUR_IMR0);
73 outb(-1,BIGSUR_IMR1);
74 outb(-1,BIGSUR_IMR2);
75 outb(-1,BIGSUR_IMR3);
76
77 /* Mask 1st level interrupts */
78 outb(-1,BIGSUR_IRLMR0);
79 outb(-1,BIGSUR_IRLMR1);
80
81#if defined (CONFIG_HD64465) && defined (CONFIG_SERIAL)
82 /* remap IO ports for first ISA serial port to HD64465 UART */
83 bigsur_port_map(0x3f8, 8, CONFIG_HD64465_IOBASE + 0x8000, 1);
84#endif /* CONFIG_HD64465 && CONFIG_SERIAL */
85 /* TODO: setup IDE registers */
86 bigsur_port_map(BIGSUR_IDECTL_IOPORT, 2, BIGSUR_ICTL, 8);
87 /* Setup the Ethernet port to BIGSUR_ETHER_IOPORT */
88 bigsur_port_map(BIGSUR_ETHER_IOPORT, 16, BIGSUR_ETHR+BIGSUR_ETHER_IOPORT, 0);
89 /* set page to 1 */
90 outw(1, BIGSUR_ETHR+0xe);
91 /* set the IO port to BIGSUR_ETHER_IOPORT */
92 outw(BIGSUR_ETHER_IOPORT<<3, BIGSUR_ETHR+0x2);
93
94 return 0;
95}
96