Songmao Tian | 42d226c | 2007-06-06 14:52:38 +0800 | [diff] [blame] | 1 | /* |
Songmao Tian | 42d226c | 2007-06-06 14:52:38 +0800 | [diff] [blame] | 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. |
Songmao Tian | 42d226c | 2007-06-06 14:52:38 +0800 | [diff] [blame] | 9 | */ |
Songmao Tian | 42d226c | 2007-06-06 14:52:38 +0800 | [diff] [blame] | 10 | #include <linux/pci.h> |
Songmao Tian | 42d226c | 2007-06-06 14:52:38 +0800 | [diff] [blame] | 11 | |
Wu Zhangjin | 5e983ff | 2009-07-02 23:23:03 +0800 | [diff] [blame^] | 12 | #include <pci.h> |
| 13 | #include <loongson.h> |
Songmao Tian | 42d226c | 2007-06-06 14:52:38 +0800 | [diff] [blame] | 14 | |
| 15 | static struct resource loongson2e_pci_mem_resource = { |
| 16 | .name = "LOONGSON2E PCI MEM", |
Zhang Le | 3a63913 | 2008-10-27 23:33:24 +0000 | [diff] [blame] | 17 | .start = LOONGSON2E_PCI_MEM_START, |
| 18 | .end = LOONGSON2E_PCI_MEM_END, |
Songmao Tian | 42d226c | 2007-06-06 14:52:38 +0800 | [diff] [blame] | 19 | .flags = IORESOURCE_MEM, |
| 20 | }; |
| 21 | |
| 22 | static struct resource loongson2e_pci_io_resource = { |
| 23 | .name = "LOONGSON2E PCI IO MEM", |
Zhang Le | 3a63913 | 2008-10-27 23:33:24 +0000 | [diff] [blame] | 24 | .start = LOONGSON2E_PCI_IO_START, |
Songmao Tian | 42d226c | 2007-06-06 14:52:38 +0800 | [diff] [blame] | 25 | .end = IO_SPACE_LIMIT, |
| 26 | .flags = IORESOURCE_IO, |
| 27 | }; |
| 28 | |
| 29 | static struct pci_controller loongson2e_pci_controller = { |
| 30 | .pci_ops = &bonito64_pci_ops, |
| 31 | .io_resource = &loongson2e_pci_io_resource, |
| 32 | .mem_resource = &loongson2e_pci_mem_resource, |
| 33 | .mem_offset = 0x00000000UL, |
| 34 | .io_offset = 0x00000000UL, |
| 35 | }; |
| 36 | |
| 37 | static void __init ict_pcimap(void) |
| 38 | { |
| 39 | /* |
| 40 | * local to PCI mapping: [256M,512M] -> [256M,512M]; differ from PMON |
| 41 | * |
| 42 | * CPU address space [256M,448M] is window for accessing pci space |
| 43 | * we set pcimap_lo[0,1,2] to map it to pci space [256M,448M] |
| 44 | * pcimap: bit18,pcimap_2; bit[17-12],lo2;bit[11-6],lo1;bit[5-0],lo0 |
| 45 | */ |
| 46 | /* 1,00 0110 ,0001 01,00 0000 */ |
| 47 | BONITO_PCIMAP = 0x46140; |
| 48 | |
| 49 | /* 1, 00 0010, 0000,01, 00 0000 */ |
| 50 | /* BONITO_PCIMAP = 0x42040; */ |
| 51 | |
| 52 | /* |
| 53 | * PCI to local mapping: [2G,2G+256M] -> [0,256M] |
| 54 | */ |
| 55 | BONITO_PCIBASE0 = 0x80000000; |
| 56 | BONITO_PCIBASE1 = 0x00800000; |
| 57 | BONITO_PCIBASE2 = 0x90000000; |
| 58 | |
| 59 | } |
| 60 | |
| 61 | static int __init pcibios_init(void) |
| 62 | { |
Songmao Tian | 42d226c | 2007-06-06 14:52:38 +0800 | [diff] [blame] | 63 | ict_pcimap(); |
Zhang Le | 3a63913 | 2008-10-27 23:33:24 +0000 | [diff] [blame] | 64 | |
Wu Zhangjin | f54a40e | 2009-07-02 23:22:11 +0800 | [diff] [blame] | 65 | loongson2e_pci_controller.io_map_base = mips_io_port_base; |
Zhang Le | 3a63913 | 2008-10-27 23:33:24 +0000 | [diff] [blame] | 66 | |
Songmao Tian | 42d226c | 2007-06-06 14:52:38 +0800 | [diff] [blame] | 67 | register_pci_controller(&loongson2e_pci_controller); |
| 68 | |
| 69 | return 0; |
| 70 | } |
| 71 | |
| 72 | arch_initcall(pcibios_init); |