blob: 10f9fd9e37858b0f01ede57e84976a8063030f67 [file] [log] [blame]
Simon Glass0b591e02019-12-06 21:41:38 -07001/* SPDX-License-Identifier: GPL-2.0+ */
2/*
3 * Copyright (c) 2019 Google, Inc
4 */
5
6#ifndef __DM_PCI_H
7#define __DM_PCI_H
8
9struct udevice;
10
11/**
12 * pci_get_devfn() - Extract the devfn from fdt_pci_addr of the device
13 *
14 * Get devfn from fdt_pci_addr of the specified device
15 *
16 * This returns an int to avoid a dependency on pci.h
17 *
18 * @dev: PCI device
19 * @return devfn in bits 15...8 if found (pci_dev_t format), or -ENODEV if not
20 * found
21 */
22int pci_get_devfn(struct udevice *dev);
23
24/**
25 * pci_ofplat_get_devfn() - Get the PCI dev/fn from of-platdata
26 *
27 * This function is used to obtain a PCI device/function from of-platdata
28 * register data. In this case the first cell of the 'reg' property contains
29 * the required information.
30 *
31 * This returns an int to avoid a dependency on pci.h
32 *
33 * @reg: reg value from dt-platdata.c array (first member). This is not a
34 * pointer type, since the caller may use fdt32_t or fdt64_t depending on
35 * the address sizes.
36 * @return device/function for that device (pci_dev_t format)
37 */
38static inline int pci_ofplat_get_devfn(u32 reg)
39{
40 return reg & 0xff00;
41}
42
43#endif