pcippc2_fpga.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * (C) Copyright 2002
  3. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. */
  23. #include <config.h>
  24. #include <common.h>
  25. #include <asm/io.h>
  26. #include "pci.h"
  27. #include "hardware.h"
  28. #include "pcippc2.h"
  29. u32 pcippc2_fpga0_phys;
  30. u32 pcippc2_fpga1_phys;
  31. void pcippc2_fpga_init (void)
  32. {
  33. pci_dev_t bdf = pci_find_device(FPGA_VENDOR_ID, FPGA_DEVICE_ID, 0);
  34. unsigned int addr;
  35. u16 cmd;
  36. if (bdf == -1)
  37. {
  38. puts("Unable to find FPGA !\n");
  39. hang();
  40. }
  41. pci_read_config_word(bdf, PCI_COMMAND, &cmd);
  42. if ((cmd & (PCI_COMMAND_MEMORY | PCI_COMMAND_IO)) != (PCI_COMMAND_MEMORY | PCI_COMMAND_IO))
  43. {
  44. puts("FPGA is not configured !\n");
  45. hang();
  46. }
  47. pci_read_config_dword(bdf, PCI_BASE_ADDRESS_0, &addr);
  48. if (addr & 0x1)
  49. {
  50. /* IO space
  51. */
  52. pcippc2_fpga0_phys = pci_io_to_phys(bdf, addr & 0xfffffffc);
  53. }
  54. else
  55. {
  56. /* Memory space
  57. */
  58. pcippc2_fpga0_phys = pci_mem_to_phys(bdf, addr & 0xfffffff0);
  59. }
  60. pci_read_config_dword(bdf, PCI_BASE_ADDRESS_1, &addr);
  61. if (addr & 0x1)
  62. {
  63. /* IO space
  64. */
  65. pcippc2_fpga1_phys = pci_io_to_phys(bdf, addr & 0xfffffffc);
  66. }
  67. else
  68. {
  69. /* Memory space
  70. */
  71. pcippc2_fpga1_phys = pci_mem_to_phys(bdf, addr & 0xfffffff0);
  72. }
  73. /* Interrupts are not used
  74. */
  75. out32(FPGA(INT, INTR_MASK), 0xffffffff);
  76. iobarrier_rw();
  77. }