prep_pci.c
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:38k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

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