| Paul Mundt | 373e68b | 2006-09-27 15:41:24 +0900 | [diff] [blame] | 1 | /* | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | * linux/arch/sh/boards/snapgear/setup.c | 
|  | 3 | * | 
|  | 4 | * Copyright (C) 2002  David McCullough <davidm@snapgear.com> | 
|  | 5 | * Copyright (C) 2003  Paul Mundt <lethal@linux-sh.org> | 
|  | 6 | * | 
|  | 7 | * Based on files with the following comments: | 
|  | 8 | * | 
|  | 9 | *           Copyright (C) 2000  Kazumoto Kojima | 
|  | 10 | * | 
|  | 11 | *           Modified for 7751 Solution Engine by | 
|  | 12 | *           Ian da Silva and Jeremy Siegel, 2001. | 
|  | 13 | */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | #include <linux/init.h> | 
|  | 15 | #include <linux/irq.h> | 
|  | 16 | #include <linux/interrupt.h> | 
|  | 17 | #include <linux/timer.h> | 
|  | 18 | #include <linux/delay.h> | 
|  | 19 | #include <linux/module.h> | 
|  | 20 | #include <linux/sched.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | #include <asm/machvec.h> | 
| Paul Mundt | 373e68b | 2006-09-27 15:41:24 +0900 | [diff] [blame] | 22 | #include <asm/snapgear.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | #include <asm/irq.h> | 
|  | 24 | #include <asm/io.h> | 
| Paul Mundt | 373e68b | 2006-09-27 15:41:24 +0900 | [diff] [blame] | 25 | #include <asm/rtc.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | #include <asm/cpu/timer.h> | 
|  | 27 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | extern void secureedge5410_rtc_init(void); | 
|  | 29 | extern void pcibios_init(void); | 
|  | 30 |  | 
|  | 31 | /****************************************************************************/ | 
|  | 32 | /* | 
|  | 33 | * EraseConfig handling functions | 
|  | 34 | */ | 
|  | 35 |  | 
| Paul Mundt | 35f3c51 | 2006-10-06 15:31:16 +0900 | [diff] [blame] | 36 | static irqreturn_t eraseconfig_interrupt(int irq, void *dev_id) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | { | 
|  | 38 | volatile char dummy __attribute__((unused)) = * (volatile char *) 0xb8000000; | 
|  | 39 |  | 
|  | 40 | printk("SnapGear: erase switch interrupt!\n"); | 
|  | 41 |  | 
|  | 42 | return IRQ_HANDLED; | 
|  | 43 | } | 
|  | 44 |  | 
|  | 45 | static int __init eraseconfig_init(void) | 
|  | 46 | { | 
|  | 47 | printk("SnapGear: EraseConfig init\n"); | 
|  | 48 | /* Setup "EraseConfig" switch on external IRQ 0 */ | 
| Thomas Gleixner | 6d20819 | 2006-07-01 19:29:25 -0700 | [diff] [blame] | 49 | if (request_irq(IRL0_IRQ, eraseconfig_interrupt, IRQF_DISABLED, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | "Erase Config", NULL)) | 
|  | 51 | printk("SnapGear: failed to register IRQ%d for Reset witch\n", | 
|  | 52 | IRL0_IRQ); | 
|  | 53 | else | 
|  | 54 | printk("SnapGear: registered EraseConfig switch on IRQ%d\n", | 
|  | 55 | IRL0_IRQ); | 
|  | 56 | return(0); | 
|  | 57 | } | 
|  | 58 |  | 
|  | 59 | module_init(eraseconfig_init); | 
|  | 60 |  | 
|  | 61 | /****************************************************************************/ | 
|  | 62 | /* | 
|  | 63 | * Initialize IRQ setting | 
|  | 64 | * | 
|  | 65 | * IRL0 = erase switch | 
|  | 66 | * IRL1 = eth0 | 
|  | 67 | * IRL2 = eth1 | 
|  | 68 | * IRL3 = crypto | 
|  | 69 | */ | 
|  | 70 |  | 
| Magnus Damm | 68abdbb | 2007-06-15 18:56:19 +0900 | [diff] [blame] | 71 | static struct ipr_data ipr_irq_table[] = { | 
|  | 72 | { IRL0_IRQ, 0, IRL0_IPR_POS, IRL0_PRIORITY }, | 
|  | 73 | { IRL1_IRQ, 0, IRL1_IPR_POS, IRL1_PRIORITY }, | 
|  | 74 | { IRL2_IRQ, 0, IRL2_IPR_POS, IRL2_PRIORITY }, | 
|  | 75 | { IRL3_IRQ, 0, IRL3_IPR_POS, IRL3_PRIORITY }, | 
|  | 76 | }; | 
|  | 77 |  | 
|  | 78 | static unsigned long ipr_offsets[] = { | 
|  | 79 | INTC_IPRD, | 
|  | 80 | }; | 
|  | 81 |  | 
|  | 82 | static struct ipr_desc ipr_irq_desc = { | 
|  | 83 | .ipr_offsets	= ipr_offsets, | 
|  | 84 | .nr_offsets	= ARRAY_SIZE(ipr_offsets), | 
|  | 85 |  | 
|  | 86 | .ipr_data	= ipr_irq_table, | 
|  | 87 | .nr_irqs	= ARRAY_SIZE(ipr_irq_table), | 
|  | 88 |  | 
|  | 89 | .chip = { | 
|  | 90 | .name	= "IPR-snapgear", | 
|  | 91 | }, | 
| Jamie Lenehan | bd71ab8 | 2006-10-31 12:35:02 +0900 | [diff] [blame] | 92 | }; | 
|  | 93 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | static void __init init_snapgear_IRQ(void) | 
|  | 95 | { | 
|  | 96 | /* enable individual interrupt mode for externals */ | 
|  | 97 | ctrl_outw(ctrl_inw(INTC_ICR) | INTC_ICR_IRLM, INTC_ICR); | 
|  | 98 |  | 
|  | 99 | printk("Setup SnapGear IRQ/IPR ...\n"); | 
|  | 100 |  | 
| Magnus Damm | 68abdbb | 2007-06-15 18:56:19 +0900 | [diff] [blame] | 101 | register_ipr_controller(&ipr_irq_desc); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | } | 
|  | 103 |  | 
| Paul Mundt | 2c7834a | 2006-09-27 18:17:31 +0900 | [diff] [blame] | 104 | /* | 
|  | 105 | * Initialize the board | 
|  | 106 | */ | 
|  | 107 | static void __init snapgear_setup(char **cmdline_p) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | { | 
| Paul Mundt | 2c7834a | 2006-09-27 18:17:31 +0900 | [diff] [blame] | 109 | board_time_init = secureedge5410_rtc_init; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | } | 
|  | 111 |  | 
|  | 112 | /* | 
|  | 113 | * The Machine Vector | 
|  | 114 | */ | 
| Paul Mundt | 82f81f4 | 2007-05-15 15:19:34 +0900 | [diff] [blame] | 115 | static struct sh_machine_vector mv_snapgear __initmv = { | 
| Paul Mundt | 2c7834a | 2006-09-27 18:17:31 +0900 | [diff] [blame] | 116 | .mv_name		= "SnapGear SecureEdge5410", | 
|  | 117 | .mv_setup		= snapgear_setup, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 118 | .mv_nr_irqs		= 72, | 
|  | 119 |  | 
|  | 120 | .mv_inb			= snapgear_inb, | 
|  | 121 | .mv_inw			= snapgear_inw, | 
|  | 122 | .mv_inl			= snapgear_inl, | 
|  | 123 | .mv_outb		= snapgear_outb, | 
|  | 124 | .mv_outw		= snapgear_outw, | 
|  | 125 | .mv_outl		= snapgear_outl, | 
|  | 126 |  | 
|  | 127 | .mv_inb_p		= snapgear_inb_p, | 
|  | 128 | .mv_inw_p		= snapgear_inw, | 
|  | 129 | .mv_inl_p		= snapgear_inl, | 
|  | 130 | .mv_outb_p		= snapgear_outb_p, | 
|  | 131 | .mv_outw_p		= snapgear_outw, | 
|  | 132 | .mv_outl_p		= snapgear_outl, | 
|  | 133 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 134 | .mv_init_irq		= init_snapgear_IRQ, | 
|  | 135 | }; |