blob: d35d24d959383b370fc988b8949df63083926594 [file] [log] [blame]
Simon Glass6dd4b012019-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
Heinrich Schuchardt185f8122022-01-19 18:05:50 +010019 * Return: devfn in bits 15...8 if found (pci_dev_t format), or -ENODEV if not
Simon Glass6dd4b012019-12-06 21:41:38 -070020 * 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 *
Simon Glasscaa4daa2020-12-03 16:55:18 -070033 * @reg: reg value from dt-plat.c array (first member). This is not a
Simon Glass6dd4b012019-12-06 21:41:38 -070034 * pointer type, since the caller may use fdt32_t or fdt64_t depending on
35 * the address sizes.
Heinrich Schuchardt185f8122022-01-19 18:05:50 +010036 * Return: device/function for that device (pci_dev_t format)
Simon Glass6dd4b012019-12-06 21:41:38 -070037 */
38static inline int pci_ofplat_get_devfn(u32 reg)
39{
40 return reg & 0xff00;
41}
42
43#endif