pci.c 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. * pci.c
  3. *
  4. * Copyright (C) 2007 Lemote, Inc. & Institute of Computing Technology
  5. * Author: Fuxin Zhang, zhangfx@lemote.com
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License as published by the
  9. * Free Software Foundation; either version 2 of the License, or (at your
  10. * option) any later version.
  11. *
  12. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
  13. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  14. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
  15. * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  16. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  17. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  18. * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  19. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  20. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  21. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  22. *
  23. * You should have received a copy of the GNU General Public License along
  24. * with this program; if not, write to the Free Software Foundation, Inc.,
  25. * 675 Mass Ave, Cambridge, MA 02139, USA.
  26. *
  27. */
  28. #include <linux/types.h>
  29. #include <linux/pci.h>
  30. #include <linux/kernel.h>
  31. #include <linux/init.h>
  32. #include <asm/mips-boards/bonito64.h>
  33. #include <asm/mach-lemote/pci.h>
  34. extern struct pci_ops bonito64_pci_ops;
  35. static struct resource loongson2e_pci_mem_resource = {
  36. .name = "LOONGSON2E PCI MEM",
  37. .start = LOONGSON2E_PCI_MEM_START,
  38. .end = LOONGSON2E_PCI_MEM_END,
  39. .flags = IORESOURCE_MEM,
  40. };
  41. static struct resource loongson2e_pci_io_resource = {
  42. .name = "LOONGSON2E PCI IO MEM",
  43. .start = LOONGSON2E_PCI_IO_START,
  44. .end = IO_SPACE_LIMIT,
  45. .flags = IORESOURCE_IO,
  46. };
  47. static struct pci_controller loongson2e_pci_controller = {
  48. .pci_ops = &bonito64_pci_ops,
  49. .io_resource = &loongson2e_pci_io_resource,
  50. .mem_resource = &loongson2e_pci_mem_resource,
  51. .mem_offset = 0x00000000UL,
  52. .io_offset = 0x00000000UL,
  53. };
  54. static void __init ict_pcimap(void)
  55. {
  56. /*
  57. * local to PCI mapping: [256M,512M] -> [256M,512M]; differ from PMON
  58. *
  59. * CPU address space [256M,448M] is window for accessing pci space
  60. * we set pcimap_lo[0,1,2] to map it to pci space [256M,448M]
  61. * pcimap: bit18,pcimap_2; bit[17-12],lo2;bit[11-6],lo1;bit[5-0],lo0
  62. */
  63. /* 1,00 0110 ,0001 01,00 0000 */
  64. BONITO_PCIMAP = 0x46140;
  65. /* 1, 00 0010, 0000,01, 00 0000 */
  66. /* BONITO_PCIMAP = 0x42040; */
  67. /*
  68. * PCI to local mapping: [2G,2G+256M] -> [0,256M]
  69. */
  70. BONITO_PCIBASE0 = 0x80000000;
  71. BONITO_PCIBASE1 = 0x00800000;
  72. BONITO_PCIBASE2 = 0x90000000;
  73. }
  74. static int __init pcibios_init(void)
  75. {
  76. ict_pcimap();
  77. loongson2e_pci_controller.io_map_base =
  78. (unsigned long) ioremap(LOONGSON2E_IO_PORT_BASE,
  79. loongson2e_pci_io_resource.end -
  80. loongson2e_pci_io_resource.start + 1);
  81. register_pci_controller(&loongson2e_pci_controller);
  82. return 0;
  83. }
  84. arch_initcall(pcibios_init);