blob: 5cbe139d55f8e56cb456efd668b4326f1b4ca706 [file] [log] [blame]
Kumar Galaa6c612c2009-11-04 13:00:55 -06001/*
Kumar Galad0f27d32010-07-08 22:37:44 -05002 * Copyright 2007,2009-2010 Freescale Semiconductor, Inc.
Ed Swarthout91080f72007-08-02 14:09:49 -05003 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of
7 * the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
17 * MA 02111-1307 USA
18 *
19 */
20
Kumar Galad6bab952009-04-02 13:57:05 -050021#ifndef __FSL_PCI_H_
22#define __FSL_PCI_H_
23
Kumar Gala666ced12009-09-02 09:03:08 -050024#include <asm/fsl_law.h>
25
Kumar Galaa6c612c2009-11-04 13:00:55 -060026int fsl_setup_hose(struct pci_controller *hose, unsigned long addr);
Ed Swarthout4451a6d2009-11-02 09:05:49 -060027int fsl_is_pci_agent(struct pci_controller *hose);
Kumar Gala65e198d2009-08-03 20:44:55 -050028void fsl_pci_init(struct pci_controller *hose, u32 cfg_addr, u32 cfg_data);
Kumar Galad6bab952009-04-02 13:57:05 -050029void fsl_pci_config_unlock(struct pci_controller *hose);
Kumar Galadb943ed2010-12-17 05:57:25 -060030void ft_fsl_pci_setup(void *blob, const char *compat, unsigned long ctrl_addr);
Ed Swarthout91080f72007-08-02 14:09:49 -050031
32/*
33 * Common PCI/PCIE Register structure for mpc85xx and mpc86xx
34 */
35
36/*
37 * PCI Translation Registers
38 */
39typedef struct pci_outbound_window {
40 u32 potar; /* 0x00 - Address */
41 u32 potear; /* 0x04 - Address Extended */
42 u32 powbar; /* 0x08 - Window Base Address */
43 u32 res1;
44 u32 powar; /* 0x10 - Window Attributes */
45#define POWAR_EN 0x80000000
46#define POWAR_IO_READ 0x00080000
47#define POWAR_MEM_READ 0x00040000
48#define POWAR_IO_WRITE 0x00008000
49#define POWAR_MEM_WRITE 0x00004000
50 u32 res2[3];
51} pot_t;
52
53typedef struct pci_inbound_window {
54 u32 pitar; /* 0x00 - Address */
55 u32 res1;
56 u32 piwbar; /* 0x08 - Window Base Address */
57 u32 piwbear; /* 0x0c - Window Base Address Extended */
58 u32 piwar; /* 0x10 - Window Attributes */
59#define PIWAR_EN 0x80000000
60#define PIWAR_PF 0x20000000
61#define PIWAR_LOCAL 0x00f00000
62#define PIWAR_READ_SNOOP 0x00050000
63#define PIWAR_WRITE_SNOOP 0x00005000
64 u32 res2[3];
65} pit_t;
66
67/* PCI/PCI Express Registers */
68typedef struct ccsr_pci {
69 u32 cfg_addr; /* 0x000 - PCI Configuration Address Register */
70 u32 cfg_data; /* 0x004 - PCI Configuration Data Register */
71 u32 int_ack; /* 0x008 - PCI Interrupt Acknowledge Register */
72 u32 out_comp_to; /* 0x00C - PCI Outbound Completion Timeout Register */
73 u32 out_conf_to; /* 0x010 - PCI Configuration Timeout Register */
74 u32 config; /* 0x014 - PCIE CONFIG Register */
75 char res2[8];
76 u32 pme_msg_det; /* 0x020 - PCIE PME & message detect register */
77 u32 pme_msg_dis; /* 0x024 - PCIE PME & message disable register */
78 u32 pme_msg_int_en; /* 0x028 - PCIE PME & message interrupt enable register */
79 u32 pm_command; /* 0x02c - PCIE PM Command register */
80 char res4[3016]; /* (- #xbf8 #x30)3016 */
81 u32 block_rev1; /* 0xbf8 - PCIE Block Revision register 1 */
82 u32 block_rev2; /* 0xbfc - PCIE Block Revision register 2 */
83
84 pot_t pot[5]; /* 0xc00 - 0xc9f Outbound ATMU's 0, 1, 2, 3, and 4 */
85 u32 res5[64];
86 pit_t pit[3]; /* 0xda0 - 0xdff Inbound ATMU's 3, 2, and 1 */
87#define PIT3 0
88#define PIT2 1
89#define PIT1 2
90
91#if 0
92 u32 potar0; /* 0xc00 - PCI Outbound Transaction Address Register 0 */
93 u32 potear0; /* 0xc04 - PCI Outbound Translation Extended Address Register 0 */
94 char res5[8];
95 u32 powar0; /* 0xc10 - PCI Outbound Window Attributes Register 0 */
96 char res6[12];
97 u32 potar1; /* 0xc20 - PCI Outbound Transaction Address Register 1 */
98 u32 potear1; /* 0xc24 - PCI Outbound Translation Extended Address Register 1 */
99 u32 powbar1; /* 0xc28 - PCI Outbound Window Base Address Register 1 */
100 char res7[4];
101 u32 powar1; /* 0xc30 - PCI Outbound Window Attributes Register 1 */
102 char res8[12];
103 u32 potar2; /* 0xc40 - PCI Outbound Transaction Address Register 2 */
104 u32 potear2; /* 0xc44 - PCI Outbound Translation Extended Address Register 2 */
105 u32 powbar2; /* 0xc48 - PCI Outbound Window Base Address Register 2 */
106 char res9[4];
107 u32 powar2; /* 0xc50 - PCI Outbound Window Attributes Register 2 */
108 char res10[12];
109 u32 potar3; /* 0xc60 - PCI Outbound Transaction Address Register 3 */
110 u32 potear3; /* 0xc64 - PCI Outbound Translation Extended Address Register 3 */
111 u32 powbar3; /* 0xc68 - PCI Outbound Window Base Address Register 3 */
112 char res11[4];
113 u32 powar3; /* 0xc70 - PCI Outbound Window Attributes Register 3 */
114 char res12[12];
115 u32 potar4; /* 0xc80 - PCI Outbound Transaction Address Register 4 */
116 u32 potear4; /* 0xc84 - PCI Outbound Translation Extended Address Register 4 */
117 u32 powbar4; /* 0xc88 - PCI Outbound Window Base Address Register 4 */
118 char res13[4];
119 u32 powar4; /* 0xc90 - PCI Outbound Window Attributes Register 4 */
120 char res14[268];
121 u32 pitar3; /* 0xda0 - PCI Inbound Translation Address Register 3 */
122 char res15[4];
123 u32 piwbar3; /* 0xda8 - PCI Inbound Window Base Address Register 3 */
124 u32 piwbear3; /* 0xdac - PCI Inbound Window Base Extended Address Register 3 */
125 u32 piwar3; /* 0xdb0 - PCI Inbound Window Attributes Register 3 */
126 char res16[12];
127 u32 pitar2; /* 0xdc0 - PCI Inbound Translation Address Register 2 */
128 char res17[4];
129 u32 piwbar2; /* 0xdc8 - PCI Inbound Window Base Address Register 2 */
130 u32 piwbear2; /* 0xdcc - PCI Inbound Window Base Extended Address Register 2 */
131 u32 piwar2; /* 0xdd0 - PCI Inbound Window Attributes Register 2 */
132 char res18[12];
133 u32 pitar1; /* 0xde0 - PCI Inbound Translation Address Register 1 */
134 char res19[4];
135 u32 piwbar1; /* 0xde8 - PCI Inbound Window Base Address Register 1 */
136 char res20[4];
137 u32 piwar1; /* 0xdf0 - PCI Inbound Window Attributes Register 1 */
138 char res21[12];
139#endif
140 u32 pedr; /* 0xe00 - PCI Error Detect Register */
141 u32 pecdr; /* 0xe04 - PCI Error Capture Disable Register */
142 u32 peer; /* 0xe08 - PCI Error Interrupt Enable Register */
143 u32 peattrcr; /* 0xe0c - PCI Error Attributes Capture Register */
144 u32 peaddrcr; /* 0xe10 - PCI Error Address Capture Register */
145/* u32 perr_disr * 0xe10 - PCIE Erorr Disable Register */
146 u32 peextaddrcr; /* 0xe14 - PCI Error Extended Address Capture Register */
147 u32 pedlcr; /* 0xe18 - PCI Error Data Low Capture Register */
148 u32 pedhcr; /* 0xe1c - PCI Error Error Data High Capture Register */
149 u32 gas_timr; /* 0xe20 - PCI Gasket Timer Register */
150/* u32 perr_cap_stat; * 0xe20 - PCIE Error Capture Status Register */
151 char res22[4];
152 u32 perr_cap0; /* 0xe28 - PCIE Error Capture Register 0 */
153 u32 perr_cap1; /* 0xe2c - PCIE Error Capture Register 1 */
154 u32 perr_cap2; /* 0xe30 - PCIE Error Capture Register 2 */
155 u32 perr_cap3; /* 0xe34 - PCIE Error Capture Register 3 */
Kumar Gala93166d22007-12-07 12:17:34 -0600156 char res23[200];
157 u32 pdb_stat; /* 0xf00 - PCIE Debug Status */
158 char res24[252];
Ed Swarthout91080f72007-08-02 14:09:49 -0500159} ccsr_fsl_pci_t;
160
Poonam Aggrwal1c796172009-08-21 07:29:42 +0530161struct fsl_pci_info {
Timur Tabi472d07062010-05-28 15:05:30 -0500162 unsigned long regs;
163 pci_addr_t mem_bus;
164 phys_size_t mem_phys;
165 pci_size_t mem_size;
166 pci_addr_t io_bus;
167 phys_size_t io_phys;
168 pci_size_t io_size;
169 enum law_trgt_if law;
170 int pci_num;
Poonam Aggrwal1c796172009-08-21 07:29:42 +0530171};
172
173int fsl_pci_init_port(struct fsl_pci_info *pci_info,
Kumar Galab83ff072009-11-04 01:29:04 -0600174 struct pci_controller *hose, int busno);
Poonam Aggrwal1c796172009-08-21 07:29:42 +0530175
Paul Gortmaker7cf5c042009-09-20 20:36:01 -0400176#define SET_STD_PCI_INFO(x, num) \
177{ \
178 x.regs = CONFIG_SYS_PCI##num##_ADDR; \
179 x.mem_bus = CONFIG_SYS_PCI##num##_MEM_BUS; \
180 x.mem_phys = CONFIG_SYS_PCI##num##_MEM_PHYS; \
181 x.mem_size = CONFIG_SYS_PCI##num##_MEM_SIZE; \
182 x.io_bus = CONFIG_SYS_PCI##num##_IO_BUS; \
183 x.io_phys = CONFIG_SYS_PCI##num##_IO_PHYS; \
184 x.io_size = CONFIG_SYS_PCI##num##_IO_SIZE; \
Timur Tabi472d07062010-05-28 15:05:30 -0500185 x.law = LAW_TRGT_IF_PCI_##num; \
Paul Gortmaker7cf5c042009-09-20 20:36:01 -0400186 x.pci_num = num; \
187}
188
Poonam Aggrwal1c796172009-08-21 07:29:42 +0530189#define SET_STD_PCIE_INFO(x, num) \
190{ \
191 x.regs = CONFIG_SYS_PCIE##num##_ADDR; \
192 x.mem_bus = CONFIG_SYS_PCIE##num##_MEM_BUS; \
193 x.mem_phys = CONFIG_SYS_PCIE##num##_MEM_PHYS; \
194 x.mem_size = CONFIG_SYS_PCIE##num##_MEM_SIZE; \
195 x.io_bus = CONFIG_SYS_PCIE##num##_IO_BUS; \
196 x.io_phys = CONFIG_SYS_PCIE##num##_IO_PHYS; \
197 x.io_size = CONFIG_SYS_PCIE##num##_IO_SIZE; \
Timur Tabi472d07062010-05-28 15:05:30 -0500198 x.law = LAW_TRGT_IF_PCIE_##num; \
Poonam Aggrwal1c796172009-08-21 07:29:42 +0530199 x.pci_num = num; \
200}
201
Kumar Galad0f27d32010-07-08 22:37:44 -0500202#define __FT_FSL_PCI_SETUP(blob, compat, num) \
Kumar Galadb943ed2010-12-17 05:57:25 -0600203 ft_fsl_pci_setup(blob, compat, CONFIG_SYS_PCI##num##_ADDR)
Kumar Galad0f27d32010-07-08 22:37:44 -0500204
205#define __FT_FSL_PCIE_SETUP(blob, compat, num) \
Kumar Galadb943ed2010-12-17 05:57:25 -0600206 ft_fsl_pci_setup(blob, compat, CONFIG_SYS_PCIE##num##_ADDR)
Kumar Galad0f27d32010-07-08 22:37:44 -0500207
Kumar Galad0f27d32010-07-08 22:37:44 -0500208#define FT_FSL_PCI1_SETUP __FT_FSL_PCI_SETUP(blob, FSL_PCI_COMPAT, 1)
Kumar Galad0f27d32010-07-08 22:37:44 -0500209#define FT_FSL_PCI2_SETUP __FT_FSL_PCI_SETUP(blob, FSL_PCI_COMPAT, 2)
Kumar Galad0f27d32010-07-08 22:37:44 -0500210
Kumar Galad0f27d32010-07-08 22:37:44 -0500211#define FT_FSL_PCIE1_SETUP __FT_FSL_PCIE_SETUP(blob, FSL_PCIE_COMPAT, 1)
Kumar Galad0f27d32010-07-08 22:37:44 -0500212#define FT_FSL_PCIE2_SETUP __FT_FSL_PCIE_SETUP(blob, FSL_PCIE_COMPAT, 2)
Kumar Galad0f27d32010-07-08 22:37:44 -0500213#define FT_FSL_PCIE3_SETUP __FT_FSL_PCIE_SETUP(blob, FSL_PCIE_COMPAT, 3)
Kumar Galad0f27d32010-07-08 22:37:44 -0500214#define FT_FSL_PCIE4_SETUP __FT_FSL_PCIE_SETUP(blob, FSL_PCIE_COMPAT, 4)
Kumar Galad0f27d32010-07-08 22:37:44 -0500215
216#if defined(CONFIG_FSL_CORENET)
217#define FSL_PCIE_COMPAT "fsl,p4080-pcie"
218#define FT_FSL_PCI_SETUP \
219 FT_FSL_PCIE1_SETUP; \
220 FT_FSL_PCIE2_SETUP; \
221 FT_FSL_PCIE3_SETUP; \
222 FT_FSL_PCIE4_SETUP;
223#elif defined(CONFIG_MPC85xx)
224#define FSL_PCI_COMPAT "fsl,mpc8540-pci"
225#define FSL_PCIE_COMPAT "fsl,mpc8548-pcie"
226#define FT_FSL_PCI_SETUP \
227 FT_FSL_PCI1_SETUP; \
228 FT_FSL_PCI2_SETUP; \
229 FT_FSL_PCIE1_SETUP; \
230 FT_FSL_PCIE2_SETUP; \
231 FT_FSL_PCIE3_SETUP;
232#elif defined(CONFIG_MPC86xx)
233#define FSL_PCI_COMPAT "fsl,mpc8610-pci"
234#define FSL_PCIE_COMPAT "fsl,mpc8641-pcie"
235#define FT_FSL_PCI_SETUP \
236 FT_FSL_PCI1_SETUP; \
237 FT_FSL_PCIE1_SETUP; \
238 FT_FSL_PCIE2_SETUP;
239#else
240#error FT_FSL_PCI_SETUP not defined
241#endif
242
243
Kumar Galad6bab952009-04-02 13:57:05 -0500244#endif