Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Paul Mundt | 373e68b | 2006-09-27 15:41:24 +0900 | [diff] [blame] | 2 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | * Copyright (C) 2002 David McCullough <davidm@snapgear.com> |
| 4 | * Copyright (C) 2003 Paul Mundt <lethal@linux-sh.org> |
| 5 | * |
| 6 | * Based on files with the following comments: |
| 7 | * |
| 8 | * Copyright (C) 2000 Kazumoto Kojima |
| 9 | * |
| 10 | * Modified for 7751 Solution Engine by |
| 11 | * Ian da Silva and Jeremy Siegel, 2001. |
| 12 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | #include <linux/init.h> |
| 14 | #include <linux/irq.h> |
| 15 | #include <linux/interrupt.h> |
| 16 | #include <linux/timer.h> |
| 17 | #include <linux/delay.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | #include <linux/sched.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | #include <asm/machvec.h> |
Paul Mundt | f6eec8d | 2010-10-29 19:06:53 +0900 | [diff] [blame] | 20 | #include <mach/secureedge5410.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | #include <asm/irq.h> |
| 22 | #include <asm/io.h> |
Paul Mundt | f15cbe6 | 2008-07-29 08:09:44 +0900 | [diff] [blame] | 23 | #include <cpu/timer.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | |
Paul Mundt | 39c1198 | 2010-10-29 18:59:58 +0900 | [diff] [blame] | 25 | unsigned short secureedge5410_ioport; |
| 26 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | /* |
| 28 | * EraseConfig handling functions |
| 29 | */ |
Paul Mundt | 35f3c51 | 2006-10-06 15:31:16 +0900 | [diff] [blame] | 30 | static irqreturn_t eraseconfig_interrupt(int irq, void *dev_id) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | printk("SnapGear: erase switch interrupt!\n"); |
| 33 | |
| 34 | return IRQ_HANDLED; |
| 35 | } |
| 36 | |
| 37 | static int __init eraseconfig_init(void) |
| 38 | { |
Paul Mundt | 39c1198 | 2010-10-29 18:59:58 +0900 | [diff] [blame] | 39 | unsigned int irq = evt2irq(0x240); |
| 40 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | printk("SnapGear: EraseConfig init\n"); |
Paul Mundt | 39c1198 | 2010-10-29 18:59:58 +0900 | [diff] [blame] | 42 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | /* Setup "EraseConfig" switch on external IRQ 0 */ |
Yong Zhang | d11584a | 2011-10-22 17:56:28 +0800 | [diff] [blame] | 44 | if (request_irq(irq, eraseconfig_interrupt, 0, "Erase Config", NULL)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | printk("SnapGear: failed to register IRQ%d for Reset witch\n", |
Paul Mundt | 39c1198 | 2010-10-29 18:59:58 +0900 | [diff] [blame] | 46 | irq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | else |
| 48 | printk("SnapGear: registered EraseConfig switch on IRQ%d\n", |
Paul Mundt | 39c1198 | 2010-10-29 18:59:58 +0900 | [diff] [blame] | 49 | irq); |
| 50 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | } |
Paul Gortmaker | f368d47 | 2016-04-22 14:07:03 -0400 | [diff] [blame] | 52 | device_initcall(eraseconfig_init); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | /* |
| 55 | * Initialize IRQ setting |
| 56 | * |
| 57 | * IRL0 = erase switch |
| 58 | * IRL1 = eth0 |
| 59 | * IRL2 = eth1 |
| 60 | * IRL3 = crypto |
| 61 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | static void __init init_snapgear_IRQ(void) |
| 63 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | printk("Setup SnapGear IRQ/IPR ...\n"); |
Magnus Damm | d59645d | 2007-08-03 14:23:35 +0900 | [diff] [blame] | 65 | /* enable individual interrupt mode for externals */ |
| 66 | plat_irq_setup_pins(IRQ_MODE_IRQ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | } |
| 68 | |
Paul Mundt | 2c7834a | 2006-09-27 18:17:31 +0900 | [diff] [blame] | 69 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | * The Machine Vector |
| 71 | */ |
Paul Mundt | 82f81f4 | 2007-05-15 15:19:34 +0900 | [diff] [blame] | 72 | static struct sh_machine_vector mv_snapgear __initmv = { |
Paul Mundt | 2c7834a | 2006-09-27 18:17:31 +0900 | [diff] [blame] | 73 | .mv_name = "SnapGear SecureEdge5410", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | .mv_init_irq = init_snapgear_IRQ, |
| 75 | }; |