pciaccess.h revision 49f872b5
14f5e7dd7Smrg/*
24f5e7dd7Smrg * (C) Copyright IBM Corporation 2006
34f5e7dd7Smrg * All Rights Reserved.
44f5e7dd7Smrg *
54f5e7dd7Smrg * Permission is hereby granted, free of charge, to any person obtaining a
64f5e7dd7Smrg * copy of this software and associated documentation files (the "Software"),
74f5e7dd7Smrg * to deal in the Software without restriction, including without limitation
84f5e7dd7Smrg * on the rights to use, copy, modify, merge, publish, distribute, sub
94f5e7dd7Smrg * license, and/or sell copies of the Software, and to permit persons to whom
104f5e7dd7Smrg * the Software is furnished to do so, subject to the following conditions:
114f5e7dd7Smrg *
124f5e7dd7Smrg * The above copyright notice and this permission notice (including the next
134f5e7dd7Smrg * paragraph) shall be included in all copies or substantial portions of the
144f5e7dd7Smrg * Software.
154f5e7dd7Smrg *
164f5e7dd7Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
174f5e7dd7Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
184f5e7dd7Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
194f5e7dd7Smrg * IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
204f5e7dd7Smrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
214f5e7dd7Smrg * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
224f5e7dd7Smrg * DEALINGS IN THE SOFTWARE.
234f5e7dd7Smrg */
2449f872b5Smrg/*
2549f872b5Smrg * Copyright (c) 2007 Paulo R. Zanoni, Tiago Vignatti
2649f872b5Smrg *
2749f872b5Smrg * Permission is hereby granted, free of charge, to any person
2849f872b5Smrg * obtaining a copy of this software and associated documentation
2949f872b5Smrg * files (the "Software"), to deal in the Software without
3049f872b5Smrg * restriction, including without limitation the rights to use,
3149f872b5Smrg * copy, modify, merge, publish, distribute, sublicense, and/or sell
3249f872b5Smrg * copies of the Software, and to permit persons to whom the
3349f872b5Smrg * Software is furnished to do so, subject to the following
3449f872b5Smrg * conditions:
3549f872b5Smrg *
3649f872b5Smrg * The above copyright notice and this permission notice shall be
3749f872b5Smrg * included in all copies or substantial portions of the Software.
3849f872b5Smrg *
3949f872b5Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
4049f872b5Smrg * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
4149f872b5Smrg * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
4249f872b5Smrg * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
4349f872b5Smrg * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
4449f872b5Smrg * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
4549f872b5Smrg * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
4649f872b5Smrg * OTHER DEALINGS IN THE SOFTWARE.
4749f872b5Smrg *
4849f872b5Smrg */
494f5e7dd7Smrg
504f5e7dd7Smrg/**
514f5e7dd7Smrg * \file pciaccess.h
524f5e7dd7Smrg *
534f5e7dd7Smrg * \author Ian Romanick <idr@us.ibm.com>
544f5e7dd7Smrg */
554f5e7dd7Smrg
564f5e7dd7Smrg#ifndef PCIACCESS_H
574f5e7dd7Smrg#define PCIACCESS_H
584f5e7dd7Smrg
594f5e7dd7Smrg#include <inttypes.h>
604f5e7dd7Smrg
614f5e7dd7Smrg#if __GNUC__ >= 3
624f5e7dd7Smrg#define __deprecated __attribute__((deprecated))
634f5e7dd7Smrg#else
644f5e7dd7Smrg#define __deprecated
654f5e7dd7Smrg#endif
664f5e7dd7Smrg
674f5e7dd7Smrgtypedef uint64_t pciaddr_t;
684f5e7dd7Smrg
694f5e7dd7Smrgstruct pci_device;
704f5e7dd7Smrgstruct pci_device_iterator;
714f5e7dd7Smrgstruct pci_id_match;
724f5e7dd7Smrgstruct pci_slot_match;
734f5e7dd7Smrg
744f5e7dd7Smrg#ifdef __cplusplus
754f5e7dd7Smrgextern "C" {
764f5e7dd7Smrg#endif
774f5e7dd7Smrg
7849f872b5Smrgint pci_device_has_kernel_driver(struct pci_device *dev);
7949f872b5Smrg
8049f872b5Smrgint pci_device_is_boot_vga(struct pci_device *dev);
8149f872b5Smrg
824f5e7dd7Smrgint pci_device_read_rom(struct pci_device *dev, void *buffer);
834f5e7dd7Smrg
844f5e7dd7Smrgint  __deprecated pci_device_map_region(struct pci_device *dev,
854f5e7dd7Smrg    unsigned region, int write_enable);
864f5e7dd7Smrg
874f5e7dd7Smrgint __deprecated pci_device_unmap_region(struct pci_device *dev,
884f5e7dd7Smrg    unsigned region);
894f5e7dd7Smrg
904f5e7dd7Smrgint pci_device_map_range(struct pci_device *dev, pciaddr_t base,
914f5e7dd7Smrg    pciaddr_t size, unsigned map_flags, void **addr);
924f5e7dd7Smrg
934f5e7dd7Smrgint pci_device_unmap_range(struct pci_device *dev, void *memory,
944f5e7dd7Smrg    pciaddr_t size);
954f5e7dd7Smrg
964f5e7dd7Smrgint __deprecated pci_device_map_memory_range(struct pci_device *dev,
974f5e7dd7Smrg    pciaddr_t base, pciaddr_t size, int write_enable, void **addr);
984f5e7dd7Smrg
994f5e7dd7Smrgint __deprecated pci_device_unmap_memory_range(struct pci_device *dev,
1004f5e7dd7Smrg    void *memory, pciaddr_t size);
1014f5e7dd7Smrg
1024f5e7dd7Smrgint pci_device_probe(struct pci_device *dev);
1034f5e7dd7Smrg
1044f5e7dd7Smrgconst struct pci_agp_info *pci_device_get_agp_info(struct pci_device *dev);
1054f5e7dd7Smrg
1064f5e7dd7Smrgconst struct pci_bridge_info *pci_device_get_bridge_info(
1074f5e7dd7Smrg    struct pci_device *dev);
1084f5e7dd7Smrg
1094f5e7dd7Smrgconst struct pci_pcmcia_bridge_info *pci_device_get_pcmcia_bridge_info(
1104f5e7dd7Smrg    struct pci_device *dev);
1114f5e7dd7Smrg
1124f5e7dd7Smrgint pci_device_get_bridge_buses(struct pci_device *dev, int *primary_bus,
1134f5e7dd7Smrg    int *secondary_bus, int *subordinate_bus);
1144f5e7dd7Smrg
1154f5e7dd7Smrgint pci_system_init(void);
1164f5e7dd7Smrg
1174f5e7dd7Smrgvoid pci_system_init_dev_mem(int fd);
1184f5e7dd7Smrg
1194f5e7dd7Smrgvoid pci_system_cleanup(void);
1204f5e7dd7Smrg
1214f5e7dd7Smrgstruct pci_device_iterator *pci_slot_match_iterator_create(
1224f5e7dd7Smrg    const struct pci_slot_match *match);
1234f5e7dd7Smrg
1244f5e7dd7Smrgstruct pci_device_iterator *pci_id_match_iterator_create(
1254f5e7dd7Smrg    const struct pci_id_match *match);
1264f5e7dd7Smrg
1274f5e7dd7Smrgvoid pci_iterator_destroy(struct pci_device_iterator *iter);
1284f5e7dd7Smrg
1294f5e7dd7Smrgstruct pci_device *pci_device_next(struct pci_device_iterator *iter);
1304f5e7dd7Smrg
1314f5e7dd7Smrgstruct pci_device *pci_device_find_by_slot(uint32_t domain, uint32_t bus,
1324f5e7dd7Smrg    uint32_t dev, uint32_t func);
1334f5e7dd7Smrg
1344f5e7dd7Smrgvoid pci_get_strings(const struct pci_id_match *m,
1354f5e7dd7Smrg    const char **device_name, const char **vendor_name,
1364f5e7dd7Smrg    const char **subdevice_name, const char **subvendor_name);
1374f5e7dd7Smrgconst char *pci_device_get_device_name(const struct pci_device *dev);
1384f5e7dd7Smrgconst char *pci_device_get_subdevice_name(const struct pci_device *dev);
1394f5e7dd7Smrgconst char *pci_device_get_vendor_name(const struct pci_device *dev);
1404f5e7dd7Smrgconst char *pci_device_get_subvendor_name(const struct pci_device *dev);
1414f5e7dd7Smrg
1424f5e7dd7Smrgvoid pci_device_enable(struct pci_device *dev);
1434f5e7dd7Smrg
1444f5e7dd7Smrgint pci_device_cfg_read    (struct pci_device *dev, void *data,
1454f5e7dd7Smrg    pciaddr_t offset, pciaddr_t size, pciaddr_t *bytes_read);
1464f5e7dd7Smrgint pci_device_cfg_read_u8 (struct pci_device *dev, uint8_t  *data,
1474f5e7dd7Smrg    pciaddr_t offset);
1484f5e7dd7Smrgint pci_device_cfg_read_u16(struct pci_device *dev, uint16_t *data,
1494f5e7dd7Smrg    pciaddr_t offset);
1504f5e7dd7Smrgint pci_device_cfg_read_u32(struct pci_device *dev, uint32_t *data,
1514f5e7dd7Smrg    pciaddr_t offset);
1524f5e7dd7Smrg
1534f5e7dd7Smrgint pci_device_cfg_write    (struct pci_device *dev, const void *data,
1544f5e7dd7Smrg    pciaddr_t offset, pciaddr_t size, pciaddr_t *bytes_written);
1554f5e7dd7Smrgint pci_device_cfg_write_u8 (struct pci_device *dev, uint8_t  data,
1564f5e7dd7Smrg    pciaddr_t offset);
1574f5e7dd7Smrgint pci_device_cfg_write_u16(struct pci_device *dev, uint16_t data,
1584f5e7dd7Smrg    pciaddr_t offset);
1594f5e7dd7Smrgint pci_device_cfg_write_u32(struct pci_device *dev, uint32_t data,
1604f5e7dd7Smrg    pciaddr_t offset);
1614f5e7dd7Smrgint pci_device_cfg_write_bits(struct pci_device *dev, uint32_t mask,
1624f5e7dd7Smrg    uint32_t data, pciaddr_t offset);
1634f5e7dd7Smrg
1644f5e7dd7Smrg#ifdef __cplusplus
1654f5e7dd7Smrg}
1664f5e7dd7Smrg#endif
1674f5e7dd7Smrg
1684f5e7dd7Smrg/**
1694f5e7dd7Smrg * \name Mapping flags passed to \c pci_device_map_range
1704f5e7dd7Smrg */
1714f5e7dd7Smrg/*@{*/
1724f5e7dd7Smrg#define PCI_DEV_MAP_FLAG_WRITABLE       (1U<<0)
1734f5e7dd7Smrg#define PCI_DEV_MAP_FLAG_WRITE_COMBINE  (1U<<1)
1744f5e7dd7Smrg#define PCI_DEV_MAP_FLAG_CACHABLE       (1U<<2)
1754f5e7dd7Smrg/*@}*/
1764f5e7dd7Smrg
1774f5e7dd7Smrg
1784f5e7dd7Smrg#define PCI_MATCH_ANY  (~0)
1794f5e7dd7Smrg
1804f5e7dd7Smrg/**
1814f5e7dd7Smrg * Compare two PCI ID values (either vendor or device).  This is used
1824f5e7dd7Smrg * internally to compare the fields of \c pci_id_match to the fields of
1834f5e7dd7Smrg * \c pci_device.
1844f5e7dd7Smrg */
1854f5e7dd7Smrg#define PCI_ID_COMPARE(a, b) \
1864f5e7dd7Smrg    (((a) == PCI_MATCH_ANY) || ((a) == (b)))
1874f5e7dd7Smrg
1884f5e7dd7Smrg/**
1894f5e7dd7Smrg */
1904f5e7dd7Smrgstruct pci_id_match {
1914f5e7dd7Smrg    /**
1924f5e7dd7Smrg     * \name Device / vendor matching controls
1934f5e7dd7Smrg     *
1944f5e7dd7Smrg     * Control the search based on the device, vendor, subdevice, or subvendor
1954f5e7dd7Smrg     * IDs.  Setting any of these fields to \c PCI_MATCH_ANY will cause the
1964f5e7dd7Smrg     * field to not be used in the comparison.
1974f5e7dd7Smrg     */
1984f5e7dd7Smrg    /*@{*/
1994f5e7dd7Smrg    uint32_t    vendor_id;
2004f5e7dd7Smrg    uint32_t    device_id;
2014f5e7dd7Smrg    uint32_t    subvendor_id;
2024f5e7dd7Smrg    uint32_t    subdevice_id;
2034f5e7dd7Smrg    /*@}*/
2044f5e7dd7Smrg
2054f5e7dd7Smrg
2064f5e7dd7Smrg    /**
2074f5e7dd7Smrg     * \name Device class matching controls
2084f5e7dd7Smrg     *
2094f5e7dd7Smrg     */
2104f5e7dd7Smrg    /*@{*/
2114f5e7dd7Smrg    uint32_t    device_class;
2124f5e7dd7Smrg    uint32_t    device_class_mask;
2134f5e7dd7Smrg    /*@}*/
2144f5e7dd7Smrg
2154f5e7dd7Smrg    intptr_t    match_data;
2164f5e7dd7Smrg};
2174f5e7dd7Smrg
2184f5e7dd7Smrg
2194f5e7dd7Smrg/**
2204f5e7dd7Smrg */
2214f5e7dd7Smrgstruct pci_slot_match {
2224f5e7dd7Smrg    /**
2234f5e7dd7Smrg     * \name Device slot matching controls
2244f5e7dd7Smrg     *
2254f5e7dd7Smrg     * Control the search based on the domain, bus, slot, and function of
2264f5e7dd7Smrg     * the device.  Setting any of these fields to \c PCI_MATCH_ANY will cause
2274f5e7dd7Smrg     * the field to not be used in the comparison.
2284f5e7dd7Smrg     */
2294f5e7dd7Smrg    /*@{*/
2304f5e7dd7Smrg    uint32_t    domain;
2314f5e7dd7Smrg    uint32_t    bus;
2324f5e7dd7Smrg    uint32_t    dev;
2334f5e7dd7Smrg    uint32_t    func;
2344f5e7dd7Smrg    /*@}*/
2354f5e7dd7Smrg
2364f5e7dd7Smrg    intptr_t    match_data;
2374f5e7dd7Smrg};
2384f5e7dd7Smrg
2394f5e7dd7Smrg/**
2404f5e7dd7Smrg * BAR descriptor for a PCI device.
2414f5e7dd7Smrg */
2424f5e7dd7Smrgstruct pci_mem_region {
2434f5e7dd7Smrg    /**
2444f5e7dd7Smrg     * When the region is mapped, this is the pointer to the memory.
2454f5e7dd7Smrg     *
2464f5e7dd7Smrg     * This field is \b only set when the deprecated \c pci_device_map_region
2474f5e7dd7Smrg     * interface is used.  Use \c pci_device_map_range instead.
2484f5e7dd7Smrg     *
2494f5e7dd7Smrg     * \deprecated
2504f5e7dd7Smrg     */
2514f5e7dd7Smrg    void *memory;
2524f5e7dd7Smrg
2534f5e7dd7Smrg
2544f5e7dd7Smrg    /**
2554f5e7dd7Smrg     * Base physical address of the region within its bus / domain.
2564f5e7dd7Smrg     *
2574f5e7dd7Smrg     * \warning
2584f5e7dd7Smrg     * This address is really only useful to other devices in the same
2594f5e7dd7Smrg     * domain.  It's probably \b not the address applications will ever
2604f5e7dd7Smrg     * use.
2614f5e7dd7Smrg     *
2624f5e7dd7Smrg     * \warning
2634f5e7dd7Smrg     * Most (all?) platform back-ends leave this field unset.
2644f5e7dd7Smrg     */
2654f5e7dd7Smrg    pciaddr_t bus_addr;
2664f5e7dd7Smrg
2674f5e7dd7Smrg
2684f5e7dd7Smrg    /**
2694f5e7dd7Smrg     * Base physical address of the region from the CPU's point of view.
2704f5e7dd7Smrg     *
2714f5e7dd7Smrg     * This address is typically passed to \c pci_device_map_range to create
2724f5e7dd7Smrg     * a mapping of the region to the CPU's virtual address space.
2734f5e7dd7Smrg     */
2744f5e7dd7Smrg    pciaddr_t base_addr;
2754f5e7dd7Smrg
2764f5e7dd7Smrg
2774f5e7dd7Smrg    /**
2784f5e7dd7Smrg     * Size, in bytes, of the region.
2794f5e7dd7Smrg     */
2804f5e7dd7Smrg    pciaddr_t size;
2814f5e7dd7Smrg
2824f5e7dd7Smrg
2834f5e7dd7Smrg    /**
2844f5e7dd7Smrg     * Is the region I/O ports or memory?
2854f5e7dd7Smrg     */
2864f5e7dd7Smrg    unsigned is_IO:1;
2874f5e7dd7Smrg
2884f5e7dd7Smrg    /**
2894f5e7dd7Smrg     * Is the memory region prefetchable?
2904f5e7dd7Smrg     *
2914f5e7dd7Smrg     * \note
2924f5e7dd7Smrg     * This can only be set if \c is_IO is not set.
2934f5e7dd7Smrg     */
2944f5e7dd7Smrg    unsigned is_prefetchable:1;
2954f5e7dd7Smrg
2964f5e7dd7Smrg
2974f5e7dd7Smrg    /**
2984f5e7dd7Smrg     * Is the memory at a 64-bit address?
2994f5e7dd7Smrg     *
3004f5e7dd7Smrg     * \note
3014f5e7dd7Smrg     * This can only be set if \c is_IO is not set.
3024f5e7dd7Smrg     */
3034f5e7dd7Smrg    unsigned is_64:1;
3044f5e7dd7Smrg};
3054f5e7dd7Smrg
3064f5e7dd7Smrg
3074f5e7dd7Smrg/**
3084f5e7dd7Smrg * PCI device.
3094f5e7dd7Smrg *
3104f5e7dd7Smrg * Contains all of the information about a particular PCI device.
3114f5e7dd7Smrg */
3124f5e7dd7Smrgstruct pci_device {
3134f5e7dd7Smrg    /**
3144f5e7dd7Smrg     * \name Device bus identification.
3154f5e7dd7Smrg     *
3164f5e7dd7Smrg     * Complete bus identification, including domain, of the device.  On
3174f5e7dd7Smrg     * platforms that do not support PCI domains (e.g., 32-bit x86 hardware),
3184f5e7dd7Smrg     * the domain will always be zero.
3194f5e7dd7Smrg     */
3204f5e7dd7Smrg    /*@{*/
3214f5e7dd7Smrg    uint16_t    domain;
3224f5e7dd7Smrg    uint8_t     bus;
3234f5e7dd7Smrg    uint8_t     dev;
3244f5e7dd7Smrg    uint8_t     func;
3254f5e7dd7Smrg    /*@}*/
3264f5e7dd7Smrg
3274f5e7dd7Smrg
3284f5e7dd7Smrg    /**
3294f5e7dd7Smrg     * \name Vendor / device ID
3304f5e7dd7Smrg     *
3314f5e7dd7Smrg     * The vendor ID, device ID, and sub-IDs for the device.
3324f5e7dd7Smrg     */
3334f5e7dd7Smrg    /*@{*/
3344f5e7dd7Smrg    uint16_t    vendor_id;
3354f5e7dd7Smrg    uint16_t    device_id;
3364f5e7dd7Smrg    uint16_t    subvendor_id;
3374f5e7dd7Smrg    uint16_t    subdevice_id;
3384f5e7dd7Smrg    /*@}*/
3394f5e7dd7Smrg
3404f5e7dd7Smrg    /**
3414f5e7dd7Smrg     * Device's class, subclass, and programming interface packed into a
3424f5e7dd7Smrg     * single 32-bit value.  The class is at bits [23:16], subclass is at
3434f5e7dd7Smrg     * bits [15:8], and programming interface is at [7:0].
3444f5e7dd7Smrg     */
3454f5e7dd7Smrg    uint32_t    device_class;
3464f5e7dd7Smrg
3474f5e7dd7Smrg
3484f5e7dd7Smrg    /**
3494f5e7dd7Smrg     * Device revision number, as read from the configuration header.
3504f5e7dd7Smrg     */
3514f5e7dd7Smrg    uint8_t     revision;
3524f5e7dd7Smrg
3534f5e7dd7Smrg
3544f5e7dd7Smrg    /**
3554f5e7dd7Smrg     * BAR descriptors for the device.
3564f5e7dd7Smrg     */
3574f5e7dd7Smrg    struct pci_mem_region regions[6];
3584f5e7dd7Smrg
3594f5e7dd7Smrg
3604f5e7dd7Smrg    /**
3614f5e7dd7Smrg     * Size, in bytes, of the device's expansion ROM.
3624f5e7dd7Smrg     */
3634f5e7dd7Smrg    pciaddr_t   rom_size;
3644f5e7dd7Smrg
3654f5e7dd7Smrg
3664f5e7dd7Smrg    /**
3674f5e7dd7Smrg     * IRQ associated with the device.  If there is no IRQ, this value will
3684f5e7dd7Smrg     * be -1.
3694f5e7dd7Smrg     */
3704f5e7dd7Smrg    int irq;
3714f5e7dd7Smrg
3724f5e7dd7Smrg
3734f5e7dd7Smrg    /**
3744f5e7dd7Smrg     * Storage for user data.  Users of the library can store arbitrary
3754f5e7dd7Smrg     * data in this pointer.  The library will not use it for any purpose.
3764f5e7dd7Smrg     * It is the user's responsability to free this memory before destroying
3774f5e7dd7Smrg     * the \c pci_device structure.
3784f5e7dd7Smrg     */
3794f5e7dd7Smrg    intptr_t user_data;
38049f872b5Smrg
38149f872b5Smrg    /**
38249f872b5Smrg      * Used by the VGA arbiter. Type of resource decoded by the device and
38349f872b5Smrg      * the file descriptor (/dev/vga_arbiter). */
38449f872b5Smrg    int vgaarb_rsrc;
3854f5e7dd7Smrg};
3864f5e7dd7Smrg
3874f5e7dd7Smrg
3884f5e7dd7Smrg/**
3894f5e7dd7Smrg * Description of the AGP capability of the device.
3904f5e7dd7Smrg *
3914f5e7dd7Smrg * \sa pci_device_get_agp_info
3924f5e7dd7Smrg */
3934f5e7dd7Smrgstruct pci_agp_info {
3944f5e7dd7Smrg    /**
3954f5e7dd7Smrg     * Offset of the AGP registers in the devices configuration register
3964f5e7dd7Smrg     * space.  This is generally used so that the offset of the AGP command
3974f5e7dd7Smrg     * register can be determined.
3984f5e7dd7Smrg     */
3994f5e7dd7Smrg    unsigned    config_offset;
4004f5e7dd7Smrg
4014f5e7dd7Smrg
4024f5e7dd7Smrg    /**
4034f5e7dd7Smrg     * \name AGP major / minor version.
4044f5e7dd7Smrg     */
4054f5e7dd7Smrg    /*@{*/
4064f5e7dd7Smrg    uint8_t	major_version;
4074f5e7dd7Smrg    uint8_t     minor_version;
4084f5e7dd7Smrg    /*@}*/
4094f5e7dd7Smrg
4104f5e7dd7Smrg    /**
4114f5e7dd7Smrg     * Logical OR of the supported AGP rates.  For example, a value of 0x07
4124f5e7dd7Smrg     * means that the device can support 1x, 2x, and 4x.  A value of 0x0c
4134f5e7dd7Smrg     * means that the device can support 8x and 4x.
4144f5e7dd7Smrg     */
4154f5e7dd7Smrg    uint8_t    rates;
4164f5e7dd7Smrg
4174f5e7dd7Smrg    unsigned int    fast_writes:1;  /**< Are fast-writes supported? */
4184f5e7dd7Smrg    unsigned int    addr64:1;
4194f5e7dd7Smrg    unsigned int    htrans:1;
4204f5e7dd7Smrg    unsigned int    gart64:1;
4214f5e7dd7Smrg    unsigned int    coherent:1;
4224f5e7dd7Smrg    unsigned int    sideband:1;     /**< Is side-band addressing supported? */
4234f5e7dd7Smrg    unsigned int    isochronus:1;
4244f5e7dd7Smrg
4254f5e7dd7Smrg    uint8_t    async_req_size;
4264f5e7dd7Smrg    uint8_t    calibration_cycle_timing;
4274f5e7dd7Smrg    uint8_t    max_requests;
4284f5e7dd7Smrg};
4294f5e7dd7Smrg
4304f5e7dd7Smrg/**
4314f5e7dd7Smrg * Description of a PCI-to-PCI bridge device.
4324f5e7dd7Smrg *
4334f5e7dd7Smrg * \sa pci_device_get_bridge_info
4344f5e7dd7Smrg */
4354f5e7dd7Smrgstruct pci_bridge_info {
4364f5e7dd7Smrg    uint8_t    primary_bus;
4374f5e7dd7Smrg    uint8_t    secondary_bus;
4384f5e7dd7Smrg    uint8_t    subordinate_bus;
4394f5e7dd7Smrg    uint8_t    secondary_latency_timer;
4404f5e7dd7Smrg
4414f5e7dd7Smrg    uint8_t     io_type;
4424f5e7dd7Smrg    uint8_t     mem_type;
4434f5e7dd7Smrg    uint8_t     prefetch_mem_type;
4444f5e7dd7Smrg
4454f5e7dd7Smrg    uint16_t    secondary_status;
4464f5e7dd7Smrg    uint16_t    bridge_control;
4474f5e7dd7Smrg
4484f5e7dd7Smrg    uint32_t    io_base;
4494f5e7dd7Smrg    uint32_t    io_limit;
4504f5e7dd7Smrg
4514f5e7dd7Smrg    uint32_t    mem_base;
4524f5e7dd7Smrg    uint32_t    mem_limit;
4534f5e7dd7Smrg
4544f5e7dd7Smrg    uint64_t    prefetch_mem_base;
4554f5e7dd7Smrg    uint64_t    prefetch_mem_limit;
4564f5e7dd7Smrg};
4574f5e7dd7Smrg
4584f5e7dd7Smrg/**
4594f5e7dd7Smrg * Description of a PCI-to-PCMCIA bridge device.
4604f5e7dd7Smrg *
4614f5e7dd7Smrg * \sa pci_device_get_pcmcia_bridge_info
4624f5e7dd7Smrg */
4634f5e7dd7Smrgstruct pci_pcmcia_bridge_info {
4644f5e7dd7Smrg    uint8_t    primary_bus;
4654f5e7dd7Smrg    uint8_t    card_bus;
4664f5e7dd7Smrg    uint8_t    subordinate_bus;
4674f5e7dd7Smrg    uint8_t    cardbus_latency_timer;
4684f5e7dd7Smrg
4694f5e7dd7Smrg    uint16_t    secondary_status;
4704f5e7dd7Smrg    uint16_t    bridge_control;
4714f5e7dd7Smrg
4724f5e7dd7Smrg    struct {
4734f5e7dd7Smrg	uint32_t    base;
4744f5e7dd7Smrg	uint32_t    limit;
4754f5e7dd7Smrg    } io[2];
4764f5e7dd7Smrg
4774f5e7dd7Smrg    struct {
4784f5e7dd7Smrg	uint32_t    base;
4794f5e7dd7Smrg	uint32_t    limit;
4804f5e7dd7Smrg    } mem[2];
4814f5e7dd7Smrg
4824f5e7dd7Smrg};
4834f5e7dd7Smrg
48449f872b5Smrg
48549f872b5Smrg/**
48649f872b5Smrg * VGA Arbiter definitions, functions and related.
48749f872b5Smrg */
48849f872b5Smrg
48949f872b5Smrg/* Legacy VGA regions */
49049f872b5Smrg#define VGA_ARB_RSRC_NONE       0x00
49149f872b5Smrg#define VGA_ARB_RSRC_LEGACY_IO  0x01
49249f872b5Smrg#define VGA_ARB_RSRC_LEGACY_MEM 0x02
49349f872b5Smrg/* Non-legacy access */
49449f872b5Smrg#define VGA_ARB_RSRC_NORMAL_IO  0x04
49549f872b5Smrg#define VGA_ARB_RSRC_NORMAL_MEM 0x08
49649f872b5Smrg
49749f872b5Smrgint  pci_device_vgaarb_init         (void);
49849f872b5Smrgvoid pci_device_vgaarb_fini         (void);
49949f872b5Smrgint  pci_device_vgaarb_set_target   (struct pci_device *dev);
50049f872b5Smrg/* use the targetted device */
50149f872b5Smrgint  pci_device_vgaarb_decodes      (int new_vga_rsrc);
50249f872b5Smrgint  pci_device_vgaarb_lock         (void);
50349f872b5Smrgint  pci_device_vgaarb_trylock      (void);
50449f872b5Smrgint  pci_device_vgaarb_unlock       (void);
50549f872b5Smrg/* return the current device count + resource decodes for the device */
50649f872b5Smrgint pci_device_vgaarb_get_info	    (struct pci_device *dev, int *vga_count, int *rsrc_decodes);
50749f872b5Smrg
5084f5e7dd7Smrg#endif /* PCIACCESS_H */
509