prep_pci.c 39 KB

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