pci.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * arch/sh/drivers/pci/pci.c
  3. *
  4. * Copyright (c) 2002 M. R. Brown <mrbrown@linux-sh.org>
  5. * Copyright (c) 2004 - 2006 Paul Mundt <lethal@linux-sh.org>
  6. *
  7. * These functions are collected here to reduce duplication of common
  8. * code amongst the many platform-specific PCI support code files.
  9. *
  10. * These routines require the following board-specific routines:
  11. * void pcibios_fixup_irqs();
  12. *
  13. * See include/asm-sh/pci.h for more information.
  14. *
  15. * This file is subject to the terms and conditions of the GNU General Public
  16. * License. See the file "COPYING" in the main directory of this archive
  17. * for more details.
  18. */
  19. #include <linux/kernel.h>
  20. #include <linux/pci.h>
  21. #include <linux/init.h>
  22. #include <linux/dma-debug.h>
  23. #include <asm/io.h>
  24. static int __init pcibios_init(void)
  25. {
  26. struct pci_channel *p;
  27. struct pci_bus *bus;
  28. int busno;
  29. /* init channels */
  30. busno = 0;
  31. for (p = board_pci_channels; p->init; p++) {
  32. if (p->init(p) == 0)
  33. p->enabled = 1;
  34. else
  35. pr_err("Unable to init pci channel %d\n", busno);
  36. busno++;
  37. }
  38. #ifdef CONFIG_PCI_AUTO
  39. /* assign resources */
  40. busno = 0;
  41. for (p = board_pci_channels; p->init; p++)
  42. if (p->enabled)
  43. busno = pciauto_assign_resources(busno, p) + 1;
  44. #endif
  45. /* scan the buses */
  46. busno = 0;
  47. for (p = board_pci_channels; p->init; p++) {
  48. if (p->enabled) {
  49. bus = pci_scan_bus(busno, p->pci_ops, p);
  50. busno = bus->subordinate + 1;
  51. }
  52. }
  53. pci_fixup_irqs(pci_common_swizzle, pcibios_map_platform_irq);
  54. dma_debug_add_bus(&pci_bus_type);
  55. return 0;
  56. }
  57. subsys_initcall(pcibios_init);
  58. /*
  59. * Called after each bus is probed, but before its children
  60. * are examined.
  61. */
  62. void __devinit __weak pcibios_fixup_bus(struct pci_bus *bus)
  63. {
  64. pci_read_bridge_bases(bus);
  65. }
  66. EXPORT_SYMBOL(board_pci_channels);