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