pplus.c 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844
  1. /*
  2. * Board and PCI setup routines for MCG PowerPlus
  3. *
  4. * Author: Randy Vinson <rvinson@mvista.com>
  5. *
  6. * Derived from original PowerPlus PReP work by
  7. * Cort Dougan, Johnnie Peters, Matt Porter, and
  8. * Troy Benjegerdes.
  9. *
  10. * 2001-2004 (c) MontaVista, Software, Inc. This file is licensed under
  11. * the terms of the GNU General Public License version 2. This program
  12. * is licensed "as is" without any warranty of any kind, whether express
  13. * or implied.
  14. */
  15. #include <linux/kernel.h>
  16. #include <linux/interrupt.h>
  17. #include <linux/init.h>
  18. #include <linux/ioport.h>
  19. #include <linux/console.h>
  20. #include <linux/pci.h>
  21. #include <linux/seq_file.h>
  22. #include <linux/root_dev.h>
  23. #include <asm/system.h>
  24. #include <asm/io.h>
  25. #include <asm/pgtable.h>
  26. #include <asm/dma.h>
  27. #include <asm/machdep.h>
  28. #include <asm/prep_nvram.h>
  29. #include <asm/vga.h>
  30. #include <asm/i8259.h>
  31. #include <asm/open_pic.h>
  32. #include <asm/hawk.h>
  33. #include <asm/todc.h>
  34. #include <asm/bootinfo.h>
  35. #include <asm/kgdb.h>
  36. #include <asm/reg.h>
  37. #include "pplus.h"
  38. #undef DUMP_DBATS
  39. TODC_ALLOC();
  40. extern void pplus_setup_hose(void);
  41. extern void pplus_set_VIA_IDE_native(void);
  42. extern unsigned long loops_per_jiffy;
  43. unsigned char *Motherboard_map_name;
  44. /* Tables for known hardware */
  45. /* Motorola Mesquite */
  46. static inline int
  47. mesquite_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
  48. {
  49. static char pci_irq_table[][4] =
  50. /*
  51. * MPIC interrupts for various IDSEL values (MPIC IRQ0 =
  52. * Linux IRQ16 (to leave room for ISA IRQs at 0-15).
  53. * PCI IDSEL/INTPIN->INTLINE
  54. * A B C D
  55. */
  56. {
  57. {18, 0, 0, 0}, /* IDSEL 14 - Enet 0 */
  58. { 0, 0, 0, 0}, /* IDSEL 15 - unused */
  59. {19, 19, 19, 19}, /* IDSEL 16 - PMC Slot 1 */
  60. { 0, 0, 0, 0}, /* IDSEL 17 - unused */
  61. { 0, 0, 0, 0}, /* IDSEL 18 - unused */
  62. { 0, 0, 0, 0}, /* IDSEL 19 - unused */
  63. {24, 25, 26, 27}, /* IDSEL 20 - P2P bridge (to cPCI 1) */
  64. { 0, 0, 0, 0}, /* IDSEL 21 - unused */
  65. {28, 29, 30, 31} /* IDSEL 22 - P2P bridge (to cPCI 2) */
  66. };
  67. const long min_idsel = 14, max_idsel = 22, irqs_per_slot = 4;
  68. return PCI_IRQ_TABLE_LOOKUP;
  69. }
  70. /* Motorola Sitka */
  71. static inline int
  72. sitka_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
  73. {
  74. static char pci_irq_table[][4] =
  75. /*
  76. * MPIC interrupts for various IDSEL values (MPIC IRQ0 =
  77. * Linux IRQ16 (to leave room for ISA IRQs at 0-15).
  78. * PCI IDSEL/INTPIN->INTLINE
  79. * A B C D
  80. */
  81. {
  82. {18, 0, 0, 0}, /* IDSEL 14 - Enet 0 */
  83. { 0, 0, 0, 0}, /* IDSEL 15 - unused */
  84. {25, 26, 27, 28}, /* IDSEL 16 - PMC Slot 1 */
  85. {28, 25, 26, 27}, /* IDSEL 17 - PMC Slot 2 */
  86. { 0, 0, 0, 0}, /* IDSEL 18 - unused */
  87. { 0, 0, 0, 0}, /* IDSEL 19 - unused */
  88. {20, 0, 0, 0} /* IDSEL 20 - P2P bridge (to cPCI) */
  89. };
  90. const long min_idsel = 14, max_idsel = 20, irqs_per_slot = 4;
  91. return PCI_IRQ_TABLE_LOOKUP;
  92. }
  93. /* Motorola MTX */
  94. static inline int
  95. MTX_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
  96. {
  97. static char pci_irq_table[][4] =
  98. /*
  99. * MPIC interrupts for various IDSEL values (MPIC IRQ0 =
  100. * Linux IRQ16 (to leave room for ISA IRQs at 0-15).
  101. * PCI IDSEL/INTPIN->INTLINE
  102. * A B C D
  103. */
  104. {
  105. {19, 0, 0, 0}, /* IDSEL 12 - SCSI */
  106. { 0, 0, 0, 0}, /* IDSEL 13 - unused */
  107. {18, 0, 0, 0}, /* IDSEL 14 - Enet */
  108. { 0, 0, 0, 0}, /* IDSEL 15 - unused */
  109. {25, 26, 27, 28}, /* IDSEL 16 - PMC Slot 1 */
  110. {26, 27, 28, 25}, /* IDSEL 17 - PMC Slot 2 */
  111. {27, 28, 25, 26} /* IDSEL 18 - PCI Slot 3 */
  112. };
  113. const long min_idsel = 12, max_idsel = 18, irqs_per_slot = 4;
  114. return PCI_IRQ_TABLE_LOOKUP;
  115. }
  116. /* Motorola MTX Plus */
  117. /* Secondary bus interrupt routing is not supported yet */
  118. static inline int
  119. MTXplus_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
  120. {
  121. static char pci_irq_table[][4] =
  122. /*
  123. * MPIC interrupts for various IDSEL values (MPIC IRQ0 =
  124. * Linux IRQ16 (to leave room for ISA IRQs at 0-15).
  125. * PCI IDSEL/INTPIN->INTLINE
  126. * A B C D
  127. */
  128. {
  129. {19, 0, 0, 0}, /* IDSEL 12 - SCSI */
  130. { 0, 0, 0, 0}, /* IDSEL 13 - unused */
  131. {18, 0, 0, 0}, /* IDSEL 14 - Enet 1 */
  132. { 0, 0, 0, 0}, /* IDSEL 15 - unused */
  133. {25, 26, 27, 28}, /* IDSEL 16 - PCI Slot 1P */
  134. {26, 27, 28, 25}, /* IDSEL 17 - PCI Slot 2P */
  135. {27, 28, 25, 26}, /* IDSEL 18 - PCI Slot 3P */
  136. {26, 0, 0, 0}, /* IDSEL 19 - Enet 2 */
  137. { 0, 0, 0, 0} /* IDSEL 20 - P2P Bridge */
  138. };
  139. const long min_idsel = 12, max_idsel = 20, irqs_per_slot = 4;
  140. return PCI_IRQ_TABLE_LOOKUP;
  141. }
  142. static inline int
  143. Genesis2_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
  144. {
  145. /* 2600
  146. * Raven 31
  147. * ISA 11
  148. * SCSI 12 - IRQ3
  149. * Univ 13
  150. * eth 14 - IRQ2
  151. * VGA 15 - IRQ4
  152. * PMC1 16 - IRQ9,10,11,12 = PMC1 A-D
  153. * PMC2 17 - IRQ12,9,10,11 = A-D
  154. * SCSI2 18 - IRQ11
  155. * eth2 19 - IRQ10
  156. * PCIX 20 - IRQ9,10,11,12 = PCI A-D
  157. */
  158. /* 2400
  159. * Hawk 31
  160. * ISA 11
  161. * Univ 13
  162. * eth 14 - IRQ2
  163. * PMC1 16 - IRQ9,10,11,12 = PMC A-D
  164. * PMC2 17 - IRQ12,9,10,11 = PMC A-D
  165. * PCIX 20 - IRQ9,10,11,12 = PMC A-D
  166. */
  167. /* 2300
  168. * Raven 31
  169. * ISA 11
  170. * Univ 13
  171. * eth 14 - IRQ2
  172. * PMC1 16 - 9,10,11,12 = A-D
  173. * PMC2 17 - 9,10,11,12 = B,C,D,A
  174. */
  175. static char pci_irq_table[][4] =
  176. /*
  177. * MPIC interrupts for various IDSEL values (MPIC IRQ0 =
  178. * Linux IRQ16 (to leave room for ISA IRQs at 0-15).
  179. * PCI IDSEL/INTPIN->INTLINE
  180. * A B C D
  181. */
  182. {
  183. {19, 0, 0, 0}, /* IDSEL 12 - SCSI */
  184. { 0, 0, 0, 0}, /* IDSEL 13 - Universe PCI - VME */
  185. {18, 0, 0, 0}, /* IDSEL 14 - Enet 1 */
  186. { 0, 0, 0, 0}, /* IDSEL 15 - unused */
  187. {25, 26, 27, 28}, /* IDSEL 16 - PCI/PMC Slot 1P */
  188. {28, 25, 26, 27}, /* IDSEL 17 - PCI/PMC Slot 2P */
  189. {27, 28, 25, 26}, /* IDSEL 18 - PCI Slot 3P */
  190. {26, 0, 0, 0}, /* IDSEL 19 - Enet 2 */
  191. {25, 26, 27, 28} /* IDSEL 20 - P2P Bridge */
  192. };
  193. const long min_idsel = 12, max_idsel = 20, irqs_per_slot = 4;
  194. return PCI_IRQ_TABLE_LOOKUP;
  195. }
  196. #define MOTOROLA_CPUTYPE_REG 0x800
  197. #define MOTOROLA_BASETYPE_REG 0x803
  198. #define MPIC_RAVEN_ID 0x48010000
  199. #define MPIC_HAWK_ID 0x48030000
  200. #define MOT_PROC2_BIT 0x800
  201. static u_char pplus_openpic_initsenses[] __initdata = {
  202. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* MVME2600_INT_SIO */
  203. (IRQ_SENSE_EDGE | IRQ_POLARITY_NEGATIVE),/*MVME2600_INT_FALCN_ECC_ERR */
  204. (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),/*MVME2600_INT_PCI_ETHERNET */
  205. (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* MVME2600_INT_PCI_SCSI */
  206. (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),/*MVME2600_INT_PCI_GRAPHICS */
  207. (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* MVME2600_INT_PCI_VME0 */
  208. (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* MVME2600_INT_PCI_VME1 */
  209. (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* MVME2600_INT_PCI_VME2 */
  210. (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* MVME2600_INT_PCI_VME3 */
  211. (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* MVME2600_INT_PCI_INTA */
  212. (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* MVME2600_INT_PCI_INTB */
  213. (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* MVME2600_INT_PCI_INTC */
  214. (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* MVME2600_INT_PCI_INTD */
  215. (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* MVME2600_INT_LM_SIG0 */
  216. (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* MVME2600_INT_LM_SIG1 */
  217. (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE),
  218. };
  219. int mot_entry = -1;
  220. int prep_keybd_present = 1;
  221. int mot_multi = 0;
  222. struct brd_info {
  223. /* 0x100 mask assumes for Raven and Hawk boards that the level/edge
  224. * are set */
  225. int cpu_type;
  226. /* 0x200 if this board has a Hawk chip. */
  227. int base_type;
  228. /* or'ed with 0x80 if this board should be checked for multi CPU */
  229. int max_cpu;
  230. const char *name;
  231. int (*map_irq) (struct pci_dev *, unsigned char, unsigned char);
  232. };
  233. struct brd_info mot_info[] = {
  234. {0x300, 0x00, 0x00, "MVME 2400", Genesis2_map_irq},
  235. {0x1E0, 0xE0, 0x00, "Mesquite cPCI (MCP750)", mesquite_map_irq},
  236. {0x1E0, 0xE1, 0x00, "Sitka cPCI (MCPN750)", sitka_map_irq},
  237. {0x1E0, 0xE2, 0x00, "Mesquite cPCI (MCP750) w/ HAC", mesquite_map_irq},
  238. {0x1E0, 0xF6, 0x80, "MTX Plus", MTXplus_map_irq},
  239. {0x1E0, 0xF6, 0x81, "Dual MTX Plus", MTXplus_map_irq},
  240. {0x1E0, 0xF7, 0x80, "MTX wo/ Parallel Port", MTX_map_irq},
  241. {0x1E0, 0xF7, 0x81, "Dual MTX wo/ Parallel Port", MTX_map_irq},
  242. {0x1E0, 0xF8, 0x80, "MTX w/ Parallel Port", MTX_map_irq},
  243. {0x1E0, 0xF8, 0x81, "Dual MTX w/ Parallel Port", MTX_map_irq},
  244. {0x1E0, 0xF9, 0x00, "MVME 2300", Genesis2_map_irq},
  245. {0x1E0, 0xFA, 0x00, "MVME 2300SC/2600", Genesis2_map_irq},
  246. {0x1E0, 0xFB, 0x00, "MVME 2600 with MVME712M", Genesis2_map_irq},
  247. {0x1E0, 0xFC, 0x00, "MVME 2600/2700 with MVME761", Genesis2_map_irq},
  248. {0x1E0, 0xFD, 0x80, "MVME 3600 with MVME712M", Genesis2_map_irq},
  249. {0x1E0, 0xFD, 0x81, "MVME 4600 with MVME712M", Genesis2_map_irq},
  250. {0x1E0, 0xFE, 0x80, "MVME 3600 with MVME761", Genesis2_map_irq},
  251. {0x1E0, 0xFE, 0x81, "MVME 4600 with MVME761", Genesis2_map_irq},
  252. {0x000, 0x00, 0x00, "", NULL}
  253. };
  254. void __init pplus_set_board_type(void)
  255. {
  256. unsigned char cpu_type;
  257. unsigned char base_mod;
  258. int entry;
  259. unsigned short devid;
  260. unsigned long *ProcInfo = NULL;
  261. cpu_type = inb(MOTOROLA_CPUTYPE_REG) & 0xF0;
  262. base_mod = inb(MOTOROLA_BASETYPE_REG);
  263. early_read_config_word(0, 0, 0, PCI_VENDOR_ID, &devid);
  264. for (entry = 0; mot_info[entry].cpu_type != 0; entry++) {
  265. /* Check for Hawk chip */
  266. if (mot_info[entry].cpu_type & 0x200) {
  267. if (devid != PCI_DEVICE_ID_MOTOROLA_HAWK)
  268. continue;
  269. } else {
  270. /* store the system config register for later use. */
  271. ProcInfo =
  272. (unsigned long *)ioremap(PPLUS_SYS_CONFIG_REG, 4);
  273. /* Check non hawk boards */
  274. if ((mot_info[entry].cpu_type & 0xff) != cpu_type)
  275. continue;
  276. if (mot_info[entry].base_type == 0) {
  277. mot_entry = entry;
  278. break;
  279. }
  280. if (mot_info[entry].base_type != base_mod)
  281. continue;
  282. }
  283. if (!(mot_info[entry].max_cpu & 0x80)) {
  284. mot_entry = entry;
  285. break;
  286. }
  287. /* processor 1 not present and max processor zero indicated */
  288. if ((*ProcInfo & MOT_PROC2_BIT)
  289. && !(mot_info[entry].max_cpu & 0x7f)) {
  290. mot_entry = entry;
  291. break;
  292. }
  293. /* processor 1 present and max processor zero indicated */
  294. if (!(*ProcInfo & MOT_PROC2_BIT)
  295. && (mot_info[entry].max_cpu & 0x7f)) {
  296. mot_entry = entry;
  297. break;
  298. }
  299. /* Indicate to system if this is a multiprocessor board */
  300. if (!(*ProcInfo & MOT_PROC2_BIT))
  301. mot_multi = 1;
  302. }
  303. if (mot_entry == -1)
  304. /* No particular cpu type found - assume Mesquite (MCP750) */
  305. mot_entry = 1;
  306. Motherboard_map_name = (unsigned char *)mot_info[mot_entry].name;
  307. ppc_md.pci_map_irq = mot_info[mot_entry].map_irq;
  308. }
  309. void __init pplus_pib_init(void)
  310. {
  311. unsigned char reg;
  312. unsigned short short_reg;
  313. struct pci_dev *dev = NULL;
  314. /*
  315. * Perform specific configuration for the Via Tech or
  316. * or Winbond PCI-ISA-Bridge part.
  317. */
  318. if ((dev = pci_get_device(PCI_VENDOR_ID_VIA,
  319. PCI_DEVICE_ID_VIA_82C586_1, dev))) {
  320. /*
  321. * PPCBUG does not set the enable bits
  322. * for the IDE device. Force them on here.
  323. */
  324. pci_read_config_byte(dev, 0x40, &reg);
  325. reg |= 0x03; /* IDE: Chip Enable Bits */
  326. pci_write_config_byte(dev, 0x40, reg);
  327. }
  328. if ((dev = pci_get_device(PCI_VENDOR_ID_VIA,
  329. PCI_DEVICE_ID_VIA_82C586_2,
  330. dev)) && (dev->devfn = 0x5a)) {
  331. /* Force correct USB interrupt */
  332. dev->irq = 11;
  333. pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq);
  334. }
  335. if ((dev = pci_get_device(PCI_VENDOR_ID_WINBOND,
  336. PCI_DEVICE_ID_WINBOND_83C553, dev))) {
  337. /* Clear PCI Interrupt Routing Control Register. */
  338. short_reg = 0x0000;
  339. pci_write_config_word(dev, 0x44, short_reg);
  340. /* Route IDE interrupts to IRQ 14 */
  341. reg = 0xEE;
  342. pci_write_config_byte(dev, 0x43, reg);
  343. }
  344. if ((dev = pci_get_device(PCI_VENDOR_ID_WINBOND,
  345. PCI_DEVICE_ID_WINBOND_82C105, dev))) {
  346. /*
  347. * Disable LEGIRQ mode so PCI INTS are routed
  348. * directly to the 8259 and enable both channels
  349. */
  350. pci_write_config_dword(dev, 0x40, 0x10ff0033);
  351. /* Force correct IDE interrupt */
  352. dev->irq = 14;
  353. pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq);
  354. }
  355. pci_dev_put(dev);
  356. }
  357. void __init pplus_set_VIA_IDE_legacy(void)
  358. {
  359. unsigned short vend, dev;
  360. early_read_config_word(0, 0, PCI_DEVFN(0xb, 1), PCI_VENDOR_ID, &vend);
  361. early_read_config_word(0, 0, PCI_DEVFN(0xb, 1), PCI_DEVICE_ID, &dev);
  362. if ((vend == PCI_VENDOR_ID_VIA) &&
  363. (dev == PCI_DEVICE_ID_VIA_82C586_1)) {
  364. unsigned char temp;
  365. /* put back original "standard" port base addresses */
  366. early_write_config_dword(0, 0, PCI_DEVFN(0xb, 1),
  367. PCI_BASE_ADDRESS_0, 0x1f1);
  368. early_write_config_dword(0, 0, PCI_DEVFN(0xb, 1),
  369. PCI_BASE_ADDRESS_1, 0x3f5);
  370. early_write_config_dword(0, 0, PCI_DEVFN(0xb, 1),
  371. PCI_BASE_ADDRESS_2, 0x171);
  372. early_write_config_dword(0, 0, PCI_DEVFN(0xb, 1),
  373. PCI_BASE_ADDRESS_3, 0x375);
  374. early_write_config_dword(0, 0, PCI_DEVFN(0xb, 1),
  375. PCI_BASE_ADDRESS_4, 0xcc01);
  376. /* put into legacy mode */
  377. early_read_config_byte(0, 0, PCI_DEVFN(0xb, 1), PCI_CLASS_PROG,
  378. &temp);
  379. temp &= ~0x05;
  380. early_write_config_byte(0, 0, PCI_DEVFN(0xb, 1), PCI_CLASS_PROG,
  381. temp);
  382. }
  383. }
  384. void pplus_set_VIA_IDE_native(void)
  385. {
  386. unsigned short vend, dev;
  387. early_read_config_word(0, 0, PCI_DEVFN(0xb, 1), PCI_VENDOR_ID, &vend);
  388. early_read_config_word(0, 0, PCI_DEVFN(0xb, 1), PCI_DEVICE_ID, &dev);
  389. if ((vend == PCI_VENDOR_ID_VIA) &&
  390. (dev == PCI_DEVICE_ID_VIA_82C586_1)) {
  391. unsigned char temp;
  392. /* put into native mode */
  393. early_read_config_byte(0, 0, PCI_DEVFN(0xb, 1), PCI_CLASS_PROG,
  394. &temp);
  395. temp |= 0x05;
  396. early_write_config_byte(0, 0, PCI_DEVFN(0xb, 1), PCI_CLASS_PROG,
  397. temp);
  398. }
  399. }
  400. void __init pplus_pcibios_fixup(void)
  401. {
  402. unsigned char reg;
  403. unsigned short devid;
  404. unsigned char base_mod;
  405. printk(KERN_INFO "Setting PCI interrupts for a \"%s\"\n",
  406. Motherboard_map_name);
  407. /* Setup the Winbond or Via PIB */
  408. pplus_pib_init();
  409. /* Set up floppy in PS/2 mode */
  410. outb(0x09, SIO_CONFIG_RA);
  411. reg = inb(SIO_CONFIG_RD);
  412. reg = (reg & 0x3F) | 0x40;
  413. outb(reg, SIO_CONFIG_RD);
  414. outb(reg, SIO_CONFIG_RD); /* Have to write twice to change! */
  415. /* This is a hack. If this is a 2300 or 2400 mot board then there is
  416. * no keyboard controller and we have to indicate that.
  417. */
  418. early_read_config_word(0, 0, 0, PCI_VENDOR_ID, &devid);
  419. base_mod = inb(MOTOROLA_BASETYPE_REG);
  420. if ((devid == PCI_DEVICE_ID_MOTOROLA_HAWK) ||
  421. (base_mod == 0xF9) || (base_mod == 0xFA) || (base_mod == 0xE1))
  422. prep_keybd_present = 0;
  423. }
  424. void __init pplus_find_bridges(void)
  425. {
  426. struct pci_controller *hose;
  427. hose = pcibios_alloc_controller();
  428. if (!hose)
  429. return;
  430. hose->first_busno = 0;
  431. hose->last_busno = 0xff;
  432. hose->pci_mem_offset = PREP_ISA_MEM_BASE;
  433. hose->io_base_virt = (void *)PREP_ISA_IO_BASE;
  434. pci_init_resource(&hose->io_resource, PPLUS_PCI_IO_START,
  435. PPLUS_PCI_IO_END, IORESOURCE_IO, "PCI host bridge");
  436. pci_init_resource(&hose->mem_resources[0], PPLUS_PROC_PCI_MEM_START,
  437. PPLUS_PROC_PCI_MEM_END, IORESOURCE_MEM,
  438. "PCI host bridge");
  439. hose->io_space.start = PPLUS_PCI_IO_START;
  440. hose->io_space.end = PPLUS_PCI_IO_END;
  441. hose->mem_space.start = PPLUS_PCI_MEM_START;
  442. hose->mem_space.end = PPLUS_PCI_MEM_END - HAWK_MPIC_SIZE;
  443. if (hawk_init(hose, PPLUS_HAWK_PPC_REG_BASE, PPLUS_PROC_PCI_MEM_START,
  444. PPLUS_PROC_PCI_MEM_END - HAWK_MPIC_SIZE,
  445. PPLUS_PROC_PCI_IO_START, PPLUS_PROC_PCI_IO_END,
  446. PPLUS_PROC_PCI_MEM_END - HAWK_MPIC_SIZE + 1)
  447. != 0) {
  448. printk(KERN_CRIT "Could not initialize host bridge\n");
  449. }
  450. pplus_set_VIA_IDE_legacy();
  451. hose->last_busno = pciauto_bus_scan(hose, hose->first_busno);
  452. ppc_md.pcibios_fixup = pplus_pcibios_fixup;
  453. ppc_md.pci_swizzle = common_swizzle;
  454. }
  455. static int pplus_show_cpuinfo(struct seq_file *m)
  456. {
  457. seq_printf(m, "vendor\t\t: Motorola MCG\n");
  458. seq_printf(m, "machine\t\t: %s\n", Motherboard_map_name);
  459. return 0;
  460. }
  461. static void __init pplus_setup_arch(void)
  462. {
  463. struct pci_controller *hose;
  464. if (ppc_md.progress)
  465. ppc_md.progress("pplus_setup_arch: enter", 0);
  466. /* init to some ~sane value until calibrate_delay() runs */
  467. loops_per_jiffy = 50000000;
  468. if (ppc_md.progress)
  469. ppc_md.progress("pplus_setup_arch: find_bridges", 0);
  470. /* Setup PCI host bridge */
  471. pplus_find_bridges();
  472. hose = pci_bus_to_hose(0);
  473. isa_io_base = (ulong) hose->io_base_virt;
  474. if (ppc_md.progress)
  475. ppc_md.progress("pplus_setup_arch: set_board_type", 0);
  476. pplus_set_board_type();
  477. /* Enable L2. Assume we don't need to flush -- Cort */
  478. *(unsigned char *)(PPLUS_L2_CONTROL_REG) |= 3;
  479. #ifdef CONFIG_BLK_DEV_INITRD
  480. if (initrd_start)
  481. ROOT_DEV = Root_RAM0;
  482. else
  483. #endif
  484. #ifdef CONFIG_ROOT_NFS
  485. ROOT_DEV = Root_NFS;
  486. #else
  487. ROOT_DEV = Root_SDA2;
  488. #endif
  489. printk(KERN_INFO "Motorola PowerPlus Platform\n");
  490. printk(KERN_INFO
  491. "Port by MontaVista Software, Inc. (source@mvista.com)\n");
  492. #ifdef CONFIG_VGA_CONSOLE
  493. /* remap the VGA memory */
  494. vgacon_remap_base = (unsigned long)ioremap(PPLUS_ISA_MEM_BASE,
  495. 0x08000000);
  496. conswitchp = &vga_con;
  497. #endif
  498. #ifdef CONFIG_PPCBUG_NVRAM
  499. /* Read in NVRAM data */
  500. init_prep_nvram();
  501. /* if no bootargs, look in NVRAM */
  502. if (cmd_line[0] == '\0') {
  503. char *bootargs;
  504. bootargs = prep_nvram_get_var("bootargs");
  505. if (bootargs != NULL) {
  506. strcpy(cmd_line, bootargs);
  507. /* again.. */
  508. strcpy(boot_command_line, cmd_line);
  509. }
  510. }
  511. #endif
  512. if (ppc_md.progress)
  513. ppc_md.progress("pplus_setup_arch: exit", 0);
  514. }
  515. static void pplus_restart(char *cmd)
  516. {
  517. unsigned long i = 10000;
  518. local_irq_disable();
  519. /* set VIA IDE controller into native mode */
  520. pplus_set_VIA_IDE_native();
  521. /* set exception prefix high - to the prom */
  522. _nmask_and_or_msr(0, MSR_IP);
  523. /* make sure bit 0 (reset) is a 0 */
  524. outb(inb(0x92) & ~1L, 0x92);
  525. /* signal a reset to system control port A - soft reset */
  526. outb(inb(0x92) | 1, 0x92);
  527. while (i != 0)
  528. i++;
  529. panic("restart failed\n");
  530. }
  531. static void pplus_halt(void)
  532. {
  533. /* set exception prefix high - to the prom */
  534. _nmask_and_or_msr(MSR_EE, MSR_IP);
  535. /* make sure bit 0 (reset) is a 0 */
  536. outb(inb(0x92) & ~1L, 0x92);
  537. /* signal a reset to system control port A - soft reset */
  538. outb(inb(0x92) | 1, 0x92);
  539. while (1) ;
  540. /*
  541. * Not reached
  542. */
  543. }
  544. static void pplus_power_off(void)
  545. {
  546. pplus_halt();
  547. }
  548. static void __init pplus_init_IRQ(void)
  549. {
  550. int i;
  551. if (ppc_md.progress)
  552. ppc_md.progress("init_irq: enter", 0);
  553. OpenPIC_InitSenses = pplus_openpic_initsenses;
  554. OpenPIC_NumInitSenses = sizeof(pplus_openpic_initsenses);
  555. if (OpenPIC_Addr != NULL) {
  556. openpic_set_sources(0, 16, OpenPIC_Addr + 0x10000);
  557. openpic_init(NUM_8259_INTERRUPTS);
  558. openpic_hookup_cascade(NUM_8259_INTERRUPTS, "82c59 cascade",
  559. i8259_irq);
  560. ppc_md.get_irq = openpic_get_irq;
  561. }
  562. i8259_init(0, 0);
  563. if (ppc_md.progress)
  564. ppc_md.progress("init_irq: exit", 0);
  565. }
  566. #ifdef CONFIG_SMP
  567. /* PowerPlus (MTX) support */
  568. static int __init smp_pplus_probe(void)
  569. {
  570. extern int mot_multi;
  571. if (mot_multi) {
  572. openpic_request_IPIs();
  573. smp_hw_index[1] = 1;
  574. return 2;
  575. }
  576. return 1;
  577. }
  578. static void __init smp_pplus_kick_cpu(int nr)
  579. {
  580. *(unsigned long *)KERNELBASE = nr;
  581. asm volatile ("dcbf 0,%0"::"r" (KERNELBASE):"memory");
  582. printk(KERN_INFO "CPU1 reset, waiting\n");
  583. }
  584. static void __init smp_pplus_setup_cpu(int cpu_nr)
  585. {
  586. if (OpenPIC_Addr)
  587. do_openpic_setup_cpu();
  588. }
  589. static struct smp_ops_t pplus_smp_ops = {
  590. smp_openpic_message_pass,
  591. smp_pplus_probe,
  592. smp_pplus_kick_cpu,
  593. smp_pplus_setup_cpu,
  594. .give_timebase = smp_generic_give_timebase,
  595. .take_timebase = smp_generic_take_timebase,
  596. };
  597. #endif /* CONFIG_SMP */
  598. #ifdef DUMP_DBATS
  599. static void print_dbat(int idx, u32 bat)
  600. {
  601. char str[64];
  602. sprintf(str, "DBAT%c%c = 0x%08x\n",
  603. (char)((idx - DBAT0U) / 2) + '0', (idx & 1) ? 'L' : 'U', bat);
  604. ppc_md.progress(str, 0);
  605. }
  606. #define DUMP_DBAT(x) \
  607. do { \
  608. u32 __temp = mfspr(x);\
  609. print_dbat(x, __temp); \
  610. } while (0)
  611. static void dump_dbats(void)
  612. {
  613. if (ppc_md.progress) {
  614. DUMP_DBAT(DBAT0U);
  615. DUMP_DBAT(DBAT0L);
  616. DUMP_DBAT(DBAT1U);
  617. DUMP_DBAT(DBAT1L);
  618. DUMP_DBAT(DBAT2U);
  619. DUMP_DBAT(DBAT2L);
  620. DUMP_DBAT(DBAT3U);
  621. DUMP_DBAT(DBAT3L);
  622. }
  623. }
  624. #endif
  625. static unsigned long __init pplus_find_end_of_memory(void)
  626. {
  627. unsigned long total;
  628. if (ppc_md.progress)
  629. ppc_md.progress("pplus_find_end_of_memory", 0);
  630. #ifdef DUMP_DBATS
  631. dump_dbats();
  632. #endif
  633. total = hawk_get_mem_size(PPLUS_HAWK_SMC_BASE);
  634. return (total);
  635. }
  636. static void __init pplus_map_io(void)
  637. {
  638. io_block_mapping(PPLUS_ISA_IO_BASE, PPLUS_ISA_IO_BASE, 0x10000000,
  639. _PAGE_IO);
  640. io_block_mapping(0xfef80000, 0xfef80000, 0x00080000, _PAGE_IO);
  641. }
  642. static void __init pplus_init2(void)
  643. {
  644. #ifdef CONFIG_NVRAM
  645. request_region(PREP_NVRAM_AS0, 0x8, "nvram");
  646. #endif
  647. request_region(0x20, 0x20, "pic1");
  648. request_region(0xa0, 0x20, "pic2");
  649. request_region(0x00, 0x20, "dma1");
  650. request_region(0x40, 0x20, "timer");
  651. request_region(0x80, 0x10, "dma page reg");
  652. request_region(0xc0, 0x20, "dma2");
  653. }
  654. /*
  655. * Set BAT 2 to access 0x8000000 so progress messages will work and set BAT 3
  656. * to 0xf0000000 to access Falcon/Raven or Hawk registers
  657. */
  658. static __inline__ void pplus_set_bat(void)
  659. {
  660. /* wait for all outstanding memory accesses to complete */
  661. mb();
  662. /* setup DBATs */
  663. mtspr(SPRN_DBAT2U, 0x80001ffe);
  664. mtspr(SPRN_DBAT2L, 0x8000002a);
  665. mtspr(SPRN_DBAT3U, 0xf0001ffe);
  666. mtspr(SPRN_DBAT3L, 0xf000002a);
  667. /* wait for updates */
  668. mb();
  669. }
  670. void __init
  671. platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
  672. unsigned long r6, unsigned long r7)
  673. {
  674. parse_bootinfo(find_bootinfo());
  675. /* Map in board regs, etc. */
  676. pplus_set_bat();
  677. isa_io_base = PREP_ISA_IO_BASE;
  678. isa_mem_base = PREP_ISA_MEM_BASE;
  679. pci_dram_offset = PREP_PCI_DRAM_OFFSET;
  680. ISA_DMA_THRESHOLD = 0x00ffffff;
  681. DMA_MODE_READ = 0x44;
  682. DMA_MODE_WRITE = 0x48;
  683. ppc_do_canonicalize_irqs = 1;
  684. ppc_md.setup_arch = pplus_setup_arch;
  685. ppc_md.show_cpuinfo = pplus_show_cpuinfo;
  686. ppc_md.init_IRQ = pplus_init_IRQ;
  687. /* this gets changed later on if we have an OpenPIC -- Cort */
  688. ppc_md.get_irq = i8259_irq;
  689. ppc_md.init = pplus_init2;
  690. ppc_md.restart = pplus_restart;
  691. ppc_md.power_off = pplus_power_off;
  692. ppc_md.halt = pplus_halt;
  693. TODC_INIT(TODC_TYPE_MK48T59, PREP_NVRAM_AS0, PREP_NVRAM_AS1,
  694. PREP_NVRAM_DATA, 8);
  695. ppc_md.time_init = todc_time_init;
  696. ppc_md.set_rtc_time = todc_set_rtc_time;
  697. ppc_md.get_rtc_time = todc_get_rtc_time;
  698. ppc_md.calibrate_decr = todc_calibrate_decr;
  699. ppc_md.nvram_read_val = todc_m48txx_read_val;
  700. ppc_md.nvram_write_val = todc_m48txx_write_val;
  701. ppc_md.find_end_of_memory = pplus_find_end_of_memory;
  702. ppc_md.setup_io_mappings = pplus_map_io;
  703. #ifdef CONFIG_SERIAL_TEXT_DEBUG
  704. ppc_md.progress = gen550_progress;
  705. #endif /* CONFIG_SERIAL_TEXT_DEBUG */
  706. #ifdef CONFIG_KGDB
  707. ppc_md.kgdb_map_scc = gen550_kgdb_map_scc;
  708. #endif
  709. #ifdef CONFIG_SMP
  710. smp_ops = &pplus_smp_ops;
  711. #endif /* CONFIG_SMP */
  712. }