pci.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*
  2. * FSL SoC setup code
  3. *
  4. * Maintained by Kumar Gala (see MAINTAINERS for contact information)
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License as published by the
  8. * Free Software Foundation; either version 2 of the License, or (at your
  9. * option) any later version.
  10. */
  11. #include <linux/stddef.h>
  12. #include <linux/kernel.h>
  13. #include <linux/init.h>
  14. #include <linux/errno.h>
  15. #include <linux/pci.h>
  16. #include <linux/delay.h>
  17. #include <linux/irq.h>
  18. #include <linux/module.h>
  19. #include <asm/system.h>
  20. #include <asm/atomic.h>
  21. #include <asm/io.h>
  22. #include <asm/pci-bridge.h>
  23. #include <asm/prom.h>
  24. #include <sysdev/fsl_soc.h>
  25. #undef DEBUG
  26. #ifdef DEBUG
  27. #define DBG(x...) printk(x)
  28. #else
  29. #define DBG(x...)
  30. #endif
  31. int mpc85xx_pci2_busno = 0;
  32. #ifdef CONFIG_PCI
  33. int __init add_bridge(struct device_node *dev)
  34. {
  35. int len;
  36. struct pci_controller *hose;
  37. struct resource rsrc;
  38. const int *bus_range;
  39. int primary = 1, has_address = 0;
  40. phys_addr_t immr = get_immrbase();
  41. DBG("Adding PCI host bridge %s\n", dev->full_name);
  42. /* Fetch host bridge registers address */
  43. has_address = (of_address_to_resource(dev, 0, &rsrc) == 0);
  44. /* Get bus range if any */
  45. bus_range = get_property(dev, "bus-range", &len);
  46. if (bus_range == NULL || len < 2 * sizeof(int)) {
  47. printk(KERN_WARNING "Can't get bus-range for %s, assume"
  48. " bus 0\n", dev->full_name);
  49. }
  50. hose = pcibios_alloc_controller();
  51. if (!hose)
  52. return -ENOMEM;
  53. hose->arch_data = dev;
  54. hose->set_cfg_type = 1;
  55. hose->first_busno = bus_range ? bus_range[0] : 0;
  56. hose->last_busno = bus_range ? bus_range[1] : 0xff;
  57. /* PCI 1 */
  58. if ((rsrc.start & 0xfffff) == 0x8000) {
  59. setup_indirect_pci(hose, immr + 0x8000, immr + 0x8004);
  60. }
  61. /* PCI 2 */
  62. if ((rsrc.start & 0xfffff) == 0x9000) {
  63. setup_indirect_pci(hose, immr + 0x9000, immr + 0x9004);
  64. primary = 0;
  65. hose->bus_offset = hose->first_busno;
  66. mpc85xx_pci2_busno = hose->first_busno;
  67. }
  68. printk(KERN_INFO "Found MPC85xx PCI host bridge at 0x%016llx. "
  69. "Firmware bus number: %d->%d\n",
  70. (unsigned long long)rsrc.start, hose->first_busno,
  71. hose->last_busno);
  72. DBG(" ->Hose at 0x%p, cfg_addr=0x%p,cfg_data=0x%p\n",
  73. hose, hose->cfg_addr, hose->cfg_data);
  74. /* Interpret the "ranges" property */
  75. /* This also maps the I/O region and sets isa_io/mem_base */
  76. pci_process_bridge_OF_ranges(hose, dev, primary);
  77. return 0;
  78. }
  79. #endif