setup.c 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. /*
  2. * Carsten Langgaard, carstenl@mips.com
  3. * Copyright (C) 1999 MIPS Technologies, Inc. All rights reserved.
  4. *
  5. * Thomas Horsten <thh@lasat.com>
  6. * Copyright (C) 2000 LASAT Networks A/S.
  7. *
  8. * Brian Murphy <brian@murphy.dk>
  9. *
  10. * This program is free software; you can distribute it and/or modify it
  11. * under the terms of the GNU General Public License (Version 2) as
  12. * published by the Free Software Foundation.
  13. *
  14. * This program is distributed in the hope it will be useful, but WITHOUT
  15. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  16. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  17. * for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License along
  20. * with this program; if not, write to the Free Software Foundation, Inc.,
  21. * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
  22. *
  23. * Lasat specific setup.
  24. */
  25. #include <linux/config.h>
  26. #include <linux/init.h>
  27. #include <linux/sched.h>
  28. #include <linux/pci.h>
  29. #include <linux/interrupt.h>
  30. #include <linux/tty.h>
  31. #include <linux/serial.h>
  32. #include <linux/serial_core.h>
  33. #include <asm/time.h>
  34. #include <asm/cpu.h>
  35. #include <asm/bootinfo.h>
  36. #include <asm/irq.h>
  37. #include <asm/serial.h>
  38. #include <asm/lasat/lasat.h>
  39. #include <asm/lasat/serial.h>
  40. #ifdef CONFIG_PICVUE
  41. #include <linux/notifier.h>
  42. #endif
  43. #include "ds1603.h"
  44. #include <asm/lasat/ds1603.h>
  45. #include <asm/lasat/picvue.h>
  46. #include <asm/lasat/eeprom.h>
  47. #include "prom.h"
  48. int lasat_command_line = 0;
  49. void lasatint_init(void);
  50. extern void lasat_reboot_setup(void);
  51. extern void pcisetup(void);
  52. extern void edhac_init(void *, void *, void *);
  53. extern void addrflt_init(void);
  54. struct lasat_misc lasat_misc_info[N_MACHTYPES] = {
  55. {(void *)KSEG1ADDR(0x1c840000), (void *)KSEG1ADDR(0x1c800000), 2},
  56. {(void *)KSEG1ADDR(0x11080000), (void *)KSEG1ADDR(0x11000000), 6}
  57. };
  58. struct lasat_misc *lasat_misc = NULL;
  59. #ifdef CONFIG_DS1603
  60. static struct ds_defs ds_defs[N_MACHTYPES] = {
  61. { (void *)DS1603_REG_100, (void *)DS1603_REG_100,
  62. DS1603_RST_100, DS1603_CLK_100, DS1603_DATA_100,
  63. DS1603_DATA_SHIFT_100, 0, 0 },
  64. { (void *)DS1603_REG_200, (void *)DS1603_DATA_REG_200,
  65. DS1603_RST_200, DS1603_CLK_200, DS1603_DATA_200,
  66. DS1603_DATA_READ_SHIFT_200, 1, 2000 }
  67. };
  68. #endif
  69. #ifdef CONFIG_PICVUE
  70. #include "picvue.h"
  71. static struct pvc_defs pvc_defs[N_MACHTYPES] = {
  72. { (void *)PVC_REG_100, PVC_DATA_SHIFT_100, PVC_DATA_M_100,
  73. PVC_E_100, PVC_RW_100, PVC_RS_100 },
  74. { (void *)PVC_REG_200, PVC_DATA_SHIFT_200, PVC_DATA_M_200,
  75. PVC_E_200, PVC_RW_200, PVC_RS_200 }
  76. };
  77. #endif
  78. static int lasat_panic_display(struct notifier_block *this,
  79. unsigned long event, void *ptr)
  80. {
  81. #ifdef CONFIG_PICVUE
  82. unsigned char *string = ptr;
  83. if (string == NULL)
  84. string = "Kernel Panic";
  85. pvc_dump_string(string);
  86. #endif
  87. return NOTIFY_DONE;
  88. }
  89. static int lasat_panic_prom_monitor(struct notifier_block *this,
  90. unsigned long event, void *ptr)
  91. {
  92. prom_monitor();
  93. return NOTIFY_DONE;
  94. }
  95. static struct notifier_block lasat_panic_block[] =
  96. {
  97. { lasat_panic_display, NULL, INT_MAX },
  98. { lasat_panic_prom_monitor, NULL, INT_MIN }
  99. };
  100. static void lasat_time_init(void)
  101. {
  102. mips_hpt_frequency = lasat_board_info.li_cpu_hz / 2;
  103. }
  104. static void lasat_timer_setup(struct irqaction *irq)
  105. {
  106. write_c0_compare(
  107. read_c0_count() +
  108. mips_hpt_frequency / HZ);
  109. change_c0_status(ST0_IM, IE_IRQ0 | IE_IRQ5);
  110. }
  111. #define DYNAMIC_SERIAL_INIT
  112. #ifdef DYNAMIC_SERIAL_INIT
  113. void __init serial_init(void)
  114. {
  115. #ifdef CONFIG_SERIAL_8250
  116. struct uart_port s;
  117. memset(&s, 0, sizeof(s));
  118. s.flags = STD_COM_FLAGS;
  119. s.iotype = SERIAL_IO_MEM;
  120. if (mips_machtype == MACH_LASAT_100) {
  121. s.uartclk = LASAT_BASE_BAUD_100 * 16;
  122. s.irq = LASATINT_UART_100;
  123. s.regshift = LASAT_UART_REGS_SHIFT_100;
  124. s.membase = (char *)KSEG1ADDR(LASAT_UART_REGS_BASE_100);
  125. } else {
  126. s.uartclk = LASAT_BASE_BAUD_200 * 16;
  127. s.irq = LASATINT_UART_200;
  128. s.regshift = LASAT_UART_REGS_SHIFT_200;
  129. s.membase = (char *)KSEG1ADDR(LASAT_UART_REGS_BASE_200);
  130. }
  131. if (early_serial_setup(&s) != 0)
  132. printk(KERN_ERR "Serial setup failed!\n");
  133. #endif
  134. }
  135. #endif
  136. static int __init lasat_setup(void)
  137. {
  138. int i;
  139. lasat_misc = &lasat_misc_info[mips_machtype];
  140. #ifdef CONFIG_PICVUE
  141. picvue = &pvc_defs[mips_machtype];
  142. #endif
  143. /* Set up panic notifier */
  144. for (i = 0; i < sizeof(lasat_panic_block) / sizeof(struct notifier_block); i++)
  145. notifier_chain_register(&panic_notifier_list, &lasat_panic_block[i]);
  146. lasat_reboot_setup();
  147. board_time_init = lasat_time_init;
  148. board_timer_setup = lasat_timer_setup;
  149. #ifdef CONFIG_DS1603
  150. ds1603 = &ds_defs[mips_machtype];
  151. rtc_get_time = ds1603_read;
  152. rtc_set_time = ds1603_set;
  153. #endif
  154. #ifdef DYNAMIC_SERIAL_INIT
  155. serial_init();
  156. #endif
  157. /* Switch from prom exception handler to normal mode */
  158. change_c0_status(ST0_BEV,0);
  159. prom_printf("Lasat specific initialization complete\n");
  160. return 0;
  161. }
  162. early_initcall(lasat_setup);