1 // SPDX-License-Identifier: GPL-2.0+
3 * Compatibility functions for pre-driver-model code
5 * Copyright (C) 2014 Google, Inc
12 #include <dm/device-internal.h>
14 #include "pci_internal.h"
16 #define PCI_HOSE_OP(rw, name, size, type) \
17 int pci_hose_##rw##_config_##name(struct pci_controller *hose, \
19 int offset, type value) \
21 return pci_##rw##_config##size(dev, offset, value); \
24 PCI_HOSE_OP(read, byte, 8, u8 *)
25 PCI_HOSE_OP(read, word, 16, u16 *)
26 PCI_HOSE_OP(read, dword, 32, u32 *)
27 PCI_HOSE_OP(write, byte, 8, u8)
28 PCI_HOSE_OP(write, word, 16, u16)
29 PCI_HOSE_OP(write, dword, 32, u32)
31 pci_dev_t pci_find_devices(struct pci_device_id *ids, int index)
35 if (pci_find_device_id(ids, index, &dev))
37 return dm_pci_get_bdf(dev);
40 struct pci_controller *pci_bus_to_hose(int busnum)
45 ret = pci_get_bus(busnum, &bus);
47 debug("%s: Cannot get bus %d: ret=%d\n", __func__, busnum, ret);
51 return dev_get_uclass_priv(pci_get_controller(bus));