ip32-setup.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /*
  2. * IP32 basic setup
  3. *
  4. * This file is subject to the terms and conditions of the GNU General Public
  5. * License. See the file "COPYING" in the main directory of this archive
  6. * for more details.
  7. *
  8. * Copyright (C) 2000 Harald Koerfgen
  9. * Copyright (C) 2002, 2003, 2005 Ilya A. Volynets
  10. */
  11. #include <linux/config.h>
  12. #include <linux/console.h>
  13. #include <linux/init.h>
  14. #include <linux/interrupt.h>
  15. #include <linux/mc146818rtc.h>
  16. #include <linux/param.h>
  17. #include <linux/sched.h>
  18. #include <asm/bootinfo.h>
  19. #include <asm/mc146818-time.h>
  20. #include <asm/mipsregs.h>
  21. #include <asm/mmu_context.h>
  22. #include <asm/sgialib.h>
  23. #include <asm/time.h>
  24. #include <asm/traps.h>
  25. #include <asm/io.h>
  26. #include <asm/ip32/crime.h>
  27. #include <asm/ip32/mace.h>
  28. #include <asm/ip32/ip32_ints.h>
  29. extern void ip32_be_init(void);
  30. extern void crime_init(void);
  31. #ifdef CONFIG_SGI_O2MACE_ETH
  32. /*
  33. * This is taken care of in here 'cause they say using Arc later on is
  34. * problematic
  35. */
  36. extern char o2meth_eaddr[8];
  37. static inline unsigned char str2hexnum(unsigned char c)
  38. {
  39. if (c >= '0' && c <= '9')
  40. return c - '0';
  41. if (c >= 'a' && c <= 'f')
  42. return c - 'a' + 10;
  43. return 0; /* foo */
  44. }
  45. static inline void str2eaddr(unsigned char *ea, unsigned char *str)
  46. {
  47. int i;
  48. for (i = 0; i < 6; i++) {
  49. unsigned char num;
  50. if(*str == ':')
  51. str++;
  52. num = str2hexnum(*str++) << 4;
  53. num |= (str2hexnum(*str++));
  54. ea[i] = num;
  55. }
  56. }
  57. #endif
  58. #ifdef CONFIG_SERIAL_8250
  59. #include <linux/tty.h>
  60. #include <linux/serial.h>
  61. #include <linux/serial_core.h>
  62. #endif /* CONFIG_SERIAL_8250 */
  63. /* An arbitrary time; this can be decreased if reliability looks good */
  64. #define WAIT_MS 10
  65. void __init ip32_time_init(void)
  66. {
  67. printk(KERN_INFO "Calibrating system timer... ");
  68. write_c0_count(0);
  69. crime->timer = 0;
  70. while (crime->timer < CRIME_MASTER_FREQ * WAIT_MS / 1000) ;
  71. mips_hpt_frequency = read_c0_count() * 1000 / WAIT_MS;
  72. printk("%d MHz CPU detected\n", mips_hpt_frequency * 2 / 1000000);
  73. }
  74. void __init ip32_timer_setup(struct irqaction *irq)
  75. {
  76. irq->handler = no_action;
  77. setup_irq(IP32_R4K_TIMER_IRQ, irq);
  78. }
  79. void __init plat_setup(void)
  80. {
  81. board_be_init = ip32_be_init;
  82. rtc_mips_get_time = mc146818_get_cmos_time;
  83. rtc_mips_set_mmss = mc146818_set_rtc_mmss;
  84. board_time_init = ip32_time_init;
  85. board_timer_setup = ip32_timer_setup;
  86. #ifdef CONFIG_SERIAL_8250
  87. {
  88. static struct uart_port o2_serial[2];
  89. memset(o2_serial, 0, sizeof(o2_serial));
  90. o2_serial[0].type = PORT_16550A;
  91. o2_serial[0].line = 0;
  92. o2_serial[0].irq = MACEISA_SERIAL1_IRQ;
  93. o2_serial[0].flags = UPF_SKIP_TEST;
  94. o2_serial[0].uartclk = 1843200;
  95. o2_serial[0].iotype = UPIO_MEM;
  96. o2_serial[0].membase = (char *)&mace->isa.serial1;
  97. o2_serial[0].fifosize = 14;
  98. /* How much to shift register offset by. Each UART register
  99. * is replicated over 256 byte space */
  100. o2_serial[0].regshift = 8;
  101. o2_serial[1].type = PORT_16550A;
  102. o2_serial[1].line = 1;
  103. o2_serial[1].irq = MACEISA_SERIAL2_IRQ;
  104. o2_serial[1].flags = UPF_SKIP_TEST;
  105. o2_serial[1].uartclk = 1843200;
  106. o2_serial[1].iotype = UPIO_MEM;
  107. o2_serial[1].membase = (char *)&mace->isa.serial2;
  108. o2_serial[1].fifosize = 14;
  109. o2_serial[1].regshift = 8;
  110. early_serial_setup(&o2_serial[0]);
  111. early_serial_setup(&o2_serial[1]);
  112. }
  113. #endif
  114. #ifdef CONFIG_SGI_O2MACE_ETH
  115. {
  116. char *mac = ArcGetEnvironmentVariable("eaddr");
  117. str2eaddr(o2meth_eaddr, mac);
  118. }
  119. #endif
  120. #if defined(CONFIG_SERIAL_CORE_CONSOLE)
  121. {
  122. char* con = ArcGetEnvironmentVariable("console");
  123. if (con && *con == 'd') {
  124. static char options[8];
  125. char *baud = ArcGetEnvironmentVariable("dbaud");
  126. if (baud)
  127. strcpy(options, baud);
  128. add_preferred_console("ttyS", *(con + 1) == '2' ? 1 : 0,
  129. baud ? options : NULL);
  130. }
  131. }
  132. #endif
  133. }