Lines Matching +full:device +full:- +full:addr
2 * (C) Copyright 2001 Sysgo Real-Time Solutions, GmbH <www.elinos.com>
8 * SPDX-License-Identifier: GPL-2.0+
18 * Under PCI, each device has 256 bytes of configuration address space,
33 #define PCI_COMMAND_FAST_BACK 0x200 /* Enable back-to-back writes */
39 #define PCI_STATUS_FAST_BACK 0x80 /* Accept fast-back to back */
55 #define PCI_CLASS_DEVICE 0x0a /* Device class */
56 #define PCI_CLASS_CODE 0x0b /* Device class code */
75 /* Base Class 0x12 - 0xFE is reserved */
78 #define PCI_CLASS_SUB_CODE 0x0a /* Device sub-class code */
228 /* 0x35-0x3b are reserved */
236 /* Header type 1 (PCI-to-PCI bridges) */
263 /* 0x35-0x3b is reserved */
265 /* 0x3c-0x3d are same as for htype 0 */
311 /* 0x3c-0x3d are same as for htype 0 */
319 #define PCI_CB_BRIDGE_CTL_16BIT_INT 0x80 /* Enable interrupt for 16-bit cards */
325 #define PCI_CB_LEGACY_MODE_BASE 0x44 /* 16-bit PC Card legacy mode base address (ExCa) */
326 /* 0x48-0x7f reserved */
347 #define PCI_PM_CAP_DSI 0x0020 /* Device specific initialization */
368 #define PCI_AGP_STATUS_RQ_MASK 0xff000000 /* Maximum number of requests - 1 */
370 #define PCI_AGP_STATUS_64BIT 0x0020 /* 64-bit addressing supported */
379 #define PCI_AGP_COMMAND_64BIT 0x0020 /* Allow processing of 64-bit addresses */
386 /* PCI-X registers */
405 #define PCI_MSI_FLAGS_64BIT 0x80 /* 64-bit addresses allowed */
412 #define PCI_MSI_DATA_32 8 /* 16 bits of data for 32-bit devices */
413 #define PCI_MSI_DATA_64 12 /* 16 bits of data for 64-bit devices */
421 /* Extended Capabilities (PCI-X 2.0 and Express) */
428 #define PCI_EXT_CAP_ID_DSN 0x03 /* Device Serial Number */
433 #define PCI_EXT_CAP_ID_MFVC 0x08 /* Multi-Function VC Capability */
436 #define PCI_EXT_CAP_ID_VNDR 0x0B /* Vendor-Specific */
437 #define PCI_EXT_CAP_ID_CAC 0x0C /* Config Access - obsolete */
483 #define PCI_REGION_RO 0x00000200 /* Read-only memory */
490 reg->bus_start = bus_start; in pci_set_region()
491 reg->phys_start = phys_start; in pci_set_region()
492 reg->size = size; in pci_set_region()
493 reg->flags = flags; in pci_set_region()
509 unsigned int vendor, device; /* Vendor and device ID or PCI_ANY_ID */ member
511 unsigned int class, class_mask; /* (class,subclass,prog-if) triplet */
518 unsigned int vendor, device; /* Vendor and device ID or PCI_ANY_ID */ member
521 unsigned int dev; /* Device number, or PCI_ANY_ID */
563 * top-level controller.
576 /* Low-level architecture-dependent routines */
611 hose->read_byte = read_byte; in pci_set_ops()
612 hose->read_word = read_word; in pci_set_ops()
613 hose->read_dword = read_dword; in pci_set_ops()
614 hose->write_byte = write_byte; in pci_set_ops()
615 hose->write_word = write_word; in pci_set_ops()
616 hose->write_dword = write_dword; in pci_set_ops()
626 pci_addr_t addr, unsigned long flags);
628 phys_addr_t addr, unsigned long flags);
630 #define pci_phys_to_bus(dev, addr, flags) \ argument
631 pci_hose_phys_to_bus(pci_bus_to_hose(PCI_BUS(dev)), (addr), (flags))
632 #define pci_bus_to_phys(dev, addr, flags) \ argument
633 pci_hose_bus_to_phys(pci_bus_to_hose(PCI_BUS(dev)), (addr), (flags))
635 #define pci_virt_to_bus(dev, addr, flags) \ argument
637 (virt_to_phys(addr)), (flags))
638 #define pci_bus_to_virt(dev, addr, flags, len, map_flags) \ argument
640 (addr), (flags)), \
643 #define pci_phys_to_mem(dev, addr) \ argument
644 pci_phys_to_bus((dev), (addr), PCI_REGION_MEM)
645 #define pci_mem_to_phys(dev, addr) \ argument
646 pci_bus_to_phys((dev), (addr), PCI_REGION_MEM)
647 #define pci_phys_to_io(dev, addr) pci_phys_to_bus((dev), (addr), PCI_REGION_IO) argument
648 #define pci_io_to_phys(dev, addr) pci_bus_to_phys((dev), (addr), PCI_REGION_IO) argument
650 #define pci_virt_to_mem(dev, addr) \ argument
651 pci_virt_to_bus((dev), (addr), PCI_REGION_MEM)
652 #define pci_mem_to_virt(dev, addr, len, map_flags) \ argument
653 pci_bus_to_virt((dev), (addr), PCI_REGION_MEM, (len), (map_flags))
654 #define pci_virt_to_io(dev, addr) \ argument
655 pci_virt_to_bus((dev), (addr), PCI_REGION_IO)
656 #define pci_io_to_virt(dev, addr, len, map_flags) \ argument
657 pci_bus_to_virt((dev), (addr), PCI_REGION_IO, (len), (map_flags))
720 extern pci_dev_t pci_find_device (unsigned int vendor, unsigned int device, int index);
745 unsigned short device,
763 * pci_write_bar32() - Write the address of a BAR including control bits
766 * with devices which require hard-coded addresses, not part of the normal
770 * @dev: PCI device to update
771 * @barnum: BAR number (0-5)
772 * @addr: BAR address with control bits
775 u32 addr);
778 * pci_read_bar32() - read the address of a bar
781 * @dev: PCI device to inspect
782 * @barnum: BAR number (0-5)
788 * pci_hose_find_devices() - Find devices by vendor/device ID
792 * @ids: PCI vendor/device IDs to look for, terminated by 0, 0 record
793 * @indexp: Pointer to device index to find. To find the first matching
794 * device, pass 0; to find the second, pass 1, etc. This
795 * parameter is decremented for each non-matching device so
813 * struct pci_child_platdata - information stored about each PCI device
815 * Every device on a PCI bus has this per-child data.
817 * It can be accessed using dev_get_parent_priv(dev) if dev->parent is a
820 * @devfn: Encoded device and function index - see PCI_DEVFN()
822 * @device: PCI device ID (see pci_ids.h)
823 * @class: PCI class, 3 bytes: (base, sub, prog-if)
828 unsigned short device; member
835 * read_config() - Read a PCI configuration value
840 * Normally PCI_BUS(@bdf) is the same as @bus->seq, but not always.
841 * If bridges exist it is possible to use the top-level bus to
842 * access a sub-bus. In that case @bus will be the top-level bus
846 * @bdf: Bus, device and function to read
847 * @offset: Byte offset within the device's configuration space
850 * @return 0 if OK, -ve on error
855 * write_config() - Write a PCI configuration value
858 * @bdf: Bus, device and function to write
859 * @offset: Byte offset within the device's configuration space
862 * @return 0 if OK, -ve on error
869 #define pci_get_ops(dev) ((struct dm_pci_ops *)(dev)->driver->ops)
872 * dm_pci_get_bdf() - Get the BDF value for a device
874 * @dev: Device to check
875 * @return bus/device/function value (see PCI_BDF())
880 * pci_bind_bus_devices() - scan a PCI bus and bind devices
884 * child data so that the device can be used correctly (this happens when
885 * the device tree describes devices we expect to see on the bus).
888 * does nothing. The device can still be accessed but will not provide any
892 * @return 0 if OK, -ve on error
897 * pci_auto_config_devices() - configure bus devices ready for use
907 * @return 0 if OK, -ve on error
912 * dm_pci_bus_find_bdf() - Find a device given its PCI bus address
914 * @bdf: PCI device address: bus, device and function -see PCI_BDF()
915 * @devp: Returns the device for this address, if found
916 * @return 0 if OK, -ENODEV if not found
921 * pci_bus_find_devfn() - Find a device on a bus
923 * @find_devfn: PCI device address (device and function only)
924 * @devp: Returns the device for this address, if found
925 * @return 0 if OK, -ENODEV if not found
931 * pci_find_first_device() - return the first available PCI device
937 * @devp: Set to the first available device, or NULL if no more are left
939 * @return 0 if all is OK, -ve on error (e.g. a bus/bridge failed to probe)
944 * pci_find_next_device() - return the next available PCI device
946 * Finds the next available PCI device after the one supplied, or sets @devp
949 * @devp: On entry, the last device returned. Set to the next available
950 * device, or NULL if no more are left or we got an error
951 * @return 0 if all is OK, -ve on error (e.g. a bus/bridge failed to probe)
956 * pci_get_ff() - Returns a mask for the given access size
965 * pci_bus_find_devices () - Find devices on a bus
968 * @ids: PCI vendor/device IDs to look for, terminated by 0, 0 record
969 * @indexp: Pointer to device index to find. To find the first matching
970 * device, pass 0; to find the second, pass 1, etc. This
971 * parameter is decremented for each non-matching device so
973 * @devp: Returns matching device if found
974 * @return 0 if found, -ENODEV if not
980 * pci_find_device_id() - Find a device on any bus
982 * @ids: PCI vendor/device IDs to look for, terminated by 0, 0 record
983 * @index: Index number of device to find, 0 for the first match, 1 for
985 * @devp: Returns matching device if found
986 * @return 0 if found, -ENODEV if not
992 * dm_pci_hose_probe_bus() - probe a subordinate bus, scanning it for devices
998 * always a top-level bus with uclass UCLASS_PCI. The bus to scan is
1003 * @return 0 if OK, -ve on error
1008 * pci_bus_read_config() - Read a configuration value from a device
1010 * TODO(sjg@chromium.org): We should be able to pass just a device and have
1014 * @bdf: PCI device address: bus, device and function -see PCI_BDF()
1018 * @return 0 if OK, -ve on error
1024 * pci_bus_write_config() - Write a configuration value to a device
1027 * @bdf: PCI device address: bus, device and function -see PCI_BDF()
1031 * @return 0 if OK, -ve on error
1037 * pci_bus_clrset_config32() - Update a configuration value for a device
1042 * @bdf: PCI device address: bus, device and function -see PCI_BDF()
1046 * @return 0 if OK, -ve on error
1053 * when you have a valid device
1079 * size parameter. We are trying to encourage the use of the 8/16/32-style
1134 * dm_pciauto_config_device() - configure a device ready for use
1139 * @dev: Device to configure
1140 * @return 0 if OK, -ve on error
1145 * pci_conv_32_to_size() - convert a 32-bit read value to the given size
1147 * Some PCI buses must always perform 32-bit reads. The data must then be
1151 * @value: Value to transform (32-bit value read from @offset & ~3)
1160 * pci_conv_size_to_32() - update a 32-bit value to prepare for a write
1162 * Some PCI buses must always perform 32-bit writes. To emulate a smaller
1163 * write the old 32-bit data must be read, updated with the required new data
1164 * and written back as a 32-bit value. This function performs the
1167 * @value: Value to transform (32-bit value read from @offset & ~3)
1170 * @return the value that should be written as a 32-bit access to @offset & ~3.
1176 * pci_get_controller() - obtain the controller to use for a bus
1178 * @dev: Device to check
1179 * @return pointer to the controller device for this bus
1184 * pci_get_regions() - obtain pointers to all the region types
1186 * @dev: Device to check
1189 * @prefp: Returns a pointer to the pre-fetch region, or NULL if none
1190 * @return the number of non-NULL regions returned, normally 3
1196 * dm_pci_write_bar32() - Write the address of a BAR
1200 * @dev: PCI device to update
1201 * @barnum: BAR number (0-5)
1202 * @addr: BAR address
1204 void dm_pci_write_bar32(struct udevice *dev, int barnum, u32 addr);
1207 * dm_pci_read_bar32() - read a base address register from a device
1209 * @dev: Device to check
1216 * dm_pci_bus_to_phys() - convert a PCI bus address to a physical address
1218 * @dev: Device containing the PCI address
1219 * @addr: PCI address to convert
1223 phys_addr_t dm_pci_bus_to_phys(struct udevice *dev, pci_addr_t addr,
1227 * dm_pci_phys_to_bus() - convert a physical address to a PCI bus address
1229 * @dev: Device containing the bus address
1230 * @addr: Physical address to convert
1234 pci_addr_t dm_pci_phys_to_bus(struct udevice *dev, phys_addr_t addr,
1238 * dm_pci_map_bar() - get a virtual address associated with a BAR region
1243 * @dev: Device to check
1250 #define dm_pci_virt_to_bus(dev, addr, flags) \ argument
1251 dm_pci_phys_to_bus(dev, (virt_to_phys(addr)), (flags))
1252 #define dm_pci_bus_to_virt(dev, addr, flags, len, map_flags) \ argument
1253 map_physmem(dm_pci_bus_to_phys(dev, (addr), (flags)), \
1256 #define dm_pci_phys_to_mem(dev, addr) \ argument
1257 dm_pci_phys_to_bus((dev), (addr), PCI_REGION_MEM)
1258 #define dm_pci_mem_to_phys(dev, addr) \ argument
1259 dm_pci_bus_to_phys((dev), (addr), PCI_REGION_MEM)
1260 #define dm_pci_phys_to_io(dev, addr) \ argument
1261 dm_pci_phys_to_bus((dev), (addr), PCI_REGION_IO)
1262 #define dm_pci_io_to_phys(dev, addr) \ argument
1263 dm_pci_bus_to_phys((dev), (addr), PCI_REGION_IO)
1265 #define dm_pci_virt_to_mem(dev, addr) \ argument
1266 dm_pci_virt_to_bus((dev), (addr), PCI_REGION_MEM)
1267 #define dm_pci_mem_to_virt(dev, addr, len, map_flags) \ argument
1268 dm_pci_bus_to_virt((dev), (addr), PCI_REGION_MEM, (len), (map_flags))
1269 #define dm_pci_virt_to_io(dev, addr) \ argument
1270 dm_pci_virt_to_bus((dev), (addr), PCI_REGION_IO)
1271 #define dm_pci_io_to_virt(dev, addr, len, map_flags) \ argument
1272 dm_pci_bus_to_virt((dev), (addr), PCI_REGION_IO, (len), (map_flags))
1275 * dm_pci_find_device() - find a device by vendor/device ID
1278 * @device: Device ID
1280 * @devp: Returns pointer to the device, if found
1281 * @return 0 if found, -ve on error
1283 int dm_pci_find_device(unsigned int vendor, unsigned int device, int index,
1287 * dm_pci_find_class() - find a device by class
1289 * @find_class: 3-byte (24-bit) class value to find
1291 * @devp: Returns pointer to the device, if found
1292 * @return 0 if found, -ve on error
1297 * struct dm_pci_emul_ops - PCI device emulator operations
1301 * get_devfn(): Check which device and function this emulators
1303 * @dev: device to check
1304 * @return the device and function this emulates, or -ve on error
1308 * read_config() - Read a PCI configuration value
1310 * @dev: Emulated device to read from
1311 * @offset: Byte offset within the device's configuration space
1314 * @return 0 if OK, -ve on error
1319 * write_config() - Write a PCI configuration value
1321 * @dev: Emulated device to write to
1322 * @offset: Byte offset within the device's configuration space
1325 * @return 0 if OK, -ve on error
1330 * read_io() - Read a PCI I/O value
1332 * @dev: Emulated device to read from
1333 * @addr: I/O address to read
1336 * @return 0 if OK, -ENOENT if @addr is not mapped by this device,
1337 * other -ve value on error
1339 int (*read_io)(struct udevice *dev, unsigned int addr, ulong *valuep,
1342 * write_io() - Write a PCI I/O value
1344 * @dev: Emulated device to write from
1345 * @addr: I/O address to write
1348 * @return 0 if OK, -ENOENT if @addr is not mapped by this device,
1349 * other -ve value on error
1351 int (*write_io)(struct udevice *dev, unsigned int addr,
1354 * map_physmem() - Map a device into sandbox memory
1356 * @dev: Emulated device to map
1357 * @addr: Memory address, normally corresponding to a PCI BAR.
1358 * The device should have been configured to have a BAR
1362 * if the device has less space
1363 * @ptrp: Returns a pointer to the mapped address. The device's
1365 * @return 0 if OK, -ENOENT if @addr is not mapped by this device,
1366 * other -ve value on error
1368 int (*map_physmem)(struct udevice *dev, phys_addr_t addr,
1371 * unmap_physmem() - undo a memory mapping
1377 * the emulated device and its users.
1379 * @dev: Emuated device to unmap
1382 * @return 0 if OK, -ve on error
1388 /* Get access to a PCI device emulator's operations */
1389 #define pci_get_emul_ops(dev) ((struct dm_pci_emul_ops *)(dev)->driver->ops)
1392 * sandbox_pci_get_emul() - Get the emulation device for a PCI device
1394 * Searches for a suitable emulator for the given PCI bus device
1397 * @find_devfn: PCI device and function address (PCI_DEVFN())
1398 * @emulp: Returns emulated device if found
1399 * @return 0 if found, -ENODEV if not found
1407 * PCI_DEVICE - macro used to describe a specific pci device
1409 * @dev: the 16 bit PCI Device ID
1412 * specific device. The subvendor and subdevice fields will be set to
1416 .vendor = (vend), .device = (dev), \
1420 * PCI_DEVICE_SUB - macro used to describe a specific pci device with subsystem
1422 * @dev: the 16 bit PCI Device ID
1427 * specific device with subsystem information.
1430 .vendor = (vend), .device = (dev), \
1434 * PCI_DEVICE_CLASS - macro used to describe a specific pci device class
1435 * @dev_class: the class, subclass, prog-if triple for this device
1436 * @dev_class_mask: the class mask for this device
1439 * specific PCI class. The vendor, device, subvendor, and subdevice
1444 .vendor = PCI_ANY_ID, .device = PCI_ANY_ID, \
1448 * PCI_VDEVICE - macro used to describe a specific pci device in short form
1450 * @dev: the 16 bit PCI Device ID
1453 * specific PCI device. The subvendor, and subdevice fields will be set
1454 * to PCI_ANY_ID. The macro allows the next field to follow as the device
1459 .vendor = PCI_VENDOR_ID_##vend, .device = (dev), \
1463 * struct pci_driver_entry - Matches a driver to its pci_device_id list