blob: bee846e6d8a88708c4ab4d5c8ff98ef26bd7b46c [file] [log] [blame]
Songmao Tian42d226c2007-06-06 14:52:38 +08001/*
Songmao Tian42d226c2007-06-06 14:52:38 +08002 * 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 Tian42d226c2007-06-06 14:52:38 +08009 */
Songmao Tian42d226c2007-06-06 14:52:38 +080010#include <linux/pci.h>
Songmao Tian42d226c2007-06-06 14:52:38 +080011
Wu Zhangjin5e983ff2009-07-02 23:23:03 +080012#include <pci.h>
13#include <loongson.h>
Songmao Tian42d226c2007-06-06 14:52:38 +080014
15static struct resource loongson2e_pci_mem_resource = {
16 .name = "LOONGSON2E PCI MEM",
Zhang Le3a639132008-10-27 23:33:24 +000017 .start = LOONGSON2E_PCI_MEM_START,
18 .end = LOONGSON2E_PCI_MEM_END,
Songmao Tian42d226c2007-06-06 14:52:38 +080019 .flags = IORESOURCE_MEM,
20};
21
22static struct resource loongson2e_pci_io_resource = {
23 .name = "LOONGSON2E PCI IO MEM",
Zhang Le3a639132008-10-27 23:33:24 +000024 .start = LOONGSON2E_PCI_IO_START,
Songmao Tian42d226c2007-06-06 14:52:38 +080025 .end = IO_SPACE_LIMIT,
26 .flags = IORESOURCE_IO,
27};
28
29static 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
37static 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
61static int __init pcibios_init(void)
62{
Songmao Tian42d226c2007-06-06 14:52:38 +080063 ict_pcimap();
Zhang Le3a639132008-10-27 23:33:24 +000064
Wu Zhangjinf54a40e2009-07-02 23:22:11 +080065 loongson2e_pci_controller.io_map_base = mips_io_port_base;
Zhang Le3a639132008-10-27 23:33:24 +000066
Songmao Tian42d226c2007-06-06 14:52:38 +080067 register_pci_controller(&loongson2e_pci_controller);
68
69 return 0;
70}
71
72arch_initcall(pcibios_init);