pci.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696
  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. /* The bus contains a bridge from root -> device, we need to
  378. * make it visible on bus 0 so that we pick the right type
  379. * of config cycles. If we didn't, we would have to force all
  380. * config cycles to be type 1. So we override the "bus-range"
  381. * property here
  382. */
  383. hose->first_busno = 0x00;
  384. hose->last_busno = 0xff;
  385. u4_pcie = hose;
  386. }
  387. static void __init setup_u3_ht(struct pci_controller* hose)
  388. {
  389. hose->ops = &u3_ht_pci_ops;
  390. /* We hard code the address because of the different size of
  391. * the reg address cell, we shall fix that by killing struct
  392. * reg_property and using some accessor functions instead
  393. */
  394. hose->cfg_data = ioremap(0xf2000000, 0x02000000);
  395. hose->first_busno = 0;
  396. hose->last_busno = 0xef;
  397. u3_ht = hose;
  398. }
  399. static int __init add_bridge(struct device_node *dev)
  400. {
  401. int len;
  402. struct pci_controller *hose;
  403. char* disp_name;
  404. const int *bus_range;
  405. int primary = 1;
  406. DBG("Adding PCI host bridge %s\n", dev->full_name);
  407. bus_range = get_property(dev, "bus-range", &len);
  408. if (bus_range == NULL || len < 2 * sizeof(int)) {
  409. printk(KERN_WARNING "Can't get bus-range for %s, assume bus 0\n",
  410. dev->full_name);
  411. }
  412. hose = pcibios_alloc_controller(dev);
  413. if (hose == NULL)
  414. return -ENOMEM;
  415. hose->first_busno = bus_range ? bus_range[0] : 0;
  416. hose->last_busno = bus_range ? bus_range[1] : 0xff;
  417. disp_name = NULL;
  418. if (device_is_compatible(dev, "u3-agp")) {
  419. setup_u3_agp(hose);
  420. disp_name = "U3-AGP";
  421. primary = 0;
  422. } else if (device_is_compatible(dev, "u3-ht")) {
  423. setup_u3_ht(hose);
  424. disp_name = "U3-HT";
  425. primary = 1;
  426. } else if (device_is_compatible(dev, "u4-pcie")) {
  427. setup_u4_pcie(hose);
  428. disp_name = "U4-PCIE";
  429. primary = 0;
  430. }
  431. printk(KERN_INFO "Found %s PCI host bridge. Firmware bus number: %d->%d\n",
  432. disp_name, hose->first_busno, hose->last_busno);
  433. /* Interpret the "ranges" property */
  434. /* This also maps the I/O region and sets isa_io/mem_base */
  435. pci_process_bridge_OF_ranges(hose, dev, primary);
  436. /* Fixup "bus-range" OF property */
  437. fixup_bus_range(dev);
  438. return 0;
  439. }
  440. void __init maple_pcibios_fixup(void)
  441. {
  442. struct pci_dev *dev = NULL;
  443. DBG(" -> maple_pcibios_fixup\n");
  444. for_each_pci_dev(dev) {
  445. /* Fixup IRQ for PCIe host */
  446. if (u4_pcie != NULL && dev->bus->number == 0 &&
  447. pci_bus_to_host(dev->bus) == u4_pcie) {
  448. printk(KERN_DEBUG "Fixup U4 PCIe IRQ\n");
  449. dev->irq = irq_create_mapping(NULL, 1);
  450. if (dev->irq != NO_IRQ)
  451. set_irq_type(dev->irq, IRQ_TYPE_LEVEL_LOW);
  452. continue;
  453. }
  454. /* Hide AMD8111 IDE interrupt when in legacy mode so
  455. * the driver calls pci_get_legacy_ide_irq()
  456. */
  457. if (dev->vendor == PCI_VENDOR_ID_AMD &&
  458. dev->device == PCI_DEVICE_ID_AMD_8111_IDE &&
  459. (dev->class & 5) != 5) {
  460. dev->irq = NO_IRQ;
  461. continue;
  462. }
  463. /* For all others, map the interrupt from the device-tree */
  464. pci_read_irq_line(dev);
  465. }
  466. DBG(" <- maple_pcibios_fixup\n");
  467. }
  468. static void __init maple_fixup_phb_resources(void)
  469. {
  470. struct pci_controller *hose, *tmp;
  471. list_for_each_entry_safe(hose, tmp, &hose_list, list_node) {
  472. unsigned long offset = (unsigned long)hose->io_base_virt - pci_io_base;
  473. hose->io_resource.start += offset;
  474. hose->io_resource.end += offset;
  475. printk(KERN_INFO "PCI Host %d, io start: %llx; io end: %llx\n",
  476. hose->global_number,
  477. (unsigned long long)hose->io_resource.start,
  478. (unsigned long long)hose->io_resource.end);
  479. }
  480. }
  481. void __init maple_pci_init(void)
  482. {
  483. struct device_node *np, *root;
  484. struct device_node *ht = NULL;
  485. /* Probe root PCI hosts, that is on U3 the AGP host and the
  486. * HyperTransport host. That one is actually "kept" around
  487. * and actually added last as it's resource management relies
  488. * on the AGP resources to have been setup first
  489. */
  490. root = of_find_node_by_path("/");
  491. if (root == NULL) {
  492. printk(KERN_CRIT "maple_find_bridges: can't find root of device tree\n");
  493. return;
  494. }
  495. for (np = NULL; (np = of_get_next_child(root, np)) != NULL;) {
  496. if (np->name == NULL)
  497. continue;
  498. if (strcmp(np->name, "pci") == 0) {
  499. if (add_bridge(np) == 0)
  500. of_node_get(np);
  501. }
  502. if (strcmp(np->name, "ht") == 0) {
  503. of_node_get(np);
  504. ht = np;
  505. }
  506. }
  507. of_node_put(root);
  508. /* Now setup the HyperTransport host if we found any
  509. */
  510. if (ht && add_bridge(ht) != 0)
  511. of_node_put(ht);
  512. /*
  513. * We need to call pci_setup_phb_io for the HT bridge first
  514. * so it gets the I/O port numbers starting at 0, and we
  515. * need to call it for the AGP bridge after that so it gets
  516. * small positive I/O port numbers.
  517. */
  518. if (u3_ht)
  519. pci_setup_phb_io(u3_ht, 1);
  520. if (u3_agp)
  521. pci_setup_phb_io(u3_agp, 0);
  522. if (u4_pcie)
  523. pci_setup_phb_io(u4_pcie, 0);
  524. /* Fixup the IO resources on our host bridges as the common code
  525. * does it only for childs of the host bridges
  526. */
  527. maple_fixup_phb_resources();
  528. /* Setup the linkage between OF nodes and PHBs */
  529. pci_devs_phb_init();
  530. /* Fixup the PCI<->OF mapping for U3 AGP due to bus renumbering. We
  531. * assume there is no P2P bridge on the AGP bus, which should be a
  532. * safe assumptions hopefully.
  533. */
  534. if (u3_agp) {
  535. struct device_node *np = u3_agp->arch_data;
  536. PCI_DN(np)->busno = 0xf0;
  537. for (np = np->child; np; np = np->sibling)
  538. PCI_DN(np)->busno = 0xf0;
  539. }
  540. /* Tell pci.c to not change any resource allocations. */
  541. pci_probe_only = 1;
  542. }
  543. int maple_pci_get_legacy_ide_irq(struct pci_dev *pdev, int channel)
  544. {
  545. struct device_node *np;
  546. unsigned int defirq = channel ? 15 : 14;
  547. unsigned int irq;
  548. if (pdev->vendor != PCI_VENDOR_ID_AMD ||
  549. pdev->device != PCI_DEVICE_ID_AMD_8111_IDE)
  550. return defirq;
  551. np = pci_device_to_OF_node(pdev);
  552. if (np == NULL) {
  553. printk("Failed to locate OF node for IDE %s\n",
  554. pci_name(pdev));
  555. return defirq;
  556. }
  557. irq = irq_of_parse_and_map(np, channel & 0x1);
  558. if (irq == NO_IRQ) {
  559. printk("Failed to map onboard IDE interrupt for channel %d\n",
  560. channel);
  561. return defirq;
  562. }
  563. return irq;
  564. }
  565. /* XXX: To remove once all firmwares are ok */
  566. static void fixup_maple_ide(struct pci_dev* dev)
  567. {
  568. if (!machine_is(maple))
  569. return;
  570. #if 0 /* Enable this to enable IDE port 0 */
  571. {
  572. u8 v;
  573. pci_read_config_byte(dev, 0x40, &v);
  574. v |= 2;
  575. pci_write_config_byte(dev, 0x40, v);
  576. }
  577. #endif
  578. #if 0 /* fix bus master base */
  579. pci_write_config_dword(dev, 0x20, 0xcc01);
  580. printk("old ide resource: %lx -> %lx \n",
  581. dev->resource[4].start, dev->resource[4].end);
  582. dev->resource[4].start = 0xcc00;
  583. dev->resource[4].end = 0xcc10;
  584. #endif
  585. #if 0 /* Enable this to fixup IDE sense/polarity of irqs in IO-APICs */
  586. {
  587. struct pci_dev *apicdev;
  588. u32 v;
  589. apicdev = pci_get_slot (dev->bus, PCI_DEVFN(5,0));
  590. if (apicdev == NULL)
  591. printk("IDE Fixup IRQ: Can't find IO-APIC !\n");
  592. else {
  593. pci_write_config_byte(apicdev, 0xf2, 0x10 + 2*14);
  594. pci_read_config_dword(apicdev, 0xf4, &v);
  595. v &= ~0x00000022;
  596. pci_write_config_dword(apicdev, 0xf4, v);
  597. pci_write_config_byte(apicdev, 0xf2, 0x10 + 2*15);
  598. pci_read_config_dword(apicdev, 0xf4, &v);
  599. v &= ~0x00000022;
  600. pci_write_config_dword(apicdev, 0xf4, v);
  601. pci_dev_put(apicdev);
  602. }
  603. }
  604. #endif
  605. }
  606. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_8111_IDE,
  607. fixup_maple_ide);