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 | * |
| 5 | * See file CREDITS for list of people who contributed to this |
| 6 | * project. |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU General Public License as |
| 10 | * published by the Free Software Foundation; either version 2 of |
| 11 | * the License, or (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 21 | * MA 02111-1307 USA |
| 22 | */ |
| 23 | |
| 24 | #include <common.h> |
| 25 | |
| 26 | #ifdef CONFIG_PCI |
| 27 | |
| 28 | #include <pci.h> |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 29 | #include <mpc8260.h> |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 30 | #include <asm/m8260_pci.h> |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 31 | #include <asm/io.h> |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 32 | /* |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 33 | * Local->PCI map (from CPU) controlled by |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 34 | * MPC826x master window |
| 35 | * |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 36 | * 0x80000000 - 0xBFFFFFFF CPU2PCI space PCIBR0 |
| 37 | * 0xF4000000 - 0xF7FFFFFF CPU2PCI space PCIBR1 |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 38 | * |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 39 | * 0x80000000 - 0x9FFFFFFF 0x80000000 - 0x9FFFFFFF (Outbound ATU #1) |
| 40 | * PCI Mem with prefetch |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 41 | * |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 42 | * 0xA0000000 - 0xBFFFFFFF 0xA0000000 - 0xBFFFFFFF (Outbound ATU #2) |
| 43 | * PCI Mem w/o prefetch |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 44 | * |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 45 | * 0xF4000000 - 0xF7FFFFFF 0x00000000 - 0x03FFFFFF (Outbound ATU #3) |
| 46 | * 32-bit PCI IO |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 47 | * |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 48 | * PCI->Local map (from PCI) |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 49 | * MPC826x slave window controlled by |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 50 | * |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 51 | * 0x00000000 - 0x1FFFFFFF 0x00000000 - 0x1FFFFFFF (Inbound ATU #1) |
| 52 | * MPC826x local memory |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 53 | */ |
| 54 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 55 | /* |
| 56 | * Slave window that allows PCI masters to access MPC826x local memory. |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 57 | * This window is set up using the first set of Inbound ATU registers |
| 58 | */ |
| 59 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 60 | #ifndef CFG_PCI_SLV_MEM_LOCAL |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 61 | #define PCI_SLV_MEM_LOCAL CFG_SDRAM_BASE /* Local base */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 62 | #else |
| 63 | #define PCI_SLV_MEM_LOCAL CFG_PCI_SLV_MEM_LOCAL |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 64 | #endif |
| 65 | |
| 66 | #ifndef CFG_PCI_SLV_MEM_BUS |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 67 | #define PCI_SLV_MEM_BUS 0x00000000 /* PCI base */ |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 68 | #else |
| 69 | #define PCI_SLV_MEM_BUS CFG_PCI_SLV_MEM_BUS |
| 70 | #endif |
| 71 | |
| 72 | #ifndef CFG_PICMR0_MASK_ATTRIB |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 73 | #define PICMR0_MASK_ATTRIB (PICMR_MASK_512MB | PICMR_ENABLE | \ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 74 | PICMR_PREFETCH_EN) |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 75 | #else |
| 76 | #define PICMR0_MASK_ATTRIB CFG_PICMR0_MASK_ATTRIB |
| 77 | #endif |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 78 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 79 | /* |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 80 | * These are the windows that allow the CPU to access PCI address space. |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 81 | * All three PCI master windows, which allow the CPU to access PCI |
| 82 | * prefetch, non prefetch, and IO space (see below), must all fit within |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 83 | * these windows. |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 84 | */ |
| 85 | |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 86 | /* PCIBR0 */ |
| 87 | #ifndef CFG_PCI_MSTR0_LOCAL |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 88 | #define PCI_MSTR0_LOCAL 0x80000000 /* Local base */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 89 | #else |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 90 | #define PCI_MSTR0_LOCAL CFG_PCI_MSTR0_LOCAL |
| 91 | #endif |
| 92 | |
| 93 | #ifndef CFG_PCIMSK0_MASK |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 94 | #define PCIMSK0_MASK PCIMSK_1GB /* Size of window */ |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 95 | #else |
| 96 | #define PCIMSK0_MASK CFG_PCIMSK0_MASK |
| 97 | #endif |
| 98 | |
| 99 | /* PCIBR1 */ |
| 100 | #ifndef CFG_PCI_MSTR1_LOCAL |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 101 | #define PCI_MSTR1_LOCAL 0xF4000000 /* Local base */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 102 | #else |
| 103 | #define PCI_MSTR1_LOCAL CFG_PCI_MSTR1_LOCAL |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 104 | #endif |
| 105 | |
| 106 | #ifndef CFG_PCIMSK1_MASK |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 107 | #define PCIMSK1_MASK PCIMSK_64MB /* Size of window */ |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 108 | #else |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 109 | #define PCIMSK1_MASK CFG_PCIMSK1_MASK |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 110 | #endif |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 111 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 112 | /* |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 113 | * Master window that allows the CPU to access PCI Memory (prefetch). |
| 114 | * This window will be setup with the first set of Outbound ATU registers |
| 115 | * in the bridge. |
| 116 | */ |
| 117 | |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 118 | #ifndef CFG_PCI_MSTR_MEM_LOCAL |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 119 | #define PCI_MSTR_MEM_LOCAL 0x80000000 /* Local base */ |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 120 | #else |
| 121 | #define PCI_MSTR_MEM_LOCAL CFG_PCI_MSTR_MEM_LOCAL |
| 122 | #endif |
| 123 | |
| 124 | #ifndef CFG_PCI_MSTR_MEM_BUS |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 125 | #define PCI_MSTR_MEM_BUS 0x80000000 /* PCI base */ |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 126 | #else |
| 127 | #define PCI_MSTR_MEM_BUS CFG_PCI_MSTR_MEM_BUS |
| 128 | #endif |
| 129 | |
| 130 | #ifndef CFG_CPU_PCI_MEM_START |
| 131 | #define CPU_PCI_MEM_START PCI_MSTR_MEM_LOCAL |
| 132 | #else |
| 133 | #define CPU_PCI_MEM_START CFG_CPU_PCI_MEM_START |
| 134 | #endif |
| 135 | |
| 136 | #ifndef CFG_PCI_MSTR_MEM_SIZE |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 137 | #define PCI_MSTR_MEM_SIZE 0x10000000 /* 256MB */ |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 138 | #else |
| 139 | #define PCI_MSTR_MEM_SIZE CFG_PCI_MSTR_MEM_SIZE |
| 140 | #endif |
| 141 | |
| 142 | #ifndef CFG_POCMR0_MASK_ATTRIB |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 143 | #define POCMR0_MASK_ATTRIB (POCMR_MASK_256MB | POCMR_ENABLE | POCMR_PREFETCH_EN) |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 144 | #else |
| 145 | #define POCMR0_MASK_ATTRIB CFG_POCMR0_MASK_ATTRIB |
| 146 | #endif |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 147 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 148 | /* |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 149 | * Master window that allows the CPU to access PCI Memory (non-prefetch). |
| 150 | * This window will be setup with the second set of Outbound ATU registers |
| 151 | * in the bridge. |
| 152 | */ |
| 153 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 154 | #ifndef CFG_PCI_MSTR_MEMIO_LOCAL |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 155 | #define PCI_MSTR_MEMIO_LOCAL 0x90000000 /* Local base */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 156 | #else |
| 157 | #define PCI_MSTR_MEMIO_LOCAL CFG_PCI_MSTR_MEMIO_LOCAL |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 158 | #endif |
| 159 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 160 | #ifndef CFG_PCI_MSTR_MEMIO_BUS |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 161 | #define PCI_MSTR_MEMIO_BUS 0x90000000 /* PCI base */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 162 | #else |
| 163 | #define PCI_MSTR_MEMIO_BUS CFG_PCI_MSTR_MEMIO_BUS |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 164 | #endif |
| 165 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 166 | #ifndef CFG_CPU_PCI_MEMIO_START |
| 167 | #define CPU_PCI_MEMIO_START PCI_MSTR_MEMIO_LOCAL |
| 168 | #else |
| 169 | #define CPU_PCI_MEMIO_START CFG_CPU_PCI_MEMIO_START |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 170 | #endif |
| 171 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 172 | #ifndef CFG_PCI_MSTR_MEMIO_SIZE |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 173 | #define PCI_MSTR_MEMIO_SIZE 0x10000000 /* 256 MB */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 174 | #else |
| 175 | #define PCI_MSTR_MEMIO_SIZE CFG_PCI_MSTR_MEMIO_SIZE |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 176 | #endif |
| 177 | |
| 178 | #ifndef CFG_POCMR1_MASK_ATTRIB |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 179 | #define POCMR1_MASK_ATTRIB (POCMR_MASK_512MB | POCMR_ENABLE) |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 180 | #else |
| 181 | #define POCMR1_MASK_ATTRIB CFG_POCMR1_MASK_ATTRIB |
| 182 | #endif |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 183 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 184 | /* |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 185 | * Master window that allows the CPU to access PCI IO space. |
| 186 | * This window will be setup with the third set of Outbound ATU registers |
| 187 | * in the bridge. |
| 188 | */ |
| 189 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 190 | #ifndef CFG_PCI_MSTR_IO_LOCAL |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 191 | #define PCI_MSTR_IO_LOCAL 0xA0000000 /* Local base */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 192 | #else |
| 193 | #define PCI_MSTR_IO_LOCAL CFG_PCI_MSTR_IO_LOCAL |
wdenk | 66fd3d1 | 2003-05-18 11:30:09 +0000 | [diff] [blame] | 194 | #endif |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 195 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 196 | #ifndef CFG_PCI_MSTR_IO_BUS |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 197 | #define PCI_MSTR_IO_BUS 0xA0000000 /* PCI base */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 198 | #else |
| 199 | #define PCI_MSTR_IO_BUS CFG_PCI_MSTR_IO_BUS |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 200 | #endif |
| 201 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 202 | #ifndef CFG_CPU_PCI_IO_START |
| 203 | #define CPU_PCI_IO_START PCI_MSTR_IO_LOCAL |
| 204 | #else |
| 205 | #define CPU_PCI_IO_START CFG_CPU_PCI_IO_START |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 206 | #endif |
| 207 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 208 | #ifndef CFG_PCI_MSTR_IO_SIZE |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 209 | #define PCI_MSTR_IO_SIZE 0x10000000 /* 256MB */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 210 | #else |
| 211 | #define PCI_MSTR_IO_SIZE CFG_PCI_MSTR_IO_SIZE |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 212 | #endif |
| 213 | |
| 214 | #ifndef CFG_POCMR2_MASK_ATTRIB |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 215 | #define POCMR2_MASK_ATTRIB (POCMR_MASK_256MB | POCMR_ENABLE | POCMR_PCI_IO) |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 216 | #else |
| 217 | #define POCMR2_MASK_ATTRIB CFG_POCMR2_MASK_ATTRIB |
| 218 | #endif |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 219 | |
| 220 | /* PCI bus configuration registers. |
| 221 | */ |
| 222 | |
| 223 | #define PCI_CLASS_BRIDGE_CTLR 0x06 |
| 224 | |
| 225 | |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 226 | static inline void pci_outl (u32 addr, u32 data) |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 227 | { |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 228 | *(volatile u32 *) addr = cpu_to_le32 (data); |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 229 | } |
| 230 | |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 231 | void pci_mpc8250_init (struct pci_controller *hose) |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 232 | { |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 233 | #ifdef CONFIG_MPC8266ADS |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 234 | DECLARE_GLOBAL_DATA_PTR; |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 235 | #endif |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 236 | u16 tempShort; |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 237 | |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 238 | volatile immap_t *immap = (immap_t *) CFG_IMMR; |
| 239 | pci_dev_t host_devno = PCI_BDF (0, 0, 0); |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 240 | |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 241 | pci_setup_indirect (hose, CFG_IMMR + PCI_CFG_ADDR_REG, |
| 242 | CFG_IMMR + PCI_CFG_DATA_REG); |
| 243 | |
| 244 | /* |
| 245 | * Setting required to enable local bus for PCI (SIUMCR [LBPC]). |
| 246 | */ |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 247 | #ifdef CONFIG_MPC8266ADS |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 248 | immap->im_siu_conf.sc_siumcr = |
| 249 | (immap->im_siu_conf.sc_siumcr & ~SIUMCR_LBPC11) |
| 250 | | SIUMCR_LBPC01; |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 251 | #else |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 252 | /* |
| 253 | * Setting required to enable IRQ1-IRQ7 (SIUMCR [DPPC]), |
| 254 | * and local bus for PCI (SIUMCR [LBPC]). |
| 255 | */ |
| 256 | immap->im_siu_conf.sc_siumcr = (immap->im_siu_conf.sc_siumcr & |
| 257 | ~SIUMCR_LBPC11 & |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 258 | ~SIUMCR_CS10PC11 & |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 259 | ~SIUMCR_LBPC11) | |
| 260 | SIUMCR_LBPC01 | |
| 261 | SIUMCR_CS10PC01 | |
| 262 | SIUMCR_APPC10; |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 263 | #endif |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 264 | |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 265 | /* Make PCI lowest priority */ |
| 266 | /* Each 4 bits is a device bus request and the MS 4bits |
| 267 | is highest priority */ |
| 268 | /* Bus 4bit value |
| 269 | --- ---------- |
| 270 | CPM high 0b0000 |
| 271 | CPM middle 0b0001 |
| 272 | CPM low 0b0010 |
| 273 | PCI reguest 0b0011 |
| 274 | Reserved 0b0100 |
| 275 | Reserved 0b0101 |
| 276 | Internal Core 0b0110 |
| 277 | External Master 1 0b0111 |
| 278 | External Master 2 0b1000 |
| 279 | External Master 3 0b1001 |
| 280 | The rest are reserved */ |
| 281 | immap->im_siu_conf.sc_ppc_alrh = 0x61207893; |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 282 | |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 283 | /* Park bus on core while modifying PCI Bus accesses */ |
| 284 | immap->im_siu_conf.sc_ppc_acr = 0x6; |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 285 | |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 286 | /* |
| 287 | * Set up master windows that allow the CPU to access PCI space. These |
| 288 | * windows are set up using the two SIU PCIBR registers. |
| 289 | */ |
| 290 | immap->im_memctl.memc_pcimsk0 = PCIMSK0_MASK; |
| 291 | immap->im_memctl.memc_pcibr0 = PCI_MSTR0_LOCAL | PCIBR_ENABLE; |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 292 | |
| 293 | #ifdef CONFIG_MPC8266ADS |
wdenk | d4326ac | 2004-04-18 21:17:30 +0000 | [diff] [blame] | 294 | immap->im_memctl.memc_pcimsk1 = PCIMSK1_MASK; |
| 295 | immap->im_memctl.memc_pcibr1 = PCI_MSTR1_LOCAL | PCIBR_ENABLE; |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 296 | #endif |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 297 | |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 298 | /* Release PCI RST (by default the PCI RST signal is held low) */ |
| 299 | immap->im_pci.pci_gcr = cpu_to_le32 (PCIGCR_PCI_BUS_EN); |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 300 | |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 301 | /* give it some time */ |
| 302 | { |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 303 | #ifdef CONFIG_MPC8266ADS |
| 304 | /* Give the PCI cards more time to initialize before query |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 305 | This might be good for other boards also |
| 306 | */ |
| 307 | int i; |
| 308 | |
| 309 | for (i = 0; i < 1000; ++i) |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 310 | #endif |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 311 | udelay (1000); |
| 312 | } |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 313 | |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 314 | /* |
| 315 | * Set up master window that allows the CPU to access PCI Memory (prefetch) |
| 316 | * space. This window is set up using the first set of Outbound ATU registers. |
| 317 | */ |
| 318 | immap->im_pci.pci_potar0 = cpu_to_le32 (PCI_MSTR_MEM_BUS >> 12); /* PCI base */ |
| 319 | immap->im_pci.pci_pobar0 = cpu_to_le32 (PCI_MSTR_MEM_LOCAL >> 12); /* Local base */ |
| 320 | immap->im_pci.pci_pocmr0 = cpu_to_le32 (POCMR0_MASK_ATTRIB); /* Size & attribute */ |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 321 | |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 322 | /* |
| 323 | * Set up master window that allows the CPU to access PCI Memory (non-prefetch) |
| 324 | * space. This window is set up using the second set of Outbound ATU registers. |
| 325 | */ |
| 326 | immap->im_pci.pci_potar1 = cpu_to_le32 (PCI_MSTR_MEMIO_BUS >> 12); /* PCI base */ |
| 327 | immap->im_pci.pci_pobar1 = cpu_to_le32 (PCI_MSTR_MEMIO_LOCAL >> 12); /* Local base */ |
| 328 | immap->im_pci.pci_pocmr1 = cpu_to_le32 (POCMR1_MASK_ATTRIB); /* Size & attribute */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 329 | |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 330 | /* |
| 331 | * Set up master window that allows the CPU to access PCI IO space. This window |
| 332 | * is set up using the third set of Outbound ATU registers. |
| 333 | */ |
| 334 | immap->im_pci.pci_potar2 = cpu_to_le32 (PCI_MSTR_IO_BUS >> 12); /* PCI base */ |
| 335 | immap->im_pci.pci_pobar2 = cpu_to_le32 (PCI_MSTR_IO_LOCAL >> 12); /* Local base */ |
| 336 | immap->im_pci.pci_pocmr2 = cpu_to_le32 (POCMR2_MASK_ATTRIB); /* Size & attribute */ |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 337 | |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 338 | /* |
| 339 | * Set up slave window that allows PCI masters to access MPC826x local memory. |
| 340 | * This window is set up using the first set of Inbound ATU registers |
| 341 | */ |
| 342 | immap->im_pci.pci_pitar0 = cpu_to_le32 (PCI_SLV_MEM_LOCAL >> 12); /* PCI base */ |
| 343 | immap->im_pci.pci_pibar0 = cpu_to_le32 (PCI_SLV_MEM_BUS >> 12); /* Local base */ |
| 344 | immap->im_pci.pci_picmr0 = cpu_to_le32 (PICMR0_MASK_ATTRIB); /* Size & attribute */ |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 345 | |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 346 | /* See above for description - puts PCI request as highest priority */ |
| 347 | immap->im_siu_conf.sc_ppc_alrh = 0x03124567; |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 348 | |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 349 | /* Park the bus on the PCI */ |
| 350 | immap->im_siu_conf.sc_ppc_acr = PPC_ACR_BUS_PARK_PCI; |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 351 | |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 352 | /* Host mode - specify the bridge as a host-PCI bridge */ |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 353 | |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 354 | pci_hose_write_config_byte (hose, host_devno, PCI_CLASS_CODE, |
| 355 | PCI_CLASS_BRIDGE_CTLR); |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 356 | |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 357 | /* Enable the host bridge to be a master on the PCI bus, and to act as a PCI memory target */ |
| 358 | pci_hose_read_config_word (hose, host_devno, PCI_COMMAND, &tempShort); |
| 359 | pci_hose_write_config_word (hose, host_devno, PCI_COMMAND, |
| 360 | tempShort | PCI_COMMAND_MASTER | |
| 361 | PCI_COMMAND_MEMORY); |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 362 | |
wdenk | 7a8e9bed | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 363 | /* do some bridge init, should be done on all 8260 based bridges */ |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 364 | pci_hose_write_config_byte (hose, host_devno, PCI_CACHE_LINE_SIZE, |
| 365 | 0x08); |
| 366 | pci_hose_write_config_byte (hose, host_devno, PCI_LATENCY_TIMER, |
| 367 | 0xF8); |
wdenk | 7a8e9bed | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 368 | |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 369 | hose->first_busno = 0; |
| 370 | hose->last_busno = 0xff; |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 371 | |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 372 | /* System memory space */ |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 373 | #ifdef CONFIG_MPC8266ADS |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 374 | pci_set_region (hose->regions + 0, |
| 375 | PCI_SLV_MEM_BUS, |
| 376 | PCI_SLV_MEM_LOCAL, |
| 377 | gd->ram_size, PCI_REGION_MEM | PCI_REGION_MEMORY); |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 378 | #else |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 379 | pci_set_region (hose->regions + 0, |
| 380 | CFG_SDRAM_BASE, |
| 381 | CFG_SDRAM_BASE, |
| 382 | 0x4000000, PCI_REGION_MEM | PCI_REGION_MEMORY); |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 383 | #endif |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 384 | |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 385 | /* PCI memory space */ |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 386 | #ifdef CONFIG_MPC8266ADS |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 387 | pci_set_region (hose->regions + 1, |
| 388 | PCI_MSTR_MEMIO_BUS, |
| 389 | PCI_MSTR_MEMIO_LOCAL, |
| 390 | PCI_MSTR_MEMIO_SIZE, PCI_REGION_MEM); |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 391 | #else |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 392 | pci_set_region (hose->regions + 1, |
| 393 | PCI_MSTR_MEM_BUS, |
| 394 | PCI_MSTR_MEM_LOCAL, |
| 395 | PCI_MSTR_MEM_SIZE, PCI_REGION_MEM); |
wdenk | 5d232d0 | 2003-05-22 22:52:13 +0000 | [diff] [blame] | 396 | #endif |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 397 | |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 398 | /* PCI I/O space */ |
| 399 | pci_set_region (hose->regions + 2, |
| 400 | PCI_MSTR_IO_BUS, |
| 401 | PCI_MSTR_IO_LOCAL, PCI_MSTR_IO_SIZE, PCI_REGION_IO); |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 402 | |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 403 | hose->region_count = 3; |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 404 | |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 405 | pci_register_hose (hose); |
| 406 | /* Mask off master abort machine checks */ |
| 407 | immap->im_pci.pci_emr &= cpu_to_le32 (~PCI_ERROR_PCI_NO_RSP); |
| 408 | eieio (); |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 409 | |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 410 | hose->last_busno = pci_hose_scan (hose); |
| 411 | |
| 412 | |
| 413 | /* clear the error in the error status register */ |
| 414 | immap->im_pci.pci_esr = cpu_to_le32 (PCI_ERROR_PCI_NO_RSP); |
| 415 | |
| 416 | /* unmask master abort machine checks */ |
| 417 | immap->im_pci.pci_emr |= cpu_to_le32 (PCI_ERROR_PCI_NO_RSP); |
wdenk | 4d75a50 | 2003-03-25 16:50:56 +0000 | [diff] [blame] | 418 | } |
| 419 | |
wdenk | 3c74e32 | 2004-02-22 23:46:08 +0000 | [diff] [blame] | 420 | #endif /* CONFIG_PCI */ |