pplus.c 24 KB

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