config.c 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  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/tty.h>
  20. #include <linux/console.h>
  21. #include <linux/linkage.h>
  22. #include <linux/init.h>
  23. #include <linux/major.h>
  24. #include <linux/genhd.h>
  25. #include <linux/rtc.h>
  26. #include <linux/interrupt.h>
  27. #include <linux/module.h>
  28. #include <asm/bootinfo.h>
  29. #include <asm/system.h>
  30. #include <asm/pgtable.h>
  31. #include <asm/setup.h>
  32. #include <asm/irq.h>
  33. #include <asm/traps.h>
  34. #include <asm/rtc.h>
  35. #include <asm/machdep.h>
  36. #include <asm/mvme16xhw.h>
  37. extern t_bdid mvme_bdid;
  38. static MK48T08ptr_t volatile rtc = (MK48T08ptr_t)MVME_RTC_BASE;
  39. static void mvme16x_get_model(char *model);
  40. static int mvme16x_get_hardware_list(char *buffer);
  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 int mvme16x_get_hardware_list(char *buffer)
  79. {
  80. p_bdid p = &mvme_bdid;
  81. int len = 0;
  82. if (p->brdno == 0x0162 || p->brdno == 0x0172)
  83. {
  84. unsigned char rev = *(unsigned char *)MVME162_VERSION_REG;
  85. len += sprintf (buffer+len, "VMEchip2 %spresent\n",
  86. rev & MVME16x_CONFIG_NO_VMECHIP2 ? "NOT " : "");
  87. len += sprintf (buffer+len, "SCSI interface %spresent\n",
  88. rev & MVME16x_CONFIG_NO_SCSICHIP ? "NOT " : "");
  89. len += sprintf (buffer+len, "Ethernet i/f %spresent\n",
  90. rev & MVME16x_CONFIG_NO_ETHERNET ? "NOT " : "");
  91. }
  92. else
  93. *buffer = '\0';
  94. return (len);
  95. }
  96. /*
  97. * This function is called during kernel startup to initialize
  98. * the mvme16x IRQ handling routines. Should probably ensure
  99. * that the base vectors for the VMEChip2 and PCCChip2 are valid.
  100. */
  101. static void __init mvme16x_init_IRQ (void)
  102. {
  103. m68k_setup_user_interrupt(VEC_USER, 192, NULL);
  104. }
  105. #define pcc2chip ((volatile u_char *)0xfff42000)
  106. #define PccSCCMICR 0x1d
  107. #define PccSCCTICR 0x1e
  108. #define PccSCCRICR 0x1f
  109. void __init config_mvme16x(void)
  110. {
  111. p_bdid p = &mvme_bdid;
  112. char id[40];
  113. mach_max_dma_address = 0xffffffff;
  114. mach_sched_init = mvme16x_sched_init;
  115. mach_init_IRQ = mvme16x_init_IRQ;
  116. mach_gettimeoffset = mvme16x_gettimeoffset;
  117. mach_hwclk = mvme16x_hwclk;
  118. mach_set_clock_mmss = mvme16x_set_clock_mmss;
  119. mach_reset = mvme16x_reset;
  120. mach_get_model = mvme16x_get_model;
  121. mach_get_hardware_list = mvme16x_get_hardware_list;
  122. /* Report board revision */
  123. if (strncmp("BDID", p->bdid, 4))
  124. {
  125. printk ("\n\nBug call .BRD_ID returned garbage - giving up\n\n");
  126. while (1)
  127. ;
  128. }
  129. /* Board type is only set by newer versions of vmelilo/tftplilo */
  130. if (vme_brdtype == 0)
  131. vme_brdtype = p->brdno;
  132. mvme16x_get_model(id);
  133. printk ("\nBRD_ID: %s BUG %x.%x %02x/%02x/%02x\n", id, p->rev>>4,
  134. p->rev&0xf, p->yr, p->mth, p->day);
  135. if (p->brdno == 0x0162 || p->brdno == 0x172)
  136. {
  137. unsigned char rev = *(unsigned char *)MVME162_VERSION_REG;
  138. mvme16x_config = rev | MVME16x_CONFIG_GOT_SCCA;
  139. printk ("MVME%x Hardware status:\n", p->brdno);
  140. printk (" CPU Type 68%s040\n",
  141. rev & MVME16x_CONFIG_GOT_FPU ? "" : "LC");
  142. printk (" CPU clock %dMHz\n",
  143. rev & MVME16x_CONFIG_SPEED_32 ? 32 : 25);
  144. printk (" VMEchip2 %spresent\n",
  145. rev & MVME16x_CONFIG_NO_VMECHIP2 ? "NOT " : "");
  146. printk (" SCSI interface %spresent\n",
  147. rev & MVME16x_CONFIG_NO_SCSICHIP ? "NOT " : "");
  148. printk (" Ethernet interface %spresent\n",
  149. rev & MVME16x_CONFIG_NO_ETHERNET ? "NOT " : "");
  150. }
  151. else
  152. {
  153. mvme16x_config = MVME16x_CONFIG_GOT_LP | MVME16x_CONFIG_GOT_CD2401;
  154. /* Dont allow any interrupts from the CD2401 until the interrupt */
  155. /* handlers are installed */
  156. pcc2chip[PccSCCMICR] = 0x10;
  157. pcc2chip[PccSCCTICR] = 0x10;
  158. pcc2chip[PccSCCRICR] = 0x10;
  159. }
  160. }
  161. static irqreturn_t mvme16x_abort_int (int irq, void *dev_id)
  162. {
  163. p_bdid p = &mvme_bdid;
  164. unsigned long *new = (unsigned long *)vectors;
  165. unsigned long *old = (unsigned long *)0xffe00000;
  166. volatile unsigned char uc, *ucp;
  167. if (p->brdno == 0x0162 || p->brdno == 0x172)
  168. {
  169. ucp = (volatile unsigned char *)0xfff42043;
  170. uc = *ucp | 8;
  171. *ucp = uc;
  172. }
  173. else
  174. {
  175. *(volatile unsigned long *)0xfff40074 = 0x40000000;
  176. }
  177. *(new+4) = *(old+4); /* Illegal instruction */
  178. *(new+9) = *(old+9); /* Trace */
  179. *(new+47) = *(old+47); /* Trap #15 */
  180. if (p->brdno == 0x0162 || p->brdno == 0x172)
  181. *(new+0x5e) = *(old+0x5e); /* ABORT switch */
  182. else
  183. *(new+0x6e) = *(old+0x6e); /* ABORT switch */
  184. return IRQ_HANDLED;
  185. }
  186. static irqreturn_t mvme16x_timer_int (int irq, void *dev_id)
  187. {
  188. *(volatile unsigned char *)0xfff4201b |= 8;
  189. return tick_handler(irq, dev_id);
  190. }
  191. void mvme16x_sched_init (irq_handler_t timer_routine)
  192. {
  193. p_bdid p = &mvme_bdid;
  194. int irq;
  195. tick_handler = timer_routine;
  196. /* Using PCCchip2 or MC2 chip tick timer 1 */
  197. *(volatile unsigned long *)0xfff42008 = 0;
  198. *(volatile unsigned long *)0xfff42004 = 10000; /* 10ms */
  199. *(volatile unsigned char *)0xfff42017 |= 3;
  200. *(volatile unsigned char *)0xfff4201b = 0x16;
  201. if (request_irq(MVME16x_IRQ_TIMER, mvme16x_timer_int, 0,
  202. "timer", mvme16x_timer_int))
  203. panic ("Couldn't register timer int");
  204. if (p->brdno == 0x0162 || p->brdno == 0x172)
  205. irq = MVME162_IRQ_ABORT;
  206. else
  207. irq = MVME167_IRQ_ABORT;
  208. if (request_irq(irq, mvme16x_abort_int, 0,
  209. "abort", mvme16x_abort_int))
  210. panic ("Couldn't register abort int");
  211. }
  212. /* This is always executed with interrupts disabled. */
  213. unsigned long mvme16x_gettimeoffset (void)
  214. {
  215. return (*(volatile unsigned long *)0xfff42008);
  216. }
  217. int bcd2int (unsigned char b)
  218. {
  219. return ((b>>4)*10 + (b&15));
  220. }
  221. int mvme16x_hwclk(int op, struct rtc_time *t)
  222. {
  223. #warning check me!
  224. if (!op) {
  225. rtc->ctrl = RTC_READ;
  226. t->tm_year = bcd2int (rtc->bcd_year);
  227. t->tm_mon = bcd2int (rtc->bcd_mth);
  228. t->tm_mday = bcd2int (rtc->bcd_dom);
  229. t->tm_hour = bcd2int (rtc->bcd_hr);
  230. t->tm_min = bcd2int (rtc->bcd_min);
  231. t->tm_sec = bcd2int (rtc->bcd_sec);
  232. rtc->ctrl = 0;
  233. }
  234. return 0;
  235. }
  236. int mvme16x_set_clock_mmss (unsigned long nowtime)
  237. {
  238. return 0;
  239. }