pci.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. extern struct pci_ops bonito64_pci_ops;
  34. static struct resource loongson2e_pci_mem_resource = {
  35. .name = "LOONGSON2E PCI MEM",
  36. .start = 0x14000000UL,
  37. .end = 0x1fffffffUL,
  38. .flags = IORESOURCE_MEM,
  39. };
  40. static struct resource loongson2e_pci_io_resource = {
  41. .name = "LOONGSON2E PCI IO MEM",
  42. .start = 0x00004000UL,
  43. .end = IO_SPACE_LIMIT,
  44. .flags = IORESOURCE_IO,
  45. };
  46. static struct pci_controller loongson2e_pci_controller = {
  47. .pci_ops = &bonito64_pci_ops,
  48. .io_resource = &loongson2e_pci_io_resource,
  49. .mem_resource = &loongson2e_pci_mem_resource,
  50. .mem_offset = 0x00000000UL,
  51. .io_offset = 0x00000000UL,
  52. };
  53. static void __init ict_pcimap(void)
  54. {
  55. /*
  56. * local to PCI mapping: [256M,512M] -> [256M,512M]; differ from PMON
  57. *
  58. * CPU address space [256M,448M] is window for accessing pci space
  59. * we set pcimap_lo[0,1,2] to map it to pci space [256M,448M]
  60. * pcimap: bit18,pcimap_2; bit[17-12],lo2;bit[11-6],lo1;bit[5-0],lo0
  61. */
  62. /* 1,00 0110 ,0001 01,00 0000 */
  63. BONITO_PCIMAP = 0x46140;
  64. /* 1, 00 0010, 0000,01, 00 0000 */
  65. /* BONITO_PCIMAP = 0x42040; */
  66. /*
  67. * PCI to local mapping: [2G,2G+256M] -> [0,256M]
  68. */
  69. BONITO_PCIBASE0 = 0x80000000;
  70. BONITO_PCIBASE1 = 0x00800000;
  71. BONITO_PCIBASE2 = 0x90000000;
  72. }
  73. static int __init pcibios_init(void)
  74. {
  75. ict_pcimap();
  76. register_pci_controller(&loongson2e_pci_controller);
  77. return 0;
  78. }
  79. arch_initcall(pcibios_init);