Linux "setpci" Command Line Options and Examples
configure PCI devices

setpci is a utility for querying and configuring PCI devices. All numbers are entered in hexadecimal notation. Root privileges are necessary for almost all operations, excluding reads of the standard header of the config‐ uration space on some operating systems.


Usage:

setpci [options] devices operations...






Command Line Options:

-v
Tells setpci to be verbose and display detailed information about configuration space accesses.
setpci -v ...
--version
Show setpci version. This option should be used stand-alone.
setpci --version ...
--help
Show detailed help on available options. This option should be used stand-alone.
setpci --help ...
--dumpregs
Show a list of all known PCI registers and capabilities. This option should be used stand-alone.PCI access optionsThe PCI utilities use the PCI library to talk to PCI devices (see pcilib(7) for details). You can use the fol‐lowing options to influence its behavior:
setpci --dumpregs ...
-A
The library supports a variety of methods to access the PCI hardware. By default, it uses the firstaccess method available, but you can use this option to override this decision. See -A help for a listof available methods and their descriptions.
setpci -A ...
-O
The behavior of the library is controlled by several named parameters. This option allows to set thevalue of any of the parameters. Use -O help for a list of known parameters and their default values.
setpci -O ...
-G
DEVICE SELECTIONBefore each sequence of operations you need to select which devices you wish that operation to affect.
setpci -G ...
-s
Consider only devices in the specified domain (in case your machine has several host bridges, they caneither share a common bus number space or each of them can address a PCI domain of its own; domains arenumbered from 0 to ffff), bus (0 to ff), slot (0 to 1f) and function (0 to 7). Each component of thedevice address can be omitted or set to "*", both meaning "any value". All numbers are hexadecimal.E.g., "0:" means all devices on bus 0, "0" means all functions of device 0 on any bus, "0.3" selectsthird function of device 0 on all buses and ".4" matches only the fourth function of each device.
setpci -s ...
-d
Select devices with specified vendor and device ID. Both ID's are given in hexadecimal and may be omit‐ted or given as "*", both meaning "any value".When -s and -d are combined, only devices that match both criteria are selected. When multiple options of thesame kind are specified, the rightmost one overrides the others.OPERATIONSThere are two kinds of operations: reads and writes. To read a register, just specify its name. Writes havethe form name=value,value... where each value is either a hexadecimal number or an expression of typedata:mask where both data and mask are hexadecimal numbers. In the latter case, only the bits corresponding tobinary ones in the mask are changed (technically, this is a read-modify-write operation).There are several ways how to identity a register:· Tell its address in hexadecimal.· Spell its name. Setpci knows the names of all registers in the standard configuration headers. Use`setpci --dumpregs' to get the complete list. See PCI bus specifications for the precise meaning ofthese registers or consult header.h or /usr/include/pci/pci.h for a brief sketch.· If the register is a part of a PCI capability, you can specify the name of the capability to get theaddress of its first register. See the names starting with `CAP_' or `ECAP_' in the --dumpregs output.· If the name of the capability is not known to setpci, you can refer to it by its number in the formCAPid or ECAPid, where id is the numeric identifier of the capability in hexadecimal.· Each of the previous formats can be followed by +offset to add an offset (a hex number) to the address.This feature can be useful for addressing of registers living within a capability, or to modify partsof standard registers.· Finally, you should append a width specifier .B, .W, or .L to choose how many bytes (1, 2, or 4) shouldbe transferred. The width can be omitted if you are referring to a register by its name and the widthof the register is well known.All names of registers and width specifiers are case-insensitive.EXAMPLESCOMMANDasks for the word-sized command register.4.w is a numeric address of the same register.COMMAND.lasks for a 32-bit word starting at the location of the command register, i.e., the command and statusregisters together.VENDOR_ID+1.bspecifies the upper byte of the vendor ID register (remember, PCI is little-endian).CAP_PM+2.wcorresponds to the second word of the power management capability.ECAP108.lasks for the first 32-bit word of the extended capability with ID 0x108.
setpci -d ...