setup.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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/pm.h>
  15. #include <asm/io.h>
  16. #include <asm/bootinfo.h>
  17. #include <asm/reboot.h>
  18. #include <asm/time.h>
  19. #include <asm/gt64120.h>
  20. unsigned long gt64120_base = KSEG1ADDR(0x14000000);
  21. #ifdef WRPPMC_EARLY_DEBUG
  22. static volatile unsigned char * wrppmc_led = \
  23. (volatile unsigned char *)KSEG1ADDR(WRPPMC_LED_BASE);
  24. /*
  25. * PPMC LED control register:
  26. * -) bit[0] controls DS1 LED (1 - OFF, 0 - ON)
  27. * -) bit[1] controls DS2 LED (1 - OFF, 0 - ON)
  28. * -) bit[2] controls DS4 LED (1 - OFF, 0 - ON)
  29. */
  30. void wrppmc_led_on(int mask)
  31. {
  32. unsigned char value = *wrppmc_led;
  33. value &= (0xF8 | mask);
  34. *wrppmc_led = value;
  35. }
  36. /* If mask = 0, turn off all LEDs */
  37. void wrppmc_led_off(int mask)
  38. {
  39. unsigned char value = *wrppmc_led;
  40. value |= (0x7 & mask);
  41. *wrppmc_led = value;
  42. }
  43. /*
  44. * We assume that bootloader has initialized UART16550 correctly
  45. */
  46. void __init wrppmc_early_putc(char ch)
  47. {
  48. static volatile unsigned char *wrppmc_uart = \
  49. (volatile unsigned char *)KSEG1ADDR(WRPPMC_UART16550_BASE);
  50. unsigned char value;
  51. /* Wait until Transmit-Holding-Register is empty */
  52. while (1) {
  53. value = *(wrppmc_uart + 5);
  54. if (value & 0x20)
  55. break;
  56. }
  57. *wrppmc_uart = ch;
  58. }
  59. void __init wrppmc_early_printk(const char *fmt, ...)
  60. {
  61. static char pbuf[256] = {'\0', };
  62. char *ch = pbuf;
  63. va_list args;
  64. unsigned int i;
  65. memset(pbuf, 0, 256);
  66. va_start(args, fmt);
  67. i = vsprintf(pbuf, fmt, args);
  68. va_end(args);
  69. /* Print the string */
  70. while (*ch != '\0') {
  71. wrppmc_early_putc(*ch);
  72. /* if print '\n', also print '\r' */
  73. if (*ch++ == '\n')
  74. wrppmc_early_putc('\r');
  75. }
  76. }
  77. #endif /* WRPPMC_EARLY_DEBUG */
  78. void __init prom_free_prom_memory(void)
  79. {
  80. }
  81. void __init plat_mem_setup(void)
  82. {
  83. extern void wrppmc_machine_restart(char *command);
  84. extern void wrppmc_machine_halt(void);
  85. _machine_restart = wrppmc_machine_restart;
  86. _machine_halt = wrppmc_machine_halt;
  87. pm_power_off = wrppmc_machine_halt;
  88. /* This makes the operations of 'in/out[bwl]' to the
  89. * physical address ( < KSEG0) can work via KSEG1
  90. */
  91. set_io_port_base(KSEG1);
  92. }
  93. const char *get_system_type(void)
  94. {
  95. return "Wind River PPMC (GT64120)";
  96. }
  97. /*
  98. * Initializes basic routines and structures pointers, memory size (as
  99. * given by the bios and saves the command line.
  100. */
  101. void __init prom_init(void)
  102. {
  103. add_memory_region(WRPPMC_SDRAM_SCS0_BASE, WRPPMC_SDRAM_SCS0_SIZE, BOOT_MEM_RAM);
  104. add_memory_region(WRPPMC_BOOTROM_BASE, WRPPMC_BOOTROM_SIZE, BOOT_MEM_ROM_DATA);
  105. wrppmc_early_printk("prom_init: GT64120 SDRAM Bank 0: 0x%x - 0x%08lx\n",
  106. WRPPMC_SDRAM_SCS0_BASE, (WRPPMC_SDRAM_SCS0_BASE + WRPPMC_SDRAM_SCS0_SIZE));
  107. }