summaryrefslogtreecommitdiffstats
path: root/src/include/device/pnp.h
diff options
context:
space:
mode:
authorDave Frodin <dave.frodin@se-eng.com>2015-05-12 06:53:11 -0600
committerDave Frodin <dave.frodin@se-eng.com>2015-05-14 20:49:24 +0200
commit2d3964ec29ecc5df5783f8c7366fb1416f83f68c (patch)
treeba00d786f3e007c89a8bb051a64bc973c9d745df /src/include/device/pnp.h
parentd3b194e6fe0a9d2d730ca9520f9883ce3fa763d7 (diff)
downloadcoreboot-2d3964ec29ecc5df5783f8c7366fb1416f83f68c.tar.gz
coreboot-2d3964ec29ecc5df5783f8c7366fb1416f83f68c.tar.bz2
coreboot-2d3964ec29ecc5df5783f8c7366fb1416f83f68c.zip
superio: Replace the indexed I/O functions
Replace the multiple indexed I/O read and write functions with common functions. Change-Id: Idfe7a8784c28d51b3fbcb2f4e26beaa0b91741a8 Signed-off-by: Dave Frodin <dave.frodin@se-eng.com> Reviewed-on: http://review.coreboot.org/10145 Reviewed-by: Aaron Durbin <adurbin@chromium.org> Tested-by: build bot (Jenkins)
Diffstat (limited to 'src/include/device/pnp.h')
-rw-r--r--src/include/device/pnp.h39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/include/device/pnp.h b/src/include/device/pnp.h
index d0d6fa36a928..29df77de2093 100644
--- a/src/include/device/pnp.h
+++ b/src/include/device/pnp.h
@@ -5,6 +5,7 @@
#include <rules.h>
#include <device/device.h>
#include <device/pnp_def.h>
+#include <arch/io.h>
#ifndef __SIMPLE_DEVICE__
@@ -63,5 +64,43 @@ struct pnp_mode_ops {
void pnp_enter_conf_mode(device_t dev);
void pnp_exit_conf_mode(device_t dev);
+/* PNP indexed I/O operations */
+
+/*
+ * u8 pnp_read_index(u16 port, u8 reg)
+ * Description:
+ * This routine reads indexed I/O registers. The reg byte is written
+ * to the index register at I/O address = port. The result is then
+ * read from the data register at I/O address = port + 1.
+ *
+ * Parameters:
+ * @param[in] u16 port = The I/O address of the port index register.
+ * @param[in] u8 reg = The offset within the indexed space.
+ * @param[out] u8 result = The value read back from the data register.
+ */
+static inline u8 pnp_read_index(u16 port, u8 reg)
+{
+ outb(reg, port);
+ return inb(port + 1);
+}
+
+/*
+ * void pnp_write_index(u16 port, u8 reg, u8 value)
+ * Description:
+ * This routine writes indexed I/O registers. The reg byte is written
+ * to the index register at I/O address = port. The value byte is then
+ * written to the data register at I/O address = port + 1.
+ *
+ * Parameters:
+ * @param[in] u16 port = The address of the port index register.
+ * @param[in] u8 reg = The offset within the indexed space.
+ * @param[in] u8 value = The value to be written to the data register.
+ */
+static inline void pnp_write_index(u16 port, u8 reg, u8 value)
+{
+ outb(reg, port);
+ outb(value, port + 1);
+}
+
#endif /* ! __SIMPLE_DEVICE__ */
#endif /* DEVICE_PNP_H */