pplus.c 24 KB

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