malta_setup.c 5.6 KB

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