wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2003 |
| 3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 4 | * |
Wolfgang Denk | 716c1dc | 2005-09-25 18:49:35 +0200 | [diff] [blame] | 5 | * Copyright (c) 2005 MontaVista Software, Inc. |
Wolfgang Denk | 1972dc0 | 2005-09-25 16:27:55 +0200 | [diff] [blame] | 6 | * Vitaly Bordug <vbordug@ru.mvista.com> |
| 7 | * Added support for PCI bridge on MPC8272ADS |
| 8 | * |
Wolfgang Denk | 3765b3e | 2013-10-07 13:07:26 +0200 | [diff] [blame] | 9 | * SPDX-License-Identifier: GPL-2.0+ |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 10 | */ |
| 11 | |
| 12 | #include <common.h> |
| 13 | |
| 14 | #ifdef CONFIG_PCI |
| 15 | |
| 16 | #include <pci.h> |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 17 | #include <mpc8260.h> |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 18 | #include <asm/m8260_pci.h> |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 19 | #include <asm/io.h> |
Matvejchikov Ilya | 0e6989b | 2008-07-06 13:57:00 +0400 | [diff] [blame] | 20 | #ifdef CONFIG_OF_LIBFDT |
| 21 | #include <libfdt.h> |
| 22 | #include <fdt_support.h> |
| 23 | #endif |
Wolfgang Denk | d87080b | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 24 | |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 25 | /* |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 26 | * Local->PCI map (from CPU) controlled by |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 27 | * MPC826x master window |
| 28 | * |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 29 | * 0x80000000 - 0xBFFFFFFF CPU2PCI space PCIBR0 |
| 30 | * 0xF4000000 - 0xF7FFFFFF CPU2PCI space PCIBR1 |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 31 | * |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 32 | * 0x80000000 - 0x9FFFFFFF 0x80000000 - 0x9FFFFFFF (Outbound ATU #1) |
| 33 | * PCI Mem with prefetch |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 34 | * |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 35 | * 0xA0000000 - 0xBFFFFFFF 0xA0000000 - 0xBFFFFFFF (Outbound ATU #2) |
| 36 | * PCI Mem w/o prefetch |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 37 | * |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 38 | * 0xF4000000 - 0xF7FFFFFF 0x00000000 - 0x03FFFFFF (Outbound ATU #3) |
| 39 | * 32-bit PCI IO |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 40 | * |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 41 | * PCI->Local map (from PCI) |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 42 | * MPC826x slave window controlled by |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 43 | * |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 44 | * 0x00000000 - 0x1FFFFFFF 0x00000000 - 0x1FFFFFFF (Inbound ATU #1) |
| 45 | * MPC826x local memory |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 46 | */ |
| 47 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 48 | /* |
| 49 | * Slave window that allows PCI masters to access MPC826x local memory. |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 50 | * This window is set up using the first set of Inbound ATU registers |
| 51 | */ |
| 52 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 53 | #ifndef CONFIG_SYS_PCI_SLV_MEM_LOCAL |
| 54 | #define PCI_SLV_MEM_LOCAL CONFIG_SYS_SDRAM_BASE /* Local base */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 55 | #else |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 56 | #define PCI_SLV_MEM_LOCAL CONFIG_SYS_PCI_SLV_MEM_LOCAL |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 57 | #endif |
| 58 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 59 | #ifndef CONFIG_SYS_PCI_SLV_MEM_BUS |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 60 | #define PCI_SLV_MEM_BUS 0x00000000 /* PCI base */ |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 61 | #else |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 62 | #define PCI_SLV_MEM_BUS CONFIG_SYS_PCI_SLV_MEM_BUS |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 63 | #endif |
| 64 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 65 | #ifndef CONFIG_SYS_PICMR0_MASK_ATTRIB |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 66 | #define PICMR0_MASK_ATTRIB (PICMR_MASK_512MB | PICMR_ENABLE | \ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 67 | PICMR_PREFETCH_EN) |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 68 | #else |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 69 | #define PICMR0_MASK_ATTRIB CONFIG_SYS_PICMR0_MASK_ATTRIB |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 70 | #endif |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 71 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 72 | /* |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 73 | * These are the windows that allow the CPU to access PCI address space. |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 74 | * All three PCI master windows, which allow the CPU to access PCI |
| 75 | * prefetch, non prefetch, and IO space (see below), must all fit within |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 76 | * these windows. |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 77 | */ |
| 78 | |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 79 | /* PCIBR0 */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 80 | #ifndef CONFIG_SYS_PCI_MSTR0_LOCAL |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 81 | #define PCI_MSTR0_LOCAL 0x80000000 /* Local base */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 82 | #else |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 83 | #define PCI_MSTR0_LOCAL CONFIG_SYS_PCI_MSTR0_LOCAL |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 84 | #endif |
| 85 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 86 | #ifndef CONFIG_SYS_PCIMSK0_MASK |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 87 | #define PCIMSK0_MASK PCIMSK_1GB /* Size of window */ |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 88 | #else |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 89 | #define PCIMSK0_MASK CONFIG_SYS_PCIMSK0_MASK |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 90 | #endif |
| 91 | |
| 92 | /* PCIBR1 */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 93 | #ifndef CONFIG_SYS_PCI_MSTR1_LOCAL |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 94 | #define PCI_MSTR1_LOCAL 0xF4000000 /* Local base */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 95 | #else |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 96 | #define PCI_MSTR1_LOCAL CONFIG_SYS_PCI_MSTR1_LOCAL |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 97 | #endif |
| 98 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 99 | #ifndef CONFIG_SYS_PCIMSK1_MASK |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 100 | #define PCIMSK1_MASK PCIMSK_64MB /* Size of window */ |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 101 | #else |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 102 | #define PCIMSK1_MASK CONFIG_SYS_PCIMSK1_MASK |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 103 | #endif |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 104 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 105 | /* |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 106 | * Master window that allows the CPU to access PCI Memory (prefetch). |
| 107 | * This window will be setup with the first set of Outbound ATU registers |
| 108 | * in the bridge. |
| 109 | */ |
| 110 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 111 | #ifndef CONFIG_SYS_PCI_MSTR_MEM_LOCAL |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 112 | #define PCI_MSTR_MEM_LOCAL 0x80000000 /* Local base */ |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 113 | #else |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 114 | #define PCI_MSTR_MEM_LOCAL CONFIG_SYS_PCI_MSTR_MEM_LOCAL |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 115 | #endif |
| 116 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 117 | #ifndef CONFIG_SYS_PCI_MSTR_MEM_BUS |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 118 | #define PCI_MSTR_MEM_BUS 0x80000000 /* PCI base */ |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 119 | #else |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 120 | #define PCI_MSTR_MEM_BUS CONFIG_SYS_PCI_MSTR_MEM_BUS |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 121 | #endif |
| 122 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 123 | #ifndef CONFIG_SYS_CPU_PCI_MEM_START |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 124 | #define CPU_PCI_MEM_START PCI_MSTR_MEM_LOCAL |
| 125 | #else |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 126 | #define CPU_PCI_MEM_START CONFIG_SYS_CPU_PCI_MEM_START |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 127 | #endif |
| 128 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 129 | #ifndef CONFIG_SYS_PCI_MSTR_MEM_SIZE |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 130 | #define PCI_MSTR_MEM_SIZE 0x10000000 /* 256MB */ |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 131 | #else |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 132 | #define PCI_MSTR_MEM_SIZE CONFIG_SYS_PCI_MSTR_MEM_SIZE |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 133 | #endif |
| 134 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 135 | #ifndef CONFIG_SYS_POCMR0_MASK_ATTRIB |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 136 | #define POCMR0_MASK_ATTRIB (POCMR_MASK_256MB | POCMR_ENABLE | POCMR_PREFETCH_EN) |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 137 | #else |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 138 | #define POCMR0_MASK_ATTRIB CONFIG_SYS_POCMR0_MASK_ATTRIB |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 139 | #endif |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 140 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 141 | /* |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 142 | * Master window that allows the CPU to access PCI Memory (non-prefetch). |
| 143 | * This window will be setup with the second set of Outbound ATU registers |
| 144 | * in the bridge. |
| 145 | */ |
| 146 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 147 | #ifndef CONFIG_SYS_PCI_MSTR_MEMIO_LOCAL |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 148 | #define PCI_MSTR_MEMIO_LOCAL 0x90000000 /* Local base */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 149 | #else |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 150 | #define PCI_MSTR_MEMIO_LOCAL CONFIG_SYS_PCI_MSTR_MEMIO_LOCAL |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 151 | #endif |
| 152 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 153 | #ifndef CONFIG_SYS_PCI_MSTR_MEMIO_BUS |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 154 | #define PCI_MSTR_MEMIO_BUS 0x90000000 /* PCI base */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 155 | #else |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 156 | #define PCI_MSTR_MEMIO_BUS CONFIG_SYS_PCI_MSTR_MEMIO_BUS |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 157 | #endif |
| 158 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 159 | #ifndef CONFIG_SYS_CPU_PCI_MEMIO_START |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 160 | #define CPU_PCI_MEMIO_START PCI_MSTR_MEMIO_LOCAL |
| 161 | #else |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 162 | #define CPU_PCI_MEMIO_START CONFIG_SYS_CPU_PCI_MEMIO_START |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 163 | #endif |
| 164 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 165 | #ifndef CONFIG_SYS_PCI_MSTR_MEMIO_SIZE |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 166 | #define PCI_MSTR_MEMIO_SIZE 0x10000000 /* 256 MB */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 167 | #else |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 168 | #define PCI_MSTR_MEMIO_SIZE CONFIG_SYS_PCI_MSTR_MEMIO_SIZE |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 169 | #endif |
| 170 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 171 | #ifndef CONFIG_SYS_POCMR1_MASK_ATTRIB |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 172 | #define POCMR1_MASK_ATTRIB (POCMR_MASK_512MB | POCMR_ENABLE) |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 173 | #else |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 174 | #define POCMR1_MASK_ATTRIB CONFIG_SYS_POCMR1_MASK_ATTRIB |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 175 | #endif |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 176 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 177 | /* |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 178 | * Master window that allows the CPU to access PCI IO space. |
| 179 | * This window will be setup with the third set of Outbound ATU registers |
| 180 | * in the bridge. |
| 181 | */ |
| 182 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 183 | #ifndef CONFIG_SYS_PCI_MSTR_IO_LOCAL |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 184 | #define PCI_MSTR_IO_LOCAL 0xA0000000 /* Local base */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 185 | #else |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 186 | #define PCI_MSTR_IO_LOCAL CONFIG_SYS_PCI_MSTR_IO_LOCAL |
wdenk | 66fd3d1 | 2003-05-18 11:30:09 +0000 | [diff] [blame] | 187 | #endif |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 188 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 189 | #ifndef CONFIG_SYS_PCI_MSTR_IO_BUS |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 190 | #define PCI_MSTR_IO_BUS 0xA0000000 /* PCI base */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 191 | #else |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 192 | #define PCI_MSTR_IO_BUS CONFIG_SYS_PCI_MSTR_IO_BUS |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 193 | #endif |
| 194 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 195 | #ifndef CONFIG_SYS_CPU_PCI_IO_START |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 196 | #define CPU_PCI_IO_START PCI_MSTR_IO_LOCAL |
| 197 | #else |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 198 | #define CPU_PCI_IO_START CONFIG_SYS_CPU_PCI_IO_START |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 199 | #endif |
| 200 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 201 | #ifndef CONFIG_SYS_PCI_MSTR_IO_SIZE |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 202 | #define PCI_MSTR_IO_SIZE 0x10000000 /* 256MB */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 203 | #else |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 204 | #define PCI_MSTR_IO_SIZE CONFIG_SYS_PCI_MSTR_IO_SIZE |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 205 | #endif |
| 206 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 207 | #ifndef CONFIG_SYS_POCMR2_MASK_ATTRIB |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 208 | #define POCMR2_MASK_ATTRIB (POCMR_MASK_256MB | POCMR_ENABLE | POCMR_PCI_IO) |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 209 | #else |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 210 | #define POCMR2_MASK_ATTRIB CONFIG_SYS_POCMR2_MASK_ATTRIB |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 211 | #endif |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 212 | |
| 213 | /* PCI bus configuration registers. |
| 214 | */ |
| 215 | |
| 216 | #define PCI_CLASS_BRIDGE_CTLR 0x06 |
| 217 | |
| 218 | |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 219 | static inline void pci_outl (u32 addr, u32 data) |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 220 | { |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 221 | *(volatile u32 *) addr = cpu_to_le32 (data); |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 222 | } |
| 223 | |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 224 | void pci_mpc8250_init (struct pci_controller *hose) |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 225 | { |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 226 | u16 tempShort; |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 227 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 228 | volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR; |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 229 | pci_dev_t host_devno = PCI_BDF (0, 0, 0); |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 230 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 231 | pci_setup_indirect (hose, CONFIG_SYS_IMMR + PCI_CFG_ADDR_REG, |
| 232 | CONFIG_SYS_IMMR + PCI_CFG_DATA_REG); |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 233 | |
| 234 | /* |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 235 | * Setting required to enable IRQ1-IRQ7 (SIUMCR [DPPC]), |
| 236 | * and local bus for PCI (SIUMCR [LBPC]). |
| 237 | */ |
| 238 | immap->im_siu_conf.sc_siumcr = (immap->im_siu_conf.sc_siumcr & |
| 239 | ~SIUMCR_LBPC11 & |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 240 | ~SIUMCR_CS10PC11 & |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 241 | ~SIUMCR_LBPC11) | |
| 242 | SIUMCR_LBPC01 | |
| 243 | SIUMCR_CS10PC01 | |
| 244 | SIUMCR_APPC10; |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 245 | |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 246 | /* Make PCI lowest priority */ |
| 247 | /* Each 4 bits is a device bus request and the MS 4bits |
| 248 | is highest priority */ |
| 249 | /* Bus 4bit value |
| 250 | --- ---------- |
| 251 | CPM high 0b0000 |
| 252 | CPM middle 0b0001 |
| 253 | CPM low 0b0010 |
| 254 | PCI reguest 0b0011 |
| 255 | Reserved 0b0100 |
| 256 | Reserved 0b0101 |
| 257 | Internal Core 0b0110 |
| 258 | External Master 1 0b0111 |
| 259 | External Master 2 0b1000 |
| 260 | External Master 3 0b1001 |
| 261 | The rest are reserved */ |
| 262 | immap->im_siu_conf.sc_ppc_alrh = 0x61207893; |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 263 | |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 264 | /* Park bus on core while modifying PCI Bus accesses */ |
| 265 | immap->im_siu_conf.sc_ppc_acr = 0x6; |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 266 | |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 267 | /* |
| 268 | * Set up master windows that allow the CPU to access PCI space. These |
| 269 | * windows are set up using the two SIU PCIBR registers. |
| 270 | */ |
| 271 | immap->im_memctl.memc_pcimsk0 = PCIMSK0_MASK; |
| 272 | immap->im_memctl.memc_pcibr0 = PCI_MSTR0_LOCAL | PCIBR_ENABLE; |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 273 | |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 274 | /* Release PCI RST (by default the PCI RST signal is held low) */ |
| 275 | immap->im_pci.pci_gcr = cpu_to_le32 (PCIGCR_PCI_BUS_EN); |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 276 | |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 277 | /* give it some time */ |
| 278 | { |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 279 | udelay (1000); |
| 280 | } |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 281 | |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 282 | /* |
| 283 | * Set up master window that allows the CPU to access PCI Memory (prefetch) |
| 284 | * space. This window is set up using the first set of Outbound ATU registers. |
| 285 | */ |
| 286 | immap->im_pci.pci_potar0 = cpu_to_le32 (PCI_MSTR_MEM_BUS >> 12); /* PCI base */ |
| 287 | immap->im_pci.pci_pobar0 = cpu_to_le32 (PCI_MSTR_MEM_LOCAL >> 12); /* Local base */ |
| 288 | immap->im_pci.pci_pocmr0 = cpu_to_le32 (POCMR0_MASK_ATTRIB); /* Size & attribute */ |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 289 | |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 290 | /* |
| 291 | * Set up master window that allows the CPU to access PCI Memory (non-prefetch) |
| 292 | * space. This window is set up using the second set of Outbound ATU registers. |
| 293 | */ |
| 294 | immap->im_pci.pci_potar1 = cpu_to_le32 (PCI_MSTR_MEMIO_BUS >> 12); /* PCI base */ |
| 295 | immap->im_pci.pci_pobar1 = cpu_to_le32 (PCI_MSTR_MEMIO_LOCAL >> 12); /* Local base */ |
| 296 | immap->im_pci.pci_pocmr1 = cpu_to_le32 (POCMR1_MASK_ATTRIB); /* Size & attribute */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 297 | |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 298 | /* |
| 299 | * Set up master window that allows the CPU to access PCI IO space. This window |
| 300 | * is set up using the third set of Outbound ATU registers. |
| 301 | */ |
| 302 | immap->im_pci.pci_potar2 = cpu_to_le32 (PCI_MSTR_IO_BUS >> 12); /* PCI base */ |
| 303 | immap->im_pci.pci_pobar2 = cpu_to_le32 (PCI_MSTR_IO_LOCAL >> 12); /* Local base */ |
| 304 | immap->im_pci.pci_pocmr2 = cpu_to_le32 (POCMR2_MASK_ATTRIB); /* Size & attribute */ |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 305 | |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 306 | /* |
| 307 | * Set up slave window that allows PCI masters to access MPC826x local memory. |
| 308 | * This window is set up using the first set of Inbound ATU registers |
| 309 | */ |
| 310 | immap->im_pci.pci_pitar0 = cpu_to_le32 (PCI_SLV_MEM_LOCAL >> 12); /* PCI base */ |
| 311 | immap->im_pci.pci_pibar0 = cpu_to_le32 (PCI_SLV_MEM_BUS >> 12); /* Local base */ |
| 312 | immap->im_pci.pci_picmr0 = cpu_to_le32 (PICMR0_MASK_ATTRIB); /* Size & attribute */ |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 313 | |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 314 | /* See above for description - puts PCI request as highest priority */ |
| 315 | immap->im_siu_conf.sc_ppc_alrh = 0x03124567; |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 316 | |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 317 | /* Park the bus on the PCI */ |
| 318 | immap->im_siu_conf.sc_ppc_acr = PPC_ACR_BUS_PARK_PCI; |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 319 | |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 320 | /* Host mode - specify the bridge as a host-PCI bridge */ |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 321 | |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 322 | pci_hose_write_config_byte (hose, host_devno, PCI_CLASS_CODE, |
| 323 | PCI_CLASS_BRIDGE_CTLR); |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 324 | |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 325 | /* Enable the host bridge to be a master on the PCI bus, and to act as a PCI memory target */ |
| 326 | pci_hose_read_config_word (hose, host_devno, PCI_COMMAND, &tempShort); |
| 327 | pci_hose_write_config_word (hose, host_devno, PCI_COMMAND, |
| 328 | tempShort | PCI_COMMAND_MASTER | |
| 329 | PCI_COMMAND_MEMORY); |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 330 | |
wdenk | 7a8e9bed | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 331 | /* do some bridge init, should be done on all 8260 based bridges */ |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 332 | pci_hose_write_config_byte (hose, host_devno, PCI_CACHE_LINE_SIZE, |
| 333 | 0x08); |
| 334 | pci_hose_write_config_byte (hose, host_devno, PCI_LATENCY_TIMER, |
| 335 | 0xF8); |
wdenk | 7a8e9bed | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 336 | |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 337 | hose->first_busno = 0; |
| 338 | hose->last_busno = 0xff; |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 339 | |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 340 | /* System memory space */ |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 341 | pci_set_region (hose->regions + 0, |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 342 | CONFIG_SYS_SDRAM_BASE, |
| 343 | CONFIG_SYS_SDRAM_BASE, |
Kumar Gala | ff4e66e | 2009-02-06 09:49:31 -0600 | [diff] [blame] | 344 | 0x4000000, PCI_REGION_MEM | PCI_REGION_SYS_MEMORY); |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 345 | |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 346 | /* PCI memory space */ |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 347 | pci_set_region (hose->regions + 1, |
| 348 | PCI_MSTR_MEM_BUS, |
| 349 | PCI_MSTR_MEM_LOCAL, |
| 350 | PCI_MSTR_MEM_SIZE, PCI_REGION_MEM); |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 351 | |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 352 | /* PCI I/O space */ |
| 353 | pci_set_region (hose->regions + 2, |
| 354 | PCI_MSTR_IO_BUS, |
| 355 | PCI_MSTR_IO_LOCAL, PCI_MSTR_IO_SIZE, PCI_REGION_IO); |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 356 | |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 357 | hose->region_count = 3; |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 358 | |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 359 | pci_register_hose (hose); |
| 360 | /* Mask off master abort machine checks */ |
| 361 | immap->im_pci.pci_emr &= cpu_to_le32 (~PCI_ERROR_PCI_NO_RSP); |
| 362 | eieio (); |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 363 | |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 364 | hose->last_busno = pci_hose_scan (hose); |
| 365 | |
| 366 | |
| 367 | /* clear the error in the error status register */ |
| 368 | immap->im_pci.pci_esr = cpu_to_le32 (PCI_ERROR_PCI_NO_RSP); |
| 369 | |
| 370 | /* unmask master abort machine checks */ |
| 371 | immap->im_pci.pci_emr |= cpu_to_le32 (PCI_ERROR_PCI_NO_RSP); |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 372 | } |
| 373 | |
Matvejchikov Ilya | 0e6989b | 2008-07-06 13:57:00 +0400 | [diff] [blame] | 374 | #if defined(CONFIG_OF_LIBFDT) |
| 375 | void ft_pci_setup(void *blob, bd_t *bd) |
| 376 | { |
| 377 | do_fixup_by_prop_u32(blob, "device_type", "pci", 4, |
Wolfgang Denk | 52b047a | 2008-08-12 12:10:11 +0200 | [diff] [blame] | 378 | "clock-frequency", gd->pci_clk, 1); |
Matvejchikov Ilya | 0e6989b | 2008-07-06 13:57:00 +0400 | [diff] [blame] | 379 | } |
| 380 | #endif |
| 381 | |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 382 | #endif /* CONFIG_PCI */ |