setup.c 5.2 KB

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