1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (C) NEC Electronics Corporation 2004-2006
5 * This file is based on the arch/mips/ddb5xxx/ddb5477/pci.c
7 * Copyright 2001 MontaVista Software Inc.
10 #include <linux/kernel.h>
11 #include <linux/init.h>
12 #include <linux/types.h>
13 #include <linux/pci.h>
15 #include <asm/bootinfo.h>
17 #include <asm/emma/emma2rh.h>
19 static struct resource pci_io_resource
= {
20 .name
= "pci IO space",
21 .start
= EMMA2RH_PCI_IO_BASE
,
22 .end
= EMMA2RH_PCI_IO_BASE
+ EMMA2RH_PCI_IO_SIZE
- 1,
23 .flags
= IORESOURCE_IO
,
26 static struct resource pci_mem_resource
= {
27 .name
= "pci memory space",
28 .start
= EMMA2RH_PCI_MEM_BASE
,
29 .end
= EMMA2RH_PCI_MEM_BASE
+ EMMA2RH_PCI_MEM_SIZE
- 1,
30 .flags
= IORESOURCE_MEM
,
33 extern struct pci_ops emma2rh_pci_ops
;
35 static struct pci_controller emma2rh_pci_controller
= {
36 .pci_ops
= &emma2rh_pci_ops
,
37 .mem_resource
= &pci_mem_resource
,
38 .io_resource
= &pci_io_resource
,
39 .mem_offset
= -0x04000000,
43 static void __init
emma2rh_pci_init(void)
45 /* setup PCI interface */
46 emma2rh_out32(EMMA2RH_PCI_ARBIT_CTR
, 0x70f);
48 emma2rh_out32(EMMA2RH_PCI_IWIN0_CTR
, 0x80000a18);
49 emma2rh_out32(EMMA2RH_PCI_CONFIG_BASE
+ PCI_COMMAND
,
50 PCI_STATUS_DEVSEL_MEDIUM
| PCI_STATUS_CAP_LIST
|
51 PCI_COMMAND_MASTER
| PCI_COMMAND_MEMORY
);
52 emma2rh_out32(EMMA2RH_PCI_CONFIG_BASE
+ PCI_BASE_ADDRESS_0
, 0x10000000);
53 emma2rh_out32(EMMA2RH_PCI_CONFIG_BASE
+ PCI_BASE_ADDRESS_1
, 0x00000000);
55 emma2rh_out32(EMMA2RH_PCI_IWIN0_CTR
, 0x12000000 | 0x218);
56 emma2rh_out32(EMMA2RH_PCI_IWIN1_CTR
, 0x18000000 | 0x600);
57 emma2rh_out32(EMMA2RH_PCI_INIT_ESWP
, 0x00000200);
59 emma2rh_out32(EMMA2RH_PCI_TWIN_CTR
, 0x00009200);
60 emma2rh_out32(EMMA2RH_PCI_TWIN_BADR
, 0x00000000);
61 emma2rh_out32(EMMA2RH_PCI_TWIN0_DADR
, 0x00000000);
62 emma2rh_out32(EMMA2RH_PCI_TWIN1_DADR
, 0x00000000);
65 static int __init
emma2rh_pci_setup(void)
68 register_pci_controller(&emma2rh_pci_controller
);
72 arch_initcall(emma2rh_pci_setup
);