]> git.ipfire.org Git - thirdparty/u-boot.git/blame - drivers/pci/pci_compat.c
Revert "Merge patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet""
[thirdparty/u-boot.git] / drivers / pci / pci_compat.c
CommitLineData
83d290c5 1// SPDX-License-Identifier: GPL-2.0+
ff3e077b
SG
2/*
3 * Compatibility functions for pre-driver-model code
4 *
5 * Copyright (C) 2014 Google, Inc
ff3e077b 6 */
d678a59d 7#include <common.h>
ff3e077b
SG
8#include <dm.h>
9#include <errno.h>
f7ae49fc 10#include <log.h>
ff3e077b
SG
11#include <malloc.h>
12#include <pci.h>
13#include <dm/device-internal.h>
14#include <dm/lists.h>
a6eb93b3 15#include "pci_internal.h"
ff3e077b
SG
16
17#define PCI_HOSE_OP(rw, name, size, type) \
18int pci_hose_##rw##_config_##name(struct pci_controller *hose, \
19 pci_dev_t dev, \
20 int offset, type value) \
21{ \
22 return pci_##rw##_config##size(dev, offset, value); \
23}
24
25PCI_HOSE_OP(read, byte, 8, u8 *)
26PCI_HOSE_OP(read, word, 16, u16 *)
27PCI_HOSE_OP(read, dword, 32, u32 *)
28PCI_HOSE_OP(write, byte, 8, u8)
29PCI_HOSE_OP(write, word, 16, u16)
30PCI_HOSE_OP(write, dword, 32, u32)
31
32pci_dev_t pci_find_devices(struct pci_device_id *ids, int index)
33{
4b515e4f 34 struct udevice *dev;
ff3e077b
SG
35
36 if (pci_find_device_id(ids, index, &dev))
37 return -1;
21ccce1b 38 return dm_pci_get_bdf(dev);
ff3e077b 39}
a6eb93b3
SG
40
41struct pci_controller *pci_bus_to_hose(int busnum)
42{
43 struct udevice *bus;
44 int ret;
45
46 ret = pci_get_bus(busnum, &bus);
47 if (ret) {
48 debug("%s: Cannot get bus %d: ret=%d\n", __func__, busnum, ret);
49 return NULL;
50 }
51
d7482ca4 52 return dev_get_uclass_priv(pci_get_controller(bus));
a6eb93b3 53}