pci.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * (C) Copyright 2002 ELTEC Elektronik AG
  3. * Frank Gottschling <fgottschling@eltec.de>
  4. *
  5. * SPDX-License-Identifier: GPL-2.0+
  6. */
  7. /*
  8. * PCI initialisation for the MPC10x.
  9. */
  10. #include <common.h>
  11. #include <pci.h>
  12. #include <mpc106.h>
  13. #ifdef CONFIG_PCI
  14. struct pci_controller local_hose;
  15. void pci_init_board(void)
  16. {
  17. struct pci_controller* hose = (struct pci_controller *)&local_hose;
  18. u16 reg16;
  19. hose->first_busno = 0;
  20. hose->last_busno = 0xff;
  21. pci_set_region(hose->regions + 0,
  22. CONFIG_SYS_PCI_MEMORY_BUS,
  23. CONFIG_SYS_PCI_MEMORY_PHYS,
  24. CONFIG_SYS_PCI_MEMORY_SIZE,
  25. PCI_REGION_MEM | PCI_REGION_SYS_MEMORY);
  26. /* PCI memory space */
  27. pci_set_region(hose->regions + 1,
  28. CONFIG_SYS_PCI_MEM_BUS,
  29. CONFIG_SYS_PCI_MEM_PHYS,
  30. CONFIG_SYS_PCI_MEM_SIZE,
  31. PCI_REGION_MEM);
  32. /* ISA/PCI memory space */
  33. pci_set_region(hose->regions + 2,
  34. CONFIG_SYS_ISA_MEM_BUS,
  35. CONFIG_SYS_ISA_MEM_PHYS,
  36. CONFIG_SYS_ISA_MEM_SIZE,
  37. PCI_REGION_MEM);
  38. /* PCI I/O space */
  39. pci_set_region(hose->regions + 3,
  40. CONFIG_SYS_PCI_IO_BUS,
  41. CONFIG_SYS_PCI_IO_PHYS,
  42. CONFIG_SYS_PCI_IO_SIZE,
  43. PCI_REGION_IO);
  44. /* ISA/PCI I/O space */
  45. pci_set_region(hose->regions + 4,
  46. CONFIG_SYS_ISA_IO_BUS,
  47. CONFIG_SYS_ISA_IO_PHYS,
  48. CONFIG_SYS_ISA_IO_SIZE,
  49. PCI_REGION_IO);
  50. hose->region_count = 5;
  51. pci_setup_indirect(hose,
  52. MPC106_REG_ADDR,
  53. MPC106_REG_DATA);
  54. pci_register_hose(hose);
  55. hose->last_busno = pci_hose_scan(hose);
  56. /* Initialises the MPC10x PCI Configuration regs. */
  57. pci_read_config_word (PCI_BDF(0,0,0), PCI_COMMAND, &reg16);
  58. reg16 |= PCI_COMMAND_SERR | PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY;
  59. pci_write_config_word(PCI_BDF(0,0,0), PCI_COMMAND, reg16);
  60. /* Clear non-reserved bits in status register */
  61. pci_write_config_word(PCI_BDF(0,0,0), PCI_STATUS, 0xffff);
  62. }
  63. #endif /* CONFIG_PCI */