setup.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*
  2. * BRIEF MODULE DESCRIPTION
  3. * setup.c - board dependent boot routines
  4. *
  5. * Copyright (C) 2007 Lemote Inc. & Insititute of Computing Technology
  6. * Author: Fuxin Zhang, zhangfx@lemote.com
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License as published by the
  10. * Free Software Foundation; either version 2 of the License, or (at your
  11. * option) any later version.
  12. *
  13. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
  14. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  15. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
  16. * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  17. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  18. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  19. * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  20. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  21. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  22. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  23. *
  24. * You should have received a copy of the GNU General Public License along
  25. * with this program; if not, write to the Free Software Foundation, Inc.,
  26. * 675 Mass Ave, Cambridge, MA 02139, USA.
  27. *
  28. */
  29. #include <linux/bootmem.h>
  30. #include <linux/init.h>
  31. #include <linux/irq.h>
  32. #include <asm/bootinfo.h>
  33. #include <asm/mc146818-time.h>
  34. #include <asm/time.h>
  35. #include <asm/wbflush.h>
  36. #include <asm/mach-lemote/pci.h>
  37. #ifdef CONFIG_VT
  38. #include <linux/console.h>
  39. #include <linux/screen_info.h>
  40. #endif
  41. extern void mips_reboot_setup(void);
  42. unsigned long cpu_clock_freq;
  43. unsigned long bus_clock;
  44. unsigned int memsize;
  45. unsigned int highmemsize = 0;
  46. void __init plat_time_init(void)
  47. {
  48. /* setup mips r4k timer */
  49. mips_hpt_frequency = cpu_clock_freq / 2;
  50. }
  51. unsigned long read_persistent_clock(void)
  52. {
  53. return mc146818_get_cmos_time();
  54. }
  55. void (*__wbflush)(void);
  56. EXPORT_SYMBOL(__wbflush);
  57. static void wbflush_loongson2e(void)
  58. {
  59. asm(".set\tpush\n\t"
  60. ".set\tnoreorder\n\t"
  61. ".set mips3\n\t"
  62. "sync\n\t"
  63. "nop\n\t"
  64. ".set\tpop\n\t"
  65. ".set mips0\n\t");
  66. }
  67. void __init plat_mem_setup(void)
  68. {
  69. set_io_port_base((unsigned long)ioremap(LOONGSON2E_IO_PORT_BASE,
  70. IO_SPACE_LIMIT - LOONGSON2E_PCI_IO_START + 1));
  71. mips_reboot_setup();
  72. __wbflush = wbflush_loongson2e;
  73. add_memory_region(0x0, (memsize << 20), BOOT_MEM_RAM);
  74. #ifdef CONFIG_64BIT
  75. if (highmemsize > 0) {
  76. add_memory_region(0x20000000, highmemsize << 20, BOOT_MEM_RAM);
  77. }
  78. #endif
  79. #ifdef CONFIG_VT
  80. #if defined(CONFIG_VGA_CONSOLE)
  81. conswitchp = &vga_con;
  82. screen_info = (struct screen_info) {
  83. 0, 25, /* orig-x, orig-y */
  84. 0, /* unused */
  85. 0, /* orig-video-page */
  86. 0, /* orig-video-mode */
  87. 80, /* orig-video-cols */
  88. 0, 0, 0, /* ega_ax, ega_bx, ega_cx */
  89. 25, /* orig-video-lines */
  90. VIDEO_TYPE_VGAC, /* orig-video-isVGA */
  91. 16 /* orig-video-points */
  92. };
  93. #elif defined(CONFIG_DUMMY_CONSOLE)
  94. conswitchp = &dummy_con;
  95. #endif
  96. #endif
  97. }