irq.c 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314
  1. /*
  2. * Low-Level PCI Support for PC -- Routing of Interrupts
  3. *
  4. * (c) 1999--2000 Martin Mares <mj@ucw.cz>
  5. */
  6. #include <linux/types.h>
  7. #include <linux/kernel.h>
  8. #include <linux/pci.h>
  9. #include <linux/init.h>
  10. #include <linux/slab.h>
  11. #include <linux/interrupt.h>
  12. #include <linux/dmi.h>
  13. #include <linux/io.h>
  14. #include <linux/smp.h>
  15. #include <asm/io_apic.h>
  16. #include <linux/irq.h>
  17. #include <linux/acpi.h>
  18. #include "pci.h"
  19. #define PIRQ_SIGNATURE (('$' << 0) + ('P' << 8) + ('I' << 16) + ('R' << 24))
  20. #define PIRQ_VERSION 0x0100
  21. static int broken_hp_bios_irq9;
  22. static int acer_tm360_irqrouting;
  23. static struct irq_routing_table *pirq_table;
  24. static int pirq_enable_irq(struct pci_dev *dev);
  25. /*
  26. * Never use: 0, 1, 2 (timer, keyboard, and cascade)
  27. * Avoid using: 13, 14 and 15 (FP error and IDE).
  28. * Penalize: 3, 4, 6, 7, 12 (known ISA uses: serial, floppy, parallel and mouse)
  29. */
  30. unsigned int pcibios_irq_mask = 0xfff8;
  31. static int pirq_penalty[16] = {
  32. 1000000, 1000000, 1000000, 1000, 1000, 0, 1000, 1000,
  33. 0, 0, 0, 0, 1000, 100000, 100000, 100000
  34. };
  35. struct irq_router {
  36. char *name;
  37. u16 vendor, device;
  38. int (*get)(struct pci_dev *router, struct pci_dev *dev, int pirq);
  39. int (*set)(struct pci_dev *router, struct pci_dev *dev, int pirq,
  40. int new);
  41. };
  42. struct irq_router_handler {
  43. u16 vendor;
  44. int (*probe)(struct irq_router *r, struct pci_dev *router, u16 device);
  45. };
  46. int (*pcibios_enable_irq)(struct pci_dev *dev) = NULL;
  47. void (*pcibios_disable_irq)(struct pci_dev *dev) = NULL;
  48. /*
  49. * Check passed address for the PCI IRQ Routing Table signature
  50. * and perform checksum verification.
  51. */
  52. static inline struct irq_routing_table *pirq_check_routing_table(u8 *addr)
  53. {
  54. struct irq_routing_table *rt;
  55. int i;
  56. u8 sum;
  57. rt = (struct irq_routing_table *) addr;
  58. if (rt->signature != PIRQ_SIGNATURE ||
  59. rt->version != PIRQ_VERSION ||
  60. rt->size % 16 ||
  61. rt->size < sizeof(struct irq_routing_table))
  62. return NULL;
  63. sum = 0;
  64. for (i = 0; i < rt->size; i++)
  65. sum += addr[i];
  66. if (!sum) {
  67. DBG(KERN_DEBUG "PCI: Interrupt Routing Table found at 0x%p\n",
  68. rt);
  69. return rt;
  70. }
  71. return NULL;
  72. }
  73. /*
  74. * Search 0xf0000 -- 0xfffff for the PCI IRQ Routing Table.
  75. */
  76. static struct irq_routing_table * __init pirq_find_routing_table(void)
  77. {
  78. u8 *addr;
  79. struct irq_routing_table *rt;
  80. if (pirq_table_addr) {
  81. rt = pirq_check_routing_table((u8 *) __va(pirq_table_addr));
  82. if (rt)
  83. return rt;
  84. printk(KERN_WARNING "PCI: PIRQ table NOT found at pirqaddr\n");
  85. }
  86. for (addr = (u8 *) __va(0xf0000); addr < (u8 *) __va(0x100000);
  87. addr += 16) {
  88. rt = pirq_check_routing_table(addr);
  89. if (rt)
  90. return rt;
  91. }
  92. return NULL;
  93. }
  94. /*
  95. * If we have a IRQ routing table, use it to search for peer host
  96. * bridges. It's a gross hack, but since there are no other known
  97. * ways how to get a list of buses, we have to go this way.
  98. */
  99. static void __init pirq_peer_trick(void)
  100. {
  101. struct irq_routing_table *rt = pirq_table;
  102. u8 busmap[256];
  103. int i;
  104. struct irq_info *e;
  105. memset(busmap, 0, sizeof(busmap));
  106. for (i = 0; i < (rt->size - sizeof(struct irq_routing_table)) /
  107. sizeof(struct irq_info); i++) {
  108. e = &rt->slots[i];
  109. #ifdef DEBUG
  110. {
  111. int j;
  112. DBG(KERN_DEBUG "%02x:%02x slot=%02x", e->bus,
  113. e->devfn/8, e->slot);
  114. for (j = 0; j < 4; j++)
  115. DBG(" %d:%02x/%04x", j, e->irq[j].link,
  116. e->irq[j].bitmap);
  117. DBG("\n");
  118. }
  119. #endif
  120. busmap[e->bus] = 1;
  121. }
  122. for (i = 1; i < 256; i++) {
  123. int node;
  124. if (!busmap[i] || pci_find_bus(0, i))
  125. continue;
  126. node = get_mp_bus_to_node(i);
  127. if (pci_scan_bus_on_node(i, &pci_root_ops, node))
  128. printk(KERN_INFO "PCI: Discovered primary peer "
  129. "bus %02x [IRQ]\n", i);
  130. }
  131. pcibios_last_bus = -1;
  132. }
  133. /*
  134. * Code for querying and setting of IRQ routes on various interrupt routers.
  135. */
  136. void eisa_set_level_irq(unsigned int irq)
  137. {
  138. unsigned char mask = 1 << (irq & 7);
  139. unsigned int port = 0x4d0 + (irq >> 3);
  140. unsigned char val;
  141. static u16 eisa_irq_mask;
  142. if (irq >= 16 || (1 << irq) & eisa_irq_mask)
  143. return;
  144. eisa_irq_mask |= (1 << irq);
  145. printk(KERN_DEBUG "PCI: setting IRQ %u as level-triggered\n", irq);
  146. val = inb(port);
  147. if (!(val & mask)) {
  148. DBG(KERN_DEBUG " -> edge");
  149. outb(val | mask, port);
  150. }
  151. }
  152. /*
  153. * Common IRQ routing practice: nibbles in config space,
  154. * offset by some magic constant.
  155. */
  156. static unsigned int
  157. read_config_nybble(struct pci_dev *router, unsigned offset, unsigned nr)
  158. {
  159. u8 x;
  160. unsigned reg = offset + (nr >> 1);
  161. pci_read_config_byte(router, reg, &x);
  162. return (nr & 1) ? (x >> 4) : (x & 0xf);
  163. }
  164. static void write_config_nybble(struct pci_dev *router, unsigned offset,
  165. unsigned nr, unsigned int val)
  166. {
  167. u8 x;
  168. unsigned reg = offset + (nr >> 1);
  169. pci_read_config_byte(router, reg, &x);
  170. x = (nr & 1) ? ((x & 0x0f) | (val << 4)) : ((x & 0xf0) | val);
  171. pci_write_config_byte(router, reg, x);
  172. }
  173. /*
  174. * ALI pirq entries are damn ugly, and completely undocumented.
  175. * This has been figured out from pirq tables, and it's not a pretty
  176. * picture.
  177. */
  178. static int pirq_ali_get(struct pci_dev *router, struct pci_dev *dev, int pirq)
  179. {
  180. static const unsigned char irqmap[16] = { 0, 9, 3, 10, 4, 5, 7, 6, 1,
  181. 11, 0, 12, 0, 14, 0, 15 };
  182. WARN_ON_ONCE(pirq > 16);
  183. return irqmap[read_config_nybble(router, 0x48, pirq-1)];
  184. }
  185. static int
  186. pirq_ali_set(struct pci_dev *router, struct pci_dev *dev, int pirq, int irq)
  187. {
  188. static const unsigned char irqmap[16] = { 0, 8, 0, 2, 4, 5, 7, 6, 0, 1,
  189. 3, 9, 11, 0, 13, 15 };
  190. unsigned int val = irqmap[irq];
  191. WARN_ON_ONCE(pirq > 16);
  192. if (val) {
  193. write_config_nybble(router, 0x48, pirq-1, val);
  194. return 1;
  195. }
  196. return 0;
  197. }
  198. /*
  199. * The Intel PIIX4 pirq rules are fairly simple: "pirq" is
  200. * just a pointer to the config space.
  201. */
  202. static int pirq_piix_get(struct pci_dev *router, struct pci_dev *dev, int pirq)
  203. {
  204. u8 x;
  205. pci_read_config_byte(router, pirq, &x);
  206. return (x < 16) ? x : 0;
  207. }
  208. static int
  209. pirq_piix_set(struct pci_dev *router, struct pci_dev *dev, int pirq, int irq)
  210. {
  211. pci_write_config_byte(router, pirq, irq);
  212. return 1;
  213. }
  214. /*
  215. * The VIA pirq rules are nibble-based, like ALI,
  216. * but without the ugly irq number munging.
  217. * However, PIRQD is in the upper instead of lower 4 bits.
  218. */
  219. static int pirq_via_get(struct pci_dev *router, struct pci_dev *dev, int pirq)
  220. {
  221. return read_config_nybble(router, 0x55, pirq == 4 ? 5 : pirq);
  222. }
  223. static int
  224. pirq_via_set(struct pci_dev *router, struct pci_dev *dev, int pirq, int irq)
  225. {
  226. write_config_nybble(router, 0x55, pirq == 4 ? 5 : pirq, irq);
  227. return 1;
  228. }
  229. /*
  230. * The VIA pirq rules are nibble-based, like ALI,
  231. * but without the ugly irq number munging.
  232. * However, for 82C586, nibble map is different .
  233. */
  234. static int
  235. pirq_via586_get(struct pci_dev *router, struct pci_dev *dev, int pirq)
  236. {
  237. static const unsigned int pirqmap[5] = { 3, 2, 5, 1, 1 };
  238. WARN_ON_ONCE(pirq > 5);
  239. return read_config_nybble(router, 0x55, pirqmap[pirq-1]);
  240. }
  241. static int
  242. pirq_via586_set(struct pci_dev *router, struct pci_dev *dev, int pirq, int irq)
  243. {
  244. static const unsigned int pirqmap[5] = { 3, 2, 5, 1, 1 };
  245. WARN_ON_ONCE(pirq > 5);
  246. write_config_nybble(router, 0x55, pirqmap[pirq-1], irq);
  247. return 1;
  248. }
  249. /*
  250. * ITE 8330G pirq rules are nibble-based
  251. * FIXME: pirqmap may be { 1, 0, 3, 2 },
  252. * 2+3 are both mapped to irq 9 on my system
  253. */
  254. static int pirq_ite_get(struct pci_dev *router, struct pci_dev *dev, int pirq)
  255. {
  256. static const unsigned char pirqmap[4] = { 1, 0, 2, 3 };
  257. WARN_ON_ONCE(pirq > 4);
  258. return read_config_nybble(router, 0x43, pirqmap[pirq-1]);
  259. }
  260. static int
  261. pirq_ite_set(struct pci_dev *router, struct pci_dev *dev, int pirq, int irq)
  262. {
  263. static const unsigned char pirqmap[4] = { 1, 0, 2, 3 };
  264. WARN_ON_ONCE(pirq > 4);
  265. write_config_nybble(router, 0x43, pirqmap[pirq-1], irq);
  266. return 1;
  267. }
  268. /*
  269. * OPTI: high four bits are nibble pointer..
  270. * I wonder what the low bits do?
  271. */
  272. static int pirq_opti_get(struct pci_dev *router, struct pci_dev *dev, int pirq)
  273. {
  274. return read_config_nybble(router, 0xb8, pirq >> 4);
  275. }
  276. static int
  277. pirq_opti_set(struct pci_dev *router, struct pci_dev *dev, int pirq, int irq)
  278. {
  279. write_config_nybble(router, 0xb8, pirq >> 4, irq);
  280. return 1;
  281. }
  282. /*
  283. * Cyrix: nibble offset 0x5C
  284. * 0x5C bits 7:4 is INTB bits 3:0 is INTA
  285. * 0x5D bits 7:4 is INTD bits 3:0 is INTC
  286. */
  287. static int pirq_cyrix_get(struct pci_dev *router, struct pci_dev *dev, int pirq)
  288. {
  289. return read_config_nybble(router, 0x5C, (pirq-1)^1);
  290. }
  291. static int
  292. pirq_cyrix_set(struct pci_dev *router, struct pci_dev *dev, int pirq, int irq)
  293. {
  294. write_config_nybble(router, 0x5C, (pirq-1)^1, irq);
  295. return 1;
  296. }
  297. /*
  298. * PIRQ routing for SiS 85C503 router used in several SiS chipsets.
  299. * We have to deal with the following issues here:
  300. * - vendors have different ideas about the meaning of link values
  301. * - some onboard devices (integrated in the chipset) have special
  302. * links and are thus routed differently (i.e. not via PCI INTA-INTD)
  303. * - different revision of the router have a different layout for
  304. * the routing registers, particularly for the onchip devices
  305. *
  306. * For all routing registers the common thing is we have one byte
  307. * per routeable link which is defined as:
  308. * bit 7 IRQ mapping enabled (0) or disabled (1)
  309. * bits [6:4] reserved (sometimes used for onchip devices)
  310. * bits [3:0] IRQ to map to
  311. * allowed: 3-7, 9-12, 14-15
  312. * reserved: 0, 1, 2, 8, 13
  313. *
  314. * The config-space registers located at 0x41/0x42/0x43/0x44 are
  315. * always used to route the normal PCI INT A/B/C/D respectively.
  316. * Apparently there are systems implementing PCI routing table using
  317. * link values 0x01-0x04 and others using 0x41-0x44 for PCI INTA..D.
  318. * We try our best to handle both link mappings.
  319. *
  320. * Currently (2003-05-21) it appears most SiS chipsets follow the
  321. * definition of routing registers from the SiS-5595 southbridge.
  322. * According to the SiS 5595 datasheets the revision id's of the
  323. * router (ISA-bridge) should be 0x01 or 0xb0.
  324. *
  325. * Furthermore we've also seen lspci dumps with revision 0x00 and 0xb1.
  326. * Looks like these are used in a number of SiS 5xx/6xx/7xx chipsets.
  327. * They seem to work with the current routing code. However there is
  328. * some concern because of the two USB-OHCI HCs (original SiS 5595
  329. * had only one). YMMV.
  330. *
  331. * Onchip routing for router rev-id 0x01/0xb0 and probably 0x00/0xb1:
  332. *
  333. * 0x61: IDEIRQ:
  334. * bits [6:5] must be written 01
  335. * bit 4 channel-select primary (0), secondary (1)
  336. *
  337. * 0x62: USBIRQ:
  338. * bit 6 OHCI function disabled (0), enabled (1)
  339. *
  340. * 0x6a: ACPI/SCI IRQ: bits 4-6 reserved
  341. *
  342. * 0x7e: Data Acq. Module IRQ - bits 4-6 reserved
  343. *
  344. * We support USBIRQ (in addition to INTA-INTD) and keep the
  345. * IDE, ACPI and DAQ routing untouched as set by the BIOS.
  346. *
  347. * Currently the only reported exception is the new SiS 65x chipset
  348. * which includes the SiS 69x southbridge. Here we have the 85C503
  349. * router revision 0x04 and there are changes in the register layout
  350. * mostly related to the different USB HCs with USB 2.0 support.
  351. *
  352. * Onchip routing for router rev-id 0x04 (try-and-error observation)
  353. *
  354. * 0x60/0x61/0x62/0x63: 1xEHCI and 3xOHCI (companion) USB-HCs
  355. * bit 6-4 are probably unused, not like 5595
  356. */
  357. #define PIRQ_SIS_IRQ_MASK 0x0f
  358. #define PIRQ_SIS_IRQ_DISABLE 0x80
  359. #define PIRQ_SIS_USB_ENABLE 0x40
  360. static int pirq_sis_get(struct pci_dev *router, struct pci_dev *dev, int pirq)
  361. {
  362. u8 x;
  363. int reg;
  364. reg = pirq;
  365. if (reg >= 0x01 && reg <= 0x04)
  366. reg += 0x40;
  367. pci_read_config_byte(router, reg, &x);
  368. return (x & PIRQ_SIS_IRQ_DISABLE) ? 0 : (x & PIRQ_SIS_IRQ_MASK);
  369. }
  370. static int
  371. pirq_sis_set(struct pci_dev *router, struct pci_dev *dev, int pirq, int irq)
  372. {
  373. u8 x;
  374. int reg;
  375. reg = pirq;
  376. if (reg >= 0x01 && reg <= 0x04)
  377. reg += 0x40;
  378. pci_read_config_byte(router, reg, &x);
  379. x &= ~(PIRQ_SIS_IRQ_MASK | PIRQ_SIS_IRQ_DISABLE);
  380. x |= irq ? irq: PIRQ_SIS_IRQ_DISABLE;
  381. pci_write_config_byte(router, reg, x);
  382. return 1;
  383. }
  384. /*
  385. * VLSI: nibble offset 0x74 - educated guess due to routing table and
  386. * config space of VLSI 82C534 PCI-bridge/router (1004:0102)
  387. * Tested on HP OmniBook 800 covering PIRQ 1, 2, 4, 8 for onboard
  388. * devices, PIRQ 3 for non-pci(!) soundchip and (untested) PIRQ 6
  389. * for the busbridge to the docking station.
  390. */
  391. static int pirq_vlsi_get(struct pci_dev *router, struct pci_dev *dev, int pirq)
  392. {
  393. WARN_ON_ONCE(pirq >= 9);
  394. if (pirq > 8) {
  395. printk(KERN_INFO "VLSI router pirq escape (%d)\n", pirq);
  396. return 0;
  397. }
  398. return read_config_nybble(router, 0x74, pirq-1);
  399. }
  400. static int
  401. pirq_vlsi_set(struct pci_dev *router, struct pci_dev *dev, int pirq, int irq)
  402. {
  403. WARN_ON_ONCE(pirq >= 9);
  404. if (pirq > 8) {
  405. printk(KERN_INFO "VLSI router pirq escape (%d)\n", pirq);
  406. return 0;
  407. }
  408. write_config_nybble(router, 0x74, pirq-1, irq);
  409. return 1;
  410. }
  411. /*
  412. * ServerWorks: PCI interrupts mapped to system IRQ lines through Index
  413. * and Redirect I/O registers (0x0c00 and 0x0c01). The Index register
  414. * format is (PCIIRQ## | 0x10), e.g.: PCIIRQ10=0x1a. The Redirect
  415. * register is a straight binary coding of desired PIC IRQ (low nibble).
  416. *
  417. * The 'link' value in the PIRQ table is already in the correct format
  418. * for the Index register. There are some special index values:
  419. * 0x00 for ACPI (SCI), 0x01 for USB, 0x02 for IDE0, 0x04 for IDE1,
  420. * and 0x03 for SMBus.
  421. */
  422. static int
  423. pirq_serverworks_get(struct pci_dev *router, struct pci_dev *dev, int pirq)
  424. {
  425. outb(pirq, 0xc00);
  426. return inb(0xc01) & 0xf;
  427. }
  428. static int pirq_serverworks_set(struct pci_dev *router, struct pci_dev *dev,
  429. int pirq, int irq)
  430. {
  431. outb(pirq, 0xc00);
  432. outb(irq, 0xc01);
  433. return 1;
  434. }
  435. /* Support for AMD756 PCI IRQ Routing
  436. * Jhon H. Caicedo <jhcaiced@osso.org.co>
  437. * Jun/21/2001 0.2.0 Release, fixed to use "nybble" functions... (jhcaiced)
  438. * Jun/19/2001 Alpha Release 0.1.0 (jhcaiced)
  439. * The AMD756 pirq rules are nibble-based
  440. * offset 0x56 0-3 PIRQA 4-7 PIRQB
  441. * offset 0x57 0-3 PIRQC 4-7 PIRQD
  442. */
  443. static int
  444. pirq_amd756_get(struct pci_dev *router, struct pci_dev *dev, int pirq)
  445. {
  446. u8 irq;
  447. irq = 0;
  448. if (pirq <= 4)
  449. irq = read_config_nybble(router, 0x56, pirq - 1);
  450. printk(KERN_INFO
  451. "AMD756: dev %04x:%04x, router pirq : %d get irq : %2d\n",
  452. dev->vendor, dev->device, pirq, irq);
  453. return irq;
  454. }
  455. static int
  456. pirq_amd756_set(struct pci_dev *router, struct pci_dev *dev, int pirq, int irq)
  457. {
  458. printk(KERN_INFO
  459. "AMD756: dev %04x:%04x, router pirq : %d SET irq : %2d\n",
  460. dev->vendor, dev->device, pirq, irq);
  461. if (pirq <= 4)
  462. write_config_nybble(router, 0x56, pirq - 1, irq);
  463. return 1;
  464. }
  465. /*
  466. * PicoPower PT86C523
  467. */
  468. static int pirq_pico_get(struct pci_dev *router, struct pci_dev *dev, int pirq)
  469. {
  470. outb(0x10 + ((pirq - 1) >> 1), 0x24);
  471. return ((pirq - 1) & 1) ? (inb(0x26) >> 4) : (inb(0x26) & 0xf);
  472. }
  473. static int pirq_pico_set(struct pci_dev *router, struct pci_dev *dev, int pirq,
  474. int irq)
  475. {
  476. unsigned int x;
  477. outb(0x10 + ((pirq - 1) >> 1), 0x24);
  478. x = inb(0x26);
  479. x = ((pirq - 1) & 1) ? ((x & 0x0f) | (irq << 4)) : ((x & 0xf0) | (irq));
  480. outb(x, 0x26);
  481. return 1;
  482. }
  483. #ifdef CONFIG_PCI_BIOS
  484. static int
  485. pirq_bios_set(struct pci_dev *router, struct pci_dev *dev, int pirq, int irq)
  486. {
  487. struct pci_dev *bridge;
  488. int pin = pci_get_interrupt_pin(dev, &bridge);
  489. return pcibios_set_irq_routing(bridge, pin, irq);
  490. }
  491. #endif
  492. static __init int
  493. intel_router_probe(struct irq_router *r, struct pci_dev *router, u16 device)
  494. {
  495. static struct pci_device_id __initdata pirq_440gx[] = {
  496. { PCI_DEVICE(PCI_VENDOR_ID_INTEL,
  497. PCI_DEVICE_ID_INTEL_82443GX_0) },
  498. { PCI_DEVICE(PCI_VENDOR_ID_INTEL,
  499. PCI_DEVICE_ID_INTEL_82443GX_2) },
  500. { },
  501. };
  502. /* 440GX has a proprietary PIRQ router -- don't use it */
  503. if (pci_dev_present(pirq_440gx))
  504. return 0;
  505. switch (device) {
  506. case PCI_DEVICE_ID_INTEL_82371FB_0:
  507. case PCI_DEVICE_ID_INTEL_82371SB_0:
  508. case PCI_DEVICE_ID_INTEL_82371AB_0:
  509. case PCI_DEVICE_ID_INTEL_82371MX:
  510. case PCI_DEVICE_ID_INTEL_82443MX_0:
  511. case PCI_DEVICE_ID_INTEL_82801AA_0:
  512. case PCI_DEVICE_ID_INTEL_82801AB_0:
  513. case PCI_DEVICE_ID_INTEL_82801BA_0:
  514. case PCI_DEVICE_ID_INTEL_82801BA_10:
  515. case PCI_DEVICE_ID_INTEL_82801CA_0:
  516. case PCI_DEVICE_ID_INTEL_82801CA_12:
  517. case PCI_DEVICE_ID_INTEL_82801DB_0:
  518. case PCI_DEVICE_ID_INTEL_82801E_0:
  519. case PCI_DEVICE_ID_INTEL_82801EB_0:
  520. case PCI_DEVICE_ID_INTEL_ESB_1:
  521. case PCI_DEVICE_ID_INTEL_ICH6_0:
  522. case PCI_DEVICE_ID_INTEL_ICH6_1:
  523. case PCI_DEVICE_ID_INTEL_ICH7_0:
  524. case PCI_DEVICE_ID_INTEL_ICH7_1:
  525. case PCI_DEVICE_ID_INTEL_ICH7_30:
  526. case PCI_DEVICE_ID_INTEL_ICH7_31:
  527. case PCI_DEVICE_ID_INTEL_ESB2_0:
  528. case PCI_DEVICE_ID_INTEL_ICH8_0:
  529. case PCI_DEVICE_ID_INTEL_ICH8_1:
  530. case PCI_DEVICE_ID_INTEL_ICH8_2:
  531. case PCI_DEVICE_ID_INTEL_ICH8_3:
  532. case PCI_DEVICE_ID_INTEL_ICH8_4:
  533. case PCI_DEVICE_ID_INTEL_ICH9_0:
  534. case PCI_DEVICE_ID_INTEL_ICH9_1:
  535. case PCI_DEVICE_ID_INTEL_ICH9_2:
  536. case PCI_DEVICE_ID_INTEL_ICH9_3:
  537. case PCI_DEVICE_ID_INTEL_ICH9_4:
  538. case PCI_DEVICE_ID_INTEL_ICH9_5:
  539. case PCI_DEVICE_ID_INTEL_TOLAPAI_0:
  540. case PCI_DEVICE_ID_INTEL_ICH10_0:
  541. case PCI_DEVICE_ID_INTEL_ICH10_1:
  542. case PCI_DEVICE_ID_INTEL_ICH10_2:
  543. case PCI_DEVICE_ID_INTEL_ICH10_3:
  544. r->name = "PIIX/ICH";
  545. r->get = pirq_piix_get;
  546. r->set = pirq_piix_set;
  547. return 1;
  548. }
  549. return 0;
  550. }
  551. static __init int via_router_probe(struct irq_router *r,
  552. struct pci_dev *router, u16 device)
  553. {
  554. /* FIXME: We should move some of the quirk fixup stuff here */
  555. /*
  556. * workarounds for some buggy BIOSes
  557. */
  558. if (device == PCI_DEVICE_ID_VIA_82C586_0) {
  559. switch (router->device) {
  560. case PCI_DEVICE_ID_VIA_82C686:
  561. /*
  562. * Asus k7m bios wrongly reports 82C686A
  563. * as 586-compatible
  564. */
  565. device = PCI_DEVICE_ID_VIA_82C686;
  566. break;
  567. case PCI_DEVICE_ID_VIA_8235:
  568. /**
  569. * Asus a7v-x bios wrongly reports 8235
  570. * as 586-compatible
  571. */
  572. device = PCI_DEVICE_ID_VIA_8235;
  573. break;
  574. case PCI_DEVICE_ID_VIA_8237:
  575. /**
  576. * Asus a7v600 bios wrongly reports 8237
  577. * as 586-compatible
  578. */
  579. device = PCI_DEVICE_ID_VIA_8237;
  580. break;
  581. }
  582. }
  583. switch (device) {
  584. case PCI_DEVICE_ID_VIA_82C586_0:
  585. r->name = "VIA";
  586. r->get = pirq_via586_get;
  587. r->set = pirq_via586_set;
  588. return 1;
  589. case PCI_DEVICE_ID_VIA_82C596:
  590. case PCI_DEVICE_ID_VIA_82C686:
  591. case PCI_DEVICE_ID_VIA_8231:
  592. case PCI_DEVICE_ID_VIA_8233A:
  593. case PCI_DEVICE_ID_VIA_8235:
  594. case PCI_DEVICE_ID_VIA_8237:
  595. /* FIXME: add new ones for 8233/5 */
  596. r->name = "VIA";
  597. r->get = pirq_via_get;
  598. r->set = pirq_via_set;
  599. return 1;
  600. }
  601. return 0;
  602. }
  603. static __init int
  604. vlsi_router_probe(struct irq_router *r, struct pci_dev *router, u16 device)
  605. {
  606. switch (device) {
  607. case PCI_DEVICE_ID_VLSI_82C534:
  608. r->name = "VLSI 82C534";
  609. r->get = pirq_vlsi_get;
  610. r->set = pirq_vlsi_set;
  611. return 1;
  612. }
  613. return 0;
  614. }
  615. static __init int serverworks_router_probe(struct irq_router *r,
  616. struct pci_dev *router, u16 device)
  617. {
  618. switch (device) {
  619. case PCI_DEVICE_ID_SERVERWORKS_OSB4:
  620. case PCI_DEVICE_ID_SERVERWORKS_CSB5:
  621. r->name = "ServerWorks";
  622. r->get = pirq_serverworks_get;
  623. r->set = pirq_serverworks_set;
  624. return 1;
  625. }
  626. return 0;
  627. }
  628. static __init int
  629. sis_router_probe(struct irq_router *r, struct pci_dev *router, u16 device)
  630. {
  631. if (device != PCI_DEVICE_ID_SI_503)
  632. return 0;
  633. r->name = "SIS";
  634. r->get = pirq_sis_get;
  635. r->set = pirq_sis_set;
  636. return 1;
  637. }
  638. static __init int
  639. cyrix_router_probe(struct irq_router *r, struct pci_dev *router, u16 device)
  640. {
  641. switch (device) {
  642. case PCI_DEVICE_ID_CYRIX_5520:
  643. r->name = "NatSemi";
  644. r->get = pirq_cyrix_get;
  645. r->set = pirq_cyrix_set;
  646. return 1;
  647. }
  648. return 0;
  649. }
  650. static __init int
  651. opti_router_probe(struct irq_router *r, struct pci_dev *router, u16 device)
  652. {
  653. switch (device) {
  654. case PCI_DEVICE_ID_OPTI_82C700:
  655. r->name = "OPTI";
  656. r->get = pirq_opti_get;
  657. r->set = pirq_opti_set;
  658. return 1;
  659. }
  660. return 0;
  661. }
  662. static __init int
  663. ite_router_probe(struct irq_router *r, struct pci_dev *router, u16 device)
  664. {
  665. switch (device) {
  666. case PCI_DEVICE_ID_ITE_IT8330G_0:
  667. r->name = "ITE";
  668. r->get = pirq_ite_get;
  669. r->set = pirq_ite_set;
  670. return 1;
  671. }
  672. return 0;
  673. }
  674. static __init int
  675. ali_router_probe(struct irq_router *r, struct pci_dev *router, u16 device)
  676. {
  677. switch (device) {
  678. case PCI_DEVICE_ID_AL_M1533:
  679. case PCI_DEVICE_ID_AL_M1563:
  680. printk(KERN_DEBUG "PCI: Using ALI IRQ Router\n");
  681. r->name = "ALI";
  682. r->get = pirq_ali_get;
  683. r->set = pirq_ali_set;
  684. return 1;
  685. }
  686. return 0;
  687. }
  688. static __init int
  689. amd_router_probe(struct irq_router *r, struct pci_dev *router, u16 device)
  690. {
  691. switch (device) {
  692. case PCI_DEVICE_ID_AMD_VIPER_740B:
  693. r->name = "AMD756";
  694. break;
  695. case PCI_DEVICE_ID_AMD_VIPER_7413:
  696. r->name = "AMD766";
  697. break;
  698. case PCI_DEVICE_ID_AMD_VIPER_7443:
  699. r->name = "AMD768";
  700. break;
  701. default:
  702. return 0;
  703. }
  704. r->get = pirq_amd756_get;
  705. r->set = pirq_amd756_set;
  706. return 1;
  707. }
  708. static __init int
  709. pico_router_probe(struct irq_router *r, struct pci_dev *router, u16 device)
  710. {
  711. switch (device) {
  712. case PCI_DEVICE_ID_PICOPOWER_PT86C523:
  713. r->name = "PicoPower PT86C523";
  714. r->get = pirq_pico_get;
  715. r->set = pirq_pico_set;
  716. return 1;
  717. case PCI_DEVICE_ID_PICOPOWER_PT86C523BBP:
  718. r->name = "PicoPower PT86C523 rev. BB+";
  719. r->get = pirq_pico_get;
  720. r->set = pirq_pico_set;
  721. return 1;
  722. }
  723. return 0;
  724. }
  725. static __initdata struct irq_router_handler pirq_routers[] = {
  726. { PCI_VENDOR_ID_INTEL, intel_router_probe },
  727. { PCI_VENDOR_ID_AL, ali_router_probe },
  728. { PCI_VENDOR_ID_ITE, ite_router_probe },
  729. { PCI_VENDOR_ID_VIA, via_router_probe },
  730. { PCI_VENDOR_ID_OPTI, opti_router_probe },
  731. { PCI_VENDOR_ID_SI, sis_router_probe },
  732. { PCI_VENDOR_ID_CYRIX, cyrix_router_probe },
  733. { PCI_VENDOR_ID_VLSI, vlsi_router_probe },
  734. { PCI_VENDOR_ID_SERVERWORKS, serverworks_router_probe },
  735. { PCI_VENDOR_ID_AMD, amd_router_probe },
  736. { PCI_VENDOR_ID_PICOPOWER, pico_router_probe },
  737. /* Someone with docs needs to add the ATI Radeon IGP */
  738. { 0, NULL }
  739. };
  740. static struct irq_router pirq_router;
  741. static struct pci_dev *pirq_router_dev;
  742. /*
  743. * FIXME: should we have an option to say "generic for
  744. * chipset" ?
  745. */
  746. static void __init pirq_find_router(struct irq_router *r)
  747. {
  748. struct irq_routing_table *rt = pirq_table;
  749. struct irq_router_handler *h;
  750. #ifdef CONFIG_PCI_BIOS
  751. if (!rt->signature) {
  752. printk(KERN_INFO "PCI: Using BIOS for IRQ routing\n");
  753. r->set = pirq_bios_set;
  754. r->name = "BIOS";
  755. return;
  756. }
  757. #endif
  758. /* Default unless a driver reloads it */
  759. r->name = "default";
  760. r->get = NULL;
  761. r->set = NULL;
  762. DBG(KERN_DEBUG "PCI: Attempting to find IRQ router for %04x:%04x\n",
  763. rt->rtr_vendor, rt->rtr_device);
  764. pirq_router_dev = pci_get_bus_and_slot(rt->rtr_bus, rt->rtr_devfn);
  765. if (!pirq_router_dev) {
  766. DBG(KERN_DEBUG "PCI: Interrupt router not found at "
  767. "%02x:%02x\n", rt->rtr_bus, rt->rtr_devfn);
  768. return;
  769. }
  770. for (h = pirq_routers; h->vendor; h++) {
  771. /* First look for a router match */
  772. if (rt->rtr_vendor == h->vendor &&
  773. h->probe(r, pirq_router_dev, rt->rtr_device))
  774. break;
  775. /* Fall back to a device match */
  776. if (pirq_router_dev->vendor == h->vendor &&
  777. h->probe(r, pirq_router_dev, pirq_router_dev->device))
  778. break;
  779. }
  780. printk(KERN_INFO "PCI: Using IRQ router %s [%04x/%04x] at %s\n",
  781. pirq_router.name,
  782. pirq_router_dev->vendor,
  783. pirq_router_dev->device,
  784. pci_name(pirq_router_dev));
  785. /* The device remains referenced for the kernel lifetime */
  786. }
  787. static struct irq_info *pirq_get_info(struct pci_dev *dev)
  788. {
  789. struct irq_routing_table *rt = pirq_table;
  790. int entries = (rt->size - sizeof(struct irq_routing_table)) /
  791. sizeof(struct irq_info);
  792. struct irq_info *info;
  793. for (info = rt->slots; entries--; info++)
  794. if (info->bus == dev->bus->number &&
  795. PCI_SLOT(info->devfn) == PCI_SLOT(dev->devfn))
  796. return info;
  797. return NULL;
  798. }
  799. static int pcibios_lookup_irq(struct pci_dev *dev, int assign)
  800. {
  801. u8 pin;
  802. struct irq_info *info;
  803. int i, pirq, newirq;
  804. int irq = 0;
  805. u32 mask;
  806. struct irq_router *r = &pirq_router;
  807. struct pci_dev *dev2 = NULL;
  808. char *msg = NULL;
  809. /* Find IRQ pin */
  810. pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin);
  811. if (!pin) {
  812. DBG(KERN_DEBUG " -> no interrupt pin\n");
  813. return 0;
  814. }
  815. pin = pin - 1;
  816. /* Find IRQ routing entry */
  817. if (!pirq_table)
  818. return 0;
  819. DBG(KERN_DEBUG "IRQ for %s[%c]", pci_name(dev), 'A' + pin);
  820. info = pirq_get_info(dev);
  821. if (!info) {
  822. DBG(" -> not found in routing table\n" KERN_DEBUG);
  823. return 0;
  824. }
  825. pirq = info->irq[pin].link;
  826. mask = info->irq[pin].bitmap;
  827. if (!pirq) {
  828. DBG(" -> not routed\n" KERN_DEBUG);
  829. return 0;
  830. }
  831. DBG(" -> PIRQ %02x, mask %04x, excl %04x", pirq, mask,
  832. pirq_table->exclusive_irqs);
  833. mask &= pcibios_irq_mask;
  834. /* Work around broken HP Pavilion Notebooks which assign USB to
  835. IRQ 9 even though it is actually wired to IRQ 11 */
  836. if (broken_hp_bios_irq9 && pirq == 0x59 && dev->irq == 9) {
  837. dev->irq = 11;
  838. pci_write_config_byte(dev, PCI_INTERRUPT_LINE, 11);
  839. r->set(pirq_router_dev, dev, pirq, 11);
  840. }
  841. /* same for Acer Travelmate 360, but with CB and irq 11 -> 10 */
  842. if (acer_tm360_irqrouting && dev->irq == 11 &&
  843. dev->vendor == PCI_VENDOR_ID_O2) {
  844. pirq = 0x68;
  845. mask = 0x400;
  846. dev->irq = r->get(pirq_router_dev, dev, pirq);
  847. pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq);
  848. }
  849. /*
  850. * Find the best IRQ to assign: use the one
  851. * reported by the device if possible.
  852. */
  853. newirq = dev->irq;
  854. if (newirq && !((1 << newirq) & mask)) {
  855. if (pci_probe & PCI_USE_PIRQ_MASK)
  856. newirq = 0;
  857. else
  858. printk("\n" KERN_WARNING
  859. "PCI: IRQ %i for device %s doesn't match PIRQ mask - try pci=usepirqmask\n"
  860. KERN_DEBUG, newirq,
  861. pci_name(dev));
  862. }
  863. if (!newirq && assign) {
  864. for (i = 0; i < 16; i++) {
  865. if (!(mask & (1 << i)))
  866. continue;
  867. if (pirq_penalty[i] < pirq_penalty[newirq] &&
  868. can_request_irq(i, IRQF_SHARED))
  869. newirq = i;
  870. }
  871. }
  872. DBG(" -> newirq=%d", newirq);
  873. /* Check if it is hardcoded */
  874. if ((pirq & 0xf0) == 0xf0) {
  875. irq = pirq & 0xf;
  876. DBG(" -> hardcoded IRQ %d\n", irq);
  877. msg = "Hardcoded";
  878. } else if (r->get && (irq = r->get(pirq_router_dev, dev, pirq)) && \
  879. ((!(pci_probe & PCI_USE_PIRQ_MASK)) || ((1 << irq) & mask))) {
  880. DBG(" -> got IRQ %d\n", irq);
  881. msg = "Found";
  882. eisa_set_level_irq(irq);
  883. } else if (newirq && r->set &&
  884. (dev->class >> 8) != PCI_CLASS_DISPLAY_VGA) {
  885. DBG(" -> assigning IRQ %d", newirq);
  886. if (r->set(pirq_router_dev, dev, pirq, newirq)) {
  887. eisa_set_level_irq(newirq);
  888. DBG(" ... OK\n");
  889. msg = "Assigned";
  890. irq = newirq;
  891. }
  892. }
  893. if (!irq) {
  894. DBG(" ... failed\n");
  895. if (newirq && mask == (1 << newirq)) {
  896. msg = "Guessed";
  897. irq = newirq;
  898. } else
  899. return 0;
  900. }
  901. printk(KERN_INFO "PCI: %s IRQ %d for device %s\n", msg, irq,
  902. pci_name(dev));
  903. /* Update IRQ for all devices with the same pirq value */
  904. while ((dev2 = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev2)) != NULL) {
  905. pci_read_config_byte(dev2, PCI_INTERRUPT_PIN, &pin);
  906. if (!pin)
  907. continue;
  908. pin--;
  909. info = pirq_get_info(dev2);
  910. if (!info)
  911. continue;
  912. if (info->irq[pin].link == pirq) {
  913. /*
  914. * We refuse to override the dev->irq
  915. * information. Give a warning!
  916. */
  917. if (dev2->irq && dev2->irq != irq && \
  918. (!(pci_probe & PCI_USE_PIRQ_MASK) || \
  919. ((1 << dev2->irq) & mask))) {
  920. #ifndef CONFIG_PCI_MSI
  921. printk(KERN_INFO
  922. "IRQ routing conflict for %s, have irq %d, want irq %d\n",
  923. pci_name(dev2), dev2->irq, irq);
  924. #endif
  925. continue;
  926. }
  927. dev2->irq = irq;
  928. pirq_penalty[irq]++;
  929. if (dev != dev2)
  930. printk(KERN_INFO
  931. "PCI: Sharing IRQ %d with %s\n",
  932. irq, pci_name(dev2));
  933. }
  934. }
  935. return 1;
  936. }
  937. static void __init pcibios_fixup_irqs(void)
  938. {
  939. struct pci_dev *dev = NULL;
  940. u8 pin;
  941. DBG(KERN_DEBUG "PCI: IRQ fixup\n");
  942. while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
  943. /*
  944. * If the BIOS has set an out of range IRQ number, just
  945. * ignore it. Also keep track of which IRQ's are
  946. * already in use.
  947. */
  948. if (dev->irq >= 16) {
  949. DBG(KERN_DEBUG "%s: ignoring bogus IRQ %d\n",
  950. pci_name(dev), dev->irq);
  951. dev->irq = 0;
  952. }
  953. /*
  954. * If the IRQ is already assigned to a PCI device,
  955. * ignore its ISA use penalty
  956. */
  957. if (pirq_penalty[dev->irq] >= 100 &&
  958. pirq_penalty[dev->irq] < 100000)
  959. pirq_penalty[dev->irq] = 0;
  960. pirq_penalty[dev->irq]++;
  961. }
  962. dev = NULL;
  963. while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
  964. pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin);
  965. #ifdef CONFIG_X86_IO_APIC
  966. /*
  967. * Recalculate IRQ numbers if we use the I/O APIC.
  968. */
  969. if (io_apic_assign_pci_irqs) {
  970. int irq;
  971. if (pin) {
  972. /*
  973. * interrupt pins are numbered starting
  974. * from 1
  975. */
  976. pin--;
  977. irq = IO_APIC_get_PCI_irq_vector(dev->bus->number,
  978. PCI_SLOT(dev->devfn), pin);
  979. /*
  980. * Busses behind bridges are typically not listed in the MP-table.
  981. * In this case we have to look up the IRQ based on the parent bus,
  982. * parent slot, and pin number. The SMP code detects such bridged
  983. * busses itself so we should get into this branch reliably.
  984. */
  985. if (irq < 0 && dev->bus->parent) {
  986. /* go back to the bridge */
  987. struct pci_dev *bridge = dev->bus->self;
  988. pin = (pin + PCI_SLOT(dev->devfn)) % 4;
  989. irq = IO_APIC_get_PCI_irq_vector(bridge->bus->number,
  990. PCI_SLOT(bridge->devfn),
  991. pin);
  992. if (irq >= 0)
  993. printk(KERN_WARNING
  994. "PCI: using PPB %s[%c] to get irq %d\n",
  995. pci_name(bridge),
  996. 'A' + pin, irq);
  997. }
  998. if (irq >= 0) {
  999. printk(KERN_INFO
  1000. "PCI->APIC IRQ transform: %s[%c] -> IRQ %d\n",
  1001. pci_name(dev), 'A' + pin, irq);
  1002. dev->irq = irq;
  1003. }
  1004. }
  1005. }
  1006. #endif
  1007. /*
  1008. * Still no IRQ? Try to lookup one...
  1009. */
  1010. if (pin && !dev->irq)
  1011. pcibios_lookup_irq(dev, 0);
  1012. }
  1013. }
  1014. /*
  1015. * Work around broken HP Pavilion Notebooks which assign USB to
  1016. * IRQ 9 even though it is actually wired to IRQ 11
  1017. */
  1018. static int __init fix_broken_hp_bios_irq9(const struct dmi_system_id *d)
  1019. {
  1020. if (!broken_hp_bios_irq9) {
  1021. broken_hp_bios_irq9 = 1;
  1022. printk(KERN_INFO "%s detected - fixing broken IRQ routing\n",
  1023. d->ident);
  1024. }
  1025. return 0;
  1026. }
  1027. /*
  1028. * Work around broken Acer TravelMate 360 Notebooks which assign
  1029. * Cardbus to IRQ 11 even though it is actually wired to IRQ 10
  1030. */
  1031. static int __init fix_acer_tm360_irqrouting(const struct dmi_system_id *d)
  1032. {
  1033. if (!acer_tm360_irqrouting) {
  1034. acer_tm360_irqrouting = 1;
  1035. printk(KERN_INFO "%s detected - fixing broken IRQ routing\n",
  1036. d->ident);
  1037. }
  1038. return 0;
  1039. }
  1040. static struct dmi_system_id __initdata pciirq_dmi_table[] = {
  1041. {
  1042. .callback = fix_broken_hp_bios_irq9,
  1043. .ident = "HP Pavilion N5400 Series Laptop",
  1044. .matches = {
  1045. DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
  1046. DMI_MATCH(DMI_BIOS_VERSION, "GE.M1.03"),
  1047. DMI_MATCH(DMI_PRODUCT_VERSION,
  1048. "HP Pavilion Notebook Model GE"),
  1049. DMI_MATCH(DMI_BOARD_VERSION, "OmniBook N32N-736"),
  1050. },
  1051. },
  1052. {
  1053. .callback = fix_acer_tm360_irqrouting,
  1054. .ident = "Acer TravelMate 36x Laptop",
  1055. .matches = {
  1056. DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
  1057. DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 360"),
  1058. },
  1059. },
  1060. { }
  1061. };
  1062. static int __init pcibios_irq_init(void)
  1063. {
  1064. DBG(KERN_DEBUG "PCI: IRQ init\n");
  1065. if (pcibios_enable_irq || raw_pci_ops == NULL)
  1066. return 0;
  1067. dmi_check_system(pciirq_dmi_table);
  1068. pirq_table = pirq_find_routing_table();
  1069. #ifdef CONFIG_PCI_BIOS
  1070. if (!pirq_table && (pci_probe & PCI_BIOS_IRQ_SCAN))
  1071. pirq_table = pcibios_get_irq_routing_table();
  1072. #endif
  1073. if (pirq_table) {
  1074. pirq_peer_trick();
  1075. pirq_find_router(&pirq_router);
  1076. if (pirq_table->exclusive_irqs) {
  1077. int i;
  1078. for (i = 0; i < 16; i++)
  1079. if (!(pirq_table->exclusive_irqs & (1 << i)))
  1080. pirq_penalty[i] += 100;
  1081. }
  1082. /*
  1083. * If we're using the I/O APIC, avoid using the PCI IRQ
  1084. * routing table
  1085. */
  1086. if (io_apic_assign_pci_irqs)
  1087. pirq_table = NULL;
  1088. }
  1089. pcibios_enable_irq = pirq_enable_irq;
  1090. pcibios_fixup_irqs();
  1091. return 0;
  1092. }
  1093. subsys_initcall(pcibios_irq_init);
  1094. static void pirq_penalize_isa_irq(int irq, int active)
  1095. {
  1096. /*
  1097. * If any ISAPnP device reports an IRQ in its list of possible
  1098. * IRQ's, we try to avoid assigning it to PCI devices.
  1099. */
  1100. if (irq < 16) {
  1101. if (active)
  1102. pirq_penalty[irq] += 1000;
  1103. else
  1104. pirq_penalty[irq] += 100;
  1105. }
  1106. }
  1107. void pcibios_penalize_isa_irq(int irq, int active)
  1108. {
  1109. #ifdef CONFIG_ACPI
  1110. if (!acpi_noirq)
  1111. acpi_penalize_isa_irq(irq, active);
  1112. else
  1113. #endif
  1114. pirq_penalize_isa_irq(irq, active);
  1115. }
  1116. static int pirq_enable_irq(struct pci_dev *dev)
  1117. {
  1118. u8 pin;
  1119. struct pci_dev *temp_dev;
  1120. pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin);
  1121. if (pin && !pcibios_lookup_irq(dev, 1) && !dev->irq) {
  1122. char *msg = "";
  1123. pin--; /* interrupt pins are numbered starting from 1 */
  1124. if (io_apic_assign_pci_irqs) {
  1125. int irq;
  1126. irq = IO_APIC_get_PCI_irq_vector(dev->bus->number,
  1127. PCI_SLOT(dev->devfn), pin);
  1128. /*
  1129. * Busses behind bridges are typically not
  1130. * listed in the MP-table. In this case we have
  1131. * to look up the IRQ based on the parent bus,
  1132. * parent slot, and pin number. The SMP code
  1133. * detects such bridged busses itself so we
  1134. * should get into this branch reliably.
  1135. */
  1136. temp_dev = dev;
  1137. while (irq < 0 && dev->bus->parent) {
  1138. /* go back to the bridge */
  1139. struct pci_dev *bridge = dev->bus->self;
  1140. pin = (pin + PCI_SLOT(dev->devfn)) % 4;
  1141. irq = IO_APIC_get_PCI_irq_vector(bridge->bus->number,
  1142. PCI_SLOT(bridge->devfn), pin);
  1143. if (irq >= 0)
  1144. printk(KERN_WARNING
  1145. "PCI: using PPB %s[%c] to get irq %d\n",
  1146. pci_name(bridge),
  1147. 'A' + pin, irq);
  1148. dev = bridge;
  1149. }
  1150. dev = temp_dev;
  1151. if (irq >= 0) {
  1152. printk(KERN_INFO
  1153. "PCI->APIC IRQ transform: %s[%c] -> IRQ %d\n",
  1154. pci_name(dev), 'A' + pin, irq);
  1155. dev->irq = irq;
  1156. return 0;
  1157. } else
  1158. msg = " Probably buggy MP table.";
  1159. } else if (pci_probe & PCI_BIOS_IRQ_SCAN)
  1160. msg = "";
  1161. else
  1162. msg = " Please try using pci=biosirq.";
  1163. /*
  1164. * With IDE legacy devices the IRQ lookup failure is not
  1165. * a problem..
  1166. */
  1167. if (dev->class >> 8 == PCI_CLASS_STORAGE_IDE &&
  1168. !(dev->class & 0x5))
  1169. return 0;
  1170. printk(KERN_WARNING
  1171. "PCI: No IRQ known for interrupt pin %c of device %s.%s\n",
  1172. 'A' + pin, pci_name(dev), msg);
  1173. }
  1174. return 0;
  1175. }