blob: 08fc98342a0b35550e9ff13b933f6ce7f32514a9 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/****************************************************************************/
2/*
3 * linux/arch/sh/boards/snapgear/setup.c
4 *
5 * Copyright (C) 2002 David McCullough <davidm@snapgear.com>
6 * Copyright (C) 2003 Paul Mundt <lethal@linux-sh.org>
7 *
8 * Based on files with the following comments:
9 *
10 * Copyright (C) 2000 Kazumoto Kojima
11 *
12 * Modified for 7751 Solution Engine by
13 * Ian da Silva and Jeremy Siegel, 2001.
14 */
15/****************************************************************************/
16
17#include <linux/config.h>
18#include <linux/init.h>
19#include <linux/irq.h>
20#include <linux/interrupt.h>
21#include <linux/timer.h>
22#include <linux/delay.h>
23#include <linux/module.h>
24#include <linux/sched.h>
25
26#include <asm/machvec.h>
27#include <asm/mach/io.h>
28#include <asm/irq.h>
29#include <asm/io.h>
30#include <asm/cpu/timer.h>
31
32extern void (*board_time_init)(void);
33extern void secureedge5410_rtc_init(void);
34extern void pcibios_init(void);
35
36/****************************************************************************/
37/*
38 * EraseConfig handling functions
39 */
40
41static irqreturn_t eraseconfig_interrupt(int irq, void *dev_id, struct pt_regs *regs)
42{
43 volatile char dummy __attribute__((unused)) = * (volatile char *) 0xb8000000;
44
45 printk("SnapGear: erase switch interrupt!\n");
46
47 return IRQ_HANDLED;
48}
49
50static int __init eraseconfig_init(void)
51{
52 printk("SnapGear: EraseConfig init\n");
53 /* Setup "EraseConfig" switch on external IRQ 0 */
54 if (request_irq(IRL0_IRQ, eraseconfig_interrupt, SA_INTERRUPT,
55 "Erase Config", NULL))
56 printk("SnapGear: failed to register IRQ%d for Reset witch\n",
57 IRL0_IRQ);
58 else
59 printk("SnapGear: registered EraseConfig switch on IRQ%d\n",
60 IRL0_IRQ);
61 return(0);
62}
63
64module_init(eraseconfig_init);
65
66/****************************************************************************/
67/*
68 * Initialize IRQ setting
69 *
70 * IRL0 = erase switch
71 * IRL1 = eth0
72 * IRL2 = eth1
73 * IRL3 = crypto
74 */
75
76static void __init init_snapgear_IRQ(void)
77{
78 /* enable individual interrupt mode for externals */
79 ctrl_outw(ctrl_inw(INTC_ICR) | INTC_ICR_IRLM, INTC_ICR);
80
81 printk("Setup SnapGear IRQ/IPR ...\n");
82
83 make_ipr_irq(IRL0_IRQ, IRL0_IPR_ADDR, IRL0_IPR_POS, IRL0_PRIORITY);
84 make_ipr_irq(IRL1_IRQ, IRL1_IPR_ADDR, IRL1_IPR_POS, IRL1_PRIORITY);
85 make_ipr_irq(IRL2_IRQ, IRL2_IPR_ADDR, IRL2_IPR_POS, IRL2_PRIORITY);
86 make_ipr_irq(IRL3_IRQ, IRL3_IPR_ADDR, IRL3_IPR_POS, IRL3_PRIORITY);
87}
88
89/****************************************************************************/
90/*
91 * Fast poll interrupt simulator.
92 */
93
94/*
95 * Leave all of the fast timer/fast poll stuff commented out for now, since
96 * it's not clear whether it actually works or not. Since it wasn't being used
97 * at all in 2.4, we'll assume it's not sane for 2.6 either.. -- PFM
98 */
99#if 0
100#define FAST_POLL 1000
101//#define FAST_POLL_INTR
102
103#define FASTTIMER_IRQ 17
104#define FASTTIMER_IPR_ADDR INTC_IPRA
105#define FASTTIMER_IPR_POS 2
106#define FASTTIMER_PRIORITY 3
107
108#ifdef FAST_POLL_INTR
109#define TMU1_TCR_INIT 0x0020
110#else
111#define TMU1_TCR_INIT 0
112#endif
113#define TMU_TSTR_INIT 1
114#define TMU1_TCR_CALIB 0x0000
115
116
117#ifdef FAST_POLL_INTR
118static void fast_timer_irq(int irq, void *dev_instance, struct pt_regs *regs)
119{
120 unsigned long timer_status;
121 timer_status = ctrl_inw(TMU1_TCR);
122 timer_status &= ~0x100;
123 ctrl_outw(timer_status, TMU1_TCR);
124}
125#endif
126
127/*
128 * return the current ticks on the fast timer
129 */
130
131unsigned long fast_timer_count(void)
132{
133 return(ctrl_inl(TMU1_TCNT));
134}
135
136/*
137 * setup a fast timer for profiling etc etc
138 */
139
140static void setup_fast_timer()
141{
142 unsigned long interval;
143
144#ifdef FAST_POLL_INTR
145 interval = (current_cpu_data.module_clock/4 + FAST_POLL/2) / FAST_POLL;
146
147 make_ipr_irq(FASTTIMER_IRQ, FASTTIMER_IPR_ADDR, FASTTIMER_IPR_POS,
148 FASTTIMER_PRIORITY);
149
150 printk("SnapGear: %dHz fast timer on IRQ %d\n",FAST_POLL,FASTTIMER_IRQ);
151
152 if (request_irq(FASTTIMER_IRQ, fast_timer_irq, 0, "SnapGear fast timer",
153 NULL) != 0)
154 printk("%s(%d): request_irq() failed?\n", __FILE__, __LINE__);
155#else
156 printk("SnapGear: fast timer running\n",FAST_POLL,FASTTIMER_IRQ);
157 interval = 0xffffffff;
158#endif
159
160 ctrl_outb(ctrl_inb(TMU_TSTR) & ~0x2, TMU_TSTR); /* disable timer 1 */
161 ctrl_outw(TMU1_TCR_INIT, TMU1_TCR);
162 ctrl_outl(interval, TMU1_TCOR);
163 ctrl_outl(interval, TMU1_TCNT);
164 ctrl_outb(ctrl_inb(TMU_TSTR) | 0x2, TMU_TSTR); /* enable timer 1 */
165
166 printk("Timer count 1 = 0x%x\n", fast_timer_count());
167 udelay(1000);
168 printk("Timer count 2 = 0x%x\n", fast_timer_count());
169}
170#endif
171
172/****************************************************************************/
173
174const char *get_system_type(void)
175{
176 return "SnapGear SecureEdge5410";
177}
178
179/*
180 * The Machine Vector
181 */
182
183struct sh_machine_vector mv_snapgear __initmv = {
184 .mv_nr_irqs = 72,
185
186 .mv_inb = snapgear_inb,
187 .mv_inw = snapgear_inw,
188 .mv_inl = snapgear_inl,
189 .mv_outb = snapgear_outb,
190 .mv_outw = snapgear_outw,
191 .mv_outl = snapgear_outl,
192
193 .mv_inb_p = snapgear_inb_p,
194 .mv_inw_p = snapgear_inw,
195 .mv_inl_p = snapgear_inl,
196 .mv_outb_p = snapgear_outb_p,
197 .mv_outw_p = snapgear_outw,
198 .mv_outl_p = snapgear_outl,
199
200 .mv_isa_port2addr = snapgear_isa_port2addr,
201
202 .mv_init_irq = init_snapgear_IRQ,
203};
204ALIAS_MV(snapgear)
205
206/*
207 * Initialize the board
208 */
209
210int __init platform_setup(void)
211{
212 board_time_init = secureedge5410_rtc_init;
213
214 return 0;
215}
216