blob: 712c48f28f46220c2e7088282e5a53b2e756d7f9 [file] [log] [blame]
Simon Glassff3e0772015-03-05 12:25:25 -07001/*
2 * Compatibility functions for pre-driver-model code
3 *
4 * Copyright (C) 2014 Google, Inc
5 *
6 * SPDX-License-Identifier: GPL-2.0+
7 */
Simon Glassff3e0772015-03-05 12:25:25 -07008#include <common.h>
9#include <dm.h>
10#include <errno.h>
11#include <malloc.h>
12#include <pci.h>
13#include <dm/device-internal.h>
14#include <dm/lists.h>
15
16#define PCI_HOSE_OP(rw, name, size, type) \
17int pci_hose_##rw##_config_##name(struct pci_controller *hose, \
18 pci_dev_t dev, \
19 int offset, type value) \
20{ \
21 return pci_##rw##_config##size(dev, offset, value); \
22}
23
24PCI_HOSE_OP(read, byte, 8, u8 *)
25PCI_HOSE_OP(read, word, 16, u16 *)
26PCI_HOSE_OP(read, dword, 32, u32 *)
27PCI_HOSE_OP(write, byte, 8, u8)
28PCI_HOSE_OP(write, word, 16, u16)
29PCI_HOSE_OP(write, dword, 32, u32)
30
31pci_dev_t pci_find_devices(struct pci_device_id *ids, int index)
32{
Simon Glass4b515e42015-07-06 16:47:46 -060033 struct udevice *dev;
Simon Glassff3e0772015-03-05 12:25:25 -070034
35 if (pci_find_device_id(ids, index, &dev))
36 return -1;
Simon Glass4b515e42015-07-06 16:47:46 -060037 return pci_get_bdf(dev);
Simon Glassff3e0772015-03-05 12:25:25 -070038}