malta_setup.c 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. /*
  2. * Carsten Langgaard, carstenl@mips.com
  3. * Copyright (C) 2000 MIPS Technologies, Inc. All rights reserved.
  4. *
  5. * This program is free software; you can distribute it and/or modify it
  6. * under the terms of the GNU General Public License (Version 2) as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  12. * for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along
  15. * with this program; if not, write to the Free Software Foundation, Inc.,
  16. * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
  17. */
  18. #include <linux/cpu.h>
  19. #include <linux/init.h>
  20. #include <linux/sched.h>
  21. #include <linux/ioport.h>
  22. #include <linux/irq.h>
  23. #include <linux/pci.h>
  24. #include <linux/screen_info.h>
  25. #include <linux/time.h>
  26. #include <asm/bootinfo.h>
  27. #include <asm/mips-boards/generic.h>
  28. #include <asm/mips-boards/prom.h>
  29. #include <asm/mips-boards/malta.h>
  30. #include <asm/mips-boards/maltaint.h>
  31. #include <asm/dma.h>
  32. #include <asm/traps.h>
  33. #ifdef CONFIG_VT
  34. #include <linux/console.h>
  35. #endif
  36. struct resource standard_io_resources[] = {
  37. {
  38. .name = "dma1",
  39. .start = 0x00,
  40. .end = 0x1f,
  41. .flags = IORESOURCE_BUSY
  42. },
  43. {
  44. .name = "timer",
  45. .start = 0x40,
  46. .end = 0x5f,
  47. .flags = IORESOURCE_BUSY
  48. },
  49. {
  50. .name = "keyboard",
  51. .start = 0x60,
  52. .end = 0x6f,
  53. .flags = IORESOURCE_BUSY
  54. },
  55. {
  56. .name = "dma page reg",
  57. .start = 0x80,
  58. .end = 0x8f,
  59. .flags = IORESOURCE_BUSY
  60. },
  61. {
  62. .name = "dma2",
  63. .start = 0xc0,
  64. .end = 0xdf,
  65. .flags = IORESOURCE_BUSY
  66. },
  67. };
  68. const char *get_system_type(void)
  69. {
  70. return "MIPS Malta";
  71. }
  72. #if defined(CONFIG_MIPS_MT_SMTC)
  73. const char display_string[] = " SMTC LINUX ON MALTA ";
  74. #else
  75. const char display_string[] = " LINUX ON MALTA ";
  76. #endif /* CONFIG_MIPS_MT_SMTC */
  77. #ifdef CONFIG_BLK_DEV_FD
  78. void __init fd_activate(void)
  79. {
  80. /*
  81. * Activate Floppy Controller in the SMSC FDC37M817 Super I/O
  82. * Controller.
  83. * Done by YAMON 2.00 onwards
  84. */
  85. /* Entering config state. */
  86. SMSC_WRITE(SMSC_CONFIG_ENTER, SMSC_CONFIG_REG);
  87. /* Activate floppy controller. */
  88. SMSC_WRITE(SMSC_CONFIG_DEVNUM, SMSC_CONFIG_REG);
  89. SMSC_WRITE(SMSC_CONFIG_DEVNUM_FLOPPY, SMSC_DATA_REG);
  90. SMSC_WRITE(SMSC_CONFIG_ACTIVATE, SMSC_CONFIG_REG);
  91. SMSC_WRITE(SMSC_CONFIG_ACTIVATE_ENABLE, SMSC_DATA_REG);
  92. /* Exit config state. */
  93. SMSC_WRITE(SMSC_CONFIG_EXIT, SMSC_CONFIG_REG);
  94. }
  95. #endif
  96. #ifdef CONFIG_BLK_DEV_IDE
  97. static void __init pci_clock_check(void)
  98. {
  99. unsigned int __iomem *jmpr_p =
  100. (unsigned int *) ioremap(MALTA_JMPRS_REG, sizeof(unsigned int));
  101. int jmpr = (__raw_readl(jmpr_p) >> 2) & 0x07;
  102. static const int pciclocks[] __initdata = {
  103. 33, 20, 25, 30, 12, 16, 37, 10
  104. };
  105. int pciclock = pciclocks[jmpr];
  106. char *argptr = prom_getcmdline();
  107. if (pciclock != 33 && !strstr(argptr, "idebus=")) {
  108. printk(KERN_WARNING "WARNING: PCI clock is %dMHz, "
  109. "setting idebus\n", pciclock);
  110. argptr += strlen(argptr);
  111. sprintf(argptr, " idebus=%d", pciclock);
  112. if (pciclock < 20 || pciclock > 66)
  113. printk(KERN_WARNING "WARNING: IDE timing "
  114. "calculations will be incorrect\n");
  115. }
  116. }
  117. #endif
  118. #if defined(CONFIG_VT) && defined(CONFIG_VGA_CONSOLE)
  119. static void __init screen_info_setup(void)
  120. {
  121. screen_info = (struct screen_info) {
  122. .orig_x = 0,
  123. .orig_y = 25,
  124. .ext_mem_k = 0,
  125. .orig_video_page = 0,
  126. .orig_video_mode = 0,
  127. .orig_video_cols = 80,
  128. .unused2 = 0,
  129. .orig_video_ega_bx = 0,
  130. .unused3 = 0,
  131. .orig_video_lines = 25,
  132. .orig_video_isVGA = VIDEO_TYPE_VGAC,
  133. .orig_video_points = 16
  134. };
  135. }
  136. #endif
  137. void __init plat_mem_setup(void)
  138. {
  139. unsigned int i;
  140. mips_pcibios_init();
  141. /* Request I/O space for devices used on the Malta board. */
  142. for (i = 0; i < ARRAY_SIZE(standard_io_resources); i++)
  143. request_resource(&ioport_resource, standard_io_resources+i);
  144. /*
  145. * Enable DMA channel 4 (cascade channel) in the PIIX4 south bridge.
  146. */
  147. enable_dma(4);
  148. #ifdef CONFIG_KGDB
  149. kgdb_config();
  150. #endif
  151. if (mips_revision_sconid == MIPS_REVISION_SCON_BONITO) {
  152. char *argptr;
  153. argptr = prom_getcmdline();
  154. if (strstr(argptr, "debug")) {
  155. BONITO_BONGENCFG |= BONITO_BONGENCFG_DEBUGMODE;
  156. printk("Enabled Bonito debug mode\n");
  157. }
  158. else
  159. BONITO_BONGENCFG &= ~BONITO_BONGENCFG_DEBUGMODE;
  160. #ifdef CONFIG_DMA_COHERENT
  161. if (BONITO_PCICACHECTRL & BONITO_PCICACHECTRL_CPUCOH_PRES) {
  162. BONITO_PCICACHECTRL |= BONITO_PCICACHECTRL_CPUCOH_EN;
  163. printk("Enabled Bonito CPU coherency\n");
  164. argptr = prom_getcmdline();
  165. if (strstr(argptr, "iobcuncached")) {
  166. BONITO_PCICACHECTRL &= ~BONITO_PCICACHECTRL_IOBCCOH_EN;
  167. BONITO_PCIMEMBASECFG = BONITO_PCIMEMBASECFG &
  168. ~(BONITO_PCIMEMBASECFG_MEMBASE0_CACHED |
  169. BONITO_PCIMEMBASECFG_MEMBASE1_CACHED);
  170. printk("Disabled Bonito IOBC coherency\n");
  171. }
  172. else {
  173. BONITO_PCICACHECTRL |= BONITO_PCICACHECTRL_IOBCCOH_EN;
  174. BONITO_PCIMEMBASECFG |=
  175. (BONITO_PCIMEMBASECFG_MEMBASE0_CACHED |
  176. BONITO_PCIMEMBASECFG_MEMBASE1_CACHED);
  177. printk("Enabled Bonito IOBC coherency\n");
  178. }
  179. }
  180. else
  181. panic("Hardware DMA cache coherency not supported");
  182. #endif
  183. }
  184. #ifdef CONFIG_DMA_COHERENT
  185. else {
  186. panic("Hardware DMA cache coherency not supported");
  187. }
  188. #endif
  189. #ifdef CONFIG_BLK_DEV_IDE
  190. pci_clock_check();
  191. #endif
  192. #ifdef CONFIG_BLK_DEV_FD
  193. fd_activate();
  194. #endif
  195. #if defined(CONFIG_VT) && defined(CONFIG_VGA_CONSOLE)
  196. screen_info_setup();
  197. #endif
  198. mips_reboot_setup();
  199. }