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