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