setup.c 4.0 KB

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