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 { |
Kumar Gala | 3e7b6c1 | 2009-09-02 09:03:08 -0500 | [diff] [blame] | 28 | u16 cfg; |
| 29 | }; |
| 30 | |
Kumar Gala | ee53650 | 2009-11-04 13:00:55 -0600 | [diff] [blame] | 31 | /* The cfg field is a bit mask in which each bit represents the value of |
| 32 | * cfg_IO_ports[] signal and the bit is set if the interface would be |
| 33 | * enabled based on the value of cfg_IO_ports[] signal |
Kumar Gala | 3e7b6c1 | 2009-09-02 09:03:08 -0500 | [diff] [blame] | 34 | * |
| 35 | * On MPC86xx/PQ3 based systems: |
Kumar Gala | 3e7b6c1 | 2009-09-02 09:03:08 -0500 | [diff] [blame] | 36 | * we extract cfg_IO_ports from GUTS register PORDEVSR |
| 37 | * |
| 38 | * cfg_IO_ports only exist on systems w/PCIe (we set cfg 0 for systems |
| 39 | * without PCIe) |
| 40 | */ |
| 41 | |
| 42 | #if defined(CONFIG_MPC8540) || defined(CONFIG_MPC8560) |
| 43 | static struct pci_info pci_config_info[] = |
| 44 | { |
| 45 | [LAW_TRGT_IF_PCI] = { |
Kumar Gala | 3e7b6c1 | 2009-09-02 09:03:08 -0500 | [diff] [blame] | 46 | .cfg = 0, |
| 47 | }, |
| 48 | }; |
| 49 | #elif defined(CONFIG_MPC8541) || defined(CONFIG_MPC8555) |
| 50 | static struct pci_info pci_config_info[] = |
| 51 | { |
| 52 | [LAW_TRGT_IF_PCI] = { |
Kumar Gala | 3e7b6c1 | 2009-09-02 09:03:08 -0500 | [diff] [blame] | 53 | .cfg = 0, |
| 54 | }, |
| 55 | }; |
| 56 | #elif defined(CONFIG_MPC8536) |
| 57 | static struct pci_info pci_config_info[] = |
| 58 | { |
| 59 | [LAW_TRGT_IF_PCI] = { |
Kumar Gala | 3e7b6c1 | 2009-09-02 09:03:08 -0500 | [diff] [blame] | 60 | .cfg = 0, |
| 61 | }, |
| 62 | [LAW_TRGT_IF_PCIE_1] = { |
Kumar Gala | 3e7b6c1 | 2009-09-02 09:03:08 -0500 | [diff] [blame] | 63 | .cfg = (1 << 2) | (1 << 3) | (1 << 5) | (1 << 7), |
| 64 | }, |
| 65 | [LAW_TRGT_IF_PCIE_2] = { |
Kumar Gala | 3e7b6c1 | 2009-09-02 09:03:08 -0500 | [diff] [blame] | 66 | .cfg = (1 << 5) | (1 << 7), |
| 67 | }, |
| 68 | [LAW_TRGT_IF_PCIE_3] = { |
Kumar Gala | 3e7b6c1 | 2009-09-02 09:03:08 -0500 | [diff] [blame] | 69 | .cfg = (1 << 7), |
| 70 | }, |
| 71 | }; |
| 72 | #elif defined(CONFIG_MPC8544) |
| 73 | static struct pci_info pci_config_info[] = |
| 74 | { |
| 75 | [LAW_TRGT_IF_PCI] = { |
Kumar Gala | 3e7b6c1 | 2009-09-02 09:03:08 -0500 | [diff] [blame] | 76 | .cfg = 0, |
| 77 | }, |
| 78 | [LAW_TRGT_IF_PCIE_1] = { |
Kumar Gala | 3e7b6c1 | 2009-09-02 09:03:08 -0500 | [diff] [blame] | 79 | .cfg = (1 << 2) | (1 << 3) | (1 << 4) | (1 << 5) | |
| 80 | (1 << 6) | (1 << 7), |
| 81 | }, |
| 82 | [LAW_TRGT_IF_PCIE_2] = { |
Kumar Gala | 3e7b6c1 | 2009-09-02 09:03:08 -0500 | [diff] [blame] | 83 | .cfg = (1 << 4) | (1 << 5) | (1 << 6) | (1 << 7), |
| 84 | }, |
| 85 | [LAW_TRGT_IF_PCIE_3] = { |
Kumar Gala | 3e7b6c1 | 2009-09-02 09:03:08 -0500 | [diff] [blame] | 86 | .cfg = (1 << 6) | (1 << 7), |
| 87 | }, |
| 88 | }; |
| 89 | #elif defined(CONFIG_MPC8548) |
| 90 | static struct pci_info pci_config_info[] = |
| 91 | { |
| 92 | [LAW_TRGT_IF_PCI_1] = { |
Kumar Gala | 3e7b6c1 | 2009-09-02 09:03:08 -0500 | [diff] [blame] | 93 | .cfg = 0, |
| 94 | }, |
| 95 | [LAW_TRGT_IF_PCI_2] = { |
Kumar Gala | 3e7b6c1 | 2009-09-02 09:03:08 -0500 | [diff] [blame] | 96 | .cfg = 0, |
| 97 | }, |
| 98 | /* PCI_2 is always host and we dont use iosel to determine enable/disable */ |
| 99 | [LAW_TRGT_IF_PCIE_1] = { |
Kumar Gala | 3e7b6c1 | 2009-09-02 09:03:08 -0500 | [diff] [blame] | 100 | .cfg = (1 << 3) | (1 << 4) | (1 << 7), |
| 101 | }, |
| 102 | }; |
| 103 | #elif defined(CONFIG_MPC8568) |
| 104 | static struct pci_info pci_config_info[] = |
| 105 | { |
| 106 | [LAW_TRGT_IF_PCI] = { |
Kumar Gala | 3e7b6c1 | 2009-09-02 09:03:08 -0500 | [diff] [blame] | 107 | .cfg = 0, |
| 108 | }, |
| 109 | [LAW_TRGT_IF_PCIE_1] = { |
Kumar Gala | 3e7b6c1 | 2009-09-02 09:03:08 -0500 | [diff] [blame] | 110 | .cfg = (1 << 3) | (1 << 4) | (1 << 7), |
| 111 | }, |
| 112 | }; |
| 113 | #elif defined(CONFIG_MPC8569) |
| 114 | static struct pci_info pci_config_info[] = |
| 115 | { |
| 116 | [LAW_TRGT_IF_PCIE_1] = { |
Kumar Gala | 3e7b6c1 | 2009-09-02 09:03:08 -0500 | [diff] [blame] | 117 | .cfg = (1 << 0) | (1 << 4) | (1 << 5) | (1 << 6) | (1 << 7) | |
| 118 | (1 << 8) | (1 << 0xc) | (1 << 0xf), |
| 119 | }, |
| 120 | }; |
| 121 | #elif defined(CONFIG_MPC8572) |
| 122 | static struct pci_info pci_config_info[] = |
| 123 | { |
| 124 | [LAW_TRGT_IF_PCIE_1] = { |
Kumar Gala | 3e7b6c1 | 2009-09-02 09:03:08 -0500 | [diff] [blame] | 125 | .cfg = (1 << 2) | (1 << 3) | (1 << 7) | |
| 126 | (1 << 0xb) | (1 << 0xc) | (1 << 0xf), |
| 127 | }, |
| 128 | [LAW_TRGT_IF_PCIE_2] = { |
Kumar Gala | 3e7b6c1 | 2009-09-02 09:03:08 -0500 | [diff] [blame] | 129 | .cfg = (1 << 3) | (1 << 7), |
| 130 | }, |
| 131 | [LAW_TRGT_IF_PCIE_3] = { |
Kumar Gala | 3e7b6c1 | 2009-09-02 09:03:08 -0500 | [diff] [blame] | 132 | .cfg = (1 << 7), |
| 133 | }, |
| 134 | }; |
| 135 | #elif defined(CONFIG_MPC8610) |
| 136 | static struct pci_info pci_config_info[] = |
| 137 | { |
| 138 | [LAW_TRGT_IF_PCI_1] = { |
Kumar Gala | 3e7b6c1 | 2009-09-02 09:03:08 -0500 | [diff] [blame] | 139 | .cfg = 0, |
| 140 | }, |
| 141 | [LAW_TRGT_IF_PCIE_1] = { |
Kumar Gala | 3e7b6c1 | 2009-09-02 09:03:08 -0500 | [diff] [blame] | 142 | .cfg = (1 << 1) | (1 << 4), |
| 143 | }, |
| 144 | [LAW_TRGT_IF_PCIE_2] = { |
Kumar Gala | 3e7b6c1 | 2009-09-02 09:03:08 -0500 | [diff] [blame] | 145 | .cfg = (1 << 0) | (1 << 4), |
| 146 | }, |
| 147 | }; |
| 148 | #elif defined(CONFIG_MPC8641) |
| 149 | static struct pci_info pci_config_info[] = |
| 150 | { |
| 151 | [LAW_TRGT_IF_PCIE_1] = { |
Kumar Gala | 3e7b6c1 | 2009-09-02 09:03:08 -0500 | [diff] [blame] | 152 | .cfg = (1 << 2) | (1 << 3) | (1 << 5) | (1 << 6) | |
| 153 | (1 << 7) | (1 << 0xe) | (1 << 0xf), |
| 154 | }, |
| 155 | }; |
| 156 | #elif defined(CONFIG_P1011) || defined(CONFIG_P1020) |
| 157 | static struct pci_info pci_config_info[] = |
| 158 | { |
| 159 | [LAW_TRGT_IF_PCIE_1] = { |
Kumar Gala | 3e7b6c1 | 2009-09-02 09:03:08 -0500 | [diff] [blame] | 160 | .cfg = (1 << 0) | (1 << 6) | (1 << 0xe) | (1 << 0xf), |
| 161 | }, |
| 162 | [LAW_TRGT_IF_PCIE_2] = { |
Kumar Gala | 3e7b6c1 | 2009-09-02 09:03:08 -0500 | [diff] [blame] | 163 | .cfg = (1 << 0xe), |
| 164 | }, |
| 165 | }; |
| 166 | #elif defined(CONFIG_P2010) || defined(CONFIG_P2020) |
| 167 | static struct pci_info pci_config_info[] = |
| 168 | { |
| 169 | [LAW_TRGT_IF_PCIE_1] = { |
Kumar Gala | 3e7b6c1 | 2009-09-02 09:03:08 -0500 | [diff] [blame] | 170 | .cfg = (1 << 0) | (1 << 2) | (1 << 4) | (1 << 6) | |
| 171 | (1 << 0xd) | (1 << 0xe) | (1 << 0xf), |
| 172 | }, |
| 173 | [LAW_TRGT_IF_PCIE_2] = { |
Kumar Gala | 3e7b6c1 | 2009-09-02 09:03:08 -0500 | [diff] [blame] | 174 | .cfg = (1 << 2) | (1 << 0xe), |
| 175 | }, |
| 176 | [LAW_TRGT_IF_PCIE_3] = { |
Kumar Gala | 3e7b6c1 | 2009-09-02 09:03:08 -0500 | [diff] [blame] | 177 | .cfg = (1 << 2) | (1 << 4), |
| 178 | }, |
| 179 | }; |
Kumar Gala | 178e39e | 2009-09-17 00:01:14 -0500 | [diff] [blame] | 180 | #elif defined(CONFIG_FSL_CORENET) |
Kumar Gala | 3e7b6c1 | 2009-09-02 09:03:08 -0500 | [diff] [blame] | 181 | #else |
| 182 | #error Need to define pci_config_info for processor |
| 183 | #endif |
| 184 | |
Kumar Gala | 178e39e | 2009-09-17 00:01:14 -0500 | [diff] [blame] | 185 | #ifndef CONFIG_FSL_CORENET |
Kumar Gala | 3e7b6c1 | 2009-09-02 09:03:08 -0500 | [diff] [blame] | 186 | int is_fsl_pci_cfg(enum law_trgt_if trgt, u32 io_sel) |
| 187 | { |
| 188 | return ((1 << io_sel) & pci_config_info[trgt].cfg); |
| 189 | } |
Kumar Gala | 178e39e | 2009-09-17 00:01:14 -0500 | [diff] [blame] | 190 | #endif |