Kumar Gala | 3e7b6c1 | 2009-09-02 09:03:08 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2009 Freescale Semiconductor, Inc. |
| 3 | * |
| 4 | * See file CREDITS for list of people who contributed to this |
| 5 | * project. |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU General Public License as |
| 9 | * published by the Free Software Foundation; either version 2 of |
| 10 | * the License, or (at your option) any later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program; if not, write to the Free Software |
| 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 20 | * MA 02111-1307 USA |
| 21 | */ |
| 22 | |
| 23 | #include <common.h> |
| 24 | #include <asm/fsl_law.h> |
| 25 | #include <pci.h> |
| 26 | |
| 27 | struct pci_info { |
| 28 | u16 agent; |
| 29 | u16 cfg; |
| 30 | }; |
| 31 | |
| 32 | /* The agent field is a bit mask in which each bit represents the value of |
| 33 | * cfg_host_agt[] signal and the bit is set of the given interface would be |
| 34 | * in agent/end-point mode for the given interface. |
| 35 | * |
| 36 | * The same idea is true of the cfg field. The bit will be set if the |
| 37 | * interface would be enabled based on the value of cfg_IO_ports[] signal |
| 38 | * |
| 39 | * On MPC86xx/PQ3 based systems: |
| 40 | * we extract cfg_host_agt from GUTS register PORBMSR |
| 41 | * we extract cfg_IO_ports from GUTS register PORDEVSR |
| 42 | * |
| 43 | * cfg_IO_ports only exist on systems w/PCIe (we set cfg 0 for systems |
| 44 | * without PCIe) |
| 45 | */ |
| 46 | |
| 47 | #if defined(CONFIG_MPC8540) || defined(CONFIG_MPC8560) |
| 48 | static struct pci_info pci_config_info[] = |
| 49 | { |
| 50 | [LAW_TRGT_IF_PCI] = { |
| 51 | .agent = (1 << 0) | (1 << 2), |
| 52 | .cfg = 0, |
| 53 | }, |
| 54 | }; |
| 55 | #elif defined(CONFIG_MPC8541) || defined(CONFIG_MPC8555) |
| 56 | static struct pci_info pci_config_info[] = |
| 57 | { |
| 58 | [LAW_TRGT_IF_PCI] = { |
| 59 | .agent = (1 << 0), |
| 60 | .cfg = 0, |
| 61 | }, |
| 62 | }; |
| 63 | #elif defined(CONFIG_MPC8536) |
| 64 | static struct pci_info pci_config_info[] = |
| 65 | { |
| 66 | [LAW_TRGT_IF_PCI] = { |
| 67 | .agent = (1 << 6), |
| 68 | .cfg = 0, |
| 69 | }, |
| 70 | [LAW_TRGT_IF_PCIE_1] = { |
| 71 | .agent = (1 << 5), |
| 72 | .cfg = (1 << 2) | (1 << 3) | (1 << 5) | (1 << 7), |
| 73 | }, |
| 74 | [LAW_TRGT_IF_PCIE_2] = { |
| 75 | .agent = (1 << 3), |
| 76 | .cfg = (1 << 5) | (1 << 7), |
| 77 | }, |
| 78 | [LAW_TRGT_IF_PCIE_3] = { |
| 79 | .agent = (1 << 1), |
| 80 | .cfg = (1 << 7), |
| 81 | }, |
| 82 | }; |
| 83 | #elif defined(CONFIG_MPC8544) |
| 84 | static struct pci_info pci_config_info[] = |
| 85 | { |
| 86 | [LAW_TRGT_IF_PCI] = { |
| 87 | .agent = (1 << 6), |
| 88 | .cfg = 0, |
| 89 | }, |
| 90 | [LAW_TRGT_IF_PCIE_1] = { |
| 91 | .agent = (1 << 5), |
| 92 | .cfg = (1 << 2) | (1 << 3) | (1 << 4) | (1 << 5) | |
| 93 | (1 << 6) | (1 << 7), |
| 94 | }, |
| 95 | [LAW_TRGT_IF_PCIE_2] = { |
| 96 | .agent = (1 << 3), |
| 97 | .cfg = (1 << 4) | (1 << 5) | (1 << 6) | (1 << 7), |
| 98 | }, |
| 99 | [LAW_TRGT_IF_PCIE_3] = { |
| 100 | .agent = (1 << 1), |
| 101 | .cfg = (1 << 6) | (1 << 7), |
| 102 | }, |
| 103 | }; |
| 104 | #elif defined(CONFIG_MPC8548) |
| 105 | static struct pci_info pci_config_info[] = |
| 106 | { |
| 107 | [LAW_TRGT_IF_PCI_1] = { |
| 108 | .agent = (1 << 4) | (1 << 6), |
| 109 | .cfg = 0, |
| 110 | }, |
| 111 | [LAW_TRGT_IF_PCI_2] = { |
| 112 | .agent = (1 << 4) | (1 << 6), |
| 113 | .cfg = 0, |
| 114 | }, |
| 115 | /* PCI_2 is always host and we dont use iosel to determine enable/disable */ |
| 116 | [LAW_TRGT_IF_PCIE_1] = { |
| 117 | .agent = (1 << 0) | (1 << 2), |
| 118 | .cfg = (1 << 3) | (1 << 4) | (1 << 7), |
| 119 | }, |
| 120 | }; |
| 121 | #elif defined(CONFIG_MPC8568) |
| 122 | static struct pci_info pci_config_info[] = |
| 123 | { |
| 124 | [LAW_TRGT_IF_PCI] = { |
| 125 | .agent = (1 << 0) | (1 << 4) | (1 << 6), |
| 126 | .cfg = 0, |
| 127 | }, |
| 128 | [LAW_TRGT_IF_PCIE_1] = { |
| 129 | .agent = (1 << 0) | (1 << 2) | (1 << 4), |
| 130 | .cfg = (1 << 3) | (1 << 4) | (1 << 7), |
| 131 | }, |
| 132 | }; |
| 133 | #elif defined(CONFIG_MPC8569) |
| 134 | static struct pci_info pci_config_info[] = |
| 135 | { |
| 136 | [LAW_TRGT_IF_PCIE_1] = { |
| 137 | .agent = (1 << 0) | (1 << 6), |
| 138 | .cfg = (1 << 0) | (1 << 4) | (1 << 5) | (1 << 6) | (1 << 7) | |
| 139 | (1 << 8) | (1 << 0xc) | (1 << 0xf), |
| 140 | }, |
| 141 | }; |
| 142 | #elif defined(CONFIG_MPC8572) |
| 143 | static struct pci_info pci_config_info[] = |
| 144 | { |
| 145 | [LAW_TRGT_IF_PCIE_1] = { |
| 146 | .agent = (1 << 0) | (1 << 1) | (1 << 4) | (1 << 5), |
| 147 | .cfg = (1 << 2) | (1 << 3) | (1 << 7) | |
| 148 | (1 << 0xb) | (1 << 0xc) | (1 << 0xf), |
| 149 | }, |
| 150 | [LAW_TRGT_IF_PCIE_2] = { |
| 151 | .agent = (1 << 0) | (1 << 2) | (1 << 4) | (1 << 6), |
| 152 | .cfg = (1 << 3) | (1 << 7), |
| 153 | }, |
| 154 | [LAW_TRGT_IF_PCIE_3] = { |
| 155 | .agent = (1 << 0) | (1 << 3) | (1 << 5) | (1 << 6), |
| 156 | .cfg = (1 << 7), |
| 157 | }, |
| 158 | }; |
| 159 | #elif defined(CONFIG_MPC8610) |
| 160 | static struct pci_info pci_config_info[] = |
| 161 | { |
| 162 | [LAW_TRGT_IF_PCI_1] = { |
| 163 | .agent = (1 << 4) | (1 << 5) | (1 << 6), |
| 164 | .cfg = 0, |
| 165 | }, |
| 166 | [LAW_TRGT_IF_PCIE_1] = { |
| 167 | .agent = (1 << 0) | (1 << 2) | (1 << 5), |
| 168 | .cfg = (1 << 1) | (1 << 4), |
| 169 | }, |
| 170 | [LAW_TRGT_IF_PCIE_2] = { |
| 171 | .agent = (1 << 0) | (1 << 1) | (1 << 4), |
| 172 | .cfg = (1 << 0) | (1 << 4), |
| 173 | }, |
| 174 | }; |
| 175 | #elif defined(CONFIG_MPC8641) |
| 176 | static struct pci_info pci_config_info[] = |
| 177 | { |
| 178 | [LAW_TRGT_IF_PCIE_1] = { |
| 179 | .agent = 0, /* we dont use agent on 8641 */ |
| 180 | .cfg = (1 << 2) | (1 << 3) | (1 << 5) | (1 << 6) | |
| 181 | (1 << 7) | (1 << 0xe) | (1 << 0xf), |
| 182 | }, |
| 183 | }; |
| 184 | #elif defined(CONFIG_P1011) || defined(CONFIG_P1020) |
| 185 | static struct pci_info pci_config_info[] = |
| 186 | { |
| 187 | [LAW_TRGT_IF_PCIE_1] = { |
| 188 | .agent = (1 << 0) | (1 << 1), |
| 189 | .cfg = (1 << 0) | (1 << 6) | (1 << 0xe) | (1 << 0xf), |
| 190 | }, |
| 191 | [LAW_TRGT_IF_PCIE_2] = { |
| 192 | .agent = (1 << 0) | (1 << 2), |
| 193 | .cfg = (1 << 0xe), |
| 194 | }, |
| 195 | }; |
| 196 | #elif defined(CONFIG_P2010) || defined(CONFIG_P2020) |
| 197 | static struct pci_info pci_config_info[] = |
| 198 | { |
| 199 | [LAW_TRGT_IF_PCIE_1] = { |
| 200 | .agent = (1 << 0) | (1 << 1) | (1 << 4) | (1 << 5), |
| 201 | .cfg = (1 << 0) | (1 << 2) | (1 << 4) | (1 << 6) | |
| 202 | (1 << 0xd) | (1 << 0xe) | (1 << 0xf), |
| 203 | }, |
| 204 | [LAW_TRGT_IF_PCIE_2] = { |
| 205 | .agent = (1 << 0) | (1 << 2) | (1 << 4) | (1 << 6), |
| 206 | .cfg = (1 << 2) | (1 << 0xe), |
| 207 | }, |
| 208 | [LAW_TRGT_IF_PCIE_3] = { |
| 209 | .agent = (1 << 0) | (1 << 3) | (1 << 5) | (1 << 6), |
| 210 | .cfg = (1 << 2) | (1 << 4), |
| 211 | }, |
| 212 | }; |
Kumar Gala | 178e39e | 2009-09-17 00:01:14 -0500 | [diff] [blame] | 213 | #elif defined(CONFIG_FSL_CORENET) |
Kumar Gala | 3e7b6c1 | 2009-09-02 09:03:08 -0500 | [diff] [blame] | 214 | #else |
| 215 | #error Need to define pci_config_info for processor |
| 216 | #endif |
| 217 | |
Kumar Gala | 178e39e | 2009-09-17 00:01:14 -0500 | [diff] [blame] | 218 | #ifndef CONFIG_FSL_CORENET |
Kumar Gala | 3e7b6c1 | 2009-09-02 09:03:08 -0500 | [diff] [blame] | 219 | int is_fsl_pci_agent(enum law_trgt_if trgt, u32 host_agent) |
| 220 | { |
| 221 | return ((1 << host_agent) & pci_config_info[trgt].agent); |
| 222 | } |
| 223 | |
| 224 | int is_fsl_pci_cfg(enum law_trgt_if trgt, u32 io_sel) |
| 225 | { |
| 226 | return ((1 << io_sel) & pci_config_info[trgt].cfg); |
| 227 | } |
Kumar Gala | 178e39e | 2009-09-17 00:01:14 -0500 | [diff] [blame] | 228 | #endif |