blob: 10eeea96a04b26354332d9cb0995e0fb4d040f52 [file] [log] [blame]
Paul Mundt373e68b2006-09-27 15:41:24 +09001/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 * Copyright (C) 2002 David McCullough <davidm@snapgear.com>
3 * Copyright (C) 2003 Paul Mundt <lethal@linux-sh.org>
4 *
5 * Based on files with the following comments:
6 *
7 * Copyright (C) 2000 Kazumoto Kojima
8 *
9 * Modified for 7751 Solution Engine by
10 * Ian da Silva and Jeremy Siegel, 2001.
11 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070012#include <linux/init.h>
13#include <linux/irq.h>
14#include <linux/interrupt.h>
15#include <linux/timer.h>
16#include <linux/delay.h>
17#include <linux/module.h>
18#include <linux/sched.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070019#include <asm/machvec.h>
Paul Mundt7639a452008-10-20 13:02:48 +090020#include <mach/snapgear.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070021#include <asm/irq.h>
22#include <asm/io.h>
Paul Mundtf15cbe62008-07-29 08:09:44 +090023#include <cpu/timer.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070024
Paul Mundt39c11982010-10-29 18:59:58 +090025unsigned short secureedge5410_ioport;
26
Linus Torvalds1da177e2005-04-16 15:20:36 -070027/*
28 * EraseConfig handling functions
29 */
Paul Mundt35f3c512006-10-06 15:31:16 +090030static irqreturn_t eraseconfig_interrupt(int irq, void *dev_id)
Linus Torvalds1da177e2005-04-16 15:20:36 -070031{
Paul Mundt39c11982010-10-29 18:59:58 +090032 ctrl_delay(); /* dummy read */
Linus Torvalds1da177e2005-04-16 15:20:36 -070033
34 printk("SnapGear: erase switch interrupt!\n");
35
36 return IRQ_HANDLED;
37}
38
39static int __init eraseconfig_init(void)
40{
Paul Mundt39c11982010-10-29 18:59:58 +090041 unsigned int irq = evt2irq(0x240);
42
Linus Torvalds1da177e2005-04-16 15:20:36 -070043 printk("SnapGear: EraseConfig init\n");
Paul Mundt39c11982010-10-29 18:59:58 +090044
Linus Torvalds1da177e2005-04-16 15:20:36 -070045 /* Setup "EraseConfig" switch on external IRQ 0 */
Paul Mundt39c11982010-10-29 18:59:58 +090046 if (request_irq(irq, eraseconfig_interrupt, IRQF_DISABLED,
Linus Torvalds1da177e2005-04-16 15:20:36 -070047 "Erase Config", NULL))
48 printk("SnapGear: failed to register IRQ%d for Reset witch\n",
Paul Mundt39c11982010-10-29 18:59:58 +090049 irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -070050 else
51 printk("SnapGear: registered EraseConfig switch on IRQ%d\n",
Paul Mundt39c11982010-10-29 18:59:58 +090052 irq);
53 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070054}
Linus Torvalds1da177e2005-04-16 15:20:36 -070055module_init(eraseconfig_init);
56
Linus Torvalds1da177e2005-04-16 15:20:36 -070057/*
58 * Initialize IRQ setting
59 *
60 * IRL0 = erase switch
61 * IRL1 = eth0
62 * IRL2 = eth1
63 * IRL3 = crypto
64 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070065static void __init init_snapgear_IRQ(void)
66{
Linus Torvalds1da177e2005-04-16 15:20:36 -070067 printk("Setup SnapGear IRQ/IPR ...\n");
Magnus Dammd59645d2007-08-03 14:23:35 +090068 /* enable individual interrupt mode for externals */
69 plat_irq_setup_pins(IRQ_MODE_IRQ);
Linus Torvalds1da177e2005-04-16 15:20:36 -070070}
71
Paul Mundt2c7834a2006-09-27 18:17:31 +090072/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070073 * The Machine Vector
74 */
Paul Mundt82f81f42007-05-15 15:19:34 +090075static struct sh_machine_vector mv_snapgear __initmv = {
Paul Mundt2c7834a2006-09-27 18:17:31 +090076 .mv_name = "SnapGear SecureEdge5410",
Linus Torvalds1da177e2005-04-16 15:20:36 -070077 .mv_nr_irqs = 72,
Linus Torvalds1da177e2005-04-16 15:20:36 -070078 .mv_init_irq = init_snapgear_IRQ,
79};