pci.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * Copyright (C) 2007 Lemote, Inc. & Institute of Computing Technology
  3. * Author: Fuxin Zhang, zhangfx@lemote.com
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of the GNU General Public License as published by the
  7. * Free Software Foundation; either version 2 of the License, or (at your
  8. * option) any later version.
  9. */
  10. #include <linux/pci.h>
  11. #include <pci.h>
  12. #include <loongson.h>
  13. static struct resource loongson2e_pci_mem_resource = {
  14. .name = "LOONGSON2E PCI MEM",
  15. .start = LOONGSON2E_PCI_MEM_START,
  16. .end = LOONGSON2E_PCI_MEM_END,
  17. .flags = IORESOURCE_MEM,
  18. };
  19. static struct resource loongson2e_pci_io_resource = {
  20. .name = "LOONGSON2E PCI IO MEM",
  21. .start = LOONGSON2E_PCI_IO_START,
  22. .end = IO_SPACE_LIMIT,
  23. .flags = IORESOURCE_IO,
  24. };
  25. static struct pci_controller loongson2e_pci_controller = {
  26. .pci_ops = &bonito64_pci_ops,
  27. .io_resource = &loongson2e_pci_io_resource,
  28. .mem_resource = &loongson2e_pci_mem_resource,
  29. .mem_offset = 0x00000000UL,
  30. .io_offset = 0x00000000UL,
  31. };
  32. static void __init ict_pcimap(void)
  33. {
  34. /*
  35. * local to PCI mapping: [256M,512M] -> [256M,512M]; differ from PMON
  36. *
  37. * CPU address space [256M,448M] is window for accessing pci space
  38. * we set pcimap_lo[0,1,2] to map it to pci space [256M,448M]
  39. * pcimap: bit18,pcimap_2; bit[17-12],lo2;bit[11-6],lo1;bit[5-0],lo0
  40. */
  41. /* 1,00 0110 ,0001 01,00 0000 */
  42. BONITO_PCIMAP = 0x46140;
  43. /* 1, 00 0010, 0000,01, 00 0000 */
  44. /* BONITO_PCIMAP = 0x42040; */
  45. /*
  46. * PCI to local mapping: [2G,2G+256M] -> [0,256M]
  47. */
  48. BONITO_PCIBASE0 = 0x80000000;
  49. BONITO_PCIBASE1 = 0x00800000;
  50. BONITO_PCIBASE2 = 0x90000000;
  51. }
  52. static int __init pcibios_init(void)
  53. {
  54. ict_pcimap();
  55. loongson2e_pci_controller.io_map_base = mips_io_port_base;
  56. register_pci_controller(&loongson2e_pci_controller);
  57. return 0;
  58. }
  59. arch_initcall(pcibios_init);