1
2
3
4
5
6
7#ifndef __FSL_PCI_H_
8#define __FSL_PCI_H_
9
10#include <asm/fsl_law.h>
11#include <asm/fsl_serdes.h>
12#include <pci.h>
13
14#define PEX_IP_BLK_REV_2_2 0x02080202
15#define PEX_IP_BLK_REV_2_3 0x02080203
16#define PEX_IP_BLK_REV_3_0 0x02080300
17
18
19#define FSL_PCI_PBFR 0x44
20
21#define FSL_PCIE_CFG_RDY 0x4b0
22#define FSL_PCIE_V3_CFG_RDY 0x1
23#define FSL_PROG_IF_AGENT 0x1
24
25#define PCI_LTSSM 0x404
26#define PCI_LTSSM_L0 0x16
27
28int fsl_setup_hose(struct pci_controller *hose, unsigned long addr);
29int fsl_is_pci_agent(struct pci_controller *hose);
30void fsl_pci_config_unlock(struct pci_controller *hose);
31void ft_fsl_pci_setup(void *blob, const char *compat, unsigned long ctrl_addr);
32
33
34
35
36
37
38
39
40typedef struct pci_outbound_window {
41 u32 potar;
42 u32 potear;
43 u32 powbar;
44 u32 res1;
45 u32 powar;
46#define POWAR_EN 0x80000000
47#define POWAR_IO_READ 0x00080000
48#define POWAR_MEM_READ 0x00040000
49#define POWAR_IO_WRITE 0x00008000
50#define POWAR_MEM_WRITE 0x00004000
51 u32 res2[3];
52} pot_t;
53
54typedef struct pci_inbound_window {
55 u32 pitar;
56 u32 res1;
57 u32 piwbar;
58 u32 piwbear;
59 u32 piwar;
60#define PIWAR_EN 0x80000000
61#define PIWAR_PF 0x20000000
62#define PIWAR_LOCAL 0x00f00000
63#define PIWAR_READ_SNOOP 0x00050000
64#define PIWAR_WRITE_SNOOP 0x00005000
65 u32 res2[3];
66} pit_t;
67
68
69typedef struct ccsr_pci {
70 u32 cfg_addr;
71 u32 cfg_data;
72 u32 int_ack;
73 u32 out_comp_to;
74 u32 out_conf_to;
75 u32 config;
76 u32 int_status;
77 char res2[4];
78 u32 pme_msg_det;
79 u32 pme_msg_dis;
80 u32 pme_msg_int_en;
81 u32 pm_command;
82 char res3[2188];
83 u32 dbi_ro_wr_en;
84 char res4[824];
85 u32 block_rev1;
86 u32 block_rev2;
87
88 pot_t pot[5];
89 u32 res5[24];
90 pit_t pmit;
91 u32 res6[24];
92 pit_t pit[4];
93
94#define PIT3 0
95#define PIT2 1
96#define PIT1 2
97
98#if 0
99 u32 potar0;
100 u32 potear0;
101 char res5[8];
102 u32 powar0;
103 char res6[12];
104 u32 potar1;
105 u32 potear1;
106 u32 powbar1;
107 char res7[4];
108 u32 powar1;
109 char res8[12];
110 u32 potar2;
111 u32 potear2;
112 u32 powbar2;
113 char res9[4];
114 u32 powar2;
115 char res10[12];
116 u32 potar3;
117 u32 potear3;
118 u32 powbar3;
119 char res11[4];
120 u32 powar3;
121 char res12[12];
122 u32 potar4;
123 u32 potear4;
124 u32 powbar4;
125 char res13[4];
126 u32 powar4;
127 char res14[268];
128 u32 pitar3;
129 char res15[4];
130 u32 piwbar3;
131 u32 piwbear3;
132 u32 piwar3;
133 char res16[12];
134 u32 pitar2;
135 char res17[4];
136 u32 piwbar2;
137 u32 piwbear2;
138 u32 piwar2;
139 char res18[12];
140 u32 pitar1;
141 char res19[4];
142 u32 piwbar1;
143 char res20[4];
144 u32 piwar1;
145 char res21[12];
146#endif
147 u32 pedr;
148 u32 pecdr;
149 u32 peer;
150 u32 peattrcr;
151 u32 peaddrcr;
152
153 u32 peextaddrcr;
154 u32 pedlcr;
155 u32 pedhcr;
156 u32 gas_timr;
157
158 char res22[4];
159 u32 perr_cap0;
160 u32 perr_cap1;
161 u32 perr_cap2;
162 u32 perr_cap3;
163 char res23[200];
164 u32 pdb_stat;
165 char res24[16];
166 u32 pex_csr0;
167 u32 pex_csr1;
168 char res25[228];
169} ccsr_fsl_pci_t;
170#define PCIE_CONFIG_PC 0x00020000
171#define PCIE_CONFIG_OB_CK 0x00002000
172#define PCIE_CONFIG_SAC 0x00000010
173#define PCIE_CONFIG_SP 0x80000002
174#define PCIE_CONFIG_SCC 0x80000001
175
176struct fsl_pci_info {
177 unsigned long regs;
178 pci_addr_t mem_bus;
179 phys_size_t mem_phys;
180 pci_size_t mem_size;
181 pci_addr_t io_bus;
182 phys_size_t io_phys;
183 pci_size_t io_size;
184 enum law_trgt_if law;
185 int pci_num;
186};
187
188void fsl_pci_init(struct pci_controller *hose, struct fsl_pci_info *pci_info);
189int fsl_pci_init_port(struct fsl_pci_info *pci_info,
190 struct pci_controller *hose, int busno);
191int fsl_pcie_init_ctrl(int busno, u32 devdisr, enum srds_prtcl dev,
192 struct fsl_pci_info *pci_info);
193int fsl_pcie_init_board(int busno);
194
195#define SET_STD_PCI_INFO(x, num) \
196{ \
197 x.regs = CONFIG_SYS_PCI##num##_ADDR; \
198 x.mem_bus = CONFIG_SYS_PCI##num##_MEM_BUS; \
199 x.mem_phys = CONFIG_SYS_PCI##num##_MEM_PHYS; \
200 x.mem_size = CONFIG_SYS_PCI##num##_MEM_SIZE; \
201 x.io_bus = CONFIG_SYS_PCI##num##_IO_BUS; \
202 x.io_phys = CONFIG_SYS_PCI##num##_IO_PHYS; \
203 x.io_size = CONFIG_SYS_PCI##num##_IO_SIZE; \
204 x.law = LAW_TRGT_IF_PCI_##num; \
205 x.pci_num = num; \
206}
207
208#define SET_STD_PCIE_INFO(x, num) \
209{ \
210 x.regs = CONFIG_SYS_PCIE##num##_ADDR; \
211 x.mem_bus = CONFIG_SYS_PCIE##num##_MEM_BUS; \
212 x.mem_phys = CONFIG_SYS_PCIE##num##_MEM_PHYS; \
213 x.mem_size = CONFIG_SYS_PCIE##num##_MEM_SIZE; \
214 x.io_bus = CONFIG_SYS_PCIE##num##_IO_BUS; \
215 x.io_phys = CONFIG_SYS_PCIE##num##_IO_PHYS; \
216 x.io_size = CONFIG_SYS_PCIE##num##_IO_SIZE; \
217 x.law = LAW_TRGT_IF_PCIE_##num; \
218 x.pci_num = num; \
219}
220
221#define __FT_FSL_PCI_SETUP(blob, compat, num) \
222 ft_fsl_pci_setup(blob, compat, CONFIG_SYS_PCI##num##_ADDR)
223
224#define __FT_FSL_PCIE_SETUP(blob, compat, num) \
225 ft_fsl_pci_setup(blob, compat, CONFIG_SYS_PCIE##num##_ADDR)
226
227#define FT_FSL_PCI1_SETUP __FT_FSL_PCI_SETUP(blob, FSL_PCI_COMPAT, 1)
228#define FT_FSL_PCI2_SETUP __FT_FSL_PCI_SETUP(blob, FSL_PCI_COMPAT, 2)
229
230#define FT_FSL_PCIE1_SETUP __FT_FSL_PCIE_SETUP(blob, FSL_PCIE_COMPAT, 1)
231#define FT_FSL_PCIE2_SETUP __FT_FSL_PCIE_SETUP(blob, FSL_PCIE_COMPAT, 2)
232#define FT_FSL_PCIE3_SETUP __FT_FSL_PCIE_SETUP(blob, FSL_PCIE_COMPAT, 3)
233#define FT_FSL_PCIE4_SETUP __FT_FSL_PCIE_SETUP(blob, FSL_PCIE_COMPAT, 4)
234
235#if !defined(CONFIG_PCI)
236#define FT_FSL_PCI_SETUP
237#elif defined(CONFIG_FSL_CORENET)
238#define FSL_PCIE_COMPAT CONFIG_SYS_FSL_PCIE_COMPAT
239#define FT_FSL_PCI_SETUP \
240 FT_FSL_PCIE1_SETUP; \
241 FT_FSL_PCIE2_SETUP; \
242 FT_FSL_PCIE3_SETUP; \
243 FT_FSL_PCIE4_SETUP;
244#define FT_FSL_PCIE_SETUP FT_FSL_PCI_SETUP
245#elif defined(CONFIG_MPC85xx)
246#define FSL_PCI_COMPAT "fsl,mpc8540-pci"
247#ifdef CONFIG_SYS_FSL_PCIE_COMPAT
248#define FSL_PCIE_COMPAT CONFIG_SYS_FSL_PCIE_COMPAT
249#else
250#define FSL_PCIE_COMPAT "fsl,mpc8548-pcie"
251#endif
252#define FT_FSL_PCI_SETUP \
253 FT_FSL_PCI1_SETUP; \
254 FT_FSL_PCI2_SETUP; \
255 FT_FSL_PCIE1_SETUP; \
256 FT_FSL_PCIE2_SETUP; \
257 FT_FSL_PCIE3_SETUP;
258#define FT_FSL_PCIE_SETUP \
259 FT_FSL_PCIE1_SETUP; \
260 FT_FSL_PCIE2_SETUP; \
261 FT_FSL_PCIE3_SETUP;
262#elif defined(CONFIG_MPC86xx)
263#define FSL_PCI_COMPAT "fsl,mpc8610-pci"
264#define FSL_PCIE_COMPAT "fsl,mpc8641-pcie"
265#define FT_FSL_PCI_SETUP \
266 FT_FSL_PCI1_SETUP; \
267 FT_FSL_PCIE1_SETUP; \
268 FT_FSL_PCIE2_SETUP;
269#else
270#error FT_FSL_PCI_SETUP not defined
271#endif
272
273
274#endif
275