xref: /rk3399_rockchip-uboot/drivers/pci/fsl_pci_init.c (revision b9a1fa9787a3a79573f5f932a4f8aa216bcb1785)
193a686eeSJean-Christophe PLAGNIOL-VILLARD /*
293a686eeSJean-Christophe PLAGNIOL-VILLARD  * Copyright 2007 Freescale Semiconductor, Inc.
393a686eeSJean-Christophe PLAGNIOL-VILLARD  *
493a686eeSJean-Christophe PLAGNIOL-VILLARD  * This program is free software; you can redistribute it and/or
593a686eeSJean-Christophe PLAGNIOL-VILLARD  * modify it under the terms of the GNU General Public License
693a686eeSJean-Christophe PLAGNIOL-VILLARD  * Version 2 as published by the Free Software Foundation.
793a686eeSJean-Christophe PLAGNIOL-VILLARD  *
893a686eeSJean-Christophe PLAGNIOL-VILLARD  * This program is distributed in the hope that it will be useful,
993a686eeSJean-Christophe PLAGNIOL-VILLARD  * but WITHOUT ANY WARRANTY; without even the implied warranty of
1093a686eeSJean-Christophe PLAGNIOL-VILLARD  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1193a686eeSJean-Christophe PLAGNIOL-VILLARD  * GNU General Public License for more details.
1293a686eeSJean-Christophe PLAGNIOL-VILLARD  *
1393a686eeSJean-Christophe PLAGNIOL-VILLARD  * You should have received a copy of the GNU General Public License
1493a686eeSJean-Christophe PLAGNIOL-VILLARD  * along with this program; if not, write to the Free Software
1593a686eeSJean-Christophe PLAGNIOL-VILLARD  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
1693a686eeSJean-Christophe PLAGNIOL-VILLARD  * MA 02111-1307 USA
1793a686eeSJean-Christophe PLAGNIOL-VILLARD  */
1893a686eeSJean-Christophe PLAGNIOL-VILLARD 
1993a686eeSJean-Christophe PLAGNIOL-VILLARD #include <common.h>
2093a686eeSJean-Christophe PLAGNIOL-VILLARD 
21*b9a1fa97SKumar Gala DECLARE_GLOBAL_DATA_PTR;
22*b9a1fa97SKumar Gala 
2393a686eeSJean-Christophe PLAGNIOL-VILLARD /*
2493a686eeSJean-Christophe PLAGNIOL-VILLARD  * PCI/PCIE Controller initialization for mpc85xx/mpc86xx soc's
2593a686eeSJean-Christophe PLAGNIOL-VILLARD  *
2693a686eeSJean-Christophe PLAGNIOL-VILLARD  * Initialize controller and call the common driver/pci pci_hose_scan to
2793a686eeSJean-Christophe PLAGNIOL-VILLARD  * scan for bridges and devices.
2893a686eeSJean-Christophe PLAGNIOL-VILLARD  *
2993a686eeSJean-Christophe PLAGNIOL-VILLARD  * Hose fields which need to be pre-initialized by board specific code:
3093a686eeSJean-Christophe PLAGNIOL-VILLARD  *   regions[]
3193a686eeSJean-Christophe PLAGNIOL-VILLARD  *   first_busno
3293a686eeSJean-Christophe PLAGNIOL-VILLARD  *
3393a686eeSJean-Christophe PLAGNIOL-VILLARD  * Fields updated:
3493a686eeSJean-Christophe PLAGNIOL-VILLARD  *   last_busno
3593a686eeSJean-Christophe PLAGNIOL-VILLARD  */
3693a686eeSJean-Christophe PLAGNIOL-VILLARD 
3793a686eeSJean-Christophe PLAGNIOL-VILLARD #include <pci.h>
3893a686eeSJean-Christophe PLAGNIOL-VILLARD #include <asm/immap_fsl_pci.h>
3993a686eeSJean-Christophe PLAGNIOL-VILLARD 
4093a686eeSJean-Christophe PLAGNIOL-VILLARD void pciauto_prescan_setup_bridge(struct pci_controller *hose,
4193a686eeSJean-Christophe PLAGNIOL-VILLARD 				pci_dev_t dev, int sub_bus);
4293a686eeSJean-Christophe PLAGNIOL-VILLARD void pciauto_postscan_setup_bridge(struct pci_controller *hose,
4393a686eeSJean-Christophe PLAGNIOL-VILLARD 				pci_dev_t dev, int sub_bus);
4493a686eeSJean-Christophe PLAGNIOL-VILLARD void pciauto_config_init(struct pci_controller *hose);
45612ea010SKumar Gala 
46*b9a1fa97SKumar Gala #ifndef CONFIG_SYS_PCI_MEMORY_BUS
47*b9a1fa97SKumar Gala #define CONFIG_SYS_PCI_MEMORY_BUS 0
48*b9a1fa97SKumar Gala #endif
49*b9a1fa97SKumar Gala 
50*b9a1fa97SKumar Gala #ifndef CONFIG_SYS_PCI_MEMORY_PHYS
51*b9a1fa97SKumar Gala #define CONFIG_SYS_PCI_MEMORY_PHYS 0
52*b9a1fa97SKumar Gala #endif
53*b9a1fa97SKumar Gala 
54*b9a1fa97SKumar Gala #if defined(CONFIG_SYS_PCI_64BIT) && !defined(CONFIG_SYS_PCI64_MEMORY_BUS)
55*b9a1fa97SKumar Gala #define CONFIG_SYS_PCI64_MEMORY_BUS (64ull*1024*1024*1024)
56*b9a1fa97SKumar Gala #endif
57*b9a1fa97SKumar Gala 
58*b9a1fa97SKumar Gala int fsl_pci_setup_inbound_windows(struct pci_region *r)
59*b9a1fa97SKumar Gala {
60*b9a1fa97SKumar Gala 	struct pci_region *rgn_base = r;
61*b9a1fa97SKumar Gala 	u64 sz = min((u64)gd->ram_size, 1ull << 32);
62*b9a1fa97SKumar Gala 
63*b9a1fa97SKumar Gala 	phys_addr_t phys_start = CONFIG_SYS_PCI_MEMORY_PHYS;
64*b9a1fa97SKumar Gala 	pci_addr_t bus_start = CONFIG_SYS_PCI_MEMORY_BUS;
65*b9a1fa97SKumar Gala 	pci_size_t pci_sz = 1ull << __ilog2_u64(sz);
66*b9a1fa97SKumar Gala 
67*b9a1fa97SKumar Gala 	debug ("R0 bus_start: %llx phys_start: %llx size: %llx\n",
68*b9a1fa97SKumar Gala 		(u64)bus_start, (u64)phys_start, (u64)pci_sz);
69*b9a1fa97SKumar Gala 	pci_set_region(r++, bus_start, phys_start, pci_sz,
70*b9a1fa97SKumar Gala 			PCI_REGION_MEM | PCI_REGION_MEMORY | \
71*b9a1fa97SKumar Gala 			PCI_REGION_PREFETCH);
72*b9a1fa97SKumar Gala 
73*b9a1fa97SKumar Gala 	sz -= pci_sz;
74*b9a1fa97SKumar Gala 	bus_start += pci_sz;
75*b9a1fa97SKumar Gala 	phys_start += pci_sz;
76*b9a1fa97SKumar Gala 
77*b9a1fa97SKumar Gala 	pci_sz = 1ull << __ilog2_u64(sz);
78*b9a1fa97SKumar Gala 	if (sz) {
79*b9a1fa97SKumar Gala 		debug ("R1 bus_start: %llx phys_start: %llx size: %llx\n",
80*b9a1fa97SKumar Gala 			(u64)bus_start, (u64)phys_start, (u64)pci_sz);
81*b9a1fa97SKumar Gala 		pci_set_region(r++, bus_start, phys_start, pci_sz,
82*b9a1fa97SKumar Gala 				PCI_REGION_MEM | PCI_REGION_MEMORY | \
83*b9a1fa97SKumar Gala 				PCI_REGION_PREFETCH);
84*b9a1fa97SKumar Gala 		sz -= pci_sz;
85*b9a1fa97SKumar Gala 		bus_start += pci_sz;
86*b9a1fa97SKumar Gala 		phys_start += pci_sz;
87*b9a1fa97SKumar Gala 	}
88*b9a1fa97SKumar Gala 
89*b9a1fa97SKumar Gala #if defined(CONFIG_PHYS_64BIT) && defined(CONFIG_SYS_PCI_64BIT)
90*b9a1fa97SKumar Gala 	pci_sz = 1ull << __ilog2_u64(gd->ram_size);
91*b9a1fa97SKumar Gala 	/* round up to the next largest power of two */
92*b9a1fa97SKumar Gala 	if (gd->ram_size > pci_sz)
93*b9a1fa97SKumar Gala 		sz = 1ull << (__ilog2_u64(gd->ram_size) + 1);
94*b9a1fa97SKumar Gala 	debug ("R64 bus_start: %llx phys_start: %llx size: %llx\n",
95*b9a1fa97SKumar Gala 		(u64)CONFIG_SYS_PCI_MEMORY_BUS,
96*b9a1fa97SKumar Gala 		(u64)CONFIG_SYS_PCI_MEMORY_PHYS,
97*b9a1fa97SKumar Gala 		(u64)pci_sz);
98*b9a1fa97SKumar Gala 	pci_set_region(r++,
99*b9a1fa97SKumar Gala 			CONFIG_SYS_PCI_MEMORY_BUS,
100*b9a1fa97SKumar Gala 			CONFIG_SYS_PCI_MEMORY_PHYS,
101*b9a1fa97SKumar Gala 			pci_sz,
102*b9a1fa97SKumar Gala 			PCI_REGION_MEM | PCI_REGION_MEMORY | \
103*b9a1fa97SKumar Gala 			PCI_REGION_PREFETCH);
104*b9a1fa97SKumar Gala #else
105*b9a1fa97SKumar Gala 	pci_sz = 1ull << __ilog2_u64(sz);
106*b9a1fa97SKumar Gala 	if (sz) {
107*b9a1fa97SKumar Gala 		debug ("R2 bus_start: %llx phys_start: %llx size: %llx\n",
108*b9a1fa97SKumar Gala 			(u64)bus_start, (u64)phys_start, (u64)pci_sz);
109*b9a1fa97SKumar Gala 		pci_set_region(r++, bus_start, phys_start, pci_sz,
110*b9a1fa97SKumar Gala 				PCI_REGION_MEM | PCI_REGION_MEMORY | \
111*b9a1fa97SKumar Gala 				PCI_REGION_PREFETCH);
112*b9a1fa97SKumar Gala 		sz -= pci_sz;
113*b9a1fa97SKumar Gala 		bus_start += pci_sz;
114*b9a1fa97SKumar Gala 		phys_start += pci_sz;
115*b9a1fa97SKumar Gala 	}
116*b9a1fa97SKumar Gala #endif
117*b9a1fa97SKumar Gala 
118*b9a1fa97SKumar Gala 	if (sz && (((u64)gd->ram_size) < (1ull << 32)))
119*b9a1fa97SKumar Gala 		printf("Was not able to map all of memory via "
120*b9a1fa97SKumar Gala 			"inbound windows -- %lld remaining\n", sz);
121*b9a1fa97SKumar Gala 
122*b9a1fa97SKumar Gala 	return r - rgn_base;
123*b9a1fa97SKumar Gala }
124*b9a1fa97SKumar Gala 
125612ea010SKumar Gala void fsl_pci_init(struct pci_controller *hose)
12693a686eeSJean-Christophe PLAGNIOL-VILLARD {
12793a686eeSJean-Christophe PLAGNIOL-VILLARD 	u16 temp16;
12893a686eeSJean-Christophe PLAGNIOL-VILLARD 	u32 temp32;
12993a686eeSJean-Christophe PLAGNIOL-VILLARD 	int busno = hose->first_busno;
13093a686eeSJean-Christophe PLAGNIOL-VILLARD 	int enabled;
13193a686eeSJean-Christophe PLAGNIOL-VILLARD 	u16 ltssm;
13293a686eeSJean-Christophe PLAGNIOL-VILLARD 	u8 temp8;
13393a686eeSJean-Christophe PLAGNIOL-VILLARD 	int r;
13493a686eeSJean-Christophe PLAGNIOL-VILLARD 	int bridge;
13593a686eeSJean-Christophe PLAGNIOL-VILLARD 	int inbound = 0;
13693a686eeSJean-Christophe PLAGNIOL-VILLARD 	volatile ccsr_fsl_pci_t *pci = (ccsr_fsl_pci_t *) hose->cfg_addr;
13793a686eeSJean-Christophe PLAGNIOL-VILLARD 	pci_dev_t dev = PCI_BDF(busno,0,0);
13893a686eeSJean-Christophe PLAGNIOL-VILLARD 
13993a686eeSJean-Christophe PLAGNIOL-VILLARD 	/* Initialize ATMU registers based on hose regions and flags */
14093a686eeSJean-Christophe PLAGNIOL-VILLARD 	volatile pot_t *po = &pci->pot[1];	/* skip 0 */
14193a686eeSJean-Christophe PLAGNIOL-VILLARD 	volatile pit_t *pi = &pci->pit[0];	/* ranges from: 3 to 1 */
14293a686eeSJean-Christophe PLAGNIOL-VILLARD 
14393a686eeSJean-Christophe PLAGNIOL-VILLARD #ifdef DEBUG
14493a686eeSJean-Christophe PLAGNIOL-VILLARD 	int neg_link_w;
14593a686eeSJean-Christophe PLAGNIOL-VILLARD #endif
14693a686eeSJean-Christophe PLAGNIOL-VILLARD 
14793a686eeSJean-Christophe PLAGNIOL-VILLARD 	for (r=0; r<hose->region_count; r++) {
148612ea010SKumar Gala 		u32 sz = (__ilog2_u64((u64)hose->regions[r].size) - 1);
14993a686eeSJean-Christophe PLAGNIOL-VILLARD 		if (hose->regions[r].flags & PCI_REGION_MEMORY) { /* inbound */
150612ea010SKumar Gala 			u32 flag = PIWAR_EN | PIWAR_LOCAL | \
151612ea010SKumar Gala 					PIWAR_READ_SNOOP | PIWAR_WRITE_SNOOP;
152612ea010SKumar Gala 			pi->pitar = (hose->regions[r].phys_start >> 12);
153612ea010SKumar Gala 			pi->piwbar = (hose->regions[r].bus_start >> 12);
154612ea010SKumar Gala #ifdef CONFIG_SYS_PCI_64BIT
155612ea010SKumar Gala 			pi->piwbear = (hose->regions[r].bus_start >> 44);
156612ea010SKumar Gala #else
15793a686eeSJean-Christophe PLAGNIOL-VILLARD 			pi->piwbear = 0;
158612ea010SKumar Gala #endif
159612ea010SKumar Gala 			if (hose->regions[r].flags & PCI_REGION_PREFETCH)
160612ea010SKumar Gala 				flag |= PIWAR_PF;
161612ea010SKumar Gala 			pi->piwar = flag | sz;
16293a686eeSJean-Christophe PLAGNIOL-VILLARD 			pi++;
16393a686eeSJean-Christophe PLAGNIOL-VILLARD 			inbound = hose->regions[r].size > 0;
16493a686eeSJean-Christophe PLAGNIOL-VILLARD 		} else { /* Outbound */
165612ea010SKumar Gala 			po->powbar = (hose->regions[r].phys_start >> 12);
166612ea010SKumar Gala 			po->potar = (hose->regions[r].bus_start >> 12);
167612ea010SKumar Gala #ifdef CONFIG_SYS_PCI_64BIT
168612ea010SKumar Gala 			po->potear = (hose->regions[r].bus_start >> 44);
169612ea010SKumar Gala #else
17093a686eeSJean-Christophe PLAGNIOL-VILLARD 			po->potear = 0;
171612ea010SKumar Gala #endif
17293a686eeSJean-Christophe PLAGNIOL-VILLARD 			if (hose->regions[r].flags & PCI_REGION_IO)
173612ea010SKumar Gala 				po->powar = POWAR_EN | sz | \
174612ea010SKumar Gala 					POWAR_IO_READ | POWAR_IO_WRITE;
17593a686eeSJean-Christophe PLAGNIOL-VILLARD 			else
176612ea010SKumar Gala 				po->powar = POWAR_EN | sz | \
177612ea010SKumar Gala 					POWAR_MEM_READ | POWAR_MEM_WRITE;
17893a686eeSJean-Christophe PLAGNIOL-VILLARD 			po++;
17993a686eeSJean-Christophe PLAGNIOL-VILLARD 		}
18093a686eeSJean-Christophe PLAGNIOL-VILLARD 	}
18193a686eeSJean-Christophe PLAGNIOL-VILLARD 
18293a686eeSJean-Christophe PLAGNIOL-VILLARD 	pci_register_hose(hose);
18393a686eeSJean-Christophe PLAGNIOL-VILLARD 	pciauto_config_init(hose);	/* grab pci_{mem,prefetch,io} */
18493a686eeSJean-Christophe PLAGNIOL-VILLARD 	hose->current_busno = hose->first_busno;
18593a686eeSJean-Christophe PLAGNIOL-VILLARD 
18693a686eeSJean-Christophe PLAGNIOL-VILLARD 	pci->pedr = 0xffffffff;		/* Clear any errors */
18793a686eeSJean-Christophe PLAGNIOL-VILLARD 	pci->peer = ~0x20140;		/* Enable All Error Interupts except
18893a686eeSJean-Christophe PLAGNIOL-VILLARD 					 * - Master abort (pci)
18993a686eeSJean-Christophe PLAGNIOL-VILLARD 					 * - Master PERR (pci)
19093a686eeSJean-Christophe PLAGNIOL-VILLARD 					 * - ICCA (PCIe)
19193a686eeSJean-Christophe PLAGNIOL-VILLARD 					 */
19293a686eeSJean-Christophe PLAGNIOL-VILLARD 	pci_hose_read_config_dword (hose, dev, PCI_DCR, &temp32);
19393a686eeSJean-Christophe PLAGNIOL-VILLARD 	temp32 |= 0xf000e;		/* set URR, FER, NFER (but not CER) */
19493a686eeSJean-Christophe PLAGNIOL-VILLARD 	pci_hose_write_config_dword(hose, dev, PCI_DCR, temp32);
19593a686eeSJean-Christophe PLAGNIOL-VILLARD 
19693a686eeSJean-Christophe PLAGNIOL-VILLARD 	pci_hose_read_config_byte (hose, dev, PCI_HEADER_TYPE, &temp8);
19793a686eeSJean-Christophe PLAGNIOL-VILLARD 	bridge = temp8 & PCI_HEADER_TYPE_BRIDGE; /* Bridge, such as pcie */
19893a686eeSJean-Christophe PLAGNIOL-VILLARD 
19993a686eeSJean-Christophe PLAGNIOL-VILLARD 	if ( bridge ) {
20093a686eeSJean-Christophe PLAGNIOL-VILLARD 
20193a686eeSJean-Christophe PLAGNIOL-VILLARD 		pci_hose_read_config_word(hose, dev, PCI_LTSSM, &ltssm);
20293a686eeSJean-Christophe PLAGNIOL-VILLARD 		enabled = ltssm >= PCI_LTSSM_L0;
20393a686eeSJean-Christophe PLAGNIOL-VILLARD 
2048ff3de61SKumar Gala #ifdef CONFIG_FSL_PCIE_RESET
2058ff3de61SKumar Gala 		if (ltssm == 1) {
2068ff3de61SKumar Gala 			int i;
2078ff3de61SKumar Gala 			debug("....PCIe link error. "
2088ff3de61SKumar Gala 			      "LTSSM=0x%02x.", ltssm);
2098ff3de61SKumar Gala 			pci->pdb_stat |= 0x08000000; /* assert PCIe reset */
2108ff3de61SKumar Gala 			temp32 = pci->pdb_stat;
2118ff3de61SKumar Gala 			udelay(100);
2128ff3de61SKumar Gala 			debug("  Asserting PCIe reset @%x = %x\n",
2138ff3de61SKumar Gala 			      &pci->pdb_stat, pci->pdb_stat);
2148ff3de61SKumar Gala 			pci->pdb_stat &= ~0x08000000; /* clear reset */
2158ff3de61SKumar Gala 			asm("sync;isync");
2168ff3de61SKumar Gala 			for (i=0; i<100 && ltssm < PCI_LTSSM_L0; i++) {
2178ff3de61SKumar Gala 				pci_hose_read_config_word(hose, dev, PCI_LTSSM,
2188ff3de61SKumar Gala 							&ltssm);
2198ff3de61SKumar Gala 				udelay(1000);
2208ff3de61SKumar Gala 				debug("....PCIe link error. "
2218ff3de61SKumar Gala 				      "LTSSM=0x%02x.\n", ltssm);
2228ff3de61SKumar Gala 			}
2238ff3de61SKumar Gala 			enabled = ltssm >= PCI_LTSSM_L0;
2248ff3de61SKumar Gala 		}
2258ff3de61SKumar Gala #endif
2268ff3de61SKumar Gala 
22793a686eeSJean-Christophe PLAGNIOL-VILLARD 		if (!enabled) {
22893a686eeSJean-Christophe PLAGNIOL-VILLARD 			debug("....PCIE link error.  Skipping scan."
22993a686eeSJean-Christophe PLAGNIOL-VILLARD 			      "LTSSM=0x%02x\n", ltssm);
23093a686eeSJean-Christophe PLAGNIOL-VILLARD 			hose->last_busno = hose->first_busno;
23193a686eeSJean-Christophe PLAGNIOL-VILLARD 			return;
23293a686eeSJean-Christophe PLAGNIOL-VILLARD 		}
23393a686eeSJean-Christophe PLAGNIOL-VILLARD 
23493a686eeSJean-Christophe PLAGNIOL-VILLARD 		pci->pme_msg_det = 0xffffffff;
23593a686eeSJean-Christophe PLAGNIOL-VILLARD 		pci->pme_msg_int_en = 0xffffffff;
23693a686eeSJean-Christophe PLAGNIOL-VILLARD #ifdef DEBUG
23793a686eeSJean-Christophe PLAGNIOL-VILLARD 		pci_hose_read_config_word(hose, dev, PCI_LSR, &temp16);
23893a686eeSJean-Christophe PLAGNIOL-VILLARD 		neg_link_w = (temp16 & 0x3f0 ) >> 4;
23993a686eeSJean-Christophe PLAGNIOL-VILLARD 		printf("...PCIE LTSSM=0x%x, Negotiated link width=%d\n",
24093a686eeSJean-Christophe PLAGNIOL-VILLARD 		      ltssm, neg_link_w);
24193a686eeSJean-Christophe PLAGNIOL-VILLARD #endif
24293a686eeSJean-Christophe PLAGNIOL-VILLARD 		hose->current_busno++; /* Start scan with secondary */
24393a686eeSJean-Christophe PLAGNIOL-VILLARD 		pciauto_prescan_setup_bridge(hose, dev, hose->current_busno);
24493a686eeSJean-Christophe PLAGNIOL-VILLARD 
24593a686eeSJean-Christophe PLAGNIOL-VILLARD 	}
24693a686eeSJean-Christophe PLAGNIOL-VILLARD 
24793a686eeSJean-Christophe PLAGNIOL-VILLARD 	/* Use generic setup_device to initialize standard pci regs,
24893a686eeSJean-Christophe PLAGNIOL-VILLARD 	 * but do not allocate any windows since any BAR found (such
24993a686eeSJean-Christophe PLAGNIOL-VILLARD 	 * as PCSRBAR) is not in this cpu's memory space.
25093a686eeSJean-Christophe PLAGNIOL-VILLARD 	 */
25193a686eeSJean-Christophe PLAGNIOL-VILLARD 
25293a686eeSJean-Christophe PLAGNIOL-VILLARD 	pciauto_setup_device(hose, dev, 0, hose->pci_mem,
25393a686eeSJean-Christophe PLAGNIOL-VILLARD 			     hose->pci_prefetch, hose->pci_io);
25493a686eeSJean-Christophe PLAGNIOL-VILLARD 
25593a686eeSJean-Christophe PLAGNIOL-VILLARD 	if (inbound) {
25693a686eeSJean-Christophe PLAGNIOL-VILLARD 		pci_hose_read_config_word(hose, dev, PCI_COMMAND, &temp16);
25793a686eeSJean-Christophe PLAGNIOL-VILLARD 		pci_hose_write_config_word(hose, dev, PCI_COMMAND,
25893a686eeSJean-Christophe PLAGNIOL-VILLARD 					   temp16 | PCI_COMMAND_MEMORY);
25993a686eeSJean-Christophe PLAGNIOL-VILLARD 	}
26093a686eeSJean-Christophe PLAGNIOL-VILLARD 
26193a686eeSJean-Christophe PLAGNIOL-VILLARD #ifndef CONFIG_PCI_NOSCAN
2626df0efd5SEd Swarthout 	pci_hose_read_config_byte(hose, dev, PCI_CLASS_PROG, &temp8);
2636df0efd5SEd Swarthout 
2646df0efd5SEd Swarthout 	/* Programming Interface (PCI_CLASS_PROG)
2656df0efd5SEd Swarthout 	 * 0 == pci host or pcie root-complex,
2666df0efd5SEd Swarthout 	 * 1 == pci agent or pcie end-point
2676df0efd5SEd Swarthout 	 */
2686df0efd5SEd Swarthout 	if (!temp8) {
2696df0efd5SEd Swarthout 		printf("               Scanning PCI bus %02x\n",
2706df0efd5SEd Swarthout 			hose->current_busno);
27193a686eeSJean-Christophe PLAGNIOL-VILLARD 		hose->last_busno = pci_hose_scan_bus(hose, hose->current_busno);
2726df0efd5SEd Swarthout 	} else {
2736df0efd5SEd Swarthout 		debug("               Not scanning PCI bus %02x. PI=%x\n",
2746df0efd5SEd Swarthout 			hose->current_busno, temp8);
2756df0efd5SEd Swarthout 		hose->last_busno = hose->current_busno;
2766df0efd5SEd Swarthout 	}
27793a686eeSJean-Christophe PLAGNIOL-VILLARD 
27893a686eeSJean-Christophe PLAGNIOL-VILLARD 	if ( bridge ) { /* update limit regs and subordinate busno */
27993a686eeSJean-Christophe PLAGNIOL-VILLARD 		pciauto_postscan_setup_bridge(hose, dev, hose->last_busno);
28093a686eeSJean-Christophe PLAGNIOL-VILLARD 	}
28193a686eeSJean-Christophe PLAGNIOL-VILLARD #else
28293a686eeSJean-Christophe PLAGNIOL-VILLARD 	hose->last_busno = hose->current_busno;
28393a686eeSJean-Christophe PLAGNIOL-VILLARD #endif
28493a686eeSJean-Christophe PLAGNIOL-VILLARD 
28593a686eeSJean-Christophe PLAGNIOL-VILLARD 	/* Clear all error indications */
28693a686eeSJean-Christophe PLAGNIOL-VILLARD 
287876b8f97SKumar Gala 	if (bridge)
28893a686eeSJean-Christophe PLAGNIOL-VILLARD 		pci->pme_msg_det = 0xffffffff;
28993a686eeSJean-Christophe PLAGNIOL-VILLARD 	pci->pedr = 0xffffffff;
29093a686eeSJean-Christophe PLAGNIOL-VILLARD 
29193a686eeSJean-Christophe PLAGNIOL-VILLARD 	pci_hose_read_config_word (hose, dev, PCI_DSR, &temp16);
29293a686eeSJean-Christophe PLAGNIOL-VILLARD 	if (temp16) {
29393a686eeSJean-Christophe PLAGNIOL-VILLARD 		pci_hose_write_config_word(hose, dev,
29493a686eeSJean-Christophe PLAGNIOL-VILLARD 					PCI_DSR, 0xffff);
29593a686eeSJean-Christophe PLAGNIOL-VILLARD 	}
29693a686eeSJean-Christophe PLAGNIOL-VILLARD 
29793a686eeSJean-Christophe PLAGNIOL-VILLARD 	pci_hose_read_config_word (hose, dev, PCI_SEC_STATUS, &temp16);
29893a686eeSJean-Christophe PLAGNIOL-VILLARD 	if (temp16) {
29993a686eeSJean-Christophe PLAGNIOL-VILLARD 		pci_hose_write_config_word(hose, dev, PCI_SEC_STATUS, 0xffff);
30093a686eeSJean-Christophe PLAGNIOL-VILLARD 	}
30193a686eeSJean-Christophe PLAGNIOL-VILLARD }
302