malta-setup.c 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. /*
  2. * Carsten Langgaard, carstenl@mips.com
  3. * Copyright (C) 2000 MIPS Technologies, Inc. All rights reserved.
  4. * Copyright (C) 2008 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. extern void malta_be_init(void);
  38. extern int malta_be_handler(struct pt_regs *regs, int is_fixup);
  39. static struct resource standard_io_resources[] = {
  40. {
  41. .name = "dma1",
  42. .start = 0x00,
  43. .end = 0x1f,
  44. .flags = IORESOURCE_BUSY
  45. },
  46. {
  47. .name = "timer",
  48. .start = 0x40,
  49. .end = 0x5f,
  50. .flags = IORESOURCE_BUSY
  51. },
  52. {
  53. .name = "keyboard",
  54. .start = 0x60,
  55. .end = 0x6f,
  56. .flags = IORESOURCE_BUSY
  57. },
  58. {
  59. .name = "dma page reg",
  60. .start = 0x80,
  61. .end = 0x8f,
  62. .flags = IORESOURCE_BUSY
  63. },
  64. {
  65. .name = "dma2",
  66. .start = 0xc0,
  67. .end = 0xdf,
  68. .flags = IORESOURCE_BUSY
  69. },
  70. };
  71. const char *get_system_type(void)
  72. {
  73. return "MIPS Malta";
  74. }
  75. #if defined(CONFIG_MIPS_MT_SMTC)
  76. const char display_string[] = " SMTC LINUX ON MALTA ";
  77. #else
  78. const char display_string[] = " LINUX ON MALTA ";
  79. #endif /* CONFIG_MIPS_MT_SMTC */
  80. #ifdef CONFIG_BLK_DEV_FD
  81. static void __init fd_activate(void)
  82. {
  83. /*
  84. * Activate Floppy Controller in the SMSC FDC37M817 Super I/O
  85. * Controller.
  86. * Done by YAMON 2.00 onwards
  87. */
  88. /* Entering config state. */
  89. SMSC_WRITE(SMSC_CONFIG_ENTER, SMSC_CONFIG_REG);
  90. /* Activate floppy controller. */
  91. SMSC_WRITE(SMSC_CONFIG_DEVNUM, SMSC_CONFIG_REG);
  92. SMSC_WRITE(SMSC_CONFIG_DEVNUM_FLOPPY, SMSC_DATA_REG);
  93. SMSC_WRITE(SMSC_CONFIG_ACTIVATE, SMSC_CONFIG_REG);
  94. SMSC_WRITE(SMSC_CONFIG_ACTIVATE_ENABLE, SMSC_DATA_REG);
  95. /* Exit config state. */
  96. SMSC_WRITE(SMSC_CONFIG_EXIT, SMSC_CONFIG_REG);
  97. }
  98. #endif
  99. #ifdef CONFIG_BLK_DEV_IDE
  100. static void __init pci_clock_check(void)
  101. {
  102. unsigned int __iomem *jmpr_p =
  103. (unsigned int *) ioremap(MALTA_JMPRS_REG, sizeof(unsigned int));
  104. int jmpr = (__raw_readl(jmpr_p) >> 2) & 0x07;
  105. static const int pciclocks[] __initdata = {
  106. 33, 20, 25, 30, 12, 16, 37, 10
  107. };
  108. int pciclock = pciclocks[jmpr];
  109. char *argptr = prom_getcmdline();
  110. if (pciclock != 33 && !strstr(argptr, "idebus=")) {
  111. printk(KERN_WARNING "WARNING: PCI clock is %dMHz, "
  112. "setting idebus\n", pciclock);
  113. argptr += strlen(argptr);
  114. sprintf(argptr, " idebus=%d", pciclock);
  115. if (pciclock < 20 || pciclock > 66)
  116. printk(KERN_WARNING "WARNING: IDE timing "
  117. "calculations will be incorrect\n");
  118. }
  119. }
  120. #endif
  121. #if defined(CONFIG_VT) && defined(CONFIG_VGA_CONSOLE)
  122. static void __init screen_info_setup(void)
  123. {
  124. screen_info = (struct screen_info) {
  125. .orig_x = 0,
  126. .orig_y = 25,
  127. .ext_mem_k = 0,
  128. .orig_video_page = 0,
  129. .orig_video_mode = 0,
  130. .orig_video_cols = 80,
  131. .unused2 = 0,
  132. .orig_video_ega_bx = 0,
  133. .unused3 = 0,
  134. .orig_video_lines = 25,
  135. .orig_video_isVGA = VIDEO_TYPE_VGAC,
  136. .orig_video_points = 16
  137. };
  138. }
  139. #endif
  140. static void __init bonito_quirks_setup(void)
  141. {
  142. char *argptr;
  143. argptr = prom_getcmdline();
  144. if (strstr(argptr, "debug")) {
  145. BONITO_BONGENCFG |= BONITO_BONGENCFG_DEBUGMODE;
  146. printk(KERN_INFO "Enabled Bonito debug mode\n");
  147. } else
  148. BONITO_BONGENCFG &= ~BONITO_BONGENCFG_DEBUGMODE;
  149. #ifdef CONFIG_DMA_COHERENT
  150. if (BONITO_PCICACHECTRL & BONITO_PCICACHECTRL_CPUCOH_PRES) {
  151. BONITO_PCICACHECTRL |= BONITO_PCICACHECTRL_CPUCOH_EN;
  152. printk(KERN_INFO "Enabled Bonito CPU coherency\n");
  153. argptr = prom_getcmdline();
  154. if (strstr(argptr, "iobcuncached")) {
  155. BONITO_PCICACHECTRL &= ~BONITO_PCICACHECTRL_IOBCCOH_EN;
  156. BONITO_PCIMEMBASECFG = BONITO_PCIMEMBASECFG &
  157. ~(BONITO_PCIMEMBASECFG_MEMBASE0_CACHED |
  158. BONITO_PCIMEMBASECFG_MEMBASE1_CACHED);
  159. printk(KERN_INFO "Disabled Bonito IOBC coherency\n");
  160. } else {
  161. BONITO_PCICACHECTRL |= BONITO_PCICACHECTRL_IOBCCOH_EN;
  162. BONITO_PCIMEMBASECFG |=
  163. (BONITO_PCIMEMBASECFG_MEMBASE0_CACHED |
  164. BONITO_PCIMEMBASECFG_MEMBASE1_CACHED);
  165. printk(KERN_INFO "Enabled Bonito IOBC coherency\n");
  166. }
  167. } else
  168. panic("Hardware DMA cache coherency not supported");
  169. #endif
  170. }
  171. void __init plat_mem_setup(void)
  172. {
  173. unsigned int i;
  174. mips_pcibios_init();
  175. /* Request I/O space for devices used on the Malta board. */
  176. for (i = 0; i < ARRAY_SIZE(standard_io_resources); i++)
  177. request_resource(&ioport_resource, standard_io_resources+i);
  178. /*
  179. * Enable DMA channel 4 (cascade channel) in the PIIX4 south bridge.
  180. */
  181. enable_dma(4);
  182. #ifdef CONFIG_DMA_COHERENT
  183. if (mips_revision_sconid != MIPS_REVISION_SCON_BONITO)
  184. panic("Hardware DMA cache coherency not supported");
  185. #endif
  186. if (mips_revision_sconid == MIPS_REVISION_SCON_BONITO)
  187. bonito_quirks_setup();
  188. #ifdef CONFIG_BLK_DEV_IDE
  189. pci_clock_check();
  190. #endif
  191. #ifdef CONFIG_BLK_DEV_FD
  192. fd_activate();
  193. #endif
  194. #if defined(CONFIG_VT) && defined(CONFIG_VGA_CONSOLE)
  195. screen_info_setup();
  196. #endif
  197. board_be_init = malta_be_init;
  198. board_be_handler = malta_be_handler;
  199. }