setup.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. /*
  2. * setup.c: Setup pointers to hardware dependent routines.
  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) 1996, 1997, 2004 by Ralf Baechle (ralf@linux-mips.org)
  9. * Copyright (C) 2006, Wind River System Inc. Rongkai.zhan <rongkai.zhan@windriver.com>
  10. */
  11. #include <linux/config.h>
  12. #include <linux/init.h>
  13. #include <linux/string.h>
  14. #include <linux/kernel.h>
  15. #include <linux/tty.h>
  16. #include <linux/serial.h>
  17. #include <linux/serial_core.h>
  18. #include <linux/pm.h>
  19. #include <asm/io.h>
  20. #include <asm/bootinfo.h>
  21. #include <asm/reboot.h>
  22. #include <asm/time.h>
  23. #include <asm/gt64120.h>
  24. unsigned long gt64120_base = KSEG1ADDR(0x14000000);
  25. #ifdef WRPPMC_EARLY_DEBUG
  26. static volatile unsigned char * wrppmc_led = \
  27. (volatile unsigned char *)KSEG1ADDR(WRPPMC_LED_BASE);
  28. /*
  29. * PPMC LED control register:
  30. * -) bit[0] controls DS1 LED (1 - OFF, 0 - ON)
  31. * -) bit[1] controls DS2 LED (1 - OFF, 0 - ON)
  32. * -) bit[2] controls DS4 LED (1 - OFF, 0 - ON)
  33. */
  34. void wrppmc_led_on(int mask)
  35. {
  36. unsigned char value = *wrppmc_led;
  37. value &= (0xF8 | mask);
  38. *wrppmc_led = value;
  39. }
  40. /* If mask = 0, turn off all LEDs */
  41. void wrppmc_led_off(int mask)
  42. {
  43. unsigned char value = *wrppmc_led;
  44. value |= (0x7 & mask);
  45. *wrppmc_led = value;
  46. }
  47. /*
  48. * We assume that bootloader has initialized UART16550 correctly
  49. */
  50. void __init wrppmc_early_putc(char ch)
  51. {
  52. static volatile unsigned char *wrppmc_uart = \
  53. (volatile unsigned char *)KSEG1ADDR(WRPPMC_UART16550_BASE);
  54. unsigned char value;
  55. /* Wait until Transmit-Holding-Register is empty */
  56. while (1) {
  57. value = *(wrppmc_uart + 5);
  58. if (value & 0x20)
  59. break;
  60. }
  61. *wrppmc_uart = ch;
  62. }
  63. void __init wrppmc_early_printk(const char *fmt, ...)
  64. {
  65. static char pbuf[256] = {'\0', };
  66. char *ch = pbuf;
  67. va_list args;
  68. unsigned int i;
  69. memset(pbuf, 0, 256);
  70. va_start(args, fmt);
  71. i = vsprintf(pbuf, fmt, args);
  72. va_end(args);
  73. /* Print the string */
  74. while (*ch != '\0') {
  75. wrppmc_early_putc(*ch);
  76. /* if print '\n', also print '\r' */
  77. if (*ch++ == '\n')
  78. wrppmc_early_putc('\r');
  79. }
  80. }
  81. #endif /* WRPPMC_EARLY_DEBUG */
  82. unsigned long __init prom_free_prom_memory(void)
  83. {
  84. return 0;
  85. }
  86. #ifdef CONFIG_SERIAL_8250
  87. static void wrppmc_setup_serial(void)
  88. {
  89. struct uart_port up;
  90. memset(&up, 0x00, sizeof(struct uart_port));
  91. /*
  92. * A note about mapbase/membase
  93. * -) mapbase is the physical address of the IO port.
  94. * -) membase is an 'ioremapped' cookie.
  95. */
  96. up.line = 0;
  97. up.type = PORT_16550;
  98. up.iotype = UPIO_MEM;
  99. up.mapbase = WRPPMC_UART16550_BASE;
  100. up.membase = ioremap(up.mapbase, 8);
  101. up.irq = WRPPMC_UART16550_IRQ;
  102. up.uartclk = WRPPMC_UART16550_CLOCK;
  103. up.flags = UPF_SKIP_TEST/* | UPF_BOOT_AUTOCONF */;
  104. up.regshift = 0;
  105. early_serial_setup(&up);
  106. }
  107. #endif
  108. void __init plat_mem_setup(void)
  109. {
  110. extern void wrppmc_time_init(void);
  111. extern void wrppmc_timer_setup(struct irqaction *);
  112. extern void wrppmc_machine_restart(char *command);
  113. extern void wrppmc_machine_halt(void);
  114. extern void wrppmc_machine_power_off(void);
  115. _machine_restart = wrppmc_machine_restart;
  116. _machine_halt = wrppmc_machine_halt;
  117. pm_power_off = wrppmc_machine_power_off;
  118. /* Use MIPS Count/Compare Timer */
  119. board_time_init = wrppmc_time_init;
  120. board_timer_setup = wrppmc_timer_setup;
  121. /* This makes the operations of 'in/out[bwl]' to the
  122. * physical address ( < KSEG0) can work via KSEG1
  123. */
  124. set_io_port_base(KSEG1);
  125. #ifdef CONFIG_SERIAL_8250
  126. wrppmc_setup_serial();
  127. #endif
  128. }
  129. const char *get_system_type(void)
  130. {
  131. return "Wind River PPMC (GT64120)";
  132. }
  133. /*
  134. * Initializes basic routines and structures pointers, memory size (as
  135. * given by the bios and saves the command line.
  136. */
  137. void __init prom_init(void)
  138. {
  139. mips_machgroup = MACH_GROUP_GALILEO;
  140. mips_machtype = MACH_EV64120A;
  141. add_memory_region(WRPPMC_SDRAM_SCS0_BASE, WRPPMC_SDRAM_SCS0_SIZE, BOOT_MEM_RAM);
  142. add_memory_region(WRPPMC_BOOTROM_BASE, WRPPMC_BOOTROM_SIZE, BOOT_MEM_ROM_DATA);
  143. wrppmc_early_printk("prom_init: GT64120 SDRAM Bank 0: 0x%x - 0x%08lx\n",
  144. WRPPMC_SDRAM_SCS0_BASE, (WRPPMC_SDRAM_SCS0_BASE + WRPPMC_SDRAM_SCS0_SIZE));
  145. }