Commit 2253d648f11e844d2dcf572b3bb961e1a7a2b00b

Authored by Stefan Roese
Committed by Tom Rini
1 parent e63bf1b13b

pci: Add comment to mention difference in DEVFN usage in U-Boot vs Linux

This patch adds a comment to the header with the PCI_foo macros related
to DEVFN to explain the difference in U-Boot vs Linux.

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Simon Glass <sjg@chromium.org>
Cc: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

Showing 1 changed file with 11 additions and 0 deletions Side-by-side Diff

... ... @@ -499,9 +499,20 @@
499 499 typedef int pci_dev_t;
500 500  
501 501 #define PCI_BUS(d) (((d) >> 16) & 0xff)
  502 +
  503 +/*
  504 + * Please note the difference in DEVFN usage in U-Boot vs Linux. U-Boot
  505 + * uses DEVFN in bits 15-8 but Linux instead expects DEVFN in bits 7-0.
  506 + * Please see the Linux header include/uapi/linux/pci.h for more details.
  507 + * This is relevant for the following macros:
  508 + * PCI_DEV, PCI_FUNC, PCI_DEVFN
  509 + * The U-Boot macro PCI_DEV is equivalent to the Linux PCI_SLOT version with
  510 + * the remark from above (input d in bits 15-8 instead of 7-0.
  511 + */
502 512 #define PCI_DEV(d) (((d) >> 11) & 0x1f)
503 513 #define PCI_FUNC(d) (((d) >> 8) & 0x7)
504 514 #define PCI_DEVFN(d, f) ((d) << 11 | (f) << 8)
  515 +
505 516 #define PCI_MASK_BUS(bdf) ((bdf) & 0xffff)
506 517 #define PCI_ADD_BUS(bus, devfn) (((bus) << 16) | (devfn))
507 518 #define PCI_BDF(b, d, f) ((b) << 16 | PCI_DEVFN(d, f))