summaryrefslogtreecommitdiff
path: root/src/soc
diff options
context:
space:
mode:
authorAaron Durbin <adurbin@chromium.org>2013-12-11 17:10:58 -0800
committerKyösti Mälkki <kyosti.malkki@gmail.com>2014-05-10 06:30:53 +0200
commit5cc3b401d8abc394540f9e8b0c8c33cf5a26b141 (patch)
treefc39291cf66d94d5189c03e7acf1983184f954b3 /src/soc
parentd86f0b743fba5d02cfc1500997f6c6f5e4250eb5 (diff)
downloadcoreboot-5cc3b401d8abc394540f9e8b0c8c33cf5a26b141.tar.xz
baytrail: remove verbosity in iosf
The iosf access functions already use some common code, however there is a duplication for setting up the proper control register for port and opcode. Introduce macros to remove this verbosity. BUG=chrome-os-partner:24345 BRANCH=None TEST=Built and booted. Suspend and wake. Change-Id: I5bad7e2a11fa8e8bd4a3d7fa53d917b2565644f8 Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/179747 Reviewed-by: Duncan Laurie <dlaurie@chromium.org> Reviewed-on: http://review.coreboot.org/5006 Tested-by: build bot (Jenkins) Reviewed-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
Diffstat (limited to 'src/soc')
-rw-r--r--src/soc/intel/baytrail/iosf.c77
1 files changed, 23 insertions, 54 deletions
diff --git a/src/soc/intel/baytrail/iosf.c b/src/soc/intel/baytrail/iosf.c
index 4840deaede..c3d4f0ee37 100644
--- a/src/soc/intel/baytrail/iosf.c
+++ b/src/soc/intel/baytrail/iosf.c
@@ -59,25 +59,24 @@ static void iosf_write_port(uint32_t cr, int reg, uint32_t val)
write_iosf_reg(MCR_REG, cr);
}
+#define IOSF_READ(port) \
+ IOSF_OPCODE(IOSF_OP_READ_##port) | IOSF_PORT(IOSF_PORT_##port)
+#define IOSF_WRITE(port) \
+ IOSF_OPCODE(IOSF_OP_WRITE_##port) | IOSF_PORT(IOSF_PORT_##port)
+
uint32_t iosf_bunit_read(int reg)
{
- uint32_t cr = IOSF_OPCODE(IOSF_OP_READ_BUNIT) |
- IOSF_PORT(IOSF_PORT_BUNIT);
- return iosf_read_port(cr, reg);
+ return iosf_read_port(IOSF_READ(BUNIT), reg);
}
void iosf_bunit_write(int reg, uint32_t val)
{
- uint32_t cr = IOSF_OPCODE(IOSF_OP_WRITE_BUNIT) |
- IOSF_PORT(IOSF_PORT_BUNIT);
- iosf_write_port(cr, reg, val);
+ iosf_write_port(IOSF_WRITE(BUNIT), reg, val);
}
uint32_t iosf_dunit_read(int reg)
{
- uint32_t cr = IOSF_OPCODE(IOSF_OP_READ_SYSMEMC) |
- IOSF_PORT(IOSF_PORT_SYSMEMC);
- return iosf_read_port(cr, reg);
+ return iosf_read_port(IOSF_READ(SYSMEMC), reg);
}
uint32_t iosf_dunit_ch0_read(int reg)
@@ -94,105 +93,75 @@ uint32_t iosf_dunit_ch1_read(int reg)
void iosf_dunit_write(int reg, uint32_t val)
{
- uint32_t cr = IOSF_OPCODE(IOSF_OP_WRITE_SYSMEMC) |
- IOSF_PORT(IOSF_PORT_SYSMEMC);
- iosf_write_port(cr, reg, val);
+ iosf_write_port(IOSF_WRITE(SYSMEMC), reg, val);
}
uint32_t iosf_punit_read(int reg)
{
- uint32_t cr = IOSF_OPCODE(IOSF_OP_READ_PMC) |
- IOSF_PORT(IOSF_PORT_PMC);
- return iosf_read_port(cr, reg);
+ return iosf_read_port(IOSF_READ(PMC), reg);
}
void iosf_punit_write(int reg, uint32_t val)
{
- uint32_t cr = IOSF_OPCODE(IOSF_OP_WRITE_PMC) |
- IOSF_PORT(IOSF_PORT_PMC);
- iosf_write_port(cr, reg, val);
+ iosf_write_port(IOSF_WRITE(PMC), reg, val);
}
uint32_t iosf_usbphy_read(int reg)
{
- uint32_t cr = IOSF_OPCODE(IOSF_OP_READ_USBPHY) |
- IOSF_PORT(IOSF_PORT_USBPHY);
- return iosf_read_port(cr, reg);
+ return iosf_read_port(IOSF_READ(USBPHY), reg);
}
void iosf_usbphy_write(int reg, uint32_t val)
{
- uint32_t cr = IOSF_OPCODE(IOSF_OP_WRITE_USBPHY) |
- IOSF_PORT(IOSF_PORT_USBPHY);
- return iosf_write_port(cr, reg, val);
+ return iosf_write_port(IOSF_WRITE(USBPHY), reg, val);
}
uint32_t iosf_ushphy_read(int reg)
{
- uint32_t cr = IOSF_OPCODE(IOSF_OP_READ_USHPHY) |
- IOSF_PORT(IOSF_PORT_USHPHY);
- return iosf_read_port(cr, reg);
+ return iosf_read_port(IOSF_READ(USHPHY), reg);
}
void iosf_ushphy_write(int reg, uint32_t val)
{
- uint32_t cr = IOSF_OPCODE(IOSF_OP_WRITE_USHPHY) |
- IOSF_PORT(IOSF_PORT_USHPHY);
- return iosf_write_port(cr, reg, val);
+ return iosf_write_port(IOSF_WRITE(USHPHY), reg, val);
}
uint32_t iosf_lpss_read(int reg)
{
- uint32_t cr = IOSF_OPCODE(IOSF_OP_READ_LPSS) |
- IOSF_PORT(IOSF_PORT_LPSS);
- return iosf_read_port(cr, reg);
+ return iosf_read_port(IOSF_READ(LPSS), reg);
}
void iosf_lpss_write(int reg, uint32_t val)
{
- uint32_t cr = IOSF_OPCODE(IOSF_OP_WRITE_LPSS) |
- IOSF_PORT(IOSF_PORT_LPSS);
- return iosf_write_port(cr, reg, val);
+ return iosf_write_port(IOSF_WRITE(LPSS), reg, val);
}
uint32_t iosf_ccu_read(int reg)
{
- uint32_t cr = IOSF_OPCODE(IOSF_OP_READ_CCU) |
- IOSF_PORT(IOSF_PORT_CCU);
- return iosf_read_port(cr, reg);
+ return iosf_read_port(IOSF_READ(CCU), reg);
}
void iosf_ccu_write(int reg, uint32_t val)
{
- uint32_t cr = IOSF_OPCODE(IOSF_OP_WRITE_CCU) |
- IOSF_PORT(IOSF_PORT_CCU);
- return iosf_write_port(cr, reg, val);
+ return iosf_write_port(IOSF_WRITE(CCU), reg, val);
}
uint32_t iosf_score_read(int reg)
{
- uint32_t cr = IOSF_OPCODE(IOSF_OP_READ_SCORE) |
- IOSF_PORT(IOSF_PORT_SCORE);
- return iosf_read_port(cr, reg);
+ return iosf_read_port(IOSF_READ(SCORE), reg);
}
void iosf_score_write(int reg, uint32_t val)
{
- uint32_t cr = IOSF_OPCODE(IOSF_OP_WRITE_SCORE) |
- IOSF_PORT(IOSF_PORT_SCORE);
- return iosf_write_port(cr, reg, val);
+ return iosf_write_port(IOSF_WRITE(SCORE), reg, val);
}
uint32_t iosf_scc_read(int reg)
{
- uint32_t cr = IOSF_OPCODE(IOSF_OP_READ_SCC) |
- IOSF_PORT(IOSF_PORT_SCC);
- return iosf_read_port(cr, reg);
+ return iosf_read_port(IOSF_READ(SCC), reg);
}
void iosf_scc_write(int reg, uint32_t val)
{
- uint32_t cr = IOSF_OPCODE(IOSF_OP_WRITE_SCC) |
- IOSF_PORT(IOSF_PORT_SCC);
- return iosf_write_port(cr, reg, val);
+ return iosf_write_port(IOSF_WRITE(SCC), reg, val);
}