2 * arch/v850/kernel/fpga85e2c.h -- Machine-dependent defs for
3 * FPGA implementation of V850E2/NA85E2C
5 * Copyright (C) 2002,03 NEC Electronics Corporation
6 * Copyright (C) 2002,03 Miles Bader <miles@gnu.org>
8 * This file is subject to the terms and conditions of the GNU General
9 * Public License. See the file COPYING in the main directory of this
10 * archive for more details.
12 * Written by Miles Bader <miles@gnu.org>
15 #include <linux/config.h>
16 #include <linux/kernel.h>
17 #include <linux/module.h>
18 #include <linux/init.h>
20 #include <linux/swap.h>
21 #include <linux/bootmem.h>
22 #include <linux/irq.h>
23 #include <linux/bitops.h>
25 #include <asm/atomic.h>
27 #include <asm/machdep.h>
31 extern void memcons_setup (void);
34 #define REG_DUMP_ADDR 0x220000
37 extern struct irqaction reg_snap_action
; /* fwd decl */
40 void __init
mach_early_init (void)
44 register u32
*dst
asm ("ep");
45 extern u32 _intv_end
, _intv_load_start
;
47 /* Set bus sizes: CS0 32-bit, CS1 16-bit, CS7 8-bit,
48 everything else 32-bit. */
50 for (i
= 2; i
<= 6; i
++)
51 CSDEV(i
) = 0; /* 32 bit */
53 /* Ensure that the simulator halts on a panic, instead of going
54 into an infinite loop inside the panic function. */
57 /* Move the interrupt vectors into their real location. Note that
58 any relocations there are relative to the real location, so we
59 don't have to fix anything up. We use a loop instead of calling
60 memcpy to keep this a leaf function (to avoid a function
61 prologue being generated). */
62 dst
= 0x10; /* &_intv_start + 0x10. */
63 src
= &_intv_load_start
;
65 u32 t0
= src
[0], t1
= src
[1], t2
= src
[2], t3
= src
[3];
66 u32 t4
= src
[4], t5
= src
[5], t6
= src
[6], t7
= src
[7];
67 dst
[0] = t0
; dst
[1] = t1
; dst
[2] = t2
; dst
[3] = t3
;
68 dst
[4] = t4
; dst
[5] = t5
; dst
[6] = t6
; dst
[7] = t7
;
71 } while (dst
< &_intv_end
);
74 void __init
mach_setup (char **cmdline
)
78 /* Setup up NMI0 to copy the registers to a known memory location.
79 The FGPA board has a button that produces NMI0 when pressed, so
80 this allows us to push the button, and then look at memory to see
81 what's in the registers (there's no other way to easily do so).
82 We have to use `setup_irq' instead of `request_irq' because it's
83 still too early to do memory allocation. */
84 setup_irq (IRQ_NMI (0), ®_snap_action
);
87 void mach_get_physical_ram (unsigned long *ram_start
, unsigned long *ram_len
)
89 *ram_start
= ERAM_ADDR
;
93 void __init
mach_sched_init (struct irqaction
*timer_action
)
95 /* Setup up the timer interrupt. The FPGA peripheral control
96 registers _only_ work with single-bit writes (set1/clr1)! */
97 __clear_bit (RPU_GTMC_CE_BIT
, &RPU_GTMC
);
98 __clear_bit (RPU_GTMC_CLK_BIT
, &RPU_GTMC
);
99 __set_bit (RPU_GTMC_CE_BIT
, &RPU_GTMC
);
101 /* We use the first RPU interrupt, which occurs every 8.192ms. */
102 setup_irq (IRQ_RPU (0), timer_action
);
106 void mach_gettimeofday (struct timespec
*tv
)
112 void machine_halt (void) __attribute__ ((noreturn
));
113 void machine_halt (void)
119 FLGREG(0) = 1; /* Halt immediately. */
120 asm ("di; halt; nop; nop; nop; nop; nop");
124 EXPORT_SYMBOL(machine_halt
);
126 void machine_restart (char *__unused
)
131 EXPORT_SYMBOL(machine_restart
);
133 void machine_power_off (void)
138 EXPORT_SYMBOL(machine_power_off
);
143 struct v850e_intc_irq_init irq_inits
[] = {
144 { "IRQ", 0, NUM_MACH_IRQS
, 1, 7 },
145 { "RPU", IRQ_RPU(0), IRQ_RPU_NUM
, 1, 6 },
148 #define NUM_IRQ_INITS ((sizeof irq_inits / sizeof irq_inits[0]) - 1)
150 struct hw_interrupt_type hw_itypes
[NUM_IRQ_INITS
];
152 /* Initialize interrupts. */
153 void __init
mach_init_irqs (void)
155 v850e_intc_init_irq_types (irq_inits
, hw_itypes
);
159 /* An interrupt handler that copies the registers to a known memory location,
160 for debugging purposes. */
162 static void make_reg_snap (int irq
, void *dummy
, struct pt_regs
*regs
)
164 (*(unsigned *)REG_DUMP_ADDR
)++;
165 (*(struct pt_regs
*)(REG_DUMP_ADDR
+ sizeof (unsigned))) = *regs
;
168 static int reg_snap_dev_id
;
169 static struct irqaction reg_snap_action
= {
170 make_reg_snap
, 0, CPU_MASK_NONE
, "reg_snap", ®_snap_dev_id
, 0