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