config.c 7.9 KB

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