config.c 7.3 KB

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