setup.c 5.2 KB

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