pplus.c 24 KB

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