Simon Glass | 0b591e0 | 2019-12-06 21:41:38 -0700 | [diff] [blame] | 1 | /* 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 | |
| 9 | struct 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 Schuchardt | 47b4c02 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 19 | * Return: devfn in bits 15...8 if found (pci_dev_t format), or -ENODEV if not |
Simon Glass | 0b591e0 | 2019-12-06 21:41:38 -0700 | [diff] [blame] | 20 | * found |
| 21 | */ |
| 22 | int 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 Glass | 71fa5b4 | 2020-12-03 16:55:18 -0700 | [diff] [blame] | 33 | * @reg: reg value from dt-plat.c array (first member). This is not a |
Simon Glass | 0b591e0 | 2019-12-06 21:41:38 -0700 | [diff] [blame] | 34 | * pointer type, since the caller may use fdt32_t or fdt64_t depending on |
| 35 | * the address sizes. |
Heinrich Schuchardt | 47b4c02 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 36 | * Return: device/function for that device (pci_dev_t format) |
Simon Glass | 0b591e0 | 2019-12-06 21:41:38 -0700 | [diff] [blame] | 37 | */ |
| 38 | static inline int pci_ofplat_get_devfn(u32 reg) |
| 39 | { |
| 40 | return reg & 0xff00; |
| 41 | } |
| 42 | |
| 43 | #endif |