blob: 186936f23e830b189e6c350433b1f02496f67847 [file] [log] [blame]
Kumar Gala666ced12009-09-02 09:03:08 -05001/*
Kumar Gala16a276e2010-03-30 23:06:53 -05002 * Copyright 2009-2010 Freescale Semiconductor, Inc.
Kumar Gala666ced12009-09-02 09:03:08 -05003 *
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
27struct pci_info {
Kumar Gala16a276e2010-03-30 23:06:53 -050028 u32 cfg;
Kumar Gala666ced12009-09-02 09:03:08 -050029};
30
Kumar Galaa6c612c2009-11-04 13:00:55 -060031/* 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 Gala666ced12009-09-02 09:03:08 -050034 *
35 * On MPC86xx/PQ3 based systems:
Kumar Gala666ced12009-09-02 09:03:08 -050036 * 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)
43static struct pci_info pci_config_info[] =
44{
45 [LAW_TRGT_IF_PCI] = {
Kumar Gala666ced12009-09-02 09:03:08 -050046 .cfg = 0,
47 },
48};
49#elif defined(CONFIG_MPC8541) || defined(CONFIG_MPC8555)
50static struct pci_info pci_config_info[] =
51{
52 [LAW_TRGT_IF_PCI] = {
Kumar Gala666ced12009-09-02 09:03:08 -050053 .cfg = 0,
54 },
55};
56#elif defined(CONFIG_MPC8536)
57static struct pci_info pci_config_info[] =
58{
Kumar Gala666ced12009-09-02 09:03:08 -050059};
60#elif defined(CONFIG_MPC8544)
61static struct pci_info pci_config_info[] =
62{
63 [LAW_TRGT_IF_PCI] = {
Kumar Gala666ced12009-09-02 09:03:08 -050064 .cfg = 0,
65 },
66 [LAW_TRGT_IF_PCIE_1] = {
Kumar Gala666ced12009-09-02 09:03:08 -050067 .cfg = (1 << 2) | (1 << 3) | (1 << 4) | (1 << 5) |
68 (1 << 6) | (1 << 7),
69 },
70 [LAW_TRGT_IF_PCIE_2] = {
Kumar Gala666ced12009-09-02 09:03:08 -050071 .cfg = (1 << 4) | (1 << 5) | (1 << 6) | (1 << 7),
72 },
73 [LAW_TRGT_IF_PCIE_3] = {
Kumar Gala666ced12009-09-02 09:03:08 -050074 .cfg = (1 << 6) | (1 << 7),
75 },
76};
77#elif defined(CONFIG_MPC8548)
78static struct pci_info pci_config_info[] =
79{
80 [LAW_TRGT_IF_PCI_1] = {
Kumar Gala666ced12009-09-02 09:03:08 -050081 .cfg = 0,
82 },
83 [LAW_TRGT_IF_PCI_2] = {
Kumar Gala666ced12009-09-02 09:03:08 -050084 .cfg = 0,
85 },
86 /* PCI_2 is always host and we dont use iosel to determine enable/disable */
87 [LAW_TRGT_IF_PCIE_1] = {
Kumar Gala666ced12009-09-02 09:03:08 -050088 .cfg = (1 << 3) | (1 << 4) | (1 << 7),
89 },
90};
91#elif defined(CONFIG_MPC8568)
92static struct pci_info pci_config_info[] =
93{
94 [LAW_TRGT_IF_PCI] = {
Kumar Gala666ced12009-09-02 09:03:08 -050095 .cfg = 0,
96 },
97 [LAW_TRGT_IF_PCIE_1] = {
Kumar Gala666ced12009-09-02 09:03:08 -050098 .cfg = (1 << 3) | (1 << 4) | (1 << 7),
99 },
100};
101#elif defined(CONFIG_MPC8569)
102static struct pci_info pci_config_info[] =
103{
104 [LAW_TRGT_IF_PCIE_1] = {
Kumar Gala666ced12009-09-02 09:03:08 -0500105 .cfg = (1 << 0) | (1 << 4) | (1 << 5) | (1 << 6) | (1 << 7) |
106 (1 << 8) | (1 << 0xc) | (1 << 0xf),
107 },
108};
109#elif defined(CONFIG_MPC8572)
110static struct pci_info pci_config_info[] =
111{
112 [LAW_TRGT_IF_PCIE_1] = {
Kumar Gala666ced12009-09-02 09:03:08 -0500113 .cfg = (1 << 2) | (1 << 3) | (1 << 7) |
114 (1 << 0xb) | (1 << 0xc) | (1 << 0xf),
115 },
116 [LAW_TRGT_IF_PCIE_2] = {
Kumar Gala666ced12009-09-02 09:03:08 -0500117 .cfg = (1 << 3) | (1 << 7),
118 },
119 [LAW_TRGT_IF_PCIE_3] = {
Kumar Gala666ced12009-09-02 09:03:08 -0500120 .cfg = (1 << 7),
121 },
122};
123#elif defined(CONFIG_MPC8610)
124static struct pci_info pci_config_info[] =
125{
126 [LAW_TRGT_IF_PCI_1] = {
Kumar Gala666ced12009-09-02 09:03:08 -0500127 .cfg = 0,
128 },
129 [LAW_TRGT_IF_PCIE_1] = {
Kumar Gala666ced12009-09-02 09:03:08 -0500130 .cfg = (1 << 1) | (1 << 4),
131 },
132 [LAW_TRGT_IF_PCIE_2] = {
Kumar Gala666ced12009-09-02 09:03:08 -0500133 .cfg = (1 << 0) | (1 << 4),
134 },
135};
136#elif defined(CONFIG_MPC8641)
137static struct pci_info pci_config_info[] =
138{
139 [LAW_TRGT_IF_PCIE_1] = {
Kumar Gala666ced12009-09-02 09:03:08 -0500140 .cfg = (1 << 2) | (1 << 3) | (1 << 5) | (1 << 6) |
141 (1 << 7) | (1 << 0xe) | (1 << 0xf),
142 },
143};
Kumar Gala16a276e2010-03-30 23:06:53 -0500144#elif defined(CONFIG_P1011) || defined(CONFIG_P1020) || \
145 defined(CONFIG_P1012) || defined(CONFIG_P1021)
Kumar Gala666ced12009-09-02 09:03:08 -0500146static struct pci_info pci_config_info[] =
147{
148 [LAW_TRGT_IF_PCIE_1] = {
Kumar Gala666ced12009-09-02 09:03:08 -0500149 .cfg = (1 << 0) | (1 << 6) | (1 << 0xe) | (1 << 0xf),
150 },
151 [LAW_TRGT_IF_PCIE_2] = {
Kumar Gala666ced12009-09-02 09:03:08 -0500152 .cfg = (1 << 0xe),
153 },
154};
Kumar Gala16a276e2010-03-30 23:06:53 -0500155#elif defined(CONFIG_P1013) || defined(CONFIG_P1022)
156static struct pci_info pci_config_info[] =
157{
158 [LAW_TRGT_IF_PCIE_1] = {
159 .cfg = (1 << 6) | (1 << 7) | (1 << 9) | (1 << 0xa) |
160 (1 << 0xb) | (1 << 0xd) | (1 << 0xe) |
161 (1 << 0xf) | (1 << 0x15) | (1 << 0x16) |
162 (1 << 0x17) | (1 << 0x18) | (1 << 0x19) |
163 (1 << 0x1a) | (1 << 0x1b) | (1 << 0x1c) |
164 (1 << 0x1d) | (1 << 0x1e) | (1 << 0x1f),
165 },
166 [LAW_TRGT_IF_PCIE_2] = {
Dave Liuacbd8ec2010-04-14 19:05:06 +0800167 .cfg = (1 << 1) | (1 << 6) | (1 << 7) | (1 << 9) |
168 (1 << 0xd) | (1 << 0x15) | (1 << 0x16) | (1 << 0x17) |
169 (1 << 0x18) | (1 << 0x19) | (1 << 0x1a) | (1 << 0x1b),
Kumar Gala16a276e2010-03-30 23:06:53 -0500170 },
171 [LAW_TRGT_IF_PCIE_3] = {
Dave Liuacbd8ec2010-04-14 19:05:06 +0800172 .cfg = (1 << 0) | (1 << 1) | (1 << 6) | (1 << 7) | (1 << 9) |
173 (1 << 0xa) | (1 << 0xb) | (1 << 0xd) | (1 << 0x15) |
174 (1 << 0x16) | (1 << 0x17) | (1 << 0x18) | (1 << 0x1c),
Kumar Gala16a276e2010-03-30 23:06:53 -0500175 },
176};
Kumar Gala666ced12009-09-02 09:03:08 -0500177#elif defined(CONFIG_P2010) || defined(CONFIG_P2020)
178static struct pci_info pci_config_info[] =
179{
180 [LAW_TRGT_IF_PCIE_1] = {
Kumar Gala666ced12009-09-02 09:03:08 -0500181 .cfg = (1 << 0) | (1 << 2) | (1 << 4) | (1 << 6) |
182 (1 << 0xd) | (1 << 0xe) | (1 << 0xf),
183 },
184 [LAW_TRGT_IF_PCIE_2] = {
Kumar Gala666ced12009-09-02 09:03:08 -0500185 .cfg = (1 << 2) | (1 << 0xe),
186 },
187 [LAW_TRGT_IF_PCIE_3] = {
Kumar Gala666ced12009-09-02 09:03:08 -0500188 .cfg = (1 << 2) | (1 << 4),
189 },
190};
Kumar Galab49b09b2009-09-17 00:01:14 -0500191#elif defined(CONFIG_FSL_CORENET)
Kumar Gala666ced12009-09-02 09:03:08 -0500192#else
193#error Need to define pci_config_info for processor
194#endif
195
Kumar Galab49b09b2009-09-17 00:01:14 -0500196#ifndef CONFIG_FSL_CORENET
Kumar Gala666ced12009-09-02 09:03:08 -0500197int is_fsl_pci_cfg(enum law_trgt_if trgt, u32 io_sel)
198{
199 return ((1 << io_sel) & pci_config_info[trgt].cfg);
200}
Kumar Galab49b09b2009-09-17 00:01:14 -0500201#endif