config.c 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. /*
  2. * arch/m68k/mvme16x/config.c
  3. *
  4. * Copyright (C) 1995 Richard Hirst [richard@sleepie.demon.co.uk]
  5. *
  6. * Based on:
  7. *
  8. * linux/amiga/config.c
  9. *
  10. * Copyright (C) 1993 Hamish Macdonald
  11. *
  12. * This file is subject to the terms and conditions of the GNU General Public
  13. * License. See the file README.legal in the main directory of this archive
  14. * for more details.
  15. */
  16. #include <linux/types.h>
  17. #include <linux/kernel.h>
  18. #include <linux/mm.h>
  19. #include <linux/seq_file.h>
  20. #include <linux/tty.h>
  21. #include <linux/console.h>
  22. #include <linux/linkage.h>
  23. #include <linux/init.h>
  24. #include <linux/major.h>
  25. #include <linux/genhd.h>
  26. #include <linux/rtc.h>
  27. #include <linux/interrupt.h>
  28. #include <linux/module.h>
  29. #include <asm/bootinfo.h>
  30. #include <asm/system.h>
  31. #include <asm/pgtable.h>
  32. #include <asm/setup.h>
  33. #include <asm/irq.h>
  34. #include <asm/traps.h>
  35. #include <asm/rtc.h>
  36. #include <asm/machdep.h>
  37. #include <asm/mvme16xhw.h>
  38. extern t_bdid mvme_bdid;
  39. static MK48T08ptr_t volatile rtc = (MK48T08ptr_t)MVME_RTC_BASE;
  40. static void mvme16x_get_model(char *model);
  41. extern void mvme16x_sched_init(irq_handler_t handler);
  42. extern unsigned long mvme16x_gettimeoffset (void);
  43. extern int mvme16x_hwclk (int, struct rtc_time *);
  44. extern int mvme16x_set_clock_mmss (unsigned long);
  45. extern void mvme16x_reset (void);
  46. extern void mvme16x_waitbut(void);
  47. int bcd2int (unsigned char b);
  48. /* Save tick handler routine pointer, will point to do_timer() in
  49. * kernel/sched.c, called via mvme16x_process_int() */
  50. static irq_handler_t tick_handler;
  51. unsigned short mvme16x_config;
  52. EXPORT_SYMBOL(mvme16x_config);
  53. int mvme16x_parse_bootinfo(const struct bi_record *bi)
  54. {
  55. if (bi->tag == BI_VME_TYPE || bi->tag == BI_VME_BRDINFO)
  56. return 0;
  57. else
  58. return 1;
  59. }
  60. void mvme16x_reset(void)
  61. {
  62. printk ("\r\n\nCalled mvme16x_reset\r\n"
  63. "\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r");
  64. /* The string of returns is to delay the reset until the whole
  65. * message is output. Assert reset bit in GCSR */
  66. *(volatile char *)0xfff40107 = 0x80;
  67. }
  68. static void mvme16x_get_model(char *model)
  69. {
  70. p_bdid p = &mvme_bdid;
  71. char suf[4];
  72. suf[1] = p->brdsuffix[0];
  73. suf[2] = p->brdsuffix[1];
  74. suf[3] = '\0';
  75. suf[0] = suf[1] ? '-' : '\0';
  76. sprintf(model, "Motorola MVME%x%s", p->brdno, suf);
  77. }
  78. static void mvme16x_get_hardware_list(struct seq_file *m)
  79. {
  80. p_bdid p = &mvme_bdid;
  81. if (p->brdno == 0x0162 || p->brdno == 0x0172)
  82. {
  83. unsigned char rev = *(unsigned char *)MVME162_VERSION_REG;
  84. seq_printf (m, "VMEchip2 %spresent\n",
  85. rev & MVME16x_CONFIG_NO_VMECHIP2 ? "NOT " : "");
  86. seq_printf (m, "SCSI interface %spresent\n",
  87. rev & MVME16x_CONFIG_NO_SCSICHIP ? "NOT " : "");
  88. seq_printf (m, "Ethernet i/f %spresent\n",
  89. rev & MVME16x_CONFIG_NO_ETHERNET ? "NOT " : "");
  90. }
  91. }
  92. /*
  93. * This function is called during kernel startup to initialize
  94. * the mvme16x IRQ handling routines. Should probably ensure
  95. * that the base vectors for the VMEChip2 and PCCChip2 are valid.
  96. */
  97. static void __init mvme16x_init_IRQ (void)
  98. {
  99. m68k_setup_user_interrupt(VEC_USER, 192, NULL);
  100. }
  101. #define pcc2chip ((volatile u_char *)0xfff42000)
  102. #define PccSCCMICR 0x1d
  103. #define PccSCCTICR 0x1e
  104. #define PccSCCRICR 0x1f
  105. void __init config_mvme16x(void)
  106. {
  107. p_bdid p = &mvme_bdid;
  108. char id[40];
  109. mach_max_dma_address = 0xffffffff;
  110. mach_sched_init = mvme16x_sched_init;
  111. mach_init_IRQ = mvme16x_init_IRQ;
  112. mach_gettimeoffset = mvme16x_gettimeoffset;
  113. mach_hwclk = mvme16x_hwclk;
  114. mach_set_clock_mmss = mvme16x_set_clock_mmss;
  115. mach_reset = mvme16x_reset;
  116. mach_get_model = mvme16x_get_model;
  117. mach_get_hardware_list = mvme16x_get_hardware_list;
  118. /* Report board revision */
  119. if (strncmp("BDID", p->bdid, 4))
  120. {
  121. printk ("\n\nBug call .BRD_ID returned garbage - giving up\n\n");
  122. while (1)
  123. ;
  124. }
  125. /* Board type is only set by newer versions of vmelilo/tftplilo */
  126. if (vme_brdtype == 0)
  127. vme_brdtype = p->brdno;
  128. mvme16x_get_model(id);
  129. printk ("\nBRD_ID: %s BUG %x.%x %02x/%02x/%02x\n", id, p->rev>>4,
  130. p->rev&0xf, p->yr, p->mth, p->day);
  131. if (p->brdno == 0x0162 || p->brdno == 0x172)
  132. {
  133. unsigned char rev = *(unsigned char *)MVME162_VERSION_REG;
  134. mvme16x_config = rev | MVME16x_CONFIG_GOT_SCCA;
  135. printk ("MVME%x Hardware status:\n", p->brdno);
  136. printk (" CPU Type 68%s040\n",
  137. rev & MVME16x_CONFIG_GOT_FPU ? "" : "LC");
  138. printk (" CPU clock %dMHz\n",
  139. rev & MVME16x_CONFIG_SPEED_32 ? 32 : 25);
  140. printk (" VMEchip2 %spresent\n",
  141. rev & MVME16x_CONFIG_NO_VMECHIP2 ? "NOT " : "");
  142. printk (" SCSI interface %spresent\n",
  143. rev & MVME16x_CONFIG_NO_SCSICHIP ? "NOT " : "");
  144. printk (" Ethernet interface %spresent\n",
  145. rev & MVME16x_CONFIG_NO_ETHERNET ? "NOT " : "");
  146. }
  147. else
  148. {
  149. mvme16x_config = MVME16x_CONFIG_GOT_LP | MVME16x_CONFIG_GOT_CD2401;
  150. /* Dont allow any interrupts from the CD2401 until the interrupt */
  151. /* handlers are installed */
  152. pcc2chip[PccSCCMICR] = 0x10;
  153. pcc2chip[PccSCCTICR] = 0x10;
  154. pcc2chip[PccSCCRICR] = 0x10;
  155. }
  156. }
  157. static irqreturn_t mvme16x_abort_int (int irq, void *dev_id)
  158. {
  159. p_bdid p = &mvme_bdid;
  160. unsigned long *new = (unsigned long *)vectors;
  161. unsigned long *old = (unsigned long *)0xffe00000;
  162. volatile unsigned char uc, *ucp;
  163. if (p->brdno == 0x0162 || p->brdno == 0x172)
  164. {
  165. ucp = (volatile unsigned char *)0xfff42043;
  166. uc = *ucp | 8;
  167. *ucp = uc;
  168. }
  169. else
  170. {
  171. *(volatile unsigned long *)0xfff40074 = 0x40000000;
  172. }
  173. *(new+4) = *(old+4); /* Illegal instruction */
  174. *(new+9) = *(old+9); /* Trace */
  175. *(new+47) = *(old+47); /* Trap #15 */
  176. if (p->brdno == 0x0162 || p->brdno == 0x172)
  177. *(new+0x5e) = *(old+0x5e); /* ABORT switch */
  178. else
  179. *(new+0x6e) = *(old+0x6e); /* ABORT switch */
  180. return IRQ_HANDLED;
  181. }
  182. static irqreturn_t mvme16x_timer_int (int irq, void *dev_id)
  183. {
  184. *(volatile unsigned char *)0xfff4201b |= 8;
  185. return tick_handler(irq, dev_id);
  186. }
  187. void mvme16x_sched_init (irq_handler_t timer_routine)
  188. {
  189. p_bdid p = &mvme_bdid;
  190. int irq;
  191. tick_handler = timer_routine;
  192. /* Using PCCchip2 or MC2 chip tick timer 1 */
  193. *(volatile unsigned long *)0xfff42008 = 0;
  194. *(volatile unsigned long *)0xfff42004 = 10000; /* 10ms */
  195. *(volatile unsigned char *)0xfff42017 |= 3;
  196. *(volatile unsigned char *)0xfff4201b = 0x16;
  197. if (request_irq(MVME16x_IRQ_TIMER, mvme16x_timer_int, 0,
  198. "timer", mvme16x_timer_int))
  199. panic ("Couldn't register timer int");
  200. if (p->brdno == 0x0162 || p->brdno == 0x172)
  201. irq = MVME162_IRQ_ABORT;
  202. else
  203. irq = MVME167_IRQ_ABORT;
  204. if (request_irq(irq, mvme16x_abort_int, 0,
  205. "abort", mvme16x_abort_int))
  206. panic ("Couldn't register abort int");
  207. }
  208. /* This is always executed with interrupts disabled. */
  209. unsigned long mvme16x_gettimeoffset (void)
  210. {
  211. return (*(volatile unsigned long *)0xfff42008);
  212. }
  213. int bcd2int (unsigned char b)
  214. {
  215. return ((b>>4)*10 + (b&15));
  216. }
  217. int mvme16x_hwclk(int op, struct rtc_time *t)
  218. {
  219. #warning check me!
  220. if (!op) {
  221. rtc->ctrl = RTC_READ;
  222. t->tm_year = bcd2int (rtc->bcd_year);
  223. t->tm_mon = bcd2int (rtc->bcd_mth);
  224. t->tm_mday = bcd2int (rtc->bcd_dom);
  225. t->tm_hour = bcd2int (rtc->bcd_hr);
  226. t->tm_min = bcd2int (rtc->bcd_min);
  227. t->tm_sec = bcd2int (rtc->bcd_sec);
  228. rtc->ctrl = 0;
  229. }
  230. return 0;
  231. }
  232. int mvme16x_set_clock_mmss (unsigned long nowtime)
  233. {
  234. return 0;
  235. }