11da177e4SLinus Torvalds /* 21da177e4SLinus Torvalds * pci.c - Low-Level PCI Access in IA-64 31da177e4SLinus Torvalds * 41da177e4SLinus Torvalds * Derived from bios32.c of i386 tree. 51da177e4SLinus Torvalds * 61da177e4SLinus Torvalds * (c) Copyright 2002, 2005 Hewlett-Packard Development Company, L.P. 71da177e4SLinus Torvalds * David Mosberger-Tang <davidm@hpl.hp.com> 81da177e4SLinus Torvalds * Bjorn Helgaas <bjorn.helgaas@hp.com> 91da177e4SLinus Torvalds * Copyright (C) 2004 Silicon Graphics, Inc. 101da177e4SLinus Torvalds * 111da177e4SLinus Torvalds * Note: Above list of copyright holders is incomplete... 121da177e4SLinus Torvalds */ 131da177e4SLinus Torvalds 141da177e4SLinus Torvalds #include <linux/acpi.h> 151da177e4SLinus Torvalds #include <linux/types.h> 161da177e4SLinus Torvalds #include <linux/kernel.h> 171da177e4SLinus Torvalds #include <linux/pci.h> 181da177e4SLinus Torvalds #include <linux/init.h> 191da177e4SLinus Torvalds #include <linux/ioport.h> 201da177e4SLinus Torvalds #include <linux/slab.h> 211da177e4SLinus Torvalds #include <linux/smp_lock.h> 221da177e4SLinus Torvalds #include <linux/spinlock.h> 231da177e4SLinus Torvalds 241da177e4SLinus Torvalds #include <asm/machvec.h> 251da177e4SLinus Torvalds #include <asm/page.h> 261da177e4SLinus Torvalds #include <asm/system.h> 271da177e4SLinus Torvalds #include <asm/io.h> 281da177e4SLinus Torvalds #include <asm/sal.h> 291da177e4SLinus Torvalds #include <asm/smp.h> 301da177e4SLinus Torvalds #include <asm/irq.h> 311da177e4SLinus Torvalds #include <asm/hw_irq.h> 321da177e4SLinus Torvalds 331da177e4SLinus Torvalds /* 341da177e4SLinus Torvalds * Low-level SAL-based PCI configuration access functions. Note that SAL 351da177e4SLinus Torvalds * calls are already serialized (via sal_lock), so we don't need another 361da177e4SLinus Torvalds * synchronization mechanism here. 371da177e4SLinus Torvalds */ 381da177e4SLinus Torvalds 391da177e4SLinus Torvalds #define PCI_SAL_ADDRESS(seg, bus, devfn, reg) \ 401da177e4SLinus Torvalds (((u64) seg << 24) | (bus << 16) | (devfn << 8) | (reg)) 411da177e4SLinus Torvalds 421da177e4SLinus Torvalds /* SAL 3.2 adds support for extended config space. */ 431da177e4SLinus Torvalds 441da177e4SLinus Torvalds #define PCI_SAL_EXT_ADDRESS(seg, bus, devfn, reg) \ 451da177e4SLinus Torvalds (((u64) seg << 28) | (bus << 20) | (devfn << 12) | (reg)) 461da177e4SLinus Torvalds 471da177e4SLinus Torvalds static int 481da177e4SLinus Torvalds pci_sal_read (unsigned int seg, unsigned int bus, unsigned int devfn, 491da177e4SLinus Torvalds int reg, int len, u32 *value) 501da177e4SLinus Torvalds { 511da177e4SLinus Torvalds u64 addr, data = 0; 521da177e4SLinus Torvalds int mode, result; 531da177e4SLinus Torvalds 541da177e4SLinus Torvalds if (!value || (seg > 65535) || (bus > 255) || (devfn > 255) || (reg > 4095)) 551da177e4SLinus Torvalds return -EINVAL; 561da177e4SLinus Torvalds 571da177e4SLinus Torvalds if ((seg | reg) <= 255) { 581da177e4SLinus Torvalds addr = PCI_SAL_ADDRESS(seg, bus, devfn, reg); 591da177e4SLinus Torvalds mode = 0; 601da177e4SLinus Torvalds } else { 611da177e4SLinus Torvalds addr = PCI_SAL_EXT_ADDRESS(seg, bus, devfn, reg); 621da177e4SLinus Torvalds mode = 1; 631da177e4SLinus Torvalds } 641da177e4SLinus Torvalds result = ia64_sal_pci_config_read(addr, mode, len, &data); 651da177e4SLinus Torvalds if (result != 0) 661da177e4SLinus Torvalds return -EINVAL; 671da177e4SLinus Torvalds 681da177e4SLinus Torvalds *value = (u32) data; 691da177e4SLinus Torvalds return 0; 701da177e4SLinus Torvalds } 711da177e4SLinus Torvalds 721da177e4SLinus Torvalds static int 731da177e4SLinus Torvalds pci_sal_write (unsigned int seg, unsigned int bus, unsigned int devfn, 741da177e4SLinus Torvalds int reg, int len, u32 value) 751da177e4SLinus Torvalds { 761da177e4SLinus Torvalds u64 addr; 771da177e4SLinus Torvalds int mode, result; 781da177e4SLinus Torvalds 791da177e4SLinus Torvalds if ((seg > 65535) || (bus > 255) || (devfn > 255) || (reg > 4095)) 801da177e4SLinus Torvalds return -EINVAL; 811da177e4SLinus Torvalds 821da177e4SLinus Torvalds if ((seg | reg) <= 255) { 831da177e4SLinus Torvalds addr = PCI_SAL_ADDRESS(seg, bus, devfn, reg); 841da177e4SLinus Torvalds mode = 0; 851da177e4SLinus Torvalds } else { 861da177e4SLinus Torvalds addr = PCI_SAL_EXT_ADDRESS(seg, bus, devfn, reg); 871da177e4SLinus Torvalds mode = 1; 881da177e4SLinus Torvalds } 891da177e4SLinus Torvalds result = ia64_sal_pci_config_write(addr, mode, len, value); 901da177e4SLinus Torvalds if (result != 0) 911da177e4SLinus Torvalds return -EINVAL; 921da177e4SLinus Torvalds return 0; 931da177e4SLinus Torvalds } 941da177e4SLinus Torvalds 951da177e4SLinus Torvalds static struct pci_raw_ops pci_sal_ops = { 961da177e4SLinus Torvalds .read = pci_sal_read, 971da177e4SLinus Torvalds .write = pci_sal_write 981da177e4SLinus Torvalds }; 991da177e4SLinus Torvalds 1001da177e4SLinus Torvalds struct pci_raw_ops *raw_pci_ops = &pci_sal_ops; 1011da177e4SLinus Torvalds 1021da177e4SLinus Torvalds static int 1031da177e4SLinus Torvalds pci_read (struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *value) 1041da177e4SLinus Torvalds { 1051da177e4SLinus Torvalds return raw_pci_ops->read(pci_domain_nr(bus), bus->number, 1061da177e4SLinus Torvalds devfn, where, size, value); 1071da177e4SLinus Torvalds } 1081da177e4SLinus Torvalds 1091da177e4SLinus Torvalds static int 1101da177e4SLinus Torvalds pci_write (struct pci_bus *bus, unsigned int devfn, int where, int size, u32 value) 1111da177e4SLinus Torvalds { 1121da177e4SLinus Torvalds return raw_pci_ops->write(pci_domain_nr(bus), bus->number, 1131da177e4SLinus Torvalds devfn, where, size, value); 1141da177e4SLinus Torvalds } 1151da177e4SLinus Torvalds 1161da177e4SLinus Torvalds struct pci_ops pci_root_ops = { 1171da177e4SLinus Torvalds .read = pci_read, 1181da177e4SLinus Torvalds .write = pci_write, 1191da177e4SLinus Torvalds }; 1201da177e4SLinus Torvalds 1211da177e4SLinus Torvalds /* Called by ACPI when it finds a new root bus. */ 1221da177e4SLinus Torvalds 1231da177e4SLinus Torvalds static struct pci_controller * __devinit 1241da177e4SLinus Torvalds alloc_pci_controller (int seg) 1251da177e4SLinus Torvalds { 1261da177e4SLinus Torvalds struct pci_controller *controller; 1271da177e4SLinus Torvalds 1281da177e4SLinus Torvalds controller = kmalloc(sizeof(*controller), GFP_KERNEL); 1291da177e4SLinus Torvalds if (!controller) 1301da177e4SLinus Torvalds return NULL; 1311da177e4SLinus Torvalds 1321da177e4SLinus Torvalds memset(controller, 0, sizeof(*controller)); 1331da177e4SLinus Torvalds controller->segment = seg; 134514604c6SChristoph Lameter controller->node = -1; 1351da177e4SLinus Torvalds return controller; 1361da177e4SLinus Torvalds } 1371da177e4SLinus Torvalds 1384f41d5a4SBjorn Helgaas struct pci_root_info { 1394f41d5a4SBjorn Helgaas struct pci_controller *controller; 1404f41d5a4SBjorn Helgaas char *name; 1414f41d5a4SBjorn Helgaas }; 1424f41d5a4SBjorn Helgaas 1434f41d5a4SBjorn Helgaas static unsigned int 1444f41d5a4SBjorn Helgaas new_space (u64 phys_base, int sparse) 1451da177e4SLinus Torvalds { 1464f41d5a4SBjorn Helgaas u64 mmio_base; 1471da177e4SLinus Torvalds int i; 1481da177e4SLinus Torvalds 1494f41d5a4SBjorn Helgaas if (phys_base == 0) 1504f41d5a4SBjorn Helgaas return 0; /* legacy I/O port space */ 1511da177e4SLinus Torvalds 1524f41d5a4SBjorn Helgaas mmio_base = (u64) ioremap(phys_base, 0); 1531da177e4SLinus Torvalds for (i = 0; i < num_io_spaces; i++) 1544f41d5a4SBjorn Helgaas if (io_space[i].mmio_base == mmio_base && 1551da177e4SLinus Torvalds io_space[i].sparse == sparse) 1564f41d5a4SBjorn Helgaas return i; 1571da177e4SLinus Torvalds 1581da177e4SLinus Torvalds if (num_io_spaces == MAX_IO_SPACES) { 1594f41d5a4SBjorn Helgaas printk(KERN_ERR "PCI: Too many IO port spaces " 1604f41d5a4SBjorn Helgaas "(MAX_IO_SPACES=%lu)\n", MAX_IO_SPACES); 1611da177e4SLinus Torvalds return ~0; 1621da177e4SLinus Torvalds } 1631da177e4SLinus Torvalds 1641da177e4SLinus Torvalds i = num_io_spaces++; 1654f41d5a4SBjorn Helgaas io_space[i].mmio_base = mmio_base; 1661da177e4SLinus Torvalds io_space[i].sparse = sparse; 1671da177e4SLinus Torvalds 1684f41d5a4SBjorn Helgaas return i; 1694f41d5a4SBjorn Helgaas } 1704f41d5a4SBjorn Helgaas 1714f41d5a4SBjorn Helgaas static u64 __devinit 1724f41d5a4SBjorn Helgaas add_io_space (struct pci_root_info *info, struct acpi_resource_address64 *addr) 1734f41d5a4SBjorn Helgaas { 1744f41d5a4SBjorn Helgaas struct resource *resource; 1754f41d5a4SBjorn Helgaas char *name; 1764f41d5a4SBjorn Helgaas u64 base, min, max, base_port; 1774f41d5a4SBjorn Helgaas unsigned int sparse = 0, space_nr, len; 1784f41d5a4SBjorn Helgaas 1794f41d5a4SBjorn Helgaas resource = kzalloc(sizeof(*resource), GFP_KERNEL); 1804f41d5a4SBjorn Helgaas if (!resource) { 1814f41d5a4SBjorn Helgaas printk(KERN_ERR "PCI: No memory for %s I/O port space\n", 1824f41d5a4SBjorn Helgaas info->name); 1834f41d5a4SBjorn Helgaas goto out; 1844f41d5a4SBjorn Helgaas } 1854f41d5a4SBjorn Helgaas 1864f41d5a4SBjorn Helgaas len = strlen(info->name) + 32; 1874f41d5a4SBjorn Helgaas name = kzalloc(len, GFP_KERNEL); 1884f41d5a4SBjorn Helgaas if (!name) { 1894f41d5a4SBjorn Helgaas printk(KERN_ERR "PCI: No memory for %s I/O port space name\n", 1904f41d5a4SBjorn Helgaas info->name); 1914f41d5a4SBjorn Helgaas goto free_resource; 1924f41d5a4SBjorn Helgaas } 1934f41d5a4SBjorn Helgaas 19450eca3ebSBob Moore min = addr->minimum; 1954f41d5a4SBjorn Helgaas max = min + addr->address_length - 1; 1960897831bSBob Moore if (addr->info.io.translation_type == ACPI_SPARSE_TRANSLATION) 1974f41d5a4SBjorn Helgaas sparse = 1; 1984f41d5a4SBjorn Helgaas 19950eca3ebSBob Moore space_nr = new_space(addr->translation_offset, sparse); 2004f41d5a4SBjorn Helgaas if (space_nr == ~0) 2014f41d5a4SBjorn Helgaas goto free_name; 2024f41d5a4SBjorn Helgaas 2034f41d5a4SBjorn Helgaas base = __pa(io_space[space_nr].mmio_base); 2044f41d5a4SBjorn Helgaas base_port = IO_SPACE_BASE(space_nr); 2054f41d5a4SBjorn Helgaas snprintf(name, len, "%s I/O Ports %08lx-%08lx", info->name, 2064f41d5a4SBjorn Helgaas base_port + min, base_port + max); 2074f41d5a4SBjorn Helgaas 2084f41d5a4SBjorn Helgaas /* 2094f41d5a4SBjorn Helgaas * The SDM guarantees the legacy 0-64K space is sparse, but if the 2104f41d5a4SBjorn Helgaas * mapping is done by the processor (not the bridge), ACPI may not 2114f41d5a4SBjorn Helgaas * mark it as sparse. 2124f41d5a4SBjorn Helgaas */ 2134f41d5a4SBjorn Helgaas if (space_nr == 0) 2144f41d5a4SBjorn Helgaas sparse = 1; 2154f41d5a4SBjorn Helgaas 2164f41d5a4SBjorn Helgaas resource->name = name; 2174f41d5a4SBjorn Helgaas resource->flags = IORESOURCE_MEM; 2184f41d5a4SBjorn Helgaas resource->start = base + (sparse ? IO_SPACE_SPARSE_ENCODING(min) : min); 2194f41d5a4SBjorn Helgaas resource->end = base + (sparse ? IO_SPACE_SPARSE_ENCODING(max) : max); 2204f41d5a4SBjorn Helgaas insert_resource(&iomem_resource, resource); 2214f41d5a4SBjorn Helgaas 2224f41d5a4SBjorn Helgaas return base_port; 2234f41d5a4SBjorn Helgaas 2244f41d5a4SBjorn Helgaas free_name: 2254f41d5a4SBjorn Helgaas kfree(name); 2264f41d5a4SBjorn Helgaas free_resource: 2274f41d5a4SBjorn Helgaas kfree(resource); 2284f41d5a4SBjorn Helgaas out: 2294f41d5a4SBjorn Helgaas return ~0; 2301da177e4SLinus Torvalds } 2311da177e4SLinus Torvalds 232463eb297SBjorn Helgaas static acpi_status __devinit resource_to_window(struct acpi_resource *resource, 233463eb297SBjorn Helgaas struct acpi_resource_address64 *addr) 234463eb297SBjorn Helgaas { 235463eb297SBjorn Helgaas acpi_status status; 236463eb297SBjorn Helgaas 237463eb297SBjorn Helgaas /* 238463eb297SBjorn Helgaas * We're only interested in _CRS descriptors that are 239463eb297SBjorn Helgaas * - address space descriptors for memory or I/O space 240463eb297SBjorn Helgaas * - non-zero size 241463eb297SBjorn Helgaas * - producers, i.e., the address space is routed downstream, 242463eb297SBjorn Helgaas * not consumed by the bridge itself 243463eb297SBjorn Helgaas */ 244463eb297SBjorn Helgaas status = acpi_resource_to_address64(resource, addr); 245463eb297SBjorn Helgaas if (ACPI_SUCCESS(status) && 246463eb297SBjorn Helgaas (addr->resource_type == ACPI_MEMORY_RANGE || 247463eb297SBjorn Helgaas addr->resource_type == ACPI_IO_RANGE) && 248463eb297SBjorn Helgaas addr->address_length && 249463eb297SBjorn Helgaas addr->producer_consumer == ACPI_PRODUCER) 250463eb297SBjorn Helgaas return AE_OK; 251463eb297SBjorn Helgaas 252463eb297SBjorn Helgaas return AE_ERROR; 253463eb297SBjorn Helgaas } 254463eb297SBjorn Helgaas 2551da177e4SLinus Torvalds static acpi_status __devinit 2561da177e4SLinus Torvalds count_window (struct acpi_resource *resource, void *data) 2571da177e4SLinus Torvalds { 2581da177e4SLinus Torvalds unsigned int *windows = (unsigned int *) data; 2591da177e4SLinus Torvalds struct acpi_resource_address64 addr; 2601da177e4SLinus Torvalds acpi_status status; 2611da177e4SLinus Torvalds 262463eb297SBjorn Helgaas status = resource_to_window(resource, &addr); 2631da177e4SLinus Torvalds if (ACPI_SUCCESS(status)) 2641da177e4SLinus Torvalds (*windows)++; 2651da177e4SLinus Torvalds 2661da177e4SLinus Torvalds return AE_OK; 2671da177e4SLinus Torvalds } 2681da177e4SLinus Torvalds 2691da177e4SLinus Torvalds static __devinit acpi_status add_window(struct acpi_resource *res, void *data) 2701da177e4SLinus Torvalds { 2711da177e4SLinus Torvalds struct pci_root_info *info = data; 2721da177e4SLinus Torvalds struct pci_window *window; 2731da177e4SLinus Torvalds struct acpi_resource_address64 addr; 2741da177e4SLinus Torvalds acpi_status status; 2751da177e4SLinus Torvalds unsigned long flags, offset = 0; 2761da177e4SLinus Torvalds struct resource *root; 2771da177e4SLinus Torvalds 278463eb297SBjorn Helgaas /* Return AE_OK for non-window resources to keep scanning for more */ 279463eb297SBjorn Helgaas status = resource_to_window(res, &addr); 2801da177e4SLinus Torvalds if (!ACPI_SUCCESS(status)) 2811da177e4SLinus Torvalds return AE_OK; 2821da177e4SLinus Torvalds 2831da177e4SLinus Torvalds if (addr.resource_type == ACPI_MEMORY_RANGE) { 2841da177e4SLinus Torvalds flags = IORESOURCE_MEM; 2851da177e4SLinus Torvalds root = &iomem_resource; 28650eca3ebSBob Moore offset = addr.translation_offset; 2871da177e4SLinus Torvalds } else if (addr.resource_type == ACPI_IO_RANGE) { 2881da177e4SLinus Torvalds flags = IORESOURCE_IO; 2891da177e4SLinus Torvalds root = &ioport_resource; 2904f41d5a4SBjorn Helgaas offset = add_io_space(info, &addr); 2911da177e4SLinus Torvalds if (offset == ~0) 2921da177e4SLinus Torvalds return AE_OK; 2931da177e4SLinus Torvalds } else 2941da177e4SLinus Torvalds return AE_OK; 2951da177e4SLinus Torvalds 2961da177e4SLinus Torvalds window = &info->controller->window[info->controller->windows++]; 2971da177e4SLinus Torvalds window->resource.name = info->name; 2981da177e4SLinus Torvalds window->resource.flags = flags; 29950eca3ebSBob Moore window->resource.start = addr.minimum + offset; 3004f41d5a4SBjorn Helgaas window->resource.end = window->resource.start + addr.address_length - 1; 3011da177e4SLinus Torvalds window->resource.child = NULL; 3021da177e4SLinus Torvalds window->offset = offset; 3031da177e4SLinus Torvalds 3041da177e4SLinus Torvalds if (insert_resource(root, &window->resource)) { 3051da177e4SLinus Torvalds printk(KERN_ERR "alloc 0x%lx-0x%lx from %s for %s failed\n", 3061da177e4SLinus Torvalds window->resource.start, window->resource.end, 3071da177e4SLinus Torvalds root->name, info->name); 3081da177e4SLinus Torvalds } 3091da177e4SLinus Torvalds 3101da177e4SLinus Torvalds return AE_OK; 3111da177e4SLinus Torvalds } 3121da177e4SLinus Torvalds 3131da177e4SLinus Torvalds static void __devinit 3141da177e4SLinus Torvalds pcibios_setup_root_windows(struct pci_bus *bus, struct pci_controller *ctrl) 3151da177e4SLinus Torvalds { 3161da177e4SLinus Torvalds int i, j; 3171da177e4SLinus Torvalds 3181da177e4SLinus Torvalds j = 0; 3191da177e4SLinus Torvalds for (i = 0; i < ctrl->windows; i++) { 3201da177e4SLinus Torvalds struct resource *res = &ctrl->window[i].resource; 3211da177e4SLinus Torvalds /* HP's firmware has a hack to work around a Windows bug. 3221da177e4SLinus Torvalds * Ignore these tiny memory ranges */ 3231da177e4SLinus Torvalds if ((res->flags & IORESOURCE_MEM) && 3241da177e4SLinus Torvalds (res->end - res->start < 16)) 3251da177e4SLinus Torvalds continue; 3261da177e4SLinus Torvalds if (j >= PCI_BUS_NUM_RESOURCES) { 3271da177e4SLinus Torvalds printk("Ignoring range [%lx-%lx] (%lx)\n", res->start, 3281da177e4SLinus Torvalds res->end, res->flags); 3291da177e4SLinus Torvalds continue; 3301da177e4SLinus Torvalds } 3311da177e4SLinus Torvalds bus->resource[j++] = res; 3321da177e4SLinus Torvalds } 3331da177e4SLinus Torvalds } 3341da177e4SLinus Torvalds 3351da177e4SLinus Torvalds struct pci_bus * __devinit 3361da177e4SLinus Torvalds pci_acpi_scan_root(struct acpi_device *device, int domain, int bus) 3371da177e4SLinus Torvalds { 3381da177e4SLinus Torvalds struct pci_root_info info; 3391da177e4SLinus Torvalds struct pci_controller *controller; 3401da177e4SLinus Torvalds unsigned int windows = 0; 3411da177e4SLinus Torvalds struct pci_bus *pbus; 3421da177e4SLinus Torvalds char *name; 343514604c6SChristoph Lameter int pxm; 3441da177e4SLinus Torvalds 3451da177e4SLinus Torvalds controller = alloc_pci_controller(domain); 3461da177e4SLinus Torvalds if (!controller) 3471da177e4SLinus Torvalds goto out1; 3481da177e4SLinus Torvalds 3491da177e4SLinus Torvalds controller->acpi_handle = device->handle; 3501da177e4SLinus Torvalds 351514604c6SChristoph Lameter pxm = acpi_get_pxm(controller->acpi_handle); 352514604c6SChristoph Lameter #ifdef CONFIG_NUMA 353514604c6SChristoph Lameter if (pxm >= 0) 354762834e8SYasunori Goto controller->node = pxm_to_node(pxm); 355514604c6SChristoph Lameter #endif 356514604c6SChristoph Lameter 3571da177e4SLinus Torvalds acpi_walk_resources(device->handle, METHOD_NAME__CRS, count_window, 3581da177e4SLinus Torvalds &windows); 359514604c6SChristoph Lameter controller->window = kmalloc_node(sizeof(*controller->window) * windows, 360514604c6SChristoph Lameter GFP_KERNEL, controller->node); 3611da177e4SLinus Torvalds if (!controller->window) 3621da177e4SLinus Torvalds goto out2; 3631da177e4SLinus Torvalds 3641da177e4SLinus Torvalds name = kmalloc(16, GFP_KERNEL); 3651da177e4SLinus Torvalds if (!name) 3661da177e4SLinus Torvalds goto out3; 3671da177e4SLinus Torvalds 3681da177e4SLinus Torvalds sprintf(name, "PCI Bus %04x:%02x", domain, bus); 3691da177e4SLinus Torvalds info.controller = controller; 3701da177e4SLinus Torvalds info.name = name; 3711da177e4SLinus Torvalds acpi_walk_resources(device->handle, METHOD_NAME__CRS, add_window, 3721da177e4SLinus Torvalds &info); 3731da177e4SLinus Torvalds 374c431ada4SRajesh Shah pbus = pci_scan_bus_parented(NULL, bus, &pci_root_ops, controller); 3751da177e4SLinus Torvalds if (pbus) 3761da177e4SLinus Torvalds pcibios_setup_root_windows(pbus, controller); 3771da177e4SLinus Torvalds 3781da177e4SLinus Torvalds return pbus; 3791da177e4SLinus Torvalds 3801da177e4SLinus Torvalds out3: 3811da177e4SLinus Torvalds kfree(controller->window); 3821da177e4SLinus Torvalds out2: 3831da177e4SLinus Torvalds kfree(controller); 3841da177e4SLinus Torvalds out1: 3851da177e4SLinus Torvalds return NULL; 3861da177e4SLinus Torvalds } 3871da177e4SLinus Torvalds 3881da177e4SLinus Torvalds void pcibios_resource_to_bus(struct pci_dev *dev, 3891da177e4SLinus Torvalds struct pci_bus_region *region, struct resource *res) 3901da177e4SLinus Torvalds { 3911da177e4SLinus Torvalds struct pci_controller *controller = PCI_CONTROLLER(dev); 3921da177e4SLinus Torvalds unsigned long offset = 0; 3931da177e4SLinus Torvalds int i; 3941da177e4SLinus Torvalds 3951da177e4SLinus Torvalds for (i = 0; i < controller->windows; i++) { 3961da177e4SLinus Torvalds struct pci_window *window = &controller->window[i]; 3971da177e4SLinus Torvalds if (!(window->resource.flags & res->flags)) 3981da177e4SLinus Torvalds continue; 3991da177e4SLinus Torvalds if (window->resource.start > res->start) 4001da177e4SLinus Torvalds continue; 4011da177e4SLinus Torvalds if (window->resource.end < res->end) 4021da177e4SLinus Torvalds continue; 4031da177e4SLinus Torvalds offset = window->offset; 4041da177e4SLinus Torvalds break; 4051da177e4SLinus Torvalds } 4061da177e4SLinus Torvalds 4071da177e4SLinus Torvalds region->start = res->start - offset; 4081da177e4SLinus Torvalds region->end = res->end - offset; 4091da177e4SLinus Torvalds } 4101da177e4SLinus Torvalds EXPORT_SYMBOL(pcibios_resource_to_bus); 4111da177e4SLinus Torvalds 4121da177e4SLinus Torvalds void pcibios_bus_to_resource(struct pci_dev *dev, 4131da177e4SLinus Torvalds struct resource *res, struct pci_bus_region *region) 4141da177e4SLinus Torvalds { 4151da177e4SLinus Torvalds struct pci_controller *controller = PCI_CONTROLLER(dev); 4161da177e4SLinus Torvalds unsigned long offset = 0; 4171da177e4SLinus Torvalds int i; 4181da177e4SLinus Torvalds 4191da177e4SLinus Torvalds for (i = 0; i < controller->windows; i++) { 4201da177e4SLinus Torvalds struct pci_window *window = &controller->window[i]; 4211da177e4SLinus Torvalds if (!(window->resource.flags & res->flags)) 4221da177e4SLinus Torvalds continue; 4231da177e4SLinus Torvalds if (window->resource.start - window->offset > region->start) 4241da177e4SLinus Torvalds continue; 4251da177e4SLinus Torvalds if (window->resource.end - window->offset < region->end) 4261da177e4SLinus Torvalds continue; 4271da177e4SLinus Torvalds offset = window->offset; 4281da177e4SLinus Torvalds break; 4291da177e4SLinus Torvalds } 4301da177e4SLinus Torvalds 4311da177e4SLinus Torvalds res->start = region->start + offset; 4321da177e4SLinus Torvalds res->end = region->end + offset; 4331da177e4SLinus Torvalds } 43441290c14SKeith Owens EXPORT_SYMBOL(pcibios_bus_to_resource); 4351da177e4SLinus Torvalds 43671c3511cSRajesh Shah static int __devinit is_valid_resource(struct pci_dev *dev, int idx) 43771c3511cSRajesh Shah { 43871c3511cSRajesh Shah unsigned int i, type_mask = IORESOURCE_IO | IORESOURCE_MEM; 43971c3511cSRajesh Shah struct resource *devr = &dev->resource[idx]; 44071c3511cSRajesh Shah 44171c3511cSRajesh Shah if (!dev->bus) 44271c3511cSRajesh Shah return 0; 44371c3511cSRajesh Shah for (i=0; i<PCI_BUS_NUM_RESOURCES; i++) { 44471c3511cSRajesh Shah struct resource *busr = dev->bus->resource[i]; 44571c3511cSRajesh Shah 44671c3511cSRajesh Shah if (!busr || ((busr->flags ^ devr->flags) & type_mask)) 44771c3511cSRajesh Shah continue; 44871c3511cSRajesh Shah if ((devr->start) && (devr->start >= busr->start) && 44971c3511cSRajesh Shah (devr->end <= busr->end)) 45071c3511cSRajesh Shah return 1; 45171c3511cSRajesh Shah } 45271c3511cSRajesh Shah return 0; 45371c3511cSRajesh Shah } 45471c3511cSRajesh Shah 4557b9c8ba2SKenji Kaneshige static void __devinit 4567b9c8ba2SKenji Kaneshige pcibios_fixup_resources(struct pci_dev *dev, int start, int limit) 4571da177e4SLinus Torvalds { 4581da177e4SLinus Torvalds struct pci_bus_region region; 4591da177e4SLinus Torvalds int i; 4601da177e4SLinus Torvalds 4617b9c8ba2SKenji Kaneshige for (i = start; i < limit; i++) { 4621da177e4SLinus Torvalds if (!dev->resource[i].flags) 4631da177e4SLinus Torvalds continue; 4641da177e4SLinus Torvalds region.start = dev->resource[i].start; 4651da177e4SLinus Torvalds region.end = dev->resource[i].end; 4661da177e4SLinus Torvalds pcibios_bus_to_resource(dev, &dev->resource[i], ®ion); 46771c3511cSRajesh Shah if ((is_valid_resource(dev, i))) 4681da177e4SLinus Torvalds pci_claim_resource(dev, i); 4691da177e4SLinus Torvalds } 4701da177e4SLinus Torvalds } 4711da177e4SLinus Torvalds 4727b9c8ba2SKenji Kaneshige static void __devinit pcibios_fixup_device_resources(struct pci_dev *dev) 4737b9c8ba2SKenji Kaneshige { 4747b9c8ba2SKenji Kaneshige pcibios_fixup_resources(dev, 0, PCI_BRIDGE_RESOURCES); 4757b9c8ba2SKenji Kaneshige } 4767b9c8ba2SKenji Kaneshige 4777b9c8ba2SKenji Kaneshige static void __devinit pcibios_fixup_bridge_resources(struct pci_dev *dev) 4787b9c8ba2SKenji Kaneshige { 4797b9c8ba2SKenji Kaneshige pcibios_fixup_resources(dev, PCI_BRIDGE_RESOURCES, PCI_NUM_RESOURCES); 4807b9c8ba2SKenji Kaneshige } 4817b9c8ba2SKenji Kaneshige 4821da177e4SLinus Torvalds /* 4831da177e4SLinus Torvalds * Called after each bus is probed, but before its children are examined. 4841da177e4SLinus Torvalds */ 4851da177e4SLinus Torvalds void __devinit 4861da177e4SLinus Torvalds pcibios_fixup_bus (struct pci_bus *b) 4871da177e4SLinus Torvalds { 4881da177e4SLinus Torvalds struct pci_dev *dev; 4891da177e4SLinus Torvalds 490f7d473d9SRajesh Shah if (b->self) { 491f7d473d9SRajesh Shah pci_read_bridge_bases(b); 4927b9c8ba2SKenji Kaneshige pcibios_fixup_bridge_resources(b->self); 493f7d473d9SRajesh Shah } 4941da177e4SLinus Torvalds list_for_each_entry(dev, &b->devices, bus_list) 4951da177e4SLinus Torvalds pcibios_fixup_device_resources(dev); 4961da177e4SLinus Torvalds 4971da177e4SLinus Torvalds return; 4981da177e4SLinus Torvalds } 4991da177e4SLinus Torvalds 5001da177e4SLinus Torvalds void __devinit 5011da177e4SLinus Torvalds pcibios_update_irq (struct pci_dev *dev, int irq) 5021da177e4SLinus Torvalds { 5031da177e4SLinus Torvalds pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq); 5041da177e4SLinus Torvalds 5051da177e4SLinus Torvalds /* ??? FIXME -- record old value for shutdown. */ 5061da177e4SLinus Torvalds } 5071da177e4SLinus Torvalds 5081da177e4SLinus Torvalds static inline int 5091da177e4SLinus Torvalds pcibios_enable_resources (struct pci_dev *dev, int mask) 5101da177e4SLinus Torvalds { 5111da177e4SLinus Torvalds u16 cmd, old_cmd; 5121da177e4SLinus Torvalds int idx; 5131da177e4SLinus Torvalds struct resource *r; 514fab3fb0aSRajesh Shah unsigned long type_mask = IORESOURCE_IO | IORESOURCE_MEM; 5151da177e4SLinus Torvalds 5161da177e4SLinus Torvalds if (!dev) 5171da177e4SLinus Torvalds return -EINVAL; 5181da177e4SLinus Torvalds 5191da177e4SLinus Torvalds pci_read_config_word(dev, PCI_COMMAND, &cmd); 5201da177e4SLinus Torvalds old_cmd = cmd; 521fab3fb0aSRajesh Shah for (idx=0; idx<PCI_NUM_RESOURCES; idx++) { 5221da177e4SLinus Torvalds /* Only set up the desired resources. */ 5231da177e4SLinus Torvalds if (!(mask & (1 << idx))) 5241da177e4SLinus Torvalds continue; 5251da177e4SLinus Torvalds 5261da177e4SLinus Torvalds r = &dev->resource[idx]; 527fab3fb0aSRajesh Shah if (!(r->flags & type_mask)) 528fab3fb0aSRajesh Shah continue; 529fab3fb0aSRajesh Shah if ((idx == PCI_ROM_RESOURCE) && 530fab3fb0aSRajesh Shah (!(r->flags & IORESOURCE_ROM_ENABLE))) 531fab3fb0aSRajesh Shah continue; 5321da177e4SLinus Torvalds if (!r->start && r->end) { 5331da177e4SLinus Torvalds printk(KERN_ERR 5341da177e4SLinus Torvalds "PCI: Device %s not available because of resource collisions\n", 5351da177e4SLinus Torvalds pci_name(dev)); 5361da177e4SLinus Torvalds return -EINVAL; 5371da177e4SLinus Torvalds } 5381da177e4SLinus Torvalds if (r->flags & IORESOURCE_IO) 5391da177e4SLinus Torvalds cmd |= PCI_COMMAND_IO; 5401da177e4SLinus Torvalds if (r->flags & IORESOURCE_MEM) 5411da177e4SLinus Torvalds cmd |= PCI_COMMAND_MEMORY; 5421da177e4SLinus Torvalds } 5431da177e4SLinus Torvalds if (cmd != old_cmd) { 5441da177e4SLinus Torvalds printk("PCI: Enabling device %s (%04x -> %04x)\n", pci_name(dev), old_cmd, cmd); 5451da177e4SLinus Torvalds pci_write_config_word(dev, PCI_COMMAND, cmd); 5461da177e4SLinus Torvalds } 5471da177e4SLinus Torvalds return 0; 5481da177e4SLinus Torvalds } 5491da177e4SLinus Torvalds 5501da177e4SLinus Torvalds int 5511da177e4SLinus Torvalds pcibios_enable_device (struct pci_dev *dev, int mask) 5521da177e4SLinus Torvalds { 5531da177e4SLinus Torvalds int ret; 5541da177e4SLinus Torvalds 5551da177e4SLinus Torvalds ret = pcibios_enable_resources(dev, mask); 5561da177e4SLinus Torvalds if (ret < 0) 5571da177e4SLinus Torvalds return ret; 5581da177e4SLinus Torvalds 5591da177e4SLinus Torvalds return acpi_pci_irq_enable(dev); 5601da177e4SLinus Torvalds } 5611da177e4SLinus Torvalds 5621da177e4SLinus Torvalds void 5631da177e4SLinus Torvalds pcibios_disable_device (struct pci_dev *dev) 5641da177e4SLinus Torvalds { 565aa4f63caSSatoru Takeuchi if (dev->is_enabled) 5661da177e4SLinus Torvalds acpi_pci_irq_disable(dev); 5671da177e4SLinus Torvalds } 5681da177e4SLinus Torvalds 5691da177e4SLinus Torvalds void 5701da177e4SLinus Torvalds pcibios_align_resource (void *data, struct resource *res, 571e31dd6e4SGreg Kroah-Hartman resource_size_t size, resource_size_t align) 5721da177e4SLinus Torvalds { 5731da177e4SLinus Torvalds } 5741da177e4SLinus Torvalds 5751da177e4SLinus Torvalds /* 5761da177e4SLinus Torvalds * PCI BIOS setup, always defaults to SAL interface 5771da177e4SLinus Torvalds */ 5781da177e4SLinus Torvalds char * __init 5791da177e4SLinus Torvalds pcibios_setup (char *str) 5801da177e4SLinus Torvalds { 581ac311ac2SMatthew Wilcox return str; 5821da177e4SLinus Torvalds } 5831da177e4SLinus Torvalds 5841da177e4SLinus Torvalds int 5851da177e4SLinus Torvalds pci_mmap_page_range (struct pci_dev *dev, struct vm_area_struct *vma, 5861da177e4SLinus Torvalds enum pci_mmap_state mmap_state, int write_combine) 5871da177e4SLinus Torvalds { 5881da177e4SLinus Torvalds /* 5891da177e4SLinus Torvalds * I/O space cannot be accessed via normal processor loads and 5901da177e4SLinus Torvalds * stores on this platform. 5911da177e4SLinus Torvalds */ 5921da177e4SLinus Torvalds if (mmap_state == pci_mmap_io) 5931da177e4SLinus Torvalds /* 5941da177e4SLinus Torvalds * XXX we could relax this for I/O spaces for which ACPI 5951da177e4SLinus Torvalds * indicates that the space is 1-to-1 mapped. But at the 5961da177e4SLinus Torvalds * moment, we don't support multiple PCI address spaces and 5971da177e4SLinus Torvalds * the legacy I/O space is not 1-to-1 mapped, so this is moot. 5981da177e4SLinus Torvalds */ 5991da177e4SLinus Torvalds return -EINVAL; 6001da177e4SLinus Torvalds 6011da177e4SLinus Torvalds /* 6021da177e4SLinus Torvalds * Leave vm_pgoff as-is, the PCI space address is the physical 6031da177e4SLinus Torvalds * address on this platform. 6041da177e4SLinus Torvalds */ 6051da177e4SLinus Torvalds if (write_combine && efi_range_is_wc(vma->vm_start, 6061da177e4SLinus Torvalds vma->vm_end - vma->vm_start)) 6071da177e4SLinus Torvalds vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot); 6081da177e4SLinus Torvalds else 6091da177e4SLinus Torvalds vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); 6101da177e4SLinus Torvalds 6111da177e4SLinus Torvalds if (remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff, 6121da177e4SLinus Torvalds vma->vm_end - vma->vm_start, vma->vm_page_prot)) 6131da177e4SLinus Torvalds return -EAGAIN; 6141da177e4SLinus Torvalds 6151da177e4SLinus Torvalds return 0; 6161da177e4SLinus Torvalds } 6171da177e4SLinus Torvalds 6181da177e4SLinus Torvalds /** 6191da177e4SLinus Torvalds * ia64_pci_get_legacy_mem - generic legacy mem routine 6201da177e4SLinus Torvalds * @bus: bus to get legacy memory base address for 6211da177e4SLinus Torvalds * 6221da177e4SLinus Torvalds * Find the base of legacy memory for @bus. This is typically the first 6231da177e4SLinus Torvalds * megabyte of bus address space for @bus or is simply 0 on platforms whose 6241da177e4SLinus Torvalds * chipsets support legacy I/O and memory routing. Returns the base address 6251da177e4SLinus Torvalds * or an error pointer if an error occurred. 6261da177e4SLinus Torvalds * 6271da177e4SLinus Torvalds * This is the ia64 generic version of this routine. Other platforms 6281da177e4SLinus Torvalds * are free to override it with a machine vector. 6291da177e4SLinus Torvalds */ 6301da177e4SLinus Torvalds char *ia64_pci_get_legacy_mem(struct pci_bus *bus) 6311da177e4SLinus Torvalds { 6321da177e4SLinus Torvalds return (char *)__IA64_UNCACHED_OFFSET; 6331da177e4SLinus Torvalds } 6341da177e4SLinus Torvalds 6351da177e4SLinus Torvalds /** 6361da177e4SLinus Torvalds * pci_mmap_legacy_page_range - map legacy memory space to userland 6371da177e4SLinus Torvalds * @bus: bus whose legacy space we're mapping 6381da177e4SLinus Torvalds * @vma: vma passed in by mmap 6391da177e4SLinus Torvalds * 6401da177e4SLinus Torvalds * Map legacy memory space for this device back to userspace using a machine 6411da177e4SLinus Torvalds * vector to get the base address. 6421da177e4SLinus Torvalds */ 6431da177e4SLinus Torvalds int 6441da177e4SLinus Torvalds pci_mmap_legacy_page_range(struct pci_bus *bus, struct vm_area_struct *vma) 6451da177e4SLinus Torvalds { 64632e62c63SBjorn Helgaas unsigned long size = vma->vm_end - vma->vm_start; 64732e62c63SBjorn Helgaas pgprot_t prot; 6481da177e4SLinus Torvalds char *addr; 6491da177e4SLinus Torvalds 65032e62c63SBjorn Helgaas /* 65132e62c63SBjorn Helgaas * Avoid attribute aliasing. See Documentation/ia64/aliasing.txt 65232e62c63SBjorn Helgaas * for more details. 65332e62c63SBjorn Helgaas */ 65406c67befSLennert Buytenhek if (!valid_mmap_phys_addr_range(vma->vm_pgoff, size)) 65532e62c63SBjorn Helgaas return -EINVAL; 65632e62c63SBjorn Helgaas prot = phys_mem_access_prot(NULL, vma->vm_pgoff, size, 65732e62c63SBjorn Helgaas vma->vm_page_prot); 65832e62c63SBjorn Helgaas if (pgprot_val(prot) != pgprot_val(pgprot_noncached(vma->vm_page_prot))) 65932e62c63SBjorn Helgaas return -EINVAL; 66032e62c63SBjorn Helgaas 6611da177e4SLinus Torvalds addr = pci_get_legacy_mem(bus); 6621da177e4SLinus Torvalds if (IS_ERR(addr)) 6631da177e4SLinus Torvalds return PTR_ERR(addr); 6641da177e4SLinus Torvalds 6651da177e4SLinus Torvalds vma->vm_pgoff += (unsigned long)addr >> PAGE_SHIFT; 66632e62c63SBjorn Helgaas vma->vm_page_prot = prot; 6671da177e4SLinus Torvalds 6681da177e4SLinus Torvalds if (remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff, 66932e62c63SBjorn Helgaas size, vma->vm_page_prot)) 6701da177e4SLinus Torvalds return -EAGAIN; 6711da177e4SLinus Torvalds 6721da177e4SLinus Torvalds return 0; 6731da177e4SLinus Torvalds } 6741da177e4SLinus Torvalds 6751da177e4SLinus Torvalds /** 6761da177e4SLinus Torvalds * ia64_pci_legacy_read - read from legacy I/O space 6771da177e4SLinus Torvalds * @bus: bus to read 6781da177e4SLinus Torvalds * @port: legacy port value 6791da177e4SLinus Torvalds * @val: caller allocated storage for returned value 6801da177e4SLinus Torvalds * @size: number of bytes to read 6811da177e4SLinus Torvalds * 6821da177e4SLinus Torvalds * Simply reads @size bytes from @port and puts the result in @val. 6831da177e4SLinus Torvalds * 6841da177e4SLinus Torvalds * Again, this (and the write routine) are generic versions that can be 6851da177e4SLinus Torvalds * overridden by the platform. This is necessary on platforms that don't 6861da177e4SLinus Torvalds * support legacy I/O routing or that hard fail on legacy I/O timeouts. 6871da177e4SLinus Torvalds */ 6881da177e4SLinus Torvalds int ia64_pci_legacy_read(struct pci_bus *bus, u16 port, u32 *val, u8 size) 6891da177e4SLinus Torvalds { 6901da177e4SLinus Torvalds int ret = size; 6911da177e4SLinus Torvalds 6921da177e4SLinus Torvalds switch (size) { 6931da177e4SLinus Torvalds case 1: 6941da177e4SLinus Torvalds *val = inb(port); 6951da177e4SLinus Torvalds break; 6961da177e4SLinus Torvalds case 2: 6971da177e4SLinus Torvalds *val = inw(port); 6981da177e4SLinus Torvalds break; 6991da177e4SLinus Torvalds case 4: 7001da177e4SLinus Torvalds *val = inl(port); 7011da177e4SLinus Torvalds break; 7021da177e4SLinus Torvalds default: 7031da177e4SLinus Torvalds ret = -EINVAL; 7041da177e4SLinus Torvalds break; 7051da177e4SLinus Torvalds } 7061da177e4SLinus Torvalds 7071da177e4SLinus Torvalds return ret; 7081da177e4SLinus Torvalds } 7091da177e4SLinus Torvalds 7101da177e4SLinus Torvalds /** 7111da177e4SLinus Torvalds * ia64_pci_legacy_write - perform a legacy I/O write 7121da177e4SLinus Torvalds * @bus: bus pointer 7131da177e4SLinus Torvalds * @port: port to write 7141da177e4SLinus Torvalds * @val: value to write 7151da177e4SLinus Torvalds * @size: number of bytes to write from @val 7161da177e4SLinus Torvalds * 7171da177e4SLinus Torvalds * Simply writes @size bytes of @val to @port. 7181da177e4SLinus Torvalds */ 719a72391e4SSatoru Takeuchi int ia64_pci_legacy_write(struct pci_bus *bus, u16 port, u32 val, u8 size) 7201da177e4SLinus Torvalds { 721408045afSAlex Williamson int ret = size; 7221da177e4SLinus Torvalds 7231da177e4SLinus Torvalds switch (size) { 7241da177e4SLinus Torvalds case 1: 7251da177e4SLinus Torvalds outb(val, port); 7261da177e4SLinus Torvalds break; 7271da177e4SLinus Torvalds case 2: 7281da177e4SLinus Torvalds outw(val, port); 7291da177e4SLinus Torvalds break; 7301da177e4SLinus Torvalds case 4: 7311da177e4SLinus Torvalds outl(val, port); 7321da177e4SLinus Torvalds break; 7331da177e4SLinus Torvalds default: 7341da177e4SLinus Torvalds ret = -EINVAL; 7351da177e4SLinus Torvalds break; 7361da177e4SLinus Torvalds } 7371da177e4SLinus Torvalds 7381da177e4SLinus Torvalds return ret; 7391da177e4SLinus Torvalds } 7401da177e4SLinus Torvalds 7413efe2d84SMatthew Wilcox /* It's defined in drivers/pci/pci.c */ 7423efe2d84SMatthew Wilcox extern u8 pci_cache_line_size; 7433efe2d84SMatthew Wilcox 7441da177e4SLinus Torvalds /** 7453efe2d84SMatthew Wilcox * set_pci_cacheline_size - determine cacheline size for PCI devices 7461da177e4SLinus Torvalds * 7471da177e4SLinus Torvalds * We want to use the line-size of the outer-most cache. We assume 7481da177e4SLinus Torvalds * that this line-size is the same for all CPUs. 7491da177e4SLinus Torvalds * 7501da177e4SLinus Torvalds * Code mostly taken from arch/ia64/kernel/palinfo.c:cache_info(). 7511da177e4SLinus Torvalds */ 7523efe2d84SMatthew Wilcox static void __init set_pci_cacheline_size(void) 7531da177e4SLinus Torvalds { 7541da177e4SLinus Torvalds u64 levels, unique_caches; 7551da177e4SLinus Torvalds s64 status; 7561da177e4SLinus Torvalds pal_cache_config_info_t cci; 7571da177e4SLinus Torvalds 7581da177e4SLinus Torvalds status = ia64_pal_cache_summary(&levels, &unique_caches); 7591da177e4SLinus Torvalds if (status != 0) { 7603efe2d84SMatthew Wilcox printk(KERN_ERR "%s: ia64_pal_cache_summary() failed " 7613efe2d84SMatthew Wilcox "(status=%ld)\n", __FUNCTION__, status); 7623efe2d84SMatthew Wilcox return; 7631da177e4SLinus Torvalds } 7641da177e4SLinus Torvalds 7653efe2d84SMatthew Wilcox status = ia64_pal_cache_config_info(levels - 1, 7663efe2d84SMatthew Wilcox /* cache_type (data_or_unified)= */ 2, &cci); 7671da177e4SLinus Torvalds if (status != 0) { 7683efe2d84SMatthew Wilcox printk(KERN_ERR "%s: ia64_pal_cache_config_info() failed " 7693efe2d84SMatthew Wilcox "(status=%ld)\n", __FUNCTION__, status); 7703efe2d84SMatthew Wilcox return; 7711da177e4SLinus Torvalds } 7723efe2d84SMatthew Wilcox pci_cache_line_size = (1 << cci.pcci_line_size) / 4; 7731da177e4SLinus Torvalds } 7741da177e4SLinus Torvalds 7753efe2d84SMatthew Wilcox static int __init pcibios_init(void) 7761da177e4SLinus Torvalds { 7773efe2d84SMatthew Wilcox set_pci_cacheline_size(); 7783efe2d84SMatthew Wilcox return 0; 7793efe2d84SMatthew Wilcox } 7801da177e4SLinus Torvalds 7813efe2d84SMatthew Wilcox subsys_initcall(pcibios_init); 782