prep_pci.c 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341
  1. /*
  2. * PReP pci functions.
  3. * Originally by Gary Thomas
  4. * rewritten and updated by Cort Dougan (cort@cs.nmt.edu)
  5. *
  6. * The motherboard routes/maps will disappear shortly. -- Cort
  7. */
  8. #include <linux/config.h>
  9. #include <linux/types.h>
  10. #include <linux/pci.h>
  11. #include <linux/kernel.h>
  12. #include <linux/init.h>
  13. #include <asm/sections.h>
  14. #include <asm/byteorder.h>
  15. #include <asm/io.h>
  16. #include <asm/ptrace.h>
  17. #include <asm/prom.h>
  18. #include <asm/pci-bridge.h>
  19. #include <asm/residual.h>
  20. #include <asm/irq.h>
  21. #include <asm/machdep.h>
  22. #include <asm/open_pic.h>
  23. extern void (*setup_ibm_pci)(char *irq_lo, char *irq_hi);
  24. /* Which PCI interrupt line does a given device [slot] use? */
  25. /* Note: This really should be two dimensional based in slot/pin used */
  26. static unsigned char *Motherboard_map;
  27. unsigned char *Motherboard_map_name;
  28. /* How is the 82378 PIRQ mapping setup? */
  29. static unsigned char *Motherboard_routes;
  30. static void (*Motherboard_non0)(struct pci_dev *);
  31. static void Powerplus_Map_Non0(struct pci_dev *);
  32. /* Used for Motorola to store system config register */
  33. static unsigned long *ProcInfo;
  34. /* Tables for known hardware */
  35. /* Motorola PowerStackII - Utah */
  36. static char Utah_pci_IRQ_map[23] __prepdata =
  37. {
  38. 0, /* Slot 0 - unused */
  39. 0, /* Slot 1 - unused */
  40. 5, /* Slot 2 - SCSI - NCR825A */
  41. 0, /* Slot 3 - unused */
  42. 3, /* Slot 4 - Ethernet - DEC2114x */
  43. 0, /* Slot 5 - unused */
  44. 2, /* Slot 6 - PCI Card slot #1 */
  45. 3, /* Slot 7 - PCI Card slot #2 */
  46. 5, /* Slot 8 - PCI Card slot #3 */
  47. 5, /* Slot 9 - PCI Bridge */
  48. /* added here in case we ever support PCI bridges */
  49. /* Secondary PCI bus cards are at slot-9,6 & slot-9,7 */
  50. 0, /* Slot 10 - unused */
  51. 0, /* Slot 11 - unused */
  52. 5, /* Slot 12 - SCSI - NCR825A */
  53. 0, /* Slot 13 - unused */
  54. 3, /* Slot 14 - enet */
  55. 0, /* Slot 15 - unused */
  56. 2, /* Slot 16 - unused */
  57. 3, /* Slot 17 - unused */
  58. 5, /* Slot 18 - unused */
  59. 0, /* Slot 19 - unused */
  60. 0, /* Slot 20 - unused */
  61. 0, /* Slot 21 - unused */
  62. 0, /* Slot 22 - unused */
  63. };
  64. static char Utah_pci_IRQ_routes[] __prepdata =
  65. {
  66. 0, /* Line 0 - Unused */
  67. 9, /* Line 1 */
  68. 10, /* Line 2 */
  69. 11, /* Line 3 */
  70. 14, /* Line 4 */
  71. 15, /* Line 5 */
  72. };
  73. /* Motorola PowerStackII - Omaha */
  74. /* no integrated SCSI or ethernet */
  75. static char Omaha_pci_IRQ_map[23] __prepdata =
  76. {
  77. 0, /* Slot 0 - unused */
  78. 0, /* Slot 1 - unused */
  79. 3, /* Slot 2 - Winbond EIDE */
  80. 0, /* Slot 3 - unused */
  81. 0, /* Slot 4 - unused */
  82. 0, /* Slot 5 - unused */
  83. 1, /* Slot 6 - PCI slot 1 */
  84. 2, /* Slot 7 - PCI slot 2 */
  85. 3, /* Slot 8 - PCI slot 3 */
  86. 4, /* Slot 9 - PCI slot 4 */ /* needs indirect access */
  87. 0, /* Slot 10 - unused */
  88. 0, /* Slot 11 - unused */
  89. 0, /* Slot 12 - unused */
  90. 0, /* Slot 13 - unused */
  91. 0, /* Slot 14 - unused */
  92. 0, /* Slot 15 - unused */
  93. 1, /* Slot 16 - PCI slot 1 */
  94. 2, /* Slot 17 - PCI slot 2 */
  95. 3, /* Slot 18 - PCI slot 3 */
  96. 4, /* Slot 19 - PCI slot 4 */ /* needs indirect access */
  97. 0,
  98. 0,
  99. 0,
  100. };
  101. static char Omaha_pci_IRQ_routes[] __prepdata =
  102. {
  103. 0, /* Line 0 - Unused */
  104. 9, /* Line 1 */
  105. 11, /* Line 2 */
  106. 14, /* Line 3 */
  107. 15 /* Line 4 */
  108. };
  109. /* Motorola PowerStack */
  110. static char Blackhawk_pci_IRQ_map[19] __prepdata =
  111. {
  112. 0, /* Slot 0 - unused */
  113. 0, /* Slot 1 - unused */
  114. 0, /* Slot 2 - unused */
  115. 0, /* Slot 3 - unused */
  116. 0, /* Slot 4 - unused */
  117. 0, /* Slot 5 - unused */
  118. 0, /* Slot 6 - unused */
  119. 0, /* Slot 7 - unused */
  120. 0, /* Slot 8 - unused */
  121. 0, /* Slot 9 - unused */
  122. 0, /* Slot 10 - unused */
  123. 0, /* Slot 11 - unused */
  124. 3, /* Slot 12 - SCSI */
  125. 0, /* Slot 13 - unused */
  126. 1, /* Slot 14 - Ethernet */
  127. 0, /* Slot 15 - unused */
  128. 1, /* Slot P7 */
  129. 2, /* Slot P6 */
  130. 3, /* Slot P5 */
  131. };
  132. static char Blackhawk_pci_IRQ_routes[] __prepdata =
  133. {
  134. 0, /* Line 0 - Unused */
  135. 9, /* Line 1 */
  136. 11, /* Line 2 */
  137. 15, /* Line 3 */
  138. 15 /* Line 4 */
  139. };
  140. /* Motorola Mesquite */
  141. static char Mesquite_pci_IRQ_map[23] __prepdata =
  142. {
  143. 0, /* Slot 0 - unused */
  144. 0, /* Slot 1 - unused */
  145. 0, /* Slot 2 - unused */
  146. 0, /* Slot 3 - unused */
  147. 0, /* Slot 4 - unused */
  148. 0, /* Slot 5 - unused */
  149. 0, /* Slot 6 - unused */
  150. 0, /* Slot 7 - unused */
  151. 0, /* Slot 8 - unused */
  152. 0, /* Slot 9 - unused */
  153. 0, /* Slot 10 - unused */
  154. 0, /* Slot 11 - unused */
  155. 0, /* Slot 12 - unused */
  156. 0, /* Slot 13 - unused */
  157. 2, /* Slot 14 - Ethernet */
  158. 0, /* Slot 15 - unused */
  159. 3, /* Slot 16 - PMC */
  160. 0, /* Slot 17 - unused */
  161. 0, /* Slot 18 - unused */
  162. 0, /* Slot 19 - unused */
  163. 0, /* Slot 20 - unused */
  164. 0, /* Slot 21 - unused */
  165. 0, /* Slot 22 - unused */
  166. };
  167. /* Motorola Sitka */
  168. static char Sitka_pci_IRQ_map[21] __prepdata =
  169. {
  170. 0, /* Slot 0 - unused */
  171. 0, /* Slot 1 - unused */
  172. 0, /* Slot 2 - unused */
  173. 0, /* Slot 3 - unused */
  174. 0, /* Slot 4 - unused */
  175. 0, /* Slot 5 - unused */
  176. 0, /* Slot 6 - unused */
  177. 0, /* Slot 7 - unused */
  178. 0, /* Slot 8 - unused */
  179. 0, /* Slot 9 - unused */
  180. 0, /* Slot 10 - unused */
  181. 0, /* Slot 11 - unused */
  182. 0, /* Slot 12 - unused */
  183. 0, /* Slot 13 - unused */
  184. 2, /* Slot 14 - Ethernet */
  185. 0, /* Slot 15 - unused */
  186. 9, /* Slot 16 - PMC 1 */
  187. 12, /* Slot 17 - PMC 2 */
  188. 0, /* Slot 18 - unused */
  189. 0, /* Slot 19 - unused */
  190. 4, /* Slot 20 - NT P2P bridge */
  191. };
  192. /* Motorola MTX */
  193. static char MTX_pci_IRQ_map[23] __prepdata =
  194. {
  195. 0, /* Slot 0 - unused */
  196. 0, /* Slot 1 - unused */
  197. 0, /* Slot 2 - unused */
  198. 0, /* Slot 3 - unused */
  199. 0, /* Slot 4 - unused */
  200. 0, /* Slot 5 - unused */
  201. 0, /* Slot 6 - unused */
  202. 0, /* Slot 7 - unused */
  203. 0, /* Slot 8 - unused */
  204. 0, /* Slot 9 - unused */
  205. 0, /* Slot 10 - unused */
  206. 0, /* Slot 11 - unused */
  207. 3, /* Slot 12 - SCSI */
  208. 0, /* Slot 13 - unused */
  209. 2, /* Slot 14 - Ethernet */
  210. 0, /* Slot 15 - unused */
  211. 9, /* Slot 16 - PCI/PMC slot 1 */
  212. 10, /* Slot 17 - PCI/PMC slot 2 */
  213. 11, /* Slot 18 - PCI slot 3 */
  214. 0, /* Slot 19 - unused */
  215. 0, /* Slot 20 - unused */
  216. 0, /* Slot 21 - unused */
  217. 0, /* Slot 22 - unused */
  218. };
  219. /* Motorola MTX Plus */
  220. /* Secondary bus interrupt routing is not supported yet */
  221. static char MTXplus_pci_IRQ_map[23] __prepdata =
  222. {
  223. 0, /* Slot 0 - unused */
  224. 0, /* Slot 1 - unused */
  225. 0, /* Slot 2 - unused */
  226. 0, /* Slot 3 - unused */
  227. 0, /* Slot 4 - unused */
  228. 0, /* Slot 5 - unused */
  229. 0, /* Slot 6 - unused */
  230. 0, /* Slot 7 - unused */
  231. 0, /* Slot 8 - unused */
  232. 0, /* Slot 9 - unused */
  233. 0, /* Slot 10 - unused */
  234. 0, /* Slot 11 - unused */
  235. 3, /* Slot 12 - SCSI */
  236. 0, /* Slot 13 - unused */
  237. 2, /* Slot 14 - Ethernet 1 */
  238. 0, /* Slot 15 - unused */
  239. 9, /* Slot 16 - PCI slot 1P */
  240. 10, /* Slot 17 - PCI slot 2P */
  241. 11, /* Slot 18 - PCI slot 3P */
  242. 10, /* Slot 19 - Ethernet 2 */
  243. 0, /* Slot 20 - P2P Bridge */
  244. 0, /* Slot 21 - unused */
  245. 0, /* Slot 22 - unused */
  246. };
  247. static char Raven_pci_IRQ_routes[] __prepdata =
  248. {
  249. 0, /* This is a dummy structure */
  250. };
  251. /* Motorola MVME16xx */
  252. static char Genesis_pci_IRQ_map[16] __prepdata =
  253. {
  254. 0, /* Slot 0 - unused */
  255. 0, /* Slot 1 - unused */
  256. 0, /* Slot 2 - unused */
  257. 0, /* Slot 3 - unused */
  258. 0, /* Slot 4 - unused */
  259. 0, /* Slot 5 - unused */
  260. 0, /* Slot 6 - unused */
  261. 0, /* Slot 7 - unused */
  262. 0, /* Slot 8 - unused */
  263. 0, /* Slot 9 - unused */
  264. 0, /* Slot 10 - unused */
  265. 0, /* Slot 11 - unused */
  266. 3, /* Slot 12 - SCSI */
  267. 0, /* Slot 13 - unused */
  268. 1, /* Slot 14 - Ethernet */
  269. 0, /* Slot 15 - unused */
  270. };
  271. static char Genesis_pci_IRQ_routes[] __prepdata =
  272. {
  273. 0, /* Line 0 - Unused */
  274. 10, /* Line 1 */
  275. 11, /* Line 2 */
  276. 14, /* Line 3 */
  277. 15 /* Line 4 */
  278. };
  279. static char Genesis2_pci_IRQ_map[23] __prepdata =
  280. {
  281. 0, /* Slot 0 - unused */
  282. 0, /* Slot 1 - unused */
  283. 0, /* Slot 2 - unused */
  284. 0, /* Slot 3 - unused */
  285. 0, /* Slot 4 - unused */
  286. 0, /* Slot 5 - unused */
  287. 0, /* Slot 6 - unused */
  288. 0, /* Slot 7 - unused */
  289. 0, /* Slot 8 - unused */
  290. 0, /* Slot 9 - unused */
  291. 0, /* Slot 10 - unused */
  292. 0, /* Slot 11 - IDE */
  293. 3, /* Slot 12 - SCSI */
  294. 5, /* Slot 13 - Universe PCI - VME Bridge */
  295. 2, /* Slot 14 - Ethernet */
  296. 0, /* Slot 15 - unused */
  297. 9, /* Slot 16 - PMC 1 */
  298. 12, /* Slot 17 - pci */
  299. 11, /* Slot 18 - pci */
  300. 10, /* Slot 19 - pci */
  301. 0, /* Slot 20 - pci */
  302. 0, /* Slot 21 - unused */
  303. 0, /* Slot 22 - unused */
  304. };
  305. /* Motorola Series-E */
  306. static char Comet_pci_IRQ_map[23] __prepdata =
  307. {
  308. 0, /* Slot 0 - unused */
  309. 0, /* Slot 1 - unused */
  310. 0, /* Slot 2 - unused */
  311. 0, /* Slot 3 - unused */
  312. 0, /* Slot 4 - unused */
  313. 0, /* Slot 5 - unused */
  314. 0, /* Slot 6 - unused */
  315. 0, /* Slot 7 - unused */
  316. 0, /* Slot 8 - unused */
  317. 0, /* Slot 9 - unused */
  318. 0, /* Slot 10 - unused */
  319. 0, /* Slot 11 - unused */
  320. 3, /* Slot 12 - SCSI */
  321. 0, /* Slot 13 - unused */
  322. 1, /* Slot 14 - Ethernet */
  323. 0, /* Slot 15 - unused */
  324. 1, /* Slot 16 - PCI slot 1 */
  325. 2, /* Slot 17 - PCI slot 2 */
  326. 3, /* Slot 18 - PCI slot 3 */
  327. 4, /* Slot 19 - PCI bridge */
  328. 0,
  329. 0,
  330. 0,
  331. };
  332. static char Comet_pci_IRQ_routes[] __prepdata =
  333. {
  334. 0, /* Line 0 - Unused */
  335. 10, /* Line 1 */
  336. 11, /* Line 2 */
  337. 14, /* Line 3 */
  338. 15 /* Line 4 */
  339. };
  340. /* Motorola Series-EX */
  341. static char Comet2_pci_IRQ_map[23] __prepdata =
  342. {
  343. 0, /* Slot 0 - unused */
  344. 0, /* Slot 1 - unused */
  345. 3, /* Slot 2 - SCSI - NCR825A */
  346. 0, /* Slot 3 - unused */
  347. 1, /* Slot 4 - Ethernet - DEC2104X */
  348. 0, /* Slot 5 - unused */
  349. 1, /* Slot 6 - PCI slot 1 */
  350. 2, /* Slot 7 - PCI slot 2 */
  351. 3, /* Slot 8 - PCI slot 3 */
  352. 4, /* Slot 9 - PCI bridge */
  353. 0, /* Slot 10 - unused */
  354. 0, /* Slot 11 - unused */
  355. 3, /* Slot 12 - SCSI - NCR825A */
  356. 0, /* Slot 13 - unused */
  357. 1, /* Slot 14 - Ethernet - DEC2104X */
  358. 0, /* Slot 15 - unused */
  359. 1, /* Slot 16 - PCI slot 1 */
  360. 2, /* Slot 17 - PCI slot 2 */
  361. 3, /* Slot 18 - PCI slot 3 */
  362. 4, /* Slot 19 - PCI bridge */
  363. 0,
  364. 0,
  365. 0,
  366. };
  367. static char Comet2_pci_IRQ_routes[] __prepdata =
  368. {
  369. 0, /* Line 0 - Unused */
  370. 10, /* Line 1 */
  371. 11, /* Line 2 */
  372. 14, /* Line 3 */
  373. 15, /* Line 4 */
  374. };
  375. /*
  376. * ibm 830 (and 850?).
  377. * This is actually based on the Carolina motherboard
  378. * -- Cort
  379. */
  380. static char ibm8xx_pci_IRQ_map[23] __prepdata = {
  381. 0, /* Slot 0 - unused */
  382. 0, /* Slot 1 - unused */
  383. 0, /* Slot 2 - unused */
  384. 0, /* Slot 3 - unused */
  385. 0, /* Slot 4 - unused */
  386. 0, /* Slot 5 - unused */
  387. 0, /* Slot 6 - unused */
  388. 0, /* Slot 7 - unused */
  389. 0, /* Slot 8 - unused */
  390. 0, /* Slot 9 - unused */
  391. 0, /* Slot 10 - unused */
  392. 0, /* Slot 11 - FireCoral */
  393. 4, /* Slot 12 - Ethernet PCIINTD# */
  394. 2, /* Slot 13 - PCI Slot #2 */
  395. 2, /* Slot 14 - S3 Video PCIINTD# */
  396. 0, /* Slot 15 - onboard SCSI (INDI) [1] */
  397. 3, /* Slot 16 - NCR58C810 RS6000 Only PCIINTC# */
  398. 0, /* Slot 17 - unused */
  399. 2, /* Slot 18 - PCI Slot 2 PCIINTx# (See below) */
  400. 0, /* Slot 19 - unused */
  401. 0, /* Slot 20 - unused */
  402. 0, /* Slot 21 - unused */
  403. 2, /* Slot 22 - PCI slot 1 PCIINTx# (See below) */
  404. };
  405. static char ibm8xx_pci_IRQ_routes[] __prepdata = {
  406. 0, /* Line 0 - unused */
  407. 15, /* Line 1 */
  408. 15, /* Line 2 */
  409. 15, /* Line 3 */
  410. 15, /* Line 4 */
  411. };
  412. /*
  413. * a 6015 ibm board
  414. * -- Cort
  415. */
  416. static char ibm6015_pci_IRQ_map[23] __prepdata = {
  417. 0, /* Slot 0 - unused */
  418. 0, /* Slot 1 - unused */
  419. 0, /* Slot 2 - unused */
  420. 0, /* Slot 3 - unused */
  421. 0, /* Slot 4 - unused */
  422. 0, /* Slot 5 - unused */
  423. 0, /* Slot 6 - unused */
  424. 0, /* Slot 7 - unused */
  425. 0, /* Slot 8 - unused */
  426. 0, /* Slot 9 - unused */
  427. 0, /* Slot 10 - unused */
  428. 0, /* Slot 11 - */
  429. 1, /* Slot 12 - SCSI */
  430. 2, /* Slot 13 - */
  431. 2, /* Slot 14 - */
  432. 1, /* Slot 15 - */
  433. 1, /* Slot 16 - */
  434. 0, /* Slot 17 - */
  435. 2, /* Slot 18 - */
  436. 0, /* Slot 19 - */
  437. 0, /* Slot 20 - */
  438. 0, /* Slot 21 - */
  439. 2, /* Slot 22 - */
  440. };
  441. static char ibm6015_pci_IRQ_routes[] __prepdata = {
  442. 0, /* Line 0 - unused */
  443. 13, /* Line 1 */
  444. 15, /* Line 2 */
  445. 15, /* Line 3 */
  446. 15, /* Line 4 */
  447. };
  448. /* IBM Nobis and Thinkpad 850 */
  449. static char Nobis_pci_IRQ_map[23] __prepdata ={
  450. 0, /* Slot 0 - unused */
  451. 0, /* Slot 1 - unused */
  452. 0, /* Slot 2 - unused */
  453. 0, /* Slot 3 - unused */
  454. 0, /* Slot 4 - unused */
  455. 0, /* Slot 5 - unused */
  456. 0, /* Slot 6 - unused */
  457. 0, /* Slot 7 - unused */
  458. 0, /* Slot 8 - unused */
  459. 0, /* Slot 9 - unused */
  460. 0, /* Slot 10 - unused */
  461. 0, /* Slot 11 - unused */
  462. 3, /* Slot 12 - SCSI */
  463. 0, /* Slot 13 - unused */
  464. 0, /* Slot 14 - unused */
  465. 0, /* Slot 15 - unused */
  466. };
  467. static char Nobis_pci_IRQ_routes[] __prepdata = {
  468. 0, /* Line 0 - Unused */
  469. 13, /* Line 1 */
  470. 13, /* Line 2 */
  471. 13, /* Line 3 */
  472. 13 /* Line 4 */
  473. };
  474. /*
  475. * IBM RS/6000 43p/140 -- paulus
  476. * XXX we should get all this from the residual data
  477. */
  478. static char ibm43p_pci_IRQ_map[23] __prepdata = {
  479. 0, /* Slot 0 - unused */
  480. 0, /* Slot 1 - unused */
  481. 0, /* Slot 2 - unused */
  482. 0, /* Slot 3 - unused */
  483. 0, /* Slot 4 - unused */
  484. 0, /* Slot 5 - unused */
  485. 0, /* Slot 6 - unused */
  486. 0, /* Slot 7 - unused */
  487. 0, /* Slot 8 - unused */
  488. 0, /* Slot 9 - unused */
  489. 0, /* Slot 10 - unused */
  490. 0, /* Slot 11 - FireCoral ISA bridge */
  491. 6, /* Slot 12 - Ethernet */
  492. 0, /* Slot 13 - openpic */
  493. 0, /* Slot 14 - unused */
  494. 0, /* Slot 15 - unused */
  495. 7, /* Slot 16 - NCR58C825a onboard scsi */
  496. 0, /* Slot 17 - unused */
  497. 2, /* Slot 18 - PCI Slot 2 PCIINTx# (See below) */
  498. 0, /* Slot 19 - unused */
  499. 0, /* Slot 20 - unused */
  500. 0, /* Slot 21 - unused */
  501. 1, /* Slot 22 - PCI slot 1 PCIINTx# (See below) */
  502. };
  503. static char ibm43p_pci_IRQ_routes[] __prepdata = {
  504. 0, /* Line 0 - unused */
  505. 15, /* Line 1 */
  506. 15, /* Line 2 */
  507. 15, /* Line 3 */
  508. 15, /* Line 4 */
  509. };
  510. /* Motorola PowerPlus architecture PCI IRQ tables */
  511. /* Interrupt line values for INTA-D on primary/secondary MPIC inputs */
  512. struct powerplus_irq_list
  513. {
  514. unsigned char primary[4]; /* INT A-D */
  515. unsigned char secondary[4]; /* INT A-D */
  516. };
  517. /*
  518. * For standard PowerPlus boards, bus 0 PCI INTs A-D are routed to
  519. * OpenPIC inputs 9-12. PCI INTs A-D from the on board P2P bridge
  520. * are routed to OpenPIC inputs 5-8. These values are offset by
  521. * 16 in the table to reflect the Linux kernel interrupt value.
  522. */
  523. struct powerplus_irq_list Powerplus_pci_IRQ_list __prepdata =
  524. {
  525. {25, 26, 27, 28},
  526. {21, 22, 23, 24}
  527. };
  528. /*
  529. * For the MCP750 (system slot board), cPCI INTs A-D are routed to
  530. * OpenPIC inputs 8-11 and the PMC INTs A-D are routed to OpenPIC
  531. * input 3. On a hot swap MCP750, the companion card PCI INTs A-D
  532. * are routed to OpenPIC inputs 12-15. These values are offset by
  533. * 16 in the table to reflect the Linux kernel interrupt value.
  534. */
  535. struct powerplus_irq_list Mesquite_pci_IRQ_list __prepdata =
  536. {
  537. {24, 25, 26, 27},
  538. {28, 29, 30, 31}
  539. };
  540. /*
  541. * This table represents the standard PCI swizzle defined in the
  542. * PCI bus specification.
  543. */
  544. static unsigned char prep_pci_intpins[4][4] __prepdata =
  545. {
  546. { 1, 2, 3, 4}, /* Buses 0, 4, 8, ... */
  547. { 2, 3, 4, 1}, /* Buses 1, 5, 9, ... */
  548. { 3, 4, 1, 2}, /* Buses 2, 6, 10 ... */
  549. { 4, 1, 2, 3}, /* Buses 3, 7, 11 ... */
  550. };
  551. /* We have to turn on LEVEL mode for changed IRQ's */
  552. /* All PCI IRQ's need to be level mode, so this should be something
  553. * other than hard-coded as well... IRQ's are individually mappable
  554. * to either edge or level.
  555. */
  556. /*
  557. * 8259 edge/level control definitions
  558. */
  559. #define ISA8259_M_ELCR 0x4d0
  560. #define ISA8259_S_ELCR 0x4d1
  561. #define ELCRS_INT15_LVL 0x80
  562. #define ELCRS_INT14_LVL 0x40
  563. #define ELCRS_INT12_LVL 0x10
  564. #define ELCRS_INT11_LVL 0x08
  565. #define ELCRS_INT10_LVL 0x04
  566. #define ELCRS_INT9_LVL 0x02
  567. #define ELCRS_INT8_LVL 0x01
  568. #define ELCRM_INT7_LVL 0x80
  569. #define ELCRM_INT5_LVL 0x20
  570. #if 0
  571. /*
  572. * PCI config space access.
  573. */
  574. #define CFGADDR(dev) ((1<<(dev>>3)) | ((dev&7)<<8))
  575. #define DEVNO(dev) (dev>>3)
  576. #define MIN_DEVNR 11
  577. #define MAX_DEVNR 22
  578. static int __prep
  579. prep_read_config(struct pci_bus *bus, unsigned int devfn, int offset,
  580. int len, u32 *val)
  581. {
  582. struct pci_controller *hose = bus->sysdata;
  583. volatile void __iomem *cfg_data;
  584. if (bus->number != 0 || DEVNO(devfn) < MIN_DEVNR
  585. || DEVNO(devfn) > MAX_DEVNR)
  586. return PCIBIOS_DEVICE_NOT_FOUND;
  587. /*
  588. * Note: the caller has already checked that offset is
  589. * suitably aligned and that len is 1, 2 or 4.
  590. */
  591. cfg_data = hose->cfg_data + CFGADDR(devfn) + offset;
  592. switch (len) {
  593. case 1:
  594. *val = in_8(cfg_data);
  595. break;
  596. case 2:
  597. *val = in_le16(cfg_data);
  598. break;
  599. default:
  600. *val = in_le32(cfg_data);
  601. break;
  602. }
  603. return PCIBIOS_SUCCESSFUL;
  604. }
  605. static int __prep
  606. prep_write_config(struct pci_bus *bus, unsigned int devfn, int offset,
  607. int len, u32 val)
  608. {
  609. struct pci_controller *hose = bus->sysdata;
  610. volatile void __iomem *cfg_data;
  611. if (bus->number != 0 || DEVNO(devfn) < MIN_DEVNR
  612. || DEVNO(devfn) > MAX_DEVNR)
  613. return PCIBIOS_DEVICE_NOT_FOUND;
  614. /*
  615. * Note: the caller has already checked that offset is
  616. * suitably aligned and that len is 1, 2 or 4.
  617. */
  618. cfg_data = hose->cfg_data + CFGADDR(devfn) + offset;
  619. switch (len) {
  620. case 1:
  621. out_8(cfg_data, val);
  622. break;
  623. case 2:
  624. out_le16(cfg_data, val);
  625. break;
  626. default:
  627. out_le32(cfg_data, val);
  628. break;
  629. }
  630. return PCIBIOS_SUCCESSFUL;
  631. }
  632. static struct pci_ops prep_pci_ops =
  633. {
  634. prep_read_config,
  635. prep_write_config
  636. };
  637. #endif
  638. #define MOTOROLA_CPUTYPE_REG 0x800
  639. #define MOTOROLA_BASETYPE_REG 0x803
  640. #define MPIC_RAVEN_ID 0x48010000
  641. #define MPIC_HAWK_ID 0x48030000
  642. #define MOT_PROC2_BIT 0x800
  643. static u_char prep_openpic_initsenses[] __initdata = {
  644. (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* MVME2600_INT_SIO */
  645. (IRQ_SENSE_EDGE | IRQ_POLARITY_NEGATIVE), /* MVME2600_INT_FALCN_ECC_ERR */
  646. (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* MVME2600_INT_PCI_ETHERNET */
  647. (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* MVME2600_INT_PCI_SCSI */
  648. (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* MVME2600_INT_PCI_GRAPHICS */
  649. (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* MVME2600_INT_PCI_VME0 */
  650. (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* MVME2600_INT_PCI_VME1 */
  651. (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* MVME2600_INT_PCI_VME2 */
  652. (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* MVME2600_INT_PCI_VME3 */
  653. (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* MVME2600_INT_PCI_INTA */
  654. (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* MVME2600_INT_PCI_INTB */
  655. (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* MVME2600_INT_PCI_INTC */
  656. (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* MVME2600_INT_PCI_INTD */
  657. (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* MVME2600_INT_LM_SIG0 */
  658. (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* MVME2600_INT_LM_SIG1 */
  659. };
  660. #define MOT_RAVEN_PRESENT 0x1
  661. #define MOT_HAWK_PRESENT 0x2
  662. int mot_entry = -1;
  663. int prep_keybd_present = 1;
  664. int MotMPIC;
  665. int mot_multi;
  666. int __init
  667. raven_init(void)
  668. {
  669. unsigned int devid;
  670. unsigned int pci_membase;
  671. unsigned char base_mod;
  672. /* Check to see if the Raven chip exists. */
  673. if ( _prep_type != _PREP_Motorola) {
  674. OpenPIC_Addr = NULL;
  675. return 0;
  676. }
  677. /* Check to see if this board is a type that might have a Raven. */
  678. if ((inb(MOTOROLA_CPUTYPE_REG) & 0xF0) != 0xE0) {
  679. OpenPIC_Addr = NULL;
  680. return 0;
  681. }
  682. /* Check the first PCI device to see if it is a Raven. */
  683. early_read_config_dword(NULL, 0, 0, PCI_VENDOR_ID, &devid);
  684. switch (devid & 0xffff0000) {
  685. case MPIC_RAVEN_ID:
  686. MotMPIC = MOT_RAVEN_PRESENT;
  687. break;
  688. case MPIC_HAWK_ID:
  689. MotMPIC = MOT_HAWK_PRESENT;
  690. break;
  691. default:
  692. OpenPIC_Addr = NULL;
  693. return 0;
  694. }
  695. /* Read the memory base register. */
  696. early_read_config_dword(NULL, 0, 0, PCI_BASE_ADDRESS_1, &pci_membase);
  697. if (pci_membase == 0) {
  698. OpenPIC_Addr = NULL;
  699. return 0;
  700. }
  701. /* Map the Raven MPIC registers to virtual memory. */
  702. OpenPIC_Addr = ioremap(pci_membase+0xC0000000, 0x22000);
  703. OpenPIC_InitSenses = prep_openpic_initsenses;
  704. OpenPIC_NumInitSenses = sizeof(prep_openpic_initsenses);
  705. ppc_md.get_irq = openpic_get_irq;
  706. /* If raven is present on Motorola store the system config register
  707. * for later use.
  708. */
  709. ProcInfo = (unsigned long *)ioremap(0xfef80400, 4);
  710. /* Indicate to system if this is a multiprocessor board */
  711. if (!(*ProcInfo & MOT_PROC2_BIT)) {
  712. mot_multi = 1;
  713. }
  714. /* This is a hack. If this is a 2300 or 2400 mot board then there is
  715. * no keyboard controller and we have to indicate that.
  716. */
  717. base_mod = inb(MOTOROLA_BASETYPE_REG);
  718. if ((MotMPIC == MOT_HAWK_PRESENT) || (base_mod == 0xF9) ||
  719. (base_mod == 0xFA) || (base_mod == 0xE1))
  720. prep_keybd_present = 0;
  721. return 1;
  722. }
  723. struct mot_info {
  724. int cpu_type; /* 0x100 mask assumes for Raven and Hawk boards that the level/edge are set */
  725. /* 0x200 if this board has a Hawk chip. */
  726. int base_type;
  727. int max_cpu; /* ored with 0x80 if this board should be checked for multi CPU */
  728. const char *name;
  729. unsigned char *map;
  730. unsigned char *routes;
  731. void (*map_non0_bus)(struct pci_dev *); /* For boards with more than bus 0 devices. */
  732. struct powerplus_irq_list *pci_irq_list; /* List of PCI MPIC inputs */
  733. unsigned char secondary_bridge_devfn; /* devfn of secondary bus transparent bridge */
  734. } mot_info[] __prepdata = {
  735. {0x300, 0x00, 0x00, "MVME 2400", Genesis2_pci_IRQ_map, Raven_pci_IRQ_routes, Powerplus_Map_Non0, &Powerplus_pci_IRQ_list, 0xFF},
  736. {0x010, 0x00, 0x00, "Genesis", Genesis_pci_IRQ_map, Genesis_pci_IRQ_routes, Powerplus_Map_Non0, &Powerplus_pci_IRQ_list, 0x00},
  737. {0x020, 0x00, 0x00, "Powerstack (Series E)", Comet_pci_IRQ_map, Comet_pci_IRQ_routes, NULL, NULL, 0x00},
  738. {0x040, 0x00, 0x00, "Blackhawk (Powerstack)", Blackhawk_pci_IRQ_map, Blackhawk_pci_IRQ_routes, NULL, NULL, 0x00},
  739. {0x050, 0x00, 0x00, "Omaha (PowerStack II Pro3000)", Omaha_pci_IRQ_map, Omaha_pci_IRQ_routes, NULL, NULL, 0x00},
  740. {0x060, 0x00, 0x00, "Utah (Powerstack II Pro4000)", Utah_pci_IRQ_map, Utah_pci_IRQ_routes, NULL, NULL, 0x00},
  741. {0x0A0, 0x00, 0x00, "Powerstack (Series EX)", Comet2_pci_IRQ_map, Comet2_pci_IRQ_routes, NULL, NULL, 0x00},
  742. {0x1E0, 0xE0, 0x00, "Mesquite cPCI (MCP750)", Mesquite_pci_IRQ_map, Raven_pci_IRQ_routes, Powerplus_Map_Non0, &Mesquite_pci_IRQ_list, 0xFF},
  743. {0x1E0, 0xE1, 0x00, "Sitka cPCI (MCPN750)", Sitka_pci_IRQ_map, Raven_pci_IRQ_routes, Powerplus_Map_Non0, &Powerplus_pci_IRQ_list, 0xFF},
  744. {0x1E0, 0xE2, 0x00, "Mesquite cPCI (MCP750) w/ HAC", Mesquite_pci_IRQ_map, Raven_pci_IRQ_routes, Powerplus_Map_Non0, &Mesquite_pci_IRQ_list, 0xC0},
  745. {0x1E0, 0xF6, 0x80, "MTX Plus", MTXplus_pci_IRQ_map, Raven_pci_IRQ_routes, Powerplus_Map_Non0, &Powerplus_pci_IRQ_list, 0xA0},
  746. {0x1E0, 0xF6, 0x81, "Dual MTX Plus", MTXplus_pci_IRQ_map, Raven_pci_IRQ_routes, Powerplus_Map_Non0, &Powerplus_pci_IRQ_list, 0xA0},
  747. {0x1E0, 0xF7, 0x80, "MTX wo/ Parallel Port", MTX_pci_IRQ_map, Raven_pci_IRQ_routes, Powerplus_Map_Non0, &Powerplus_pci_IRQ_list, 0x00},
  748. {0x1E0, 0xF7, 0x81, "Dual MTX wo/ Parallel Port", MTX_pci_IRQ_map, Raven_pci_IRQ_routes, Powerplus_Map_Non0, &Powerplus_pci_IRQ_list, 0x00},
  749. {0x1E0, 0xF8, 0x80, "MTX w/ Parallel Port", MTX_pci_IRQ_map, Raven_pci_IRQ_routes, Powerplus_Map_Non0, &Powerplus_pci_IRQ_list, 0x00},
  750. {0x1E0, 0xF8, 0x81, "Dual MTX w/ Parallel Port", MTX_pci_IRQ_map, Raven_pci_IRQ_routes, Powerplus_Map_Non0, &Powerplus_pci_IRQ_list, 0x00},
  751. {0x1E0, 0xF9, 0x00, "MVME 2300", Genesis2_pci_IRQ_map, Raven_pci_IRQ_routes, Powerplus_Map_Non0, &Powerplus_pci_IRQ_list, 0xFF},
  752. {0x1E0, 0xFA, 0x00, "MVME 2300SC/2600", Genesis2_pci_IRQ_map, Raven_pci_IRQ_routes, Powerplus_Map_Non0, &Powerplus_pci_IRQ_list, 0xFF},
  753. {0x1E0, 0xFB, 0x00, "MVME 2600 with MVME712M", Genesis2_pci_IRQ_map, Raven_pci_IRQ_routes, Powerplus_Map_Non0, &Powerplus_pci_IRQ_list, 0xFF},
  754. {0x1E0, 0xFC, 0x00, "MVME 2600/2700 with MVME761", Genesis2_pci_IRQ_map, Raven_pci_IRQ_routes, Powerplus_Map_Non0, &Powerplus_pci_IRQ_list, 0xFF},
  755. {0x1E0, 0xFD, 0x80, "MVME 3600 with MVME712M", Genesis2_pci_IRQ_map, Raven_pci_IRQ_routes, Powerplus_Map_Non0, &Powerplus_pci_IRQ_list, 0x00},
  756. {0x1E0, 0xFD, 0x81, "MVME 4600 with MVME712M", Genesis2_pci_IRQ_map, Raven_pci_IRQ_routes, Powerplus_Map_Non0, &Powerplus_pci_IRQ_list, 0xFF},
  757. {0x1E0, 0xFE, 0x80, "MVME 3600 with MVME761", Genesis2_pci_IRQ_map, Raven_pci_IRQ_routes, Powerplus_Map_Non0, &Powerplus_pci_IRQ_list, 0xFF},
  758. {0x1E0, 0xFE, 0x81, "MVME 4600 with MVME761", Genesis2_pci_IRQ_map, Raven_pci_IRQ_routes, Powerplus_Map_Non0, &Powerplus_pci_IRQ_list, 0xFF},
  759. {0x1E0, 0xFF, 0x00, "MVME 1600-001 or 1600-011", Genesis2_pci_IRQ_map, Raven_pci_IRQ_routes, Powerplus_Map_Non0, &Powerplus_pci_IRQ_list, 0xFF},
  760. {0x000, 0x00, 0x00, "", NULL, NULL, NULL, NULL, 0x00}
  761. };
  762. void __init
  763. ibm_prep_init(void)
  764. {
  765. if (have_residual_data) {
  766. u32 addr, real_addr, len, offset;
  767. PPC_DEVICE *mpic;
  768. PnP_TAG_PACKET *pkt;
  769. /* Use the PReP residual data to determine if an OpenPIC is
  770. * present. If so, get the large vendor packet which will
  771. * tell us the base address and length in memory.
  772. * If we are successful, ioremap the memory area and set
  773. * OpenPIC_Addr (this indicates that the OpenPIC was found).
  774. */
  775. mpic = residual_find_device(-1, NULL, SystemPeripheral,
  776. ProgrammableInterruptController, MPIC, 0);
  777. if (!mpic)
  778. return;
  779. pkt = PnP_find_large_vendor_packet(res->DevicePnPHeap +
  780. mpic->AllocatedOffset, 9, 0);
  781. if (!pkt)
  782. return;
  783. #define p pkt->L4_Pack.L4_Data.L4_PPCPack
  784. if (p.PPCData[1] == 32) {
  785. switch (p.PPCData[0]) {
  786. case 1: offset = PREP_ISA_IO_BASE; break;
  787. case 2: offset = PREP_ISA_MEM_BASE; break;
  788. default: return; /* Not I/O or memory?? */
  789. }
  790. }
  791. else
  792. return; /* Not a 32-bit address */
  793. real_addr = ld_le32((unsigned int *) (p.PPCData + 4));
  794. if (real_addr == 0xffffffff)
  795. return;
  796. /* Adjust address to be as seen by CPU */
  797. addr = real_addr + offset;
  798. len = ld_le32((unsigned int *) (p.PPCData + 12));
  799. if (!len)
  800. return;
  801. #undef p
  802. OpenPIC_Addr = ioremap(addr, len);
  803. ppc_md.get_irq = openpic_get_irq;
  804. OpenPIC_InitSenses = prep_openpic_initsenses;
  805. OpenPIC_NumInitSenses = sizeof(prep_openpic_initsenses);
  806. printk(KERN_INFO "MPIC at 0x%08x (0x%08x), length 0x%08x "
  807. "mapped to 0x%p\n", addr, real_addr, len, OpenPIC_Addr);
  808. }
  809. }
  810. static void __init
  811. ibm43p_pci_map_non0(struct pci_dev *dev)
  812. {
  813. unsigned char intpin;
  814. static unsigned char bridge_intrs[4] = { 3, 4, 5, 8 };
  815. if (dev == NULL)
  816. return;
  817. pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &intpin);
  818. if (intpin < 1 || intpin > 4)
  819. return;
  820. intpin = (PCI_SLOT(dev->devfn) + intpin - 1) & 3;
  821. dev->irq = openpic_to_irq(bridge_intrs[intpin]);
  822. pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq);
  823. }
  824. void __init
  825. prep_residual_setup_pci(char *irq_edge_mask_lo, char *irq_edge_mask_hi)
  826. {
  827. if (have_residual_data) {
  828. Motherboard_map_name = res->VitalProductData.PrintableModel;
  829. Motherboard_map = NULL;
  830. Motherboard_routes = NULL;
  831. residual_irq_mask(irq_edge_mask_lo, irq_edge_mask_hi);
  832. }
  833. }
  834. void __init
  835. prep_sandalfoot_setup_pci(char *irq_edge_mask_lo, char *irq_edge_mask_hi)
  836. {
  837. Motherboard_map_name = "IBM 6015/7020 (Sandalfoot/Sandalbow)";
  838. Motherboard_map = ibm6015_pci_IRQ_map;
  839. Motherboard_routes = ibm6015_pci_IRQ_routes;
  840. *irq_edge_mask_lo = 0x00; /* irq's 0-7 all edge-triggered */
  841. *irq_edge_mask_hi = 0xA0; /* irq's 13, 15 level-triggered */
  842. }
  843. void __init
  844. prep_thinkpad_setup_pci(char *irq_edge_mask_lo, char *irq_edge_mask_hi)
  845. {
  846. Motherboard_map_name = "IBM Thinkpad 850/860";
  847. Motherboard_map = Nobis_pci_IRQ_map;
  848. Motherboard_routes = Nobis_pci_IRQ_routes;
  849. *irq_edge_mask_lo = 0x00; /* irq's 0-7 all edge-triggered */
  850. *irq_edge_mask_hi = 0xA0; /* irq's 13, 15 level-triggered */
  851. }
  852. void __init
  853. prep_carolina_setup_pci(char *irq_edge_mask_lo, char *irq_edge_mask_hi)
  854. {
  855. Motherboard_map_name = "IBM 7248, PowerSeries 830/850 (Carolina)";
  856. Motherboard_map = ibm8xx_pci_IRQ_map;
  857. Motherboard_routes = ibm8xx_pci_IRQ_routes;
  858. *irq_edge_mask_lo = 0x00; /* irq's 0-7 all edge-triggered */
  859. *irq_edge_mask_hi = 0xA4; /* irq's 10, 13, 15 level-triggered */
  860. }
  861. void __init
  862. prep_tiger1_setup_pci(char *irq_edge_mask_lo, char *irq_edge_mask_hi)
  863. {
  864. Motherboard_map_name = "IBM 43P-140 (Tiger1)";
  865. Motherboard_map = ibm43p_pci_IRQ_map;
  866. Motherboard_routes = ibm43p_pci_IRQ_routes;
  867. Motherboard_non0 = ibm43p_pci_map_non0;
  868. *irq_edge_mask_lo = 0x00; /* irq's 0-7 all edge-triggered */
  869. *irq_edge_mask_hi = 0xA0; /* irq's 13, 15 level-triggered */
  870. }
  871. void __init
  872. prep_route_pci_interrupts(void)
  873. {
  874. unsigned char *ibc_pirq = (unsigned char *)0x80800860;
  875. unsigned char *ibc_pcicon = (unsigned char *)0x80800840;
  876. int i;
  877. if ( _prep_type == _PREP_Motorola)
  878. {
  879. unsigned short irq_mode;
  880. unsigned char cpu_type;
  881. unsigned char base_mod;
  882. int entry;
  883. cpu_type = inb(MOTOROLA_CPUTYPE_REG) & 0xF0;
  884. base_mod = inb(MOTOROLA_BASETYPE_REG);
  885. for (entry = 0; mot_info[entry].cpu_type != 0; entry++) {
  886. if (mot_info[entry].cpu_type & 0x200) { /* Check for Hawk chip */
  887. if (!(MotMPIC & MOT_HAWK_PRESENT))
  888. continue;
  889. } else { /* Check non hawk boards */
  890. if ((mot_info[entry].cpu_type & 0xff) != cpu_type)
  891. continue;
  892. if (mot_info[entry].base_type == 0) {
  893. mot_entry = entry;
  894. break;
  895. }
  896. if (mot_info[entry].base_type != base_mod)
  897. continue;
  898. }
  899. if (!(mot_info[entry].max_cpu & 0x80)) {
  900. mot_entry = entry;
  901. break;
  902. }
  903. /* processor 1 not present and max processor zero indicated */
  904. if ((*ProcInfo & MOT_PROC2_BIT) && !(mot_info[entry].max_cpu & 0x7f)) {
  905. mot_entry = entry;
  906. break;
  907. }
  908. /* processor 1 present and max processor zero indicated */
  909. if (!(*ProcInfo & MOT_PROC2_BIT) && (mot_info[entry].max_cpu & 0x7f)) {
  910. mot_entry = entry;
  911. break;
  912. }
  913. }
  914. if (mot_entry == -1) /* No particular cpu type found - assume Blackhawk */
  915. mot_entry = 3;
  916. Motherboard_map_name = (unsigned char *)mot_info[mot_entry].name;
  917. Motherboard_map = mot_info[mot_entry].map;
  918. Motherboard_routes = mot_info[mot_entry].routes;
  919. Motherboard_non0 = mot_info[mot_entry].map_non0_bus;
  920. if (!(mot_info[entry].cpu_type & 0x100)) {
  921. /* AJF adjust level/edge control according to routes */
  922. irq_mode = 0;
  923. for (i = 1; i <= 4; i++)
  924. irq_mode |= ( 1 << Motherboard_routes[i] );
  925. outb( irq_mode & 0xff, 0x4d0 );
  926. outb( (irq_mode >> 8) & 0xff, 0x4d1 );
  927. }
  928. } else if ( _prep_type == _PREP_IBM ) {
  929. unsigned char irq_edge_mask_lo, irq_edge_mask_hi;
  930. unsigned short irq_edge_mask;
  931. int i;
  932. setup_ibm_pci(&irq_edge_mask_lo, &irq_edge_mask_hi);
  933. outb(inb(0x04d0)|irq_edge_mask_lo, 0x4d0); /* primary 8259 */
  934. outb(inb(0x04d1)|irq_edge_mask_hi, 0x4d1); /* cascaded 8259 */
  935. irq_edge_mask = (irq_edge_mask_hi << 8) | irq_edge_mask_lo;
  936. for (i = 0; i < 16; ++i, irq_edge_mask >>= 1)
  937. if (irq_edge_mask & 1)
  938. irq_desc[i].status |= IRQ_LEVEL;
  939. } else {
  940. printk("No known machine pci routing!\n");
  941. return;
  942. }
  943. /* Set up mapping from slots */
  944. if (Motherboard_routes) {
  945. for (i = 1; i <= 4; i++)
  946. ibc_pirq[i-1] = Motherboard_routes[i];
  947. /* Enable PCI interrupts */
  948. *ibc_pcicon |= 0x20;
  949. }
  950. }
  951. void __init
  952. prep_pib_init(void)
  953. {
  954. unsigned char reg;
  955. unsigned short short_reg;
  956. struct pci_dev *dev = NULL;
  957. if (( _prep_type == _PREP_Motorola) && (OpenPIC_Addr)) {
  958. /*
  959. * Perform specific configuration for the Via Tech or
  960. * or Winbond PCI-ISA-Bridge part.
  961. */
  962. if ((dev = pci_get_device(PCI_VENDOR_ID_VIA,
  963. PCI_DEVICE_ID_VIA_82C586_1, dev))) {
  964. /*
  965. * PPCBUG does not set the enable bits
  966. * for the IDE device. Force them on here.
  967. */
  968. pci_read_config_byte(dev, 0x40, &reg);
  969. reg |= 0x03; /* IDE: Chip Enable Bits */
  970. pci_write_config_byte(dev, 0x40, reg);
  971. }
  972. if ((dev = pci_get_device(PCI_VENDOR_ID_VIA,
  973. PCI_DEVICE_ID_VIA_82C586_2,
  974. dev)) && (dev->devfn = 0x5a)) {
  975. /* Force correct USB interrupt */
  976. dev->irq = 11;
  977. pci_write_config_byte(dev,
  978. PCI_INTERRUPT_LINE,
  979. dev->irq);
  980. }
  981. if ((dev = pci_get_device(PCI_VENDOR_ID_WINBOND,
  982. PCI_DEVICE_ID_WINBOND_83C553, dev))) {
  983. /* Clear PCI Interrupt Routing Control Register. */
  984. short_reg = 0x0000;
  985. pci_write_config_word(dev, 0x44, short_reg);
  986. if (OpenPIC_Addr){
  987. /* Route IDE interrupts to IRQ 14 */
  988. reg = 0xEE;
  989. pci_write_config_byte(dev, 0x43, reg);
  990. }
  991. }
  992. pci_dev_put(dev);
  993. }
  994. if ((dev = pci_get_device(PCI_VENDOR_ID_WINBOND,
  995. PCI_DEVICE_ID_WINBOND_82C105, dev))){
  996. if (OpenPIC_Addr){
  997. /*
  998. * Disable LEGIRQ mode so PCI INTS are routed
  999. * directly to the 8259 and enable both channels
  1000. */
  1001. pci_write_config_dword(dev, 0x40, 0x10ff0033);
  1002. /* Force correct IDE interrupt */
  1003. dev->irq = 14;
  1004. pci_write_config_byte(dev,
  1005. PCI_INTERRUPT_LINE,
  1006. dev->irq);
  1007. } else {
  1008. /* Enable LEGIRQ for PCI INT -> 8259 IRQ routing */
  1009. pci_write_config_dword(dev, 0x40, 0x10ff08a1);
  1010. }
  1011. }
  1012. pci_dev_put(dev);
  1013. }
  1014. static void __init
  1015. Powerplus_Map_Non0(struct pci_dev *dev)
  1016. {
  1017. struct pci_bus *pbus; /* Parent bus structure pointer */
  1018. struct pci_dev *tdev = dev; /* Temporary device structure */
  1019. unsigned int devnum; /* Accumulated device number */
  1020. unsigned char intline; /* Linux interrupt value */
  1021. unsigned char intpin; /* PCI interrupt pin */
  1022. /* Check for valid PCI dev pointer */
  1023. if (dev == NULL) return;
  1024. /* Initialize bridge IDSEL variable */
  1025. devnum = PCI_SLOT(tdev->devfn);
  1026. /* Read the interrupt pin of the device and adjust for indexing */
  1027. pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &intpin);
  1028. /* If device doesn't request an interrupt, return */
  1029. if ( (intpin < 1) || (intpin > 4) )
  1030. return;
  1031. intpin--;
  1032. /*
  1033. * Walk up to bus 0, adjusting the interrupt pin for the standard
  1034. * PCI bus swizzle.
  1035. */
  1036. do {
  1037. intpin = (prep_pci_intpins[devnum % 4][intpin]) - 1;
  1038. pbus = tdev->bus; /* up one level */
  1039. tdev = pbus->self;
  1040. devnum = PCI_SLOT(tdev->devfn);
  1041. } while(tdev->bus->number);
  1042. /* Use the primary interrupt inputs by default */
  1043. intline = mot_info[mot_entry].pci_irq_list->primary[intpin];
  1044. /*
  1045. * If the board has secondary interrupt inputs, walk the bus and
  1046. * note the devfn of the bridge from bus 0. If it is the same as
  1047. * the devfn of the bus bridge with secondary inputs, use those.
  1048. * Otherwise, assume it's a PMC site and get the interrupt line
  1049. * value from the interrupt routing table.
  1050. */
  1051. if (mot_info[mot_entry].secondary_bridge_devfn) {
  1052. pbus = dev->bus;
  1053. while (pbus->primary != 0)
  1054. pbus = pbus->parent;
  1055. if ((pbus->self)->devfn != 0xA0) {
  1056. if ((pbus->self)->devfn == mot_info[mot_entry].secondary_bridge_devfn)
  1057. intline = mot_info[mot_entry].pci_irq_list->secondary[intpin];
  1058. else {
  1059. if ((char *)(mot_info[mot_entry].map) == (char *)Mesquite_pci_IRQ_map)
  1060. intline = mot_info[mot_entry].map[((pbus->self)->devfn)/8] + 16;
  1061. else {
  1062. int i;
  1063. for (i=0;i<3;i++)
  1064. intpin = (prep_pci_intpins[devnum % 4][intpin]) - 1;
  1065. intline = mot_info[mot_entry].pci_irq_list->primary[intpin];
  1066. }
  1067. }
  1068. }
  1069. }
  1070. /* Write calculated interrupt value to header and device list */
  1071. dev->irq = intline;
  1072. pci_write_config_byte(dev, PCI_INTERRUPT_LINE, (u8)dev->irq);
  1073. }
  1074. void __init
  1075. prep_pcibios_fixup(void)
  1076. {
  1077. struct pci_dev *dev = NULL;
  1078. int irq;
  1079. int have_openpic = (OpenPIC_Addr != NULL);
  1080. prep_route_pci_interrupts();
  1081. printk("Setting PCI interrupts for a \"%s\"\n", Motherboard_map_name);
  1082. /* Iterate through all the PCI devices, setting the IRQ */
  1083. for_each_pci_dev(dev) {
  1084. /*
  1085. * If we have residual data, then this is easy: query the
  1086. * residual data for the IRQ line allocated to the device.
  1087. * This works the same whether we have an OpenPic or not.
  1088. */
  1089. if (have_residual_data) {
  1090. irq = residual_pcidev_irq(dev);
  1091. dev->irq = have_openpic ? openpic_to_irq(irq) : irq;
  1092. }
  1093. /*
  1094. * If we don't have residual data, then we need to use
  1095. * tables to determine the IRQ. The table organisation
  1096. * is different depending on whether there is an OpenPIC
  1097. * or not. The tables are only used for bus 0, so check
  1098. * this first.
  1099. */
  1100. else if (dev->bus->number == 0) {
  1101. irq = Motherboard_map[PCI_SLOT(dev->devfn)];
  1102. dev->irq = have_openpic ? openpic_to_irq(irq)
  1103. : Motherboard_routes[irq];
  1104. }
  1105. /*
  1106. * Finally, if we don't have residual data and the bus is
  1107. * non-zero, use the callback (if provided)
  1108. */
  1109. else {
  1110. if (Motherboard_non0 != NULL)
  1111. Motherboard_non0(dev);
  1112. continue;
  1113. }
  1114. pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq);
  1115. }
  1116. /* Setup the Winbond or Via PIB - prep_pib_init() is coded for
  1117. * the non-openpic case, but it breaks (at least) the Utah
  1118. * (Powerstack II Pro4000), so only call it if we have an
  1119. * openpic.
  1120. */
  1121. if (have_openpic)
  1122. prep_pib_init();
  1123. }
  1124. static void __init
  1125. prep_pcibios_after_init(void)
  1126. {
  1127. #if 0
  1128. struct pci_dev *dev;
  1129. /* If there is a WD 90C, reset the IO BAR to 0x0 (it started that
  1130. * way, but the PCI layer relocated it because it thought 0x0 was
  1131. * invalid for a BAR).
  1132. * If you don't do this, the card's VGA base will be <IO BAR>+0xc0000
  1133. * instead of 0xc0000. vgacon.c (for example) is completely unaware of
  1134. * this little quirk.
  1135. */
  1136. dev = pci_get_device(PCI_VENDOR_ID_WD, PCI_DEVICE_ID_WD_90C, NULL);
  1137. if (dev) {
  1138. dev->resource[1].end -= dev->resource[1].start;
  1139. dev->resource[1].start = 0;
  1140. /* tell the hardware */
  1141. pci_write_config_dword(dev, PCI_BASE_ADDRESS_1, 0x0);
  1142. pci_dev_put(dev);
  1143. }
  1144. #endif
  1145. }
  1146. static void __init
  1147. prep_init_resource(struct resource *res, unsigned long start,
  1148. unsigned long end, int flags)
  1149. {
  1150. res->flags = flags;
  1151. res->start = start;
  1152. res->end = end;
  1153. res->name = "PCI host bridge";
  1154. res->parent = NULL;
  1155. res->sibling = NULL;
  1156. res->child = NULL;
  1157. }
  1158. void __init
  1159. prep_find_bridges(void)
  1160. {
  1161. struct pci_controller* hose;
  1162. hose = pcibios_alloc_controller();
  1163. if (!hose)
  1164. return;
  1165. hose->first_busno = 0;
  1166. hose->last_busno = 0xff;
  1167. hose->pci_mem_offset = PREP_ISA_MEM_BASE;
  1168. hose->io_base_phys = PREP_ISA_IO_BASE;
  1169. hose->io_base_virt = ioremap(PREP_ISA_IO_BASE, 0x800000);
  1170. prep_init_resource(&hose->io_resource, 0, 0x007fffff, IORESOURCE_IO);
  1171. prep_init_resource(&hose->mem_resources[0], 0xc0000000, 0xfeffffff,
  1172. IORESOURCE_MEM);
  1173. setup_indirect_pci(hose, PREP_ISA_IO_BASE + 0xcf8,
  1174. PREP_ISA_IO_BASE + 0xcfc);
  1175. printk("PReP architecture\n");
  1176. if (have_residual_data) {
  1177. PPC_DEVICE *hostbridge;
  1178. hostbridge = residual_find_device(PROCESSORDEVICE, NULL,
  1179. BridgeController, PCIBridge, -1, 0);
  1180. if (hostbridge &&
  1181. ((hostbridge->DeviceId.Interface == PCIBridgeIndirect) ||
  1182. (hostbridge->DeviceId.Interface == PCIBridgeRS6K))) {
  1183. PnP_TAG_PACKET * pkt;
  1184. pkt = PnP_find_large_vendor_packet(
  1185. res->DevicePnPHeap+hostbridge->AllocatedOffset,
  1186. 3, 0);
  1187. if(pkt) {
  1188. #define p pkt->L4_Pack.L4_Data.L4_PPCPack
  1189. setup_indirect_pci(hose,
  1190. ld_le32((unsigned *) (p.PPCData)),
  1191. ld_le32((unsigned *) (p.PPCData+8)));
  1192. #undef p
  1193. } else
  1194. setup_indirect_pci(hose, 0x80000cf8, 0x80000cfc);
  1195. }
  1196. }
  1197. ppc_md.pcibios_fixup = prep_pcibios_fixup;
  1198. ppc_md.pcibios_after_init = prep_pcibios_after_init;
  1199. }