xref: /rk3399_rockchip-uboot/arch/powerpc/include/asm/fsl_pci.h (revision a47a12becf66f02a56da91c161e2edb625e9f20c)
1*a47a12beSStefan Roese /*
2*a47a12beSStefan Roese  * Copyright 2007,2009 Freescale Semiconductor, Inc.
3*a47a12beSStefan Roese  *
4*a47a12beSStefan Roese  * This program is free software; you can redistribute it and/or
5*a47a12beSStefan Roese  * modify it under the terms of the GNU General Public License as
6*a47a12beSStefan Roese  * published by the Free Software Foundation; either version 2 of
7*a47a12beSStefan Roese  * the License, or (at your option) any later version.
8*a47a12beSStefan Roese  *
9*a47a12beSStefan Roese  * This program is distributed in the hope that it will be useful,
10*a47a12beSStefan Roese  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11*a47a12beSStefan Roese  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
12*a47a12beSStefan Roese  * GNU General Public License for more details.
13*a47a12beSStefan Roese  *
14*a47a12beSStefan Roese  * You should have received a copy of the GNU General Public License
15*a47a12beSStefan Roese  * along with this program; if not, write to the Free Software
16*a47a12beSStefan Roese  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
17*a47a12beSStefan Roese  * MA 02111-1307 USA
18*a47a12beSStefan Roese  *
19*a47a12beSStefan Roese  */
20*a47a12beSStefan Roese 
21*a47a12beSStefan Roese #ifndef __FSL_PCI_H_
22*a47a12beSStefan Roese #define __FSL_PCI_H_
23*a47a12beSStefan Roese 
24*a47a12beSStefan Roese #include <asm/fsl_law.h>
25*a47a12beSStefan Roese 
26*a47a12beSStefan Roese int is_fsl_pci_cfg(enum law_trgt_if trgt, u32 io_sel);
27*a47a12beSStefan Roese 
28*a47a12beSStefan Roese int fsl_setup_hose(struct pci_controller *hose, unsigned long addr);
29*a47a12beSStefan Roese int fsl_is_pci_agent(struct pci_controller *hose);
30*a47a12beSStefan Roese void fsl_pci_init(struct pci_controller *hose, u32 cfg_addr, u32 cfg_data);
31*a47a12beSStefan Roese void fsl_pci_config_unlock(struct pci_controller *hose);
32*a47a12beSStefan Roese void ft_fsl_pci_setup(void *blob, const char *pci_alias,
33*a47a12beSStefan Roese 			struct pci_controller *hose);
34*a47a12beSStefan Roese 
35*a47a12beSStefan Roese /*
36*a47a12beSStefan Roese  * Common PCI/PCIE Register structure for mpc85xx and mpc86xx
37*a47a12beSStefan Roese  */
38*a47a12beSStefan Roese 
39*a47a12beSStefan Roese /*
40*a47a12beSStefan Roese  * PCI Translation Registers
41*a47a12beSStefan Roese  */
42*a47a12beSStefan Roese typedef struct pci_outbound_window {
43*a47a12beSStefan Roese 	u32	potar;		/* 0x00 - Address */
44*a47a12beSStefan Roese 	u32	potear;		/* 0x04 - Address Extended */
45*a47a12beSStefan Roese 	u32	powbar;		/* 0x08 - Window Base Address */
46*a47a12beSStefan Roese 	u32	res1;
47*a47a12beSStefan Roese 	u32	powar;		/* 0x10 - Window Attributes */
48*a47a12beSStefan Roese #define POWAR_EN	0x80000000
49*a47a12beSStefan Roese #define POWAR_IO_READ	0x00080000
50*a47a12beSStefan Roese #define POWAR_MEM_READ	0x00040000
51*a47a12beSStefan Roese #define POWAR_IO_WRITE	0x00008000
52*a47a12beSStefan Roese #define POWAR_MEM_WRITE	0x00004000
53*a47a12beSStefan Roese 	u32	res2[3];
54*a47a12beSStefan Roese } pot_t;
55*a47a12beSStefan Roese 
56*a47a12beSStefan Roese typedef struct pci_inbound_window {
57*a47a12beSStefan Roese 	u32	pitar;		/* 0x00 - Address */
58*a47a12beSStefan Roese 	u32	res1;
59*a47a12beSStefan Roese 	u32	piwbar;		/* 0x08 - Window Base Address */
60*a47a12beSStefan Roese 	u32	piwbear;	/* 0x0c - Window Base Address Extended */
61*a47a12beSStefan Roese 	u32	piwar;		/* 0x10 - Window Attributes */
62*a47a12beSStefan Roese #define PIWAR_EN		0x80000000
63*a47a12beSStefan Roese #define PIWAR_PF		0x20000000
64*a47a12beSStefan Roese #define PIWAR_LOCAL		0x00f00000
65*a47a12beSStefan Roese #define PIWAR_READ_SNOOP	0x00050000
66*a47a12beSStefan Roese #define PIWAR_WRITE_SNOOP	0x00005000
67*a47a12beSStefan Roese 	u32	res2[3];
68*a47a12beSStefan Roese } pit_t;
69*a47a12beSStefan Roese 
70*a47a12beSStefan Roese /* PCI/PCI Express Registers */
71*a47a12beSStefan Roese typedef struct ccsr_pci {
72*a47a12beSStefan Roese 	u32	cfg_addr;	/* 0x000 - PCI Configuration Address Register */
73*a47a12beSStefan Roese 	u32	cfg_data;	/* 0x004 - PCI Configuration Data Register */
74*a47a12beSStefan Roese 	u32	int_ack;	/* 0x008 - PCI Interrupt Acknowledge Register */
75*a47a12beSStefan Roese 	u32	out_comp_to;	/* 0x00C - PCI Outbound Completion Timeout Register */
76*a47a12beSStefan Roese 	u32	out_conf_to;	/* 0x010 - PCI Configuration Timeout Register */
77*a47a12beSStefan Roese 	u32	config;		/* 0x014 - PCIE CONFIG Register */
78*a47a12beSStefan Roese 	char	res2[8];
79*a47a12beSStefan Roese 	u32	pme_msg_det;	/* 0x020 - PCIE PME & message detect register */
80*a47a12beSStefan Roese 	u32	pme_msg_dis;	/* 0x024 - PCIE PME & message disable register */
81*a47a12beSStefan Roese 	u32	pme_msg_int_en;	/* 0x028 - PCIE PME & message interrupt enable register */
82*a47a12beSStefan Roese 	u32	pm_command;	/* 0x02c - PCIE PM Command register */
83*a47a12beSStefan Roese 	char	res4[3016];	/*     (- #xbf8	 #x30)3016 */
84*a47a12beSStefan Roese 	u32	block_rev1;	/* 0xbf8 - PCIE Block Revision register 1 */
85*a47a12beSStefan Roese 	u32	block_rev2;	/* 0xbfc - PCIE Block Revision register 2 */
86*a47a12beSStefan Roese 
87*a47a12beSStefan Roese 	pot_t	pot[5];		/* 0xc00 - 0xc9f Outbound ATMU's 0, 1, 2, 3, and 4 */
88*a47a12beSStefan Roese 	u32	res5[64];
89*a47a12beSStefan Roese 	pit_t	pit[3];		/* 0xda0 - 0xdff Inbound ATMU's 3, 2, and 1 */
90*a47a12beSStefan Roese #define PIT3 0
91*a47a12beSStefan Roese #define PIT2 1
92*a47a12beSStefan Roese #define PIT1 2
93*a47a12beSStefan Roese 
94*a47a12beSStefan Roese #if 0
95*a47a12beSStefan Roese 	u32	potar0;		/* 0xc00 - PCI Outbound Transaction Address Register 0 */
96*a47a12beSStefan Roese 	u32	potear0;	/* 0xc04 - PCI Outbound Translation Extended Address Register 0 */
97*a47a12beSStefan Roese 	char	res5[8];
98*a47a12beSStefan Roese 	u32	powar0;		/* 0xc10 - PCI Outbound Window Attributes Register 0 */
99*a47a12beSStefan Roese 	char	res6[12];
100*a47a12beSStefan Roese 	u32	potar1;		/* 0xc20 - PCI Outbound Transaction Address Register 1 */
101*a47a12beSStefan Roese 	u32	potear1;	/* 0xc24 - PCI Outbound Translation Extended Address Register 1 */
102*a47a12beSStefan Roese 	u32	powbar1;	/* 0xc28 - PCI Outbound Window Base Address Register 1 */
103*a47a12beSStefan Roese 	char	res7[4];
104*a47a12beSStefan Roese 	u32	powar1;		/* 0xc30 - PCI Outbound Window Attributes Register 1 */
105*a47a12beSStefan Roese 	char	res8[12];
106*a47a12beSStefan Roese 	u32	potar2;		/* 0xc40 - PCI Outbound Transaction Address Register 2 */
107*a47a12beSStefan Roese 	u32	potear2;	/* 0xc44 - PCI Outbound Translation Extended Address Register 2 */
108*a47a12beSStefan Roese 	u32	powbar2;	/* 0xc48 - PCI Outbound Window Base Address Register 2 */
109*a47a12beSStefan Roese 	char	res9[4];
110*a47a12beSStefan Roese 	u32	powar2;		/* 0xc50 - PCI Outbound Window Attributes Register 2 */
111*a47a12beSStefan Roese 	char	res10[12];
112*a47a12beSStefan Roese 	u32	potar3;		/* 0xc60 - PCI Outbound Transaction Address Register 3 */
113*a47a12beSStefan Roese 	u32	potear3;	/* 0xc64 - PCI Outbound Translation Extended Address Register 3 */
114*a47a12beSStefan Roese 	u32	powbar3;	/* 0xc68 - PCI Outbound Window Base Address Register 3 */
115*a47a12beSStefan Roese 	char	res11[4];
116*a47a12beSStefan Roese 	u32	powar3;		/* 0xc70 - PCI Outbound Window Attributes Register 3 */
117*a47a12beSStefan Roese 	char	res12[12];
118*a47a12beSStefan Roese 	u32	potar4;		/* 0xc80 - PCI Outbound Transaction Address Register 4 */
119*a47a12beSStefan Roese 	u32	potear4;	/* 0xc84 - PCI Outbound Translation Extended Address Register 4 */
120*a47a12beSStefan Roese 	u32	powbar4;	/* 0xc88 - PCI Outbound Window Base Address Register 4 */
121*a47a12beSStefan Roese 	char	res13[4];
122*a47a12beSStefan Roese 	u32	powar4;		/* 0xc90 - PCI Outbound Window Attributes Register 4 */
123*a47a12beSStefan Roese 	char	res14[268];
124*a47a12beSStefan Roese 	u32	pitar3;		/* 0xda0 - PCI Inbound Translation Address Register 3 */
125*a47a12beSStefan Roese 	char	res15[4];
126*a47a12beSStefan Roese 	u32	piwbar3;	/* 0xda8 - PCI Inbound Window Base Address Register 3 */
127*a47a12beSStefan Roese 	u32	piwbear3;	/* 0xdac - PCI Inbound Window Base Extended Address Register 3 */
128*a47a12beSStefan Roese 	u32	piwar3;		/* 0xdb0 - PCI Inbound Window Attributes Register 3 */
129*a47a12beSStefan Roese 	char	res16[12];
130*a47a12beSStefan Roese 	u32	pitar2;		/* 0xdc0 - PCI Inbound Translation Address Register 2 */
131*a47a12beSStefan Roese 	char	res17[4];
132*a47a12beSStefan Roese 	u32	piwbar2;	/* 0xdc8 - PCI Inbound Window Base Address Register 2 */
133*a47a12beSStefan Roese 	u32	piwbear2;	/* 0xdcc - PCI Inbound Window Base Extended Address Register 2 */
134*a47a12beSStefan Roese 	u32	piwar2;		/* 0xdd0 - PCI Inbound Window Attributes Register 2 */
135*a47a12beSStefan Roese 	char	res18[12];
136*a47a12beSStefan Roese 	u32	pitar1;		/* 0xde0 - PCI Inbound Translation Address Register 1 */
137*a47a12beSStefan Roese 	char	res19[4];
138*a47a12beSStefan Roese 	u32	piwbar1;	/* 0xde8 - PCI Inbound Window Base Address Register 1 */
139*a47a12beSStefan Roese 	char	res20[4];
140*a47a12beSStefan Roese 	u32	piwar1;		/* 0xdf0 - PCI Inbound Window Attributes Register 1 */
141*a47a12beSStefan Roese 	char	res21[12];
142*a47a12beSStefan Roese #endif
143*a47a12beSStefan Roese 	u32	pedr;		/* 0xe00 - PCI Error Detect Register */
144*a47a12beSStefan Roese 	u32	pecdr;		/* 0xe04 - PCI Error Capture Disable Register */
145*a47a12beSStefan Roese 	u32	peer;		/* 0xe08 - PCI Error Interrupt Enable Register */
146*a47a12beSStefan Roese 	u32	peattrcr;	/* 0xe0c - PCI Error Attributes Capture Register */
147*a47a12beSStefan Roese 	u32	peaddrcr;	/* 0xe10 - PCI Error Address Capture Register */
148*a47a12beSStefan Roese /*	u32	perr_disr	 * 0xe10 - PCIE Erorr Disable Register */
149*a47a12beSStefan Roese 	u32	peextaddrcr;	/* 0xe14 - PCI	Error Extended Address Capture Register */
150*a47a12beSStefan Roese 	u32	pedlcr;		/* 0xe18 - PCI Error Data Low Capture Register */
151*a47a12beSStefan Roese 	u32	pedhcr;		/* 0xe1c - PCI Error Error Data High Capture Register */
152*a47a12beSStefan Roese 	u32	gas_timr;	/* 0xe20 - PCI Gasket Timer Register */
153*a47a12beSStefan Roese /*	u32	perr_cap_stat;	 * 0xe20 - PCIE Error Capture Status Register */
154*a47a12beSStefan Roese 	char	res22[4];
155*a47a12beSStefan Roese 	u32	perr_cap0;	/* 0xe28 - PCIE Error Capture Register 0 */
156*a47a12beSStefan Roese 	u32	perr_cap1;	/* 0xe2c - PCIE Error Capture Register 1 */
157*a47a12beSStefan Roese 	u32	perr_cap2;	/* 0xe30 - PCIE Error Capture Register 2 */
158*a47a12beSStefan Roese 	u32	perr_cap3;	/* 0xe34 - PCIE Error Capture Register 3 */
159*a47a12beSStefan Roese 	char	res23[200];
160*a47a12beSStefan Roese 	u32	pdb_stat;	/* 0xf00 - PCIE Debug Status */
161*a47a12beSStefan Roese 	char	res24[252];
162*a47a12beSStefan Roese } ccsr_fsl_pci_t;
163*a47a12beSStefan Roese 
164*a47a12beSStefan Roese struct fsl_pci_info {
165*a47a12beSStefan Roese 	unsigned long	regs;
166*a47a12beSStefan Roese 	pci_addr_t	mem_bus;
167*a47a12beSStefan Roese 	phys_size_t	mem_phys;
168*a47a12beSStefan Roese 	pci_size_t	mem_size;
169*a47a12beSStefan Roese 	pci_addr_t	io_bus;
170*a47a12beSStefan Roese 	phys_size_t	io_phys;
171*a47a12beSStefan Roese 	pci_size_t	io_size;
172*a47a12beSStefan Roese 	int		pci_num;
173*a47a12beSStefan Roese };
174*a47a12beSStefan Roese 
175*a47a12beSStefan Roese int fsl_pci_init_port(struct fsl_pci_info *pci_info,
176*a47a12beSStefan Roese 				struct pci_controller *hose, int busno);
177*a47a12beSStefan Roese 
178*a47a12beSStefan Roese #define SET_STD_PCI_INFO(x, num) \
179*a47a12beSStefan Roese {			\
180*a47a12beSStefan Roese 	x.regs = CONFIG_SYS_PCI##num##_ADDR;	\
181*a47a12beSStefan Roese 	x.mem_bus = CONFIG_SYS_PCI##num##_MEM_BUS; \
182*a47a12beSStefan Roese 	x.mem_phys = CONFIG_SYS_PCI##num##_MEM_PHYS; \
183*a47a12beSStefan Roese 	x.mem_size = CONFIG_SYS_PCI##num##_MEM_SIZE; \
184*a47a12beSStefan Roese 	x.io_bus = CONFIG_SYS_PCI##num##_IO_BUS; \
185*a47a12beSStefan Roese 	x.io_phys = CONFIG_SYS_PCI##num##_IO_PHYS; \
186*a47a12beSStefan Roese 	x.io_size = CONFIG_SYS_PCI##num##_IO_SIZE; \
187*a47a12beSStefan Roese 	x.pci_num = num; \
188*a47a12beSStefan Roese }
189*a47a12beSStefan Roese 
190*a47a12beSStefan Roese #define SET_STD_PCIE_INFO(x, num) \
191*a47a12beSStefan Roese {			\
192*a47a12beSStefan Roese 	x.regs = CONFIG_SYS_PCIE##num##_ADDR;	\
193*a47a12beSStefan Roese 	x.mem_bus = CONFIG_SYS_PCIE##num##_MEM_BUS; \
194*a47a12beSStefan Roese 	x.mem_phys = CONFIG_SYS_PCIE##num##_MEM_PHYS; \
195*a47a12beSStefan Roese 	x.mem_size = CONFIG_SYS_PCIE##num##_MEM_SIZE; \
196*a47a12beSStefan Roese 	x.io_bus = CONFIG_SYS_PCIE##num##_IO_BUS; \
197*a47a12beSStefan Roese 	x.io_phys = CONFIG_SYS_PCIE##num##_IO_PHYS; \
198*a47a12beSStefan Roese 	x.io_size = CONFIG_SYS_PCIE##num##_IO_SIZE; \
199*a47a12beSStefan Roese 	x.pci_num = num; \
200*a47a12beSStefan Roese }
201*a47a12beSStefan Roese 
202*a47a12beSStefan Roese #endif
203