aboutsummaryrefslogtreecommitdiff
path: root/include/pci.h
diff options
context:
space:
mode:
authorSimon Glass2016-03-06 19:27:52 -0700
committerBin Meng2016-03-17 10:27:23 +0800
commit319dba1f4d7bf2c82be1c5b0858c4b1c3d8b4cfe (patch)
tree6eaaacf60a8d96c7f46215d06a2fbf62ada3b311 /include/pci.h
parent17c43f1a42135cdca28991658615323c2ca92e37 (diff)
pci: Add functions to update PCI configuration registers
It is common to read a config register value, clear and set some bits, then write back the updated value. Add functions to do this in one step, for convenience. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Diffstat (limited to 'include/pci.h')
-rw-r--r--include/pci.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/include/pci.h b/include/pci.h
index 68548b00d94..db84744571e 100644
--- a/include/pci.h
+++ b/include/pci.h
@@ -1027,6 +1027,21 @@ int pci_bus_write_config(struct udevice *bus, pci_dev_t bdf, int offset,
unsigned long value, enum pci_size_t size);
/**
+ * pci_bus_clrset_config32() - Update a configuration value for a device
+ *
+ * The register at @offset is updated to (oldvalue & ~clr) | set.
+ *
+ * @bus: Bus to access
+ * @bdf: PCI device address: bus, device and function -see PCI_BDF()
+ * @offset: Register offset to update
+ * @clr: Bits to clear
+ * @set: Bits to set
+ * @return 0 if OK, -ve on error
+ */
+int pci_bus_clrset_config32(struct udevice *bus, pci_dev_t bdf, int offset,
+ u32 clr, u32 set);
+
+/**
* Driver model PCI config access functions. Use these in preference to others
* when you have a valid device
*/
@@ -1044,6 +1059,14 @@ int dm_pci_write_config8(struct udevice *dev, int offset, u8 value);
int dm_pci_write_config16(struct udevice *dev, int offset, u16 value);
int dm_pci_write_config32(struct udevice *dev, int offset, u32 value);
+/**
+ * These permit convenient read/modify/write on PCI configuration. The
+ * register is updated to (oldvalue & ~clr) | set.
+ */
+int dm_pci_clrset_config8(struct udevice *dev, int offset, u32 clr, u32 set);
+int dm_pci_clrset_config16(struct udevice *dev, int offset, u32 clr, u32 set);
+int dm_pci_clrset_config32(struct udevice *dev, int offset, u32 clr, u32 set);
+
/*
* The following functions provide access to the above without needing the
* size parameter. We are trying to encourage the use of the 8/16/32-style