pci.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682
  1. /*
  2. * Copyright (C) 2004 Benjamin Herrenschmuidt (benh@kernel.crashing.org),
  3. * IBM Corp.
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License
  7. * as published by the Free Software Foundation; either version
  8. * 2 of the License, or (at your option) any later version.
  9. */
  10. #undef DEBUG
  11. #include <linux/kernel.h>
  12. #include <linux/pci.h>
  13. #include <linux/delay.h>
  14. #include <linux/string.h>
  15. #include <linux/init.h>
  16. #include <linux/bootmem.h>
  17. #include <linux/irq.h>
  18. #include <asm/sections.h>
  19. #include <asm/io.h>
  20. #include <asm/prom.h>
  21. #include <asm/pci-bridge.h>
  22. #include <asm/machdep.h>
  23. #include <asm/iommu.h>
  24. #include <asm/ppc-pci.h>
  25. #include "maple.h"
  26. #ifdef DEBUG
  27. #define DBG(x...) printk(x)
  28. #else
  29. #define DBG(x...)
  30. #endif
  31. static struct pci_controller *u3_agp, *u3_ht, *u4_pcie;
  32. static int __init fixup_one_level_bus_range(struct device_node *node, int higher)
  33. {
  34. for (; node != 0;node = node->sibling) {
  35. const int *bus_range;
  36. const unsigned int *class_code;
  37. int len;
  38. /* For PCI<->PCI bridges or CardBus bridges, we go down */
  39. class_code = get_property(node, "class-code", NULL);
  40. if (!class_code || ((*class_code >> 8) != PCI_CLASS_BRIDGE_PCI &&
  41. (*class_code >> 8) != PCI_CLASS_BRIDGE_CARDBUS))
  42. continue;
  43. bus_range = get_property(node, "bus-range", &len);
  44. if (bus_range != NULL && len > 2 * sizeof(int)) {
  45. if (bus_range[1] > higher)
  46. higher = bus_range[1];
  47. }
  48. higher = fixup_one_level_bus_range(node->child, higher);
  49. }
  50. return higher;
  51. }
  52. /* This routine fixes the "bus-range" property of all bridges in the
  53. * system since they tend to have their "last" member wrong on macs
  54. *
  55. * Note that the bus numbers manipulated here are OF bus numbers, they
  56. * are not Linux bus numbers.
  57. */
  58. static void __init fixup_bus_range(struct device_node *bridge)
  59. {
  60. int *bus_range;
  61. struct property *prop;
  62. int len;
  63. /* Lookup the "bus-range" property for the hose */
  64. prop = of_find_property(bridge, "bus-range", &len);
  65. if (prop == NULL || prop->value == NULL || len < 2 * sizeof(int)) {
  66. printk(KERN_WARNING "Can't get bus-range for %s\n",
  67. bridge->full_name);
  68. return;
  69. }
  70. bus_range = (int *)prop->value;
  71. bus_range[1] = fixup_one_level_bus_range(bridge->child, bus_range[1]);
  72. }
  73. static unsigned long u3_agp_cfa0(u8 devfn, u8 off)
  74. {
  75. return (1 << (unsigned long)PCI_SLOT(devfn)) |
  76. ((unsigned long)PCI_FUNC(devfn) << 8) |
  77. ((unsigned long)off & 0xFCUL);
  78. }
  79. static unsigned long u3_agp_cfa1(u8 bus, u8 devfn, u8 off)
  80. {
  81. return ((unsigned long)bus << 16) |
  82. ((unsigned long)devfn << 8) |
  83. ((unsigned long)off & 0xFCUL) |
  84. 1UL;
  85. }
  86. static volatile void __iomem *u3_agp_cfg_access(struct pci_controller* hose,
  87. u8 bus, u8 dev_fn, u8 offset)
  88. {
  89. unsigned int caddr;
  90. if (bus == hose->first_busno) {
  91. if (dev_fn < (11 << 3))
  92. return NULL;
  93. caddr = u3_agp_cfa0(dev_fn, offset);
  94. } else
  95. caddr = u3_agp_cfa1(bus, dev_fn, offset);
  96. /* Uninorth will return garbage if we don't read back the value ! */
  97. do {
  98. out_le32(hose->cfg_addr, caddr);
  99. } while (in_le32(hose->cfg_addr) != caddr);
  100. offset &= 0x07;
  101. return hose->cfg_data + offset;
  102. }
  103. static int u3_agp_read_config(struct pci_bus *bus, unsigned int devfn,
  104. int offset, int len, u32 *val)
  105. {
  106. struct pci_controller *hose;
  107. volatile void __iomem *addr;
  108. hose = pci_bus_to_host(bus);
  109. if (hose == NULL)
  110. return PCIBIOS_DEVICE_NOT_FOUND;
  111. addr = u3_agp_cfg_access(hose, bus->number, devfn, offset);
  112. if (!addr)
  113. return PCIBIOS_DEVICE_NOT_FOUND;
  114. /*
  115. * Note: the caller has already checked that offset is
  116. * suitably aligned and that len is 1, 2 or 4.
  117. */
  118. switch (len) {
  119. case 1:
  120. *val = in_8(addr);
  121. break;
  122. case 2:
  123. *val = in_le16(addr);
  124. break;
  125. default:
  126. *val = in_le32(addr);
  127. break;
  128. }
  129. return PCIBIOS_SUCCESSFUL;
  130. }
  131. static int u3_agp_write_config(struct pci_bus *bus, unsigned int devfn,
  132. int offset, int len, u32 val)
  133. {
  134. struct pci_controller *hose;
  135. volatile void __iomem *addr;
  136. hose = pci_bus_to_host(bus);
  137. if (hose == NULL)
  138. return PCIBIOS_DEVICE_NOT_FOUND;
  139. addr = u3_agp_cfg_access(hose, bus->number, devfn, offset);
  140. if (!addr)
  141. return PCIBIOS_DEVICE_NOT_FOUND;
  142. /*
  143. * Note: the caller has already checked that offset is
  144. * suitably aligned and that len is 1, 2 or 4.
  145. */
  146. switch (len) {
  147. case 1:
  148. out_8(addr, val);
  149. (void) in_8(addr);
  150. break;
  151. case 2:
  152. out_le16(addr, val);
  153. (void) in_le16(addr);
  154. break;
  155. default:
  156. out_le32(addr, val);
  157. (void) in_le32(addr);
  158. break;
  159. }
  160. return PCIBIOS_SUCCESSFUL;
  161. }
  162. static struct pci_ops u3_agp_pci_ops =
  163. {
  164. u3_agp_read_config,
  165. u3_agp_write_config
  166. };
  167. static unsigned long u3_ht_cfa0(u8 devfn, u8 off)
  168. {
  169. return (devfn << 8) | off;
  170. }
  171. static unsigned long u3_ht_cfa1(u8 bus, u8 devfn, u8 off)
  172. {
  173. return u3_ht_cfa0(devfn, off) + (bus << 16) + 0x01000000UL;
  174. }
  175. static volatile void __iomem *u3_ht_cfg_access(struct pci_controller* hose,
  176. u8 bus, u8 devfn, u8 offset)
  177. {
  178. if (bus == hose->first_busno) {
  179. if (PCI_SLOT(devfn) == 0)
  180. return NULL;
  181. return hose->cfg_data + u3_ht_cfa0(devfn, offset);
  182. } else
  183. return hose->cfg_data + u3_ht_cfa1(bus, devfn, offset);
  184. }
  185. static int u3_ht_read_config(struct pci_bus *bus, unsigned int devfn,
  186. int offset, int len, u32 *val)
  187. {
  188. struct pci_controller *hose;
  189. volatile void __iomem *addr;
  190. hose = pci_bus_to_host(bus);
  191. if (hose == NULL)
  192. return PCIBIOS_DEVICE_NOT_FOUND;
  193. if (offset > 0xff)
  194. return PCIBIOS_BAD_REGISTER_NUMBER;
  195. addr = u3_ht_cfg_access(hose, bus->number, devfn, offset);
  196. if (!addr)
  197. return PCIBIOS_DEVICE_NOT_FOUND;
  198. /*
  199. * Note: the caller has already checked that offset is
  200. * suitably aligned and that len is 1, 2 or 4.
  201. */
  202. switch (len) {
  203. case 1:
  204. *val = in_8(addr);
  205. break;
  206. case 2:
  207. *val = in_le16(addr);
  208. break;
  209. default:
  210. *val = in_le32(addr);
  211. break;
  212. }
  213. return PCIBIOS_SUCCESSFUL;
  214. }
  215. static int u3_ht_write_config(struct pci_bus *bus, unsigned int devfn,
  216. int offset, int len, u32 val)
  217. {
  218. struct pci_controller *hose;
  219. volatile void __iomem *addr;
  220. hose = pci_bus_to_host(bus);
  221. if (hose == NULL)
  222. return PCIBIOS_DEVICE_NOT_FOUND;
  223. if (offset > 0xff)
  224. return PCIBIOS_BAD_REGISTER_NUMBER;
  225. addr = u3_ht_cfg_access(hose, bus->number, devfn, offset);
  226. if (!addr)
  227. return PCIBIOS_DEVICE_NOT_FOUND;
  228. /*
  229. * Note: the caller has already checked that offset is
  230. * suitably aligned and that len is 1, 2 or 4.
  231. */
  232. switch (len) {
  233. case 1:
  234. out_8(addr, val);
  235. (void) in_8(addr);
  236. break;
  237. case 2:
  238. out_le16(addr, val);
  239. (void) in_le16(addr);
  240. break;
  241. default:
  242. out_le32(addr, val);
  243. (void) in_le32(addr);
  244. break;
  245. }
  246. return PCIBIOS_SUCCESSFUL;
  247. }
  248. static struct pci_ops u3_ht_pci_ops =
  249. {
  250. u3_ht_read_config,
  251. u3_ht_write_config
  252. };
  253. static unsigned int u4_pcie_cfa0(unsigned int devfn, unsigned int off)
  254. {
  255. return (1 << PCI_SLOT(devfn)) |
  256. (PCI_FUNC(devfn) << 8) |
  257. ((off >> 8) << 28) |
  258. (off & 0xfcu);
  259. }
  260. static unsigned int u4_pcie_cfa1(unsigned int bus, unsigned int devfn,
  261. unsigned int off)
  262. {
  263. return (bus << 16) |
  264. (devfn << 8) |
  265. ((off >> 8) << 28) |
  266. (off & 0xfcu) | 1u;
  267. }
  268. static volatile void __iomem *u4_pcie_cfg_access(struct pci_controller* hose,
  269. u8 bus, u8 dev_fn, int offset)
  270. {
  271. unsigned int caddr;
  272. if (bus == hose->first_busno)
  273. caddr = u4_pcie_cfa0(dev_fn, offset);
  274. else
  275. caddr = u4_pcie_cfa1(bus, dev_fn, offset);
  276. /* Uninorth will return garbage if we don't read back the value ! */
  277. do {
  278. out_le32(hose->cfg_addr, caddr);
  279. } while (in_le32(hose->cfg_addr) != caddr);
  280. offset &= 0x03;
  281. return hose->cfg_data + offset;
  282. }
  283. static int u4_pcie_read_config(struct pci_bus *bus, unsigned int devfn,
  284. int offset, int len, u32 *val)
  285. {
  286. struct pci_controller *hose;
  287. volatile void __iomem *addr;
  288. hose = pci_bus_to_host(bus);
  289. if (hose == NULL)
  290. return PCIBIOS_DEVICE_NOT_FOUND;
  291. if (offset >= 0x1000)
  292. return PCIBIOS_BAD_REGISTER_NUMBER;
  293. addr = u4_pcie_cfg_access(hose, bus->number, devfn, offset);
  294. if (!addr)
  295. return PCIBIOS_DEVICE_NOT_FOUND;
  296. /*
  297. * Note: the caller has already checked that offset is
  298. * suitably aligned and that len is 1, 2 or 4.
  299. */
  300. switch (len) {
  301. case 1:
  302. *val = in_8(addr);
  303. break;
  304. case 2:
  305. *val = in_le16(addr);
  306. break;
  307. default:
  308. *val = in_le32(addr);
  309. break;
  310. }
  311. return PCIBIOS_SUCCESSFUL;
  312. }
  313. static int u4_pcie_write_config(struct pci_bus *bus, unsigned int devfn,
  314. int offset, int len, u32 val)
  315. {
  316. struct pci_controller *hose;
  317. volatile void __iomem *addr;
  318. hose = pci_bus_to_host(bus);
  319. if (hose == NULL)
  320. return PCIBIOS_DEVICE_NOT_FOUND;
  321. if (offset >= 0x1000)
  322. return PCIBIOS_BAD_REGISTER_NUMBER;
  323. addr = u4_pcie_cfg_access(hose, bus->number, devfn, offset);
  324. if (!addr)
  325. return PCIBIOS_DEVICE_NOT_FOUND;
  326. /*
  327. * Note: the caller has already checked that offset is
  328. * suitably aligned and that len is 1, 2 or 4.
  329. */
  330. switch (len) {
  331. case 1:
  332. out_8(addr, val);
  333. (void) in_8(addr);
  334. break;
  335. case 2:
  336. out_le16(addr, val);
  337. (void) in_le16(addr);
  338. break;
  339. default:
  340. out_le32(addr, val);
  341. (void) in_le32(addr);
  342. break;
  343. }
  344. return PCIBIOS_SUCCESSFUL;
  345. }
  346. static struct pci_ops u4_pcie_pci_ops =
  347. {
  348. u4_pcie_read_config,
  349. u4_pcie_write_config
  350. };
  351. static void __init setup_u3_agp(struct pci_controller* hose)
  352. {
  353. /* On G5, we move AGP up to high bus number so we don't need
  354. * to reassign bus numbers for HT. If we ever have P2P bridges
  355. * on AGP, we'll have to move pci_assign_all_buses to the
  356. * pci_controller structure so we enable it for AGP and not for
  357. * HT childs.
  358. * We hard code the address because of the different size of
  359. * the reg address cell, we shall fix that by killing struct
  360. * reg_property and using some accessor functions instead
  361. */
  362. hose->first_busno = 0xf0;
  363. hose->last_busno = 0xff;
  364. hose->ops = &u3_agp_pci_ops;
  365. hose->cfg_addr = ioremap(0xf0000000 + 0x800000, 0x1000);
  366. hose->cfg_data = ioremap(0xf0000000 + 0xc00000, 0x1000);
  367. u3_agp = hose;
  368. }
  369. static void __init setup_u4_pcie(struct pci_controller* hose)
  370. {
  371. /* We currently only implement the "non-atomic" config space, to
  372. * be optimised later.
  373. */
  374. hose->ops = &u4_pcie_pci_ops;
  375. hose->cfg_addr = ioremap(0xf0000000 + 0x800000, 0x1000);
  376. hose->cfg_data = ioremap(0xf0000000 + 0xc00000, 0x1000);
  377. u4_pcie = hose;
  378. }
  379. static void __init setup_u3_ht(struct pci_controller* hose)
  380. {
  381. hose->ops = &u3_ht_pci_ops;
  382. /* We hard code the address because of the different size of
  383. * the reg address cell, we shall fix that by killing struct
  384. * reg_property and using some accessor functions instead
  385. */
  386. hose->cfg_data = ioremap(0xf2000000, 0x02000000);
  387. hose->first_busno = 0;
  388. hose->last_busno = 0xef;
  389. u3_ht = hose;
  390. }
  391. static int __init add_bridge(struct device_node *dev)
  392. {
  393. int len;
  394. struct pci_controller *hose;
  395. char* disp_name;
  396. const int *bus_range;
  397. int primary = 1;
  398. DBG("Adding PCI host bridge %s\n", dev->full_name);
  399. bus_range = get_property(dev, "bus-range", &len);
  400. if (bus_range == NULL || len < 2 * sizeof(int)) {
  401. printk(KERN_WARNING "Can't get bus-range for %s, assume bus 0\n",
  402. dev->full_name);
  403. }
  404. hose = pcibios_alloc_controller(dev);
  405. if (hose == NULL)
  406. return -ENOMEM;
  407. hose->first_busno = bus_range ? bus_range[0] : 0;
  408. hose->last_busno = bus_range ? bus_range[1] : 0xff;
  409. disp_name = NULL;
  410. if (device_is_compatible(dev, "u3-agp")) {
  411. setup_u3_agp(hose);
  412. disp_name = "U3-AGP";
  413. primary = 0;
  414. } else if (device_is_compatible(dev, "u3-ht")) {
  415. setup_u3_ht(hose);
  416. disp_name = "U3-HT";
  417. primary = 1;
  418. } else if (device_is_compatible(dev, "u4-pcie")) {
  419. setup_u4_pcie(hose);
  420. disp_name = "U4-PCIE";
  421. primary = 0;
  422. }
  423. printk(KERN_INFO "Found %s PCI host bridge. Firmware bus number: %d->%d\n",
  424. disp_name, hose->first_busno, hose->last_busno);
  425. /* Interpret the "ranges" property */
  426. /* This also maps the I/O region and sets isa_io/mem_base */
  427. pci_process_bridge_OF_ranges(hose, dev, primary);
  428. /* Fixup "bus-range" OF property */
  429. fixup_bus_range(dev);
  430. return 0;
  431. }
  432. void __devinit maple_pci_irq_fixup(struct pci_dev *dev)
  433. {
  434. DBG(" -> maple_pci_irq_fixup\n");
  435. /* Fixup IRQ for PCIe host */
  436. if (u4_pcie != NULL && dev->bus->number == 0 &&
  437. pci_bus_to_host(dev->bus) == u4_pcie) {
  438. printk(KERN_DEBUG "Fixup U4 PCIe IRQ\n");
  439. dev->irq = irq_create_mapping(NULL, 1);
  440. if (dev->irq != NO_IRQ)
  441. set_irq_type(dev->irq, IRQ_TYPE_LEVEL_LOW);
  442. }
  443. /* Hide AMD8111 IDE interrupt when in legacy mode so
  444. * the driver calls pci_get_legacy_ide_irq()
  445. */
  446. if (dev->vendor == PCI_VENDOR_ID_AMD &&
  447. dev->device == PCI_DEVICE_ID_AMD_8111_IDE &&
  448. (dev->class & 5) != 5) {
  449. dev->irq = NO_IRQ;
  450. }
  451. DBG(" <- maple_pci_irq_fixup\n");
  452. }
  453. static void __init maple_fixup_phb_resources(void)
  454. {
  455. struct pci_controller *hose, *tmp;
  456. list_for_each_entry_safe(hose, tmp, &hose_list, list_node) {
  457. unsigned long offset = (unsigned long)hose->io_base_virt - pci_io_base;
  458. hose->io_resource.start += offset;
  459. hose->io_resource.end += offset;
  460. printk(KERN_INFO "PCI Host %d, io start: %llx; io end: %llx\n",
  461. hose->global_number,
  462. (unsigned long long)hose->io_resource.start,
  463. (unsigned long long)hose->io_resource.end);
  464. }
  465. }
  466. void __init maple_pci_init(void)
  467. {
  468. struct device_node *np, *root;
  469. struct device_node *ht = NULL;
  470. /* Probe root PCI hosts, that is on U3 the AGP host and the
  471. * HyperTransport host. That one is actually "kept" around
  472. * and actually added last as it's resource management relies
  473. * on the AGP resources to have been setup first
  474. */
  475. root = of_find_node_by_path("/");
  476. if (root == NULL) {
  477. printk(KERN_CRIT "maple_find_bridges: can't find root of device tree\n");
  478. return;
  479. }
  480. for (np = NULL; (np = of_get_next_child(root, np)) != NULL;) {
  481. if (!np->type)
  482. continue;
  483. if (strcmp(np->type, "pci") && strcmp(np->type, "ht"))
  484. continue;
  485. if ((device_is_compatible(np, "u4-pcie") ||
  486. device_is_compatible(np, "u3-agp")) &&
  487. add_bridge(np) == 0)
  488. of_node_get(np);
  489. if (device_is_compatible(np, "u3-ht")) {
  490. of_node_get(np);
  491. ht = np;
  492. }
  493. }
  494. of_node_put(root);
  495. /* Now setup the HyperTransport host if we found any
  496. */
  497. if (ht && add_bridge(ht) != 0)
  498. of_node_put(ht);
  499. /*
  500. * We need to call pci_setup_phb_io for the HT bridge first
  501. * so it gets the I/O port numbers starting at 0, and we
  502. * need to call it for the AGP bridge after that so it gets
  503. * small positive I/O port numbers.
  504. */
  505. if (u3_ht)
  506. pci_setup_phb_io(u3_ht, 1);
  507. if (u3_agp)
  508. pci_setup_phb_io(u3_agp, 0);
  509. if (u4_pcie)
  510. pci_setup_phb_io(u4_pcie, 0);
  511. /* Fixup the IO resources on our host bridges as the common code
  512. * does it only for childs of the host bridges
  513. */
  514. maple_fixup_phb_resources();
  515. /* Setup the linkage between OF nodes and PHBs */
  516. pci_devs_phb_init();
  517. /* Fixup the PCI<->OF mapping for U3 AGP due to bus renumbering. We
  518. * assume there is no P2P bridge on the AGP bus, which should be a
  519. * safe assumptions hopefully.
  520. */
  521. if (u3_agp) {
  522. struct device_node *np = u3_agp->arch_data;
  523. PCI_DN(np)->busno = 0xf0;
  524. for (np = np->child; np; np = np->sibling)
  525. PCI_DN(np)->busno = 0xf0;
  526. }
  527. /* Tell pci.c to not change any resource allocations. */
  528. pci_probe_only = 1;
  529. }
  530. int maple_pci_get_legacy_ide_irq(struct pci_dev *pdev, int channel)
  531. {
  532. struct device_node *np;
  533. unsigned int defirq = channel ? 15 : 14;
  534. unsigned int irq;
  535. if (pdev->vendor != PCI_VENDOR_ID_AMD ||
  536. pdev->device != PCI_DEVICE_ID_AMD_8111_IDE)
  537. return defirq;
  538. np = pci_device_to_OF_node(pdev);
  539. if (np == NULL) {
  540. printk("Failed to locate OF node for IDE %s\n",
  541. pci_name(pdev));
  542. return defirq;
  543. }
  544. irq = irq_of_parse_and_map(np, channel & 0x1);
  545. if (irq == NO_IRQ) {
  546. printk("Failed to map onboard IDE interrupt for channel %d\n",
  547. channel);
  548. return defirq;
  549. }
  550. return irq;
  551. }
  552. /* XXX: To remove once all firmwares are ok */
  553. static void fixup_maple_ide(struct pci_dev* dev)
  554. {
  555. if (!machine_is(maple))
  556. return;
  557. #if 0 /* Enable this to enable IDE port 0 */
  558. {
  559. u8 v;
  560. pci_read_config_byte(dev, 0x40, &v);
  561. v |= 2;
  562. pci_write_config_byte(dev, 0x40, v);
  563. }
  564. #endif
  565. #if 0 /* fix bus master base */
  566. pci_write_config_dword(dev, 0x20, 0xcc01);
  567. printk("old ide resource: %lx -> %lx \n",
  568. dev->resource[4].start, dev->resource[4].end);
  569. dev->resource[4].start = 0xcc00;
  570. dev->resource[4].end = 0xcc10;
  571. #endif
  572. #if 0 /* Enable this to fixup IDE sense/polarity of irqs in IO-APICs */
  573. {
  574. struct pci_dev *apicdev;
  575. u32 v;
  576. apicdev = pci_get_slot (dev->bus, PCI_DEVFN(5,0));
  577. if (apicdev == NULL)
  578. printk("IDE Fixup IRQ: Can't find IO-APIC !\n");
  579. else {
  580. pci_write_config_byte(apicdev, 0xf2, 0x10 + 2*14);
  581. pci_read_config_dword(apicdev, 0xf4, &v);
  582. v &= ~0x00000022;
  583. pci_write_config_dword(apicdev, 0xf4, v);
  584. pci_write_config_byte(apicdev, 0xf2, 0x10 + 2*15);
  585. pci_read_config_dword(apicdev, 0xf4, &v);
  586. v &= ~0x00000022;
  587. pci_write_config_dword(apicdev, 0xf4, v);
  588. pci_dev_put(apicdev);
  589. }
  590. }
  591. #endif
  592. }
  593. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_8111_IDE,
  594. fixup_maple_ide);