193a686eeSJean-Christophe PLAGNIOL-VILLARD /* 293a686eeSJean-Christophe PLAGNIOL-VILLARD * (C) Copyright 2001 Sysgo Real-Time Solutions, GmbH <www.elinos.com> 393a686eeSJean-Christophe PLAGNIOL-VILLARD * Andreas Heppel <aheppel@sysgo.de> 493a686eeSJean-Christophe PLAGNIOL-VILLARD * 593a686eeSJean-Christophe PLAGNIOL-VILLARD * (C) Copyright 2002, 2003 693a686eeSJean-Christophe PLAGNIOL-VILLARD * Wolfgang Denk, DENX Software Engineering, wd@denx.de. 793a686eeSJean-Christophe PLAGNIOL-VILLARD * 893a686eeSJean-Christophe PLAGNIOL-VILLARD * See file CREDITS for list of people who contributed to this 993a686eeSJean-Christophe PLAGNIOL-VILLARD * project. 1093a686eeSJean-Christophe PLAGNIOL-VILLARD * 1193a686eeSJean-Christophe PLAGNIOL-VILLARD * This program is free software; you can redistribute it and/or 1293a686eeSJean-Christophe PLAGNIOL-VILLARD * modify it under the terms of the GNU General Public License as 1393a686eeSJean-Christophe PLAGNIOL-VILLARD * published by the Free Software Foundation; either version 2 of 1493a686eeSJean-Christophe PLAGNIOL-VILLARD * the License, or (at your option) any later version. 1593a686eeSJean-Christophe PLAGNIOL-VILLARD * 1693a686eeSJean-Christophe PLAGNIOL-VILLARD * This program is distributed in the hope that it will be useful, 1793a686eeSJean-Christophe PLAGNIOL-VILLARD * but WITHOUT ANY WARRANTY; without even the implied warranty of 1893a686eeSJean-Christophe PLAGNIOL-VILLARD * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1993a686eeSJean-Christophe PLAGNIOL-VILLARD * GNU General Public License for more details. 2093a686eeSJean-Christophe PLAGNIOL-VILLARD * 2193a686eeSJean-Christophe PLAGNIOL-VILLARD * You should have received a copy of the GNU General Public License 2293a686eeSJean-Christophe PLAGNIOL-VILLARD * along with this program; if not, write to the Free Software 2393a686eeSJean-Christophe PLAGNIOL-VILLARD * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 2493a686eeSJean-Christophe PLAGNIOL-VILLARD * MA 02111-1307 USA 2593a686eeSJean-Christophe PLAGNIOL-VILLARD */ 2693a686eeSJean-Christophe PLAGNIOL-VILLARD 2793a686eeSJean-Christophe PLAGNIOL-VILLARD /* 2893a686eeSJean-Christophe PLAGNIOL-VILLARD * PCI routines 2993a686eeSJean-Christophe PLAGNIOL-VILLARD */ 3093a686eeSJean-Christophe PLAGNIOL-VILLARD 3193a686eeSJean-Christophe PLAGNIOL-VILLARD #include <common.h> 3293a686eeSJean-Christophe PLAGNIOL-VILLARD 3393a686eeSJean-Christophe PLAGNIOL-VILLARD #ifdef CONFIG_PCI 3493a686eeSJean-Christophe PLAGNIOL-VILLARD 3593a686eeSJean-Christophe PLAGNIOL-VILLARD #include <command.h> 3693a686eeSJean-Christophe PLAGNIOL-VILLARD #include <asm/processor.h> 3793a686eeSJean-Christophe PLAGNIOL-VILLARD #include <asm/io.h> 3893a686eeSJean-Christophe PLAGNIOL-VILLARD #include <pci.h> 3993a686eeSJean-Christophe PLAGNIOL-VILLARD 4093a686eeSJean-Christophe PLAGNIOL-VILLARD #define PCI_HOSE_OP(rw, size, type) \ 4193a686eeSJean-Christophe PLAGNIOL-VILLARD int pci_hose_##rw##_config_##size(struct pci_controller *hose, \ 4293a686eeSJean-Christophe PLAGNIOL-VILLARD pci_dev_t dev, \ 4393a686eeSJean-Christophe PLAGNIOL-VILLARD int offset, type value) \ 4493a686eeSJean-Christophe PLAGNIOL-VILLARD { \ 4593a686eeSJean-Christophe PLAGNIOL-VILLARD return hose->rw##_##size(hose, dev, offset, value); \ 4693a686eeSJean-Christophe PLAGNIOL-VILLARD } 4793a686eeSJean-Christophe PLAGNIOL-VILLARD 4893a686eeSJean-Christophe PLAGNIOL-VILLARD PCI_HOSE_OP(read, byte, u8 *) 4993a686eeSJean-Christophe PLAGNIOL-VILLARD PCI_HOSE_OP(read, word, u16 *) 5093a686eeSJean-Christophe PLAGNIOL-VILLARD PCI_HOSE_OP(read, dword, u32 *) 5193a686eeSJean-Christophe PLAGNIOL-VILLARD PCI_HOSE_OP(write, byte, u8) 5293a686eeSJean-Christophe PLAGNIOL-VILLARD PCI_HOSE_OP(write, word, u16) 5393a686eeSJean-Christophe PLAGNIOL-VILLARD PCI_HOSE_OP(write, dword, u32) 5493a686eeSJean-Christophe PLAGNIOL-VILLARD 5593a686eeSJean-Christophe PLAGNIOL-VILLARD #ifndef CONFIG_IXP425 5693a686eeSJean-Christophe PLAGNIOL-VILLARD #define PCI_OP(rw, size, type, error_code) \ 5793a686eeSJean-Christophe PLAGNIOL-VILLARD int pci_##rw##_config_##size(pci_dev_t dev, int offset, type value) \ 5893a686eeSJean-Christophe PLAGNIOL-VILLARD { \ 5993a686eeSJean-Christophe PLAGNIOL-VILLARD struct pci_controller *hose = pci_bus_to_hose(PCI_BUS(dev)); \ 6093a686eeSJean-Christophe PLAGNIOL-VILLARD \ 6193a686eeSJean-Christophe PLAGNIOL-VILLARD if (!hose) \ 6293a686eeSJean-Christophe PLAGNIOL-VILLARD { \ 6393a686eeSJean-Christophe PLAGNIOL-VILLARD error_code; \ 6493a686eeSJean-Christophe PLAGNIOL-VILLARD return -1; \ 6593a686eeSJean-Christophe PLAGNIOL-VILLARD } \ 6693a686eeSJean-Christophe PLAGNIOL-VILLARD \ 6793a686eeSJean-Christophe PLAGNIOL-VILLARD return pci_hose_##rw##_config_##size(hose, dev, offset, value); \ 6893a686eeSJean-Christophe PLAGNIOL-VILLARD } 6993a686eeSJean-Christophe PLAGNIOL-VILLARD 7093a686eeSJean-Christophe PLAGNIOL-VILLARD PCI_OP(read, byte, u8 *, *value = 0xff) 7193a686eeSJean-Christophe PLAGNIOL-VILLARD PCI_OP(read, word, u16 *, *value = 0xffff) 7293a686eeSJean-Christophe PLAGNIOL-VILLARD PCI_OP(read, dword, u32 *, *value = 0xffffffff) 7393a686eeSJean-Christophe PLAGNIOL-VILLARD PCI_OP(write, byte, u8, ) 7493a686eeSJean-Christophe PLAGNIOL-VILLARD PCI_OP(write, word, u16, ) 7593a686eeSJean-Christophe PLAGNIOL-VILLARD PCI_OP(write, dword, u32, ) 7693a686eeSJean-Christophe PLAGNIOL-VILLARD #endif /* CONFIG_IXP425 */ 7793a686eeSJean-Christophe PLAGNIOL-VILLARD 7893a686eeSJean-Christophe PLAGNIOL-VILLARD #define PCI_READ_VIA_DWORD_OP(size, type, off_mask) \ 7993a686eeSJean-Christophe PLAGNIOL-VILLARD int pci_hose_read_config_##size##_via_dword(struct pci_controller *hose,\ 8093a686eeSJean-Christophe PLAGNIOL-VILLARD pci_dev_t dev, \ 8193a686eeSJean-Christophe PLAGNIOL-VILLARD int offset, type val) \ 8293a686eeSJean-Christophe PLAGNIOL-VILLARD { \ 8393a686eeSJean-Christophe PLAGNIOL-VILLARD u32 val32; \ 8493a686eeSJean-Christophe PLAGNIOL-VILLARD \ 8593a686eeSJean-Christophe PLAGNIOL-VILLARD if (pci_hose_read_config_dword(hose, dev, offset & 0xfc, &val32) < 0) { \ 8693a686eeSJean-Christophe PLAGNIOL-VILLARD *val = -1; \ 8793a686eeSJean-Christophe PLAGNIOL-VILLARD return -1; \ 8893a686eeSJean-Christophe PLAGNIOL-VILLARD } \ 8993a686eeSJean-Christophe PLAGNIOL-VILLARD \ 9093a686eeSJean-Christophe PLAGNIOL-VILLARD *val = (val32 >> ((offset & (int)off_mask) * 8)); \ 9193a686eeSJean-Christophe PLAGNIOL-VILLARD \ 9293a686eeSJean-Christophe PLAGNIOL-VILLARD return 0; \ 9393a686eeSJean-Christophe PLAGNIOL-VILLARD } 9493a686eeSJean-Christophe PLAGNIOL-VILLARD 9593a686eeSJean-Christophe PLAGNIOL-VILLARD #define PCI_WRITE_VIA_DWORD_OP(size, type, off_mask, val_mask) \ 9693a686eeSJean-Christophe PLAGNIOL-VILLARD int pci_hose_write_config_##size##_via_dword(struct pci_controller *hose,\ 9793a686eeSJean-Christophe PLAGNIOL-VILLARD pci_dev_t dev, \ 9893a686eeSJean-Christophe PLAGNIOL-VILLARD int offset, type val) \ 9993a686eeSJean-Christophe PLAGNIOL-VILLARD { \ 10093a686eeSJean-Christophe PLAGNIOL-VILLARD u32 val32, mask, ldata, shift; \ 10193a686eeSJean-Christophe PLAGNIOL-VILLARD \ 10293a686eeSJean-Christophe PLAGNIOL-VILLARD if (pci_hose_read_config_dword(hose, dev, offset & 0xfc, &val32) < 0)\ 10393a686eeSJean-Christophe PLAGNIOL-VILLARD return -1; \ 10493a686eeSJean-Christophe PLAGNIOL-VILLARD \ 10593a686eeSJean-Christophe PLAGNIOL-VILLARD shift = ((offset & (int)off_mask) * 8); \ 10693a686eeSJean-Christophe PLAGNIOL-VILLARD ldata = (((unsigned long)val) & val_mask) << shift; \ 10793a686eeSJean-Christophe PLAGNIOL-VILLARD mask = val_mask << shift; \ 10893a686eeSJean-Christophe PLAGNIOL-VILLARD val32 = (val32 & ~mask) | ldata; \ 10993a686eeSJean-Christophe PLAGNIOL-VILLARD \ 11093a686eeSJean-Christophe PLAGNIOL-VILLARD if (pci_hose_write_config_dword(hose, dev, offset & 0xfc, val32) < 0)\ 11193a686eeSJean-Christophe PLAGNIOL-VILLARD return -1; \ 11293a686eeSJean-Christophe PLAGNIOL-VILLARD \ 11393a686eeSJean-Christophe PLAGNIOL-VILLARD return 0; \ 11493a686eeSJean-Christophe PLAGNIOL-VILLARD } 11593a686eeSJean-Christophe PLAGNIOL-VILLARD 11693a686eeSJean-Christophe PLAGNIOL-VILLARD PCI_READ_VIA_DWORD_OP(byte, u8 *, 0x03) 11793a686eeSJean-Christophe PLAGNIOL-VILLARD PCI_READ_VIA_DWORD_OP(word, u16 *, 0x02) 11893a686eeSJean-Christophe PLAGNIOL-VILLARD PCI_WRITE_VIA_DWORD_OP(byte, u8, 0x03, 0x000000ff) 11993a686eeSJean-Christophe PLAGNIOL-VILLARD PCI_WRITE_VIA_DWORD_OP(word, u16, 0x02, 0x0000ffff) 12093a686eeSJean-Christophe PLAGNIOL-VILLARD 12193a686eeSJean-Christophe PLAGNIOL-VILLARD /* 12293a686eeSJean-Christophe PLAGNIOL-VILLARD * 12393a686eeSJean-Christophe PLAGNIOL-VILLARD */ 12493a686eeSJean-Christophe PLAGNIOL-VILLARD 12593a686eeSJean-Christophe PLAGNIOL-VILLARD static struct pci_controller* hose_head = NULL; 12693a686eeSJean-Christophe PLAGNIOL-VILLARD 12793a686eeSJean-Christophe PLAGNIOL-VILLARD void pci_register_hose(struct pci_controller* hose) 12893a686eeSJean-Christophe PLAGNIOL-VILLARD { 12993a686eeSJean-Christophe PLAGNIOL-VILLARD struct pci_controller **phose = &hose_head; 13093a686eeSJean-Christophe PLAGNIOL-VILLARD 13193a686eeSJean-Christophe PLAGNIOL-VILLARD while(*phose) 13293a686eeSJean-Christophe PLAGNIOL-VILLARD phose = &(*phose)->next; 13393a686eeSJean-Christophe PLAGNIOL-VILLARD 13493a686eeSJean-Christophe PLAGNIOL-VILLARD hose->next = NULL; 13593a686eeSJean-Christophe PLAGNIOL-VILLARD 13693a686eeSJean-Christophe PLAGNIOL-VILLARD *phose = hose; 13793a686eeSJean-Christophe PLAGNIOL-VILLARD } 13893a686eeSJean-Christophe PLAGNIOL-VILLARD 13993a686eeSJean-Christophe PLAGNIOL-VILLARD struct pci_controller *pci_bus_to_hose (int bus) 14093a686eeSJean-Christophe PLAGNIOL-VILLARD { 14193a686eeSJean-Christophe PLAGNIOL-VILLARD struct pci_controller *hose; 14293a686eeSJean-Christophe PLAGNIOL-VILLARD 14393a686eeSJean-Christophe PLAGNIOL-VILLARD for (hose = hose_head; hose; hose = hose->next) 14493a686eeSJean-Christophe PLAGNIOL-VILLARD if (bus >= hose->first_busno && bus <= hose->last_busno) 14593a686eeSJean-Christophe PLAGNIOL-VILLARD return hose; 14693a686eeSJean-Christophe PLAGNIOL-VILLARD 14793a686eeSJean-Christophe PLAGNIOL-VILLARD printf("pci_bus_to_hose() failed\n"); 14893a686eeSJean-Christophe PLAGNIOL-VILLARD return NULL; 14993a686eeSJean-Christophe PLAGNIOL-VILLARD } 15093a686eeSJean-Christophe PLAGNIOL-VILLARD 15193a686eeSJean-Christophe PLAGNIOL-VILLARD #ifndef CONFIG_IXP425 15293a686eeSJean-Christophe PLAGNIOL-VILLARD pci_dev_t pci_find_devices(struct pci_device_id *ids, int index) 15393a686eeSJean-Christophe PLAGNIOL-VILLARD { 15493a686eeSJean-Christophe PLAGNIOL-VILLARD struct pci_controller * hose; 15593a686eeSJean-Christophe PLAGNIOL-VILLARD u16 vendor, device; 15693a686eeSJean-Christophe PLAGNIOL-VILLARD u8 header_type; 15793a686eeSJean-Christophe PLAGNIOL-VILLARD pci_dev_t bdf; 15893a686eeSJean-Christophe PLAGNIOL-VILLARD int i, bus, found_multi = 0; 15993a686eeSJean-Christophe PLAGNIOL-VILLARD 16093a686eeSJean-Christophe PLAGNIOL-VILLARD for (hose = hose_head; hose; hose = hose->next) 16193a686eeSJean-Christophe PLAGNIOL-VILLARD { 16293a686eeSJean-Christophe PLAGNIOL-VILLARD #ifdef CFG_SCSI_SCAN_BUS_REVERSE 16393a686eeSJean-Christophe PLAGNIOL-VILLARD for (bus = hose->last_busno; bus >= hose->first_busno; bus--) 16493a686eeSJean-Christophe PLAGNIOL-VILLARD #else 16593a686eeSJean-Christophe PLAGNIOL-VILLARD for (bus = hose->first_busno; bus <= hose->last_busno; bus++) 16693a686eeSJean-Christophe PLAGNIOL-VILLARD #endif 16793a686eeSJean-Christophe PLAGNIOL-VILLARD for (bdf = PCI_BDF(bus,0,0); 16893a686eeSJean-Christophe PLAGNIOL-VILLARD #if defined(CONFIG_ELPPC) || defined(CONFIG_PPMC7XX) 16993a686eeSJean-Christophe PLAGNIOL-VILLARD bdf < PCI_BDF(bus,PCI_MAX_PCI_DEVICES-1,PCI_MAX_PCI_FUNCTIONS-1); 17093a686eeSJean-Christophe PLAGNIOL-VILLARD #else 17193a686eeSJean-Christophe PLAGNIOL-VILLARD bdf < PCI_BDF(bus+1,0,0); 17293a686eeSJean-Christophe PLAGNIOL-VILLARD #endif 17393a686eeSJean-Christophe PLAGNIOL-VILLARD bdf += PCI_BDF(0,0,1)) 17493a686eeSJean-Christophe PLAGNIOL-VILLARD { 17593a686eeSJean-Christophe PLAGNIOL-VILLARD if (!PCI_FUNC(bdf)) { 17693a686eeSJean-Christophe PLAGNIOL-VILLARD pci_read_config_byte(bdf, 17793a686eeSJean-Christophe PLAGNIOL-VILLARD PCI_HEADER_TYPE, 17893a686eeSJean-Christophe PLAGNIOL-VILLARD &header_type); 17993a686eeSJean-Christophe PLAGNIOL-VILLARD 18093a686eeSJean-Christophe PLAGNIOL-VILLARD found_multi = header_type & 0x80; 18193a686eeSJean-Christophe PLAGNIOL-VILLARD } else { 18293a686eeSJean-Christophe PLAGNIOL-VILLARD if (!found_multi) 18393a686eeSJean-Christophe PLAGNIOL-VILLARD continue; 18493a686eeSJean-Christophe PLAGNIOL-VILLARD } 18593a686eeSJean-Christophe PLAGNIOL-VILLARD 18693a686eeSJean-Christophe PLAGNIOL-VILLARD pci_read_config_word(bdf, 18793a686eeSJean-Christophe PLAGNIOL-VILLARD PCI_VENDOR_ID, 18893a686eeSJean-Christophe PLAGNIOL-VILLARD &vendor); 18993a686eeSJean-Christophe PLAGNIOL-VILLARD pci_read_config_word(bdf, 19093a686eeSJean-Christophe PLAGNIOL-VILLARD PCI_DEVICE_ID, 19193a686eeSJean-Christophe PLAGNIOL-VILLARD &device); 19293a686eeSJean-Christophe PLAGNIOL-VILLARD 19393a686eeSJean-Christophe PLAGNIOL-VILLARD for (i=0; ids[i].vendor != 0; i++) 19493a686eeSJean-Christophe PLAGNIOL-VILLARD if (vendor == ids[i].vendor && 19593a686eeSJean-Christophe PLAGNIOL-VILLARD device == ids[i].device) 19693a686eeSJean-Christophe PLAGNIOL-VILLARD { 19793a686eeSJean-Christophe PLAGNIOL-VILLARD if (index <= 0) 19893a686eeSJean-Christophe PLAGNIOL-VILLARD return bdf; 19993a686eeSJean-Christophe PLAGNIOL-VILLARD 20093a686eeSJean-Christophe PLAGNIOL-VILLARD index--; 20193a686eeSJean-Christophe PLAGNIOL-VILLARD } 20293a686eeSJean-Christophe PLAGNIOL-VILLARD } 20393a686eeSJean-Christophe PLAGNIOL-VILLARD } 20493a686eeSJean-Christophe PLAGNIOL-VILLARD 20593a686eeSJean-Christophe PLAGNIOL-VILLARD return (-1); 20693a686eeSJean-Christophe PLAGNIOL-VILLARD } 20793a686eeSJean-Christophe PLAGNIOL-VILLARD #endif /* CONFIG_IXP425 */ 20893a686eeSJean-Christophe PLAGNIOL-VILLARD 20993a686eeSJean-Christophe PLAGNIOL-VILLARD pci_dev_t pci_find_device(unsigned int vendor, unsigned int device, int index) 21093a686eeSJean-Christophe PLAGNIOL-VILLARD { 21193a686eeSJean-Christophe PLAGNIOL-VILLARD static struct pci_device_id ids[2] = {{}, {0, 0}}; 21293a686eeSJean-Christophe PLAGNIOL-VILLARD 21393a686eeSJean-Christophe PLAGNIOL-VILLARD ids[0].vendor = vendor; 21493a686eeSJean-Christophe PLAGNIOL-VILLARD ids[0].device = device; 21593a686eeSJean-Christophe PLAGNIOL-VILLARD 21693a686eeSJean-Christophe PLAGNIOL-VILLARD return pci_find_devices(ids, index); 21793a686eeSJean-Christophe PLAGNIOL-VILLARD } 21893a686eeSJean-Christophe PLAGNIOL-VILLARD 21993a686eeSJean-Christophe PLAGNIOL-VILLARD /* 22093a686eeSJean-Christophe PLAGNIOL-VILLARD * 22193a686eeSJean-Christophe PLAGNIOL-VILLARD */ 22293a686eeSJean-Christophe PLAGNIOL-VILLARD 22393a686eeSJean-Christophe PLAGNIOL-VILLARD unsigned long pci_hose_phys_to_bus (struct pci_controller *hose, 22436f32675SBecky Bruce phys_addr_t phys_addr, 22593a686eeSJean-Christophe PLAGNIOL-VILLARD unsigned long flags) 22693a686eeSJean-Christophe PLAGNIOL-VILLARD { 22793a686eeSJean-Christophe PLAGNIOL-VILLARD struct pci_region *res; 22893a686eeSJean-Christophe PLAGNIOL-VILLARD unsigned long bus_addr; 22993a686eeSJean-Christophe PLAGNIOL-VILLARD int i; 23093a686eeSJean-Christophe PLAGNIOL-VILLARD 23193a686eeSJean-Christophe PLAGNIOL-VILLARD if (!hose) { 23293a686eeSJean-Christophe PLAGNIOL-VILLARD printf ("pci_hose_phys_to_bus: %s\n", "invalid hose"); 23393a686eeSJean-Christophe PLAGNIOL-VILLARD goto Done; 23493a686eeSJean-Christophe PLAGNIOL-VILLARD } 23593a686eeSJean-Christophe PLAGNIOL-VILLARD 23693a686eeSJean-Christophe PLAGNIOL-VILLARD for (i = 0; i < hose->region_count; i++) { 23793a686eeSJean-Christophe PLAGNIOL-VILLARD res = &hose->regions[i]; 23893a686eeSJean-Christophe PLAGNIOL-VILLARD 23993a686eeSJean-Christophe PLAGNIOL-VILLARD if (((res->flags ^ flags) & PCI_REGION_TYPE) != 0) 24093a686eeSJean-Christophe PLAGNIOL-VILLARD continue; 24193a686eeSJean-Christophe PLAGNIOL-VILLARD 24293a686eeSJean-Christophe PLAGNIOL-VILLARD bus_addr = phys_addr - res->phys_start + res->bus_start; 24393a686eeSJean-Christophe PLAGNIOL-VILLARD 24493a686eeSJean-Christophe PLAGNIOL-VILLARD if (bus_addr >= res->bus_start && 24593a686eeSJean-Christophe PLAGNIOL-VILLARD bus_addr < res->bus_start + res->size) { 24693a686eeSJean-Christophe PLAGNIOL-VILLARD return bus_addr; 24793a686eeSJean-Christophe PLAGNIOL-VILLARD } 24893a686eeSJean-Christophe PLAGNIOL-VILLARD } 24993a686eeSJean-Christophe PLAGNIOL-VILLARD 25093a686eeSJean-Christophe PLAGNIOL-VILLARD printf ("pci_hose_phys_to_bus: %s\n", "invalid physical address"); 25193a686eeSJean-Christophe PLAGNIOL-VILLARD 25293a686eeSJean-Christophe PLAGNIOL-VILLARD Done: 25393a686eeSJean-Christophe PLAGNIOL-VILLARD return 0; 25493a686eeSJean-Christophe PLAGNIOL-VILLARD } 25593a686eeSJean-Christophe PLAGNIOL-VILLARD 25636f32675SBecky Bruce phys_addr_t pci_hose_bus_to_phys(struct pci_controller* hose, 25793a686eeSJean-Christophe PLAGNIOL-VILLARD unsigned long bus_addr, 25893a686eeSJean-Christophe PLAGNIOL-VILLARD unsigned long flags) 25993a686eeSJean-Christophe PLAGNIOL-VILLARD { 26093a686eeSJean-Christophe PLAGNIOL-VILLARD struct pci_region *res; 26193a686eeSJean-Christophe PLAGNIOL-VILLARD int i; 26293a686eeSJean-Christophe PLAGNIOL-VILLARD 26393a686eeSJean-Christophe PLAGNIOL-VILLARD if (!hose) { 26493a686eeSJean-Christophe PLAGNIOL-VILLARD printf ("pci_hose_bus_to_phys: %s\n", "invalid hose"); 26593a686eeSJean-Christophe PLAGNIOL-VILLARD goto Done; 26693a686eeSJean-Christophe PLAGNIOL-VILLARD } 26793a686eeSJean-Christophe PLAGNIOL-VILLARD 26893a686eeSJean-Christophe PLAGNIOL-VILLARD for (i = 0; i < hose->region_count; i++) { 26993a686eeSJean-Christophe PLAGNIOL-VILLARD res = &hose->regions[i]; 27093a686eeSJean-Christophe PLAGNIOL-VILLARD 27193a686eeSJean-Christophe PLAGNIOL-VILLARD if (((res->flags ^ flags) & PCI_REGION_TYPE) != 0) 27293a686eeSJean-Christophe PLAGNIOL-VILLARD continue; 27393a686eeSJean-Christophe PLAGNIOL-VILLARD 27493a686eeSJean-Christophe PLAGNIOL-VILLARD if (bus_addr >= res->bus_start && 27593a686eeSJean-Christophe PLAGNIOL-VILLARD bus_addr < res->bus_start + res->size) { 27693a686eeSJean-Christophe PLAGNIOL-VILLARD return bus_addr - res->bus_start + res->phys_start; 27793a686eeSJean-Christophe PLAGNIOL-VILLARD } 27893a686eeSJean-Christophe PLAGNIOL-VILLARD } 27993a686eeSJean-Christophe PLAGNIOL-VILLARD 28093a686eeSJean-Christophe PLAGNIOL-VILLARD printf ("pci_hose_bus_to_phys: %s\n", "invalid physical address"); 28193a686eeSJean-Christophe PLAGNIOL-VILLARD 28293a686eeSJean-Christophe PLAGNIOL-VILLARD Done: 28393a686eeSJean-Christophe PLAGNIOL-VILLARD return 0; 28493a686eeSJean-Christophe PLAGNIOL-VILLARD } 28593a686eeSJean-Christophe PLAGNIOL-VILLARD 28693a686eeSJean-Christophe PLAGNIOL-VILLARD /* 28793a686eeSJean-Christophe PLAGNIOL-VILLARD * 28893a686eeSJean-Christophe PLAGNIOL-VILLARD */ 28993a686eeSJean-Christophe PLAGNIOL-VILLARD 29093a686eeSJean-Christophe PLAGNIOL-VILLARD int pci_hose_config_device(struct pci_controller *hose, 29193a686eeSJean-Christophe PLAGNIOL-VILLARD pci_dev_t dev, 29293a686eeSJean-Christophe PLAGNIOL-VILLARD unsigned long io, 29393a686eeSJean-Christophe PLAGNIOL-VILLARD unsigned long mem, 29493a686eeSJean-Christophe PLAGNIOL-VILLARD unsigned long command) 29593a686eeSJean-Christophe PLAGNIOL-VILLARD { 29693a686eeSJean-Christophe PLAGNIOL-VILLARD unsigned int bar_response, bar_size, bar_value, old_command; 29793a686eeSJean-Christophe PLAGNIOL-VILLARD unsigned char pin; 29893a686eeSJean-Christophe PLAGNIOL-VILLARD int bar, found_mem64; 29993a686eeSJean-Christophe PLAGNIOL-VILLARD 30093a686eeSJean-Christophe PLAGNIOL-VILLARD debug ("PCI Config: I/O=0x%lx, Memory=0x%lx, Command=0x%lx\n", 30193a686eeSJean-Christophe PLAGNIOL-VILLARD io, mem, command); 30293a686eeSJean-Christophe PLAGNIOL-VILLARD 30393a686eeSJean-Christophe PLAGNIOL-VILLARD pci_hose_write_config_dword (hose, dev, PCI_COMMAND, 0); 30493a686eeSJean-Christophe PLAGNIOL-VILLARD 30593a686eeSJean-Christophe PLAGNIOL-VILLARD for (bar = PCI_BASE_ADDRESS_0; bar < PCI_BASE_ADDRESS_5; bar += 4) { 30693a686eeSJean-Christophe PLAGNIOL-VILLARD pci_hose_write_config_dword (hose, dev, bar, 0xffffffff); 30793a686eeSJean-Christophe PLAGNIOL-VILLARD pci_hose_read_config_dword (hose, dev, bar, &bar_response); 30893a686eeSJean-Christophe PLAGNIOL-VILLARD 30993a686eeSJean-Christophe PLAGNIOL-VILLARD if (!bar_response) 31093a686eeSJean-Christophe PLAGNIOL-VILLARD continue; 31193a686eeSJean-Christophe PLAGNIOL-VILLARD 31293a686eeSJean-Christophe PLAGNIOL-VILLARD found_mem64 = 0; 31393a686eeSJean-Christophe PLAGNIOL-VILLARD 31493a686eeSJean-Christophe PLAGNIOL-VILLARD /* Check the BAR type and set our address mask */ 31593a686eeSJean-Christophe PLAGNIOL-VILLARD if (bar_response & PCI_BASE_ADDRESS_SPACE) { 31693a686eeSJean-Christophe PLAGNIOL-VILLARD bar_size = ~(bar_response & PCI_BASE_ADDRESS_IO_MASK) + 1; 31793a686eeSJean-Christophe PLAGNIOL-VILLARD /* round up region base address to a multiple of size */ 31893a686eeSJean-Christophe PLAGNIOL-VILLARD io = ((io - 1) | (bar_size - 1)) + 1; 31993a686eeSJean-Christophe PLAGNIOL-VILLARD bar_value = io; 32093a686eeSJean-Christophe PLAGNIOL-VILLARD /* compute new region base address */ 32193a686eeSJean-Christophe PLAGNIOL-VILLARD io = io + bar_size; 32293a686eeSJean-Christophe PLAGNIOL-VILLARD } else { 32393a686eeSJean-Christophe PLAGNIOL-VILLARD if ((bar_response & PCI_BASE_ADDRESS_MEM_TYPE_MASK) == 32493a686eeSJean-Christophe PLAGNIOL-VILLARD PCI_BASE_ADDRESS_MEM_TYPE_64) 32593a686eeSJean-Christophe PLAGNIOL-VILLARD found_mem64 = 1; 32693a686eeSJean-Christophe PLAGNIOL-VILLARD 32793a686eeSJean-Christophe PLAGNIOL-VILLARD bar_size = ~(bar_response & PCI_BASE_ADDRESS_MEM_MASK) + 1; 32893a686eeSJean-Christophe PLAGNIOL-VILLARD 32993a686eeSJean-Christophe PLAGNIOL-VILLARD /* round up region base address to multiple of size */ 33093a686eeSJean-Christophe PLAGNIOL-VILLARD mem = ((mem - 1) | (bar_size - 1)) + 1; 33193a686eeSJean-Christophe PLAGNIOL-VILLARD bar_value = mem; 33293a686eeSJean-Christophe PLAGNIOL-VILLARD /* compute new region base address */ 33393a686eeSJean-Christophe PLAGNIOL-VILLARD mem = mem + bar_size; 33493a686eeSJean-Christophe PLAGNIOL-VILLARD } 33593a686eeSJean-Christophe PLAGNIOL-VILLARD 33693a686eeSJean-Christophe PLAGNIOL-VILLARD /* Write it out and update our limit */ 33793a686eeSJean-Christophe PLAGNIOL-VILLARD pci_hose_write_config_dword (hose, dev, bar, bar_value); 33893a686eeSJean-Christophe PLAGNIOL-VILLARD 33993a686eeSJean-Christophe PLAGNIOL-VILLARD if (found_mem64) { 34093a686eeSJean-Christophe PLAGNIOL-VILLARD bar += 4; 34193a686eeSJean-Christophe PLAGNIOL-VILLARD pci_hose_write_config_dword (hose, dev, bar, 0x00000000); 34293a686eeSJean-Christophe PLAGNIOL-VILLARD } 34393a686eeSJean-Christophe PLAGNIOL-VILLARD } 34493a686eeSJean-Christophe PLAGNIOL-VILLARD 34593a686eeSJean-Christophe PLAGNIOL-VILLARD /* Configure Cache Line Size Register */ 34693a686eeSJean-Christophe PLAGNIOL-VILLARD pci_hose_write_config_byte (hose, dev, PCI_CACHE_LINE_SIZE, 0x08); 34793a686eeSJean-Christophe PLAGNIOL-VILLARD 34893a686eeSJean-Christophe PLAGNIOL-VILLARD /* Configure Latency Timer */ 34993a686eeSJean-Christophe PLAGNIOL-VILLARD pci_hose_write_config_byte (hose, dev, PCI_LATENCY_TIMER, 0x80); 35093a686eeSJean-Christophe PLAGNIOL-VILLARD 35193a686eeSJean-Christophe PLAGNIOL-VILLARD /* Disable interrupt line, if device says it wants to use interrupts */ 35293a686eeSJean-Christophe PLAGNIOL-VILLARD pci_hose_read_config_byte (hose, dev, PCI_INTERRUPT_PIN, &pin); 35393a686eeSJean-Christophe PLAGNIOL-VILLARD if (pin != 0) { 35493a686eeSJean-Christophe PLAGNIOL-VILLARD pci_hose_write_config_byte (hose, dev, PCI_INTERRUPT_LINE, 0xff); 35593a686eeSJean-Christophe PLAGNIOL-VILLARD } 35693a686eeSJean-Christophe PLAGNIOL-VILLARD 35793a686eeSJean-Christophe PLAGNIOL-VILLARD pci_hose_read_config_dword (hose, dev, PCI_COMMAND, &old_command); 35893a686eeSJean-Christophe PLAGNIOL-VILLARD pci_hose_write_config_dword (hose, dev, PCI_COMMAND, 35993a686eeSJean-Christophe PLAGNIOL-VILLARD (old_command & 0xffff0000) | command); 36093a686eeSJean-Christophe PLAGNIOL-VILLARD 36193a686eeSJean-Christophe PLAGNIOL-VILLARD return 0; 36293a686eeSJean-Christophe PLAGNIOL-VILLARD } 36393a686eeSJean-Christophe PLAGNIOL-VILLARD 36493a686eeSJean-Christophe PLAGNIOL-VILLARD /* 36593a686eeSJean-Christophe PLAGNIOL-VILLARD * 36693a686eeSJean-Christophe PLAGNIOL-VILLARD */ 36793a686eeSJean-Christophe PLAGNIOL-VILLARD 36893a686eeSJean-Christophe PLAGNIOL-VILLARD struct pci_config_table *pci_find_config(struct pci_controller *hose, 36993a686eeSJean-Christophe PLAGNIOL-VILLARD unsigned short class, 37093a686eeSJean-Christophe PLAGNIOL-VILLARD unsigned int vendor, 37193a686eeSJean-Christophe PLAGNIOL-VILLARD unsigned int device, 37293a686eeSJean-Christophe PLAGNIOL-VILLARD unsigned int bus, 37393a686eeSJean-Christophe PLAGNIOL-VILLARD unsigned int dev, 37493a686eeSJean-Christophe PLAGNIOL-VILLARD unsigned int func) 37593a686eeSJean-Christophe PLAGNIOL-VILLARD { 37693a686eeSJean-Christophe PLAGNIOL-VILLARD struct pci_config_table *table; 37793a686eeSJean-Christophe PLAGNIOL-VILLARD 37893a686eeSJean-Christophe PLAGNIOL-VILLARD for (table = hose->config_table; table && table->vendor; table++) { 37993a686eeSJean-Christophe PLAGNIOL-VILLARD if ((table->vendor == PCI_ANY_ID || table->vendor == vendor) && 38093a686eeSJean-Christophe PLAGNIOL-VILLARD (table->device == PCI_ANY_ID || table->device == device) && 38193a686eeSJean-Christophe PLAGNIOL-VILLARD (table->class == PCI_ANY_ID || table->class == class) && 38293a686eeSJean-Christophe PLAGNIOL-VILLARD (table->bus == PCI_ANY_ID || table->bus == bus) && 38393a686eeSJean-Christophe PLAGNIOL-VILLARD (table->dev == PCI_ANY_ID || table->dev == dev) && 38493a686eeSJean-Christophe PLAGNIOL-VILLARD (table->func == PCI_ANY_ID || table->func == func)) { 38593a686eeSJean-Christophe PLAGNIOL-VILLARD return table; 38693a686eeSJean-Christophe PLAGNIOL-VILLARD } 38793a686eeSJean-Christophe PLAGNIOL-VILLARD } 38893a686eeSJean-Christophe PLAGNIOL-VILLARD 38993a686eeSJean-Christophe PLAGNIOL-VILLARD return NULL; 39093a686eeSJean-Christophe PLAGNIOL-VILLARD } 39193a686eeSJean-Christophe PLAGNIOL-VILLARD 39293a686eeSJean-Christophe PLAGNIOL-VILLARD void pci_cfgfunc_config_device(struct pci_controller *hose, 39393a686eeSJean-Christophe PLAGNIOL-VILLARD pci_dev_t dev, 39493a686eeSJean-Christophe PLAGNIOL-VILLARD struct pci_config_table *entry) 39593a686eeSJean-Christophe PLAGNIOL-VILLARD { 39693a686eeSJean-Christophe PLAGNIOL-VILLARD pci_hose_config_device(hose, dev, entry->priv[0], entry->priv[1], entry->priv[2]); 39793a686eeSJean-Christophe PLAGNIOL-VILLARD } 39893a686eeSJean-Christophe PLAGNIOL-VILLARD 39993a686eeSJean-Christophe PLAGNIOL-VILLARD void pci_cfgfunc_do_nothing(struct pci_controller *hose, 40093a686eeSJean-Christophe PLAGNIOL-VILLARD pci_dev_t dev, struct pci_config_table *entry) 40193a686eeSJean-Christophe PLAGNIOL-VILLARD { 40293a686eeSJean-Christophe PLAGNIOL-VILLARD } 40393a686eeSJean-Christophe PLAGNIOL-VILLARD 40493a686eeSJean-Christophe PLAGNIOL-VILLARD /* 40593a686eeSJean-Christophe PLAGNIOL-VILLARD * 40693a686eeSJean-Christophe PLAGNIOL-VILLARD */ 40793a686eeSJean-Christophe PLAGNIOL-VILLARD 40893a686eeSJean-Christophe PLAGNIOL-VILLARD /* HJF: Changed this to return int. I think this is required 40993a686eeSJean-Christophe PLAGNIOL-VILLARD * to get the correct result when scanning bridges 41093a686eeSJean-Christophe PLAGNIOL-VILLARD */ 41193a686eeSJean-Christophe PLAGNIOL-VILLARD extern int pciauto_config_device(struct pci_controller *hose, pci_dev_t dev); 41293a686eeSJean-Christophe PLAGNIOL-VILLARD extern void pciauto_config_init(struct pci_controller *hose); 41393a686eeSJean-Christophe PLAGNIOL-VILLARD 414*dc1da42fSStefan Roese int __pci_skip_dev(struct pci_controller *hose, pci_dev_t dev) 415*dc1da42fSStefan Roese { 416*dc1da42fSStefan Roese /* 417*dc1da42fSStefan Roese * Check if pci device should be skipped in configuration 418*dc1da42fSStefan Roese */ 419*dc1da42fSStefan Roese if (dev == PCI_BDF(hose->first_busno, 0, 0)) { 420*dc1da42fSStefan Roese #if defined(CONFIG_PCI_CONFIG_HOST_BRIDGE) /* don't skip host bridge */ 421*dc1da42fSStefan Roese /* 422*dc1da42fSStefan Roese * Only skip configuration if "pciconfighost" is not set 423*dc1da42fSStefan Roese */ 424*dc1da42fSStefan Roese if (getenv("pciconfighost") == NULL) 425*dc1da42fSStefan Roese return 1; 426*dc1da42fSStefan Roese #else 427*dc1da42fSStefan Roese return 1; 428*dc1da42fSStefan Roese #endif 429*dc1da42fSStefan Roese } 430*dc1da42fSStefan Roese 431*dc1da42fSStefan Roese return 0; 432*dc1da42fSStefan Roese } 433*dc1da42fSStefan Roese int pci_skip_dev(struct pci_controller *hose, pci_dev_t dev) 434*dc1da42fSStefan Roese __attribute__((weak, alias("__pci_skip_dev"))); 435*dc1da42fSStefan Roese 436*dc1da42fSStefan Roese #ifdef CONFIG_PCI_SCAN_SHOW 437*dc1da42fSStefan Roese int __pci_print_dev(struct pci_controller *hose, pci_dev_t dev) 438*dc1da42fSStefan Roese { 439*dc1da42fSStefan Roese if (dev == PCI_BDF(hose->first_busno, 0, 0)) 440*dc1da42fSStefan Roese return 0; 441*dc1da42fSStefan Roese 442*dc1da42fSStefan Roese return 1; 443*dc1da42fSStefan Roese } 444*dc1da42fSStefan Roese int pci_print_dev(struct pci_controller *hose, pci_dev_t dev) 445*dc1da42fSStefan Roese __attribute__((weak, alias("__pci_print_dev"))); 446*dc1da42fSStefan Roese #endif /* CONFIG_PCI_SCAN_SHOW */ 447*dc1da42fSStefan Roese 44893a686eeSJean-Christophe PLAGNIOL-VILLARD int pci_hose_scan_bus(struct pci_controller *hose, int bus) 44993a686eeSJean-Christophe PLAGNIOL-VILLARD { 45093a686eeSJean-Christophe PLAGNIOL-VILLARD unsigned int sub_bus, found_multi=0; 45193a686eeSJean-Christophe PLAGNIOL-VILLARD unsigned short vendor, device, class; 45293a686eeSJean-Christophe PLAGNIOL-VILLARD unsigned char header_type; 45393a686eeSJean-Christophe PLAGNIOL-VILLARD struct pci_config_table *cfg; 45493a686eeSJean-Christophe PLAGNIOL-VILLARD pci_dev_t dev; 45593a686eeSJean-Christophe PLAGNIOL-VILLARD 45693a686eeSJean-Christophe PLAGNIOL-VILLARD sub_bus = bus; 45793a686eeSJean-Christophe PLAGNIOL-VILLARD 45893a686eeSJean-Christophe PLAGNIOL-VILLARD for (dev = PCI_BDF(bus,0,0); 45993a686eeSJean-Christophe PLAGNIOL-VILLARD dev < PCI_BDF(bus,PCI_MAX_PCI_DEVICES-1,PCI_MAX_PCI_FUNCTIONS-1); 460*dc1da42fSStefan Roese dev += PCI_BDF(0,0,1)) { 461*dc1da42fSStefan Roese 462*dc1da42fSStefan Roese if (pci_skip_dev(hose, dev)) 463*dc1da42fSStefan Roese continue; 46493a686eeSJean-Christophe PLAGNIOL-VILLARD 46593a686eeSJean-Christophe PLAGNIOL-VILLARD if (PCI_FUNC(dev) && !found_multi) 46693a686eeSJean-Christophe PLAGNIOL-VILLARD continue; 46793a686eeSJean-Christophe PLAGNIOL-VILLARD 46893a686eeSJean-Christophe PLAGNIOL-VILLARD pci_hose_read_config_byte(hose, dev, PCI_HEADER_TYPE, &header_type); 46993a686eeSJean-Christophe PLAGNIOL-VILLARD 47093a686eeSJean-Christophe PLAGNIOL-VILLARD pci_hose_read_config_word(hose, dev, PCI_VENDOR_ID, &vendor); 47193a686eeSJean-Christophe PLAGNIOL-VILLARD 47293a686eeSJean-Christophe PLAGNIOL-VILLARD if (vendor != 0xffff && vendor != 0x0000) { 47393a686eeSJean-Christophe PLAGNIOL-VILLARD 47493a686eeSJean-Christophe PLAGNIOL-VILLARD if (!PCI_FUNC(dev)) 47593a686eeSJean-Christophe PLAGNIOL-VILLARD found_multi = header_type & 0x80; 47693a686eeSJean-Christophe PLAGNIOL-VILLARD 47793a686eeSJean-Christophe PLAGNIOL-VILLARD debug ("PCI Scan: Found Bus %d, Device %d, Function %d\n", 47893a686eeSJean-Christophe PLAGNIOL-VILLARD PCI_BUS(dev), PCI_DEV(dev), PCI_FUNC(dev) ); 47993a686eeSJean-Christophe PLAGNIOL-VILLARD 48093a686eeSJean-Christophe PLAGNIOL-VILLARD pci_hose_read_config_word(hose, dev, PCI_DEVICE_ID, &device); 48193a686eeSJean-Christophe PLAGNIOL-VILLARD pci_hose_read_config_word(hose, dev, PCI_CLASS_DEVICE, &class); 48293a686eeSJean-Christophe PLAGNIOL-VILLARD 48393a686eeSJean-Christophe PLAGNIOL-VILLARD cfg = pci_find_config(hose, class, vendor, device, 48493a686eeSJean-Christophe PLAGNIOL-VILLARD PCI_BUS(dev), PCI_DEV(dev), PCI_FUNC(dev)); 48593a686eeSJean-Christophe PLAGNIOL-VILLARD if (cfg) { 48693a686eeSJean-Christophe PLAGNIOL-VILLARD cfg->config_device(hose, dev, cfg); 48793a686eeSJean-Christophe PLAGNIOL-VILLARD sub_bus = max(sub_bus, hose->current_busno); 48893a686eeSJean-Christophe PLAGNIOL-VILLARD #ifdef CONFIG_PCI_PNP 48993a686eeSJean-Christophe PLAGNIOL-VILLARD } else { 49093a686eeSJean-Christophe PLAGNIOL-VILLARD int n = pciauto_config_device(hose, dev); 49193a686eeSJean-Christophe PLAGNIOL-VILLARD 49293a686eeSJean-Christophe PLAGNIOL-VILLARD sub_bus = max(sub_bus, n); 49393a686eeSJean-Christophe PLAGNIOL-VILLARD #endif 49493a686eeSJean-Christophe PLAGNIOL-VILLARD } 49593a686eeSJean-Christophe PLAGNIOL-VILLARD if (hose->fixup_irq) 49693a686eeSJean-Christophe PLAGNIOL-VILLARD hose->fixup_irq(hose, dev); 49793a686eeSJean-Christophe PLAGNIOL-VILLARD 49893a686eeSJean-Christophe PLAGNIOL-VILLARD #ifdef CONFIG_PCI_SCAN_SHOW 499*dc1da42fSStefan Roese if (pci_print_dev(hose, dev)) { 50093a686eeSJean-Christophe PLAGNIOL-VILLARD unsigned char int_line; 50193a686eeSJean-Christophe PLAGNIOL-VILLARD 50293a686eeSJean-Christophe PLAGNIOL-VILLARD pci_hose_read_config_byte(hose, dev, PCI_INTERRUPT_LINE, 50393a686eeSJean-Christophe PLAGNIOL-VILLARD &int_line); 50493a686eeSJean-Christophe PLAGNIOL-VILLARD printf(" %02x %02x %04x %04x %04x %02x\n", 50593a686eeSJean-Christophe PLAGNIOL-VILLARD PCI_BUS(dev), PCI_DEV(dev), vendor, device, class, 50693a686eeSJean-Christophe PLAGNIOL-VILLARD int_line); 50793a686eeSJean-Christophe PLAGNIOL-VILLARD } 50893a686eeSJean-Christophe PLAGNIOL-VILLARD #endif 50993a686eeSJean-Christophe PLAGNIOL-VILLARD } 51093a686eeSJean-Christophe PLAGNIOL-VILLARD } 51193a686eeSJean-Christophe PLAGNIOL-VILLARD 51293a686eeSJean-Christophe PLAGNIOL-VILLARD return sub_bus; 51393a686eeSJean-Christophe PLAGNIOL-VILLARD } 51493a686eeSJean-Christophe PLAGNIOL-VILLARD 51593a686eeSJean-Christophe PLAGNIOL-VILLARD int pci_hose_scan(struct pci_controller *hose) 51693a686eeSJean-Christophe PLAGNIOL-VILLARD { 51793a686eeSJean-Christophe PLAGNIOL-VILLARD /* Start scan at current_busno. 51893a686eeSJean-Christophe PLAGNIOL-VILLARD * PCIe will start scan at first_busno+1. 51993a686eeSJean-Christophe PLAGNIOL-VILLARD */ 52093a686eeSJean-Christophe PLAGNIOL-VILLARD /* For legacy support, ensure current>=first */ 52193a686eeSJean-Christophe PLAGNIOL-VILLARD if (hose->first_busno > hose->current_busno) 52293a686eeSJean-Christophe PLAGNIOL-VILLARD hose->current_busno = hose->first_busno; 52393a686eeSJean-Christophe PLAGNIOL-VILLARD #ifdef CONFIG_PCI_PNP 52493a686eeSJean-Christophe PLAGNIOL-VILLARD pciauto_config_init(hose); 52593a686eeSJean-Christophe PLAGNIOL-VILLARD #endif 52693a686eeSJean-Christophe PLAGNIOL-VILLARD return pci_hose_scan_bus(hose, hose->current_busno); 52793a686eeSJean-Christophe PLAGNIOL-VILLARD } 52893a686eeSJean-Christophe PLAGNIOL-VILLARD 52993a686eeSJean-Christophe PLAGNIOL-VILLARD void pci_init(void) 53093a686eeSJean-Christophe PLAGNIOL-VILLARD { 53193a686eeSJean-Christophe PLAGNIOL-VILLARD #if defined(CONFIG_PCI_BOOTDELAY) 53293a686eeSJean-Christophe PLAGNIOL-VILLARD char *s; 53393a686eeSJean-Christophe PLAGNIOL-VILLARD int i; 53493a686eeSJean-Christophe PLAGNIOL-VILLARD 53593a686eeSJean-Christophe PLAGNIOL-VILLARD /* wait "pcidelay" ms (if defined)... */ 53693a686eeSJean-Christophe PLAGNIOL-VILLARD s = getenv ("pcidelay"); 53793a686eeSJean-Christophe PLAGNIOL-VILLARD if (s) { 53893a686eeSJean-Christophe PLAGNIOL-VILLARD int val = simple_strtoul (s, NULL, 10); 53993a686eeSJean-Christophe PLAGNIOL-VILLARD for (i=0; i<val; i++) 54093a686eeSJean-Christophe PLAGNIOL-VILLARD udelay (1000); 54193a686eeSJean-Christophe PLAGNIOL-VILLARD } 54293a686eeSJean-Christophe PLAGNIOL-VILLARD #endif /* CONFIG_PCI_BOOTDELAY */ 54393a686eeSJean-Christophe PLAGNIOL-VILLARD 54493a686eeSJean-Christophe PLAGNIOL-VILLARD /* now call board specific pci_init()... */ 54593a686eeSJean-Christophe PLAGNIOL-VILLARD pci_init_board(); 54693a686eeSJean-Christophe PLAGNIOL-VILLARD } 54793a686eeSJean-Christophe PLAGNIOL-VILLARD 54893a686eeSJean-Christophe PLAGNIOL-VILLARD #endif /* CONFIG_PCI */ 549