aboutsummaryrefslogtreecommitdiff
path: root/hw/i2c
diff options
context:
space:
mode:
authorPhilippe Mathieu-Daudé <f4bug@amsat.org>2020-06-17 09:25:28 +0200
committerPeter Maydell <peter.maydell@linaro.org>2020-06-23 11:39:47 +0100
commitcfcfbae0a1028383d7c084fc4cd3ee958ef78d71 (patch)
tree38ed5ab33d4ef56b9686cb3b2ee8bb7acc7ce1ad /hw/i2c
parentfaa1bdfa32547ea616ec554aa807b4e24e30acef (diff)
downloadqemu-cfcfbae0a1028383d7c084fc4cd3ee958ef78d71.zip
qemu-cfcfbae0a1028383d7c084fc4cd3ee958ef78d71.tar.gz
qemu-cfcfbae0a1028383d7c084fc4cd3ee958ef78d71.tar.bz2
hw/i2c/versatile_i2c: Add SCL/SDA definitions
Use self-explicit definitions instead of magic values. Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Message-id: 20200617072539.32686-4-f4bug@amsat.org Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'hw/i2c')
-rw-r--r--hw/i2c/versatile_i2c.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/hw/i2c/versatile_i2c.c b/hw/i2c/versatile_i2c.c
index 040139d..0ce10a1 100644
--- a/hw/i2c/versatile_i2c.c
+++ b/hw/i2c/versatile_i2c.c
@@ -45,6 +45,9 @@ REG32(CONTROL_GET, 0)
REG32(CONTROL_SET, 0)
REG32(CONTROL_CLR, 4)
+#define SCL BIT(0)
+#define SDA BIT(1)
+
static uint64_t versatile_i2c_read(void *opaque, hwaddr offset,
unsigned size)
{
@@ -76,8 +79,8 @@ static void versatile_i2c_write(void *opaque, hwaddr offset,
qemu_log_mask(LOG_GUEST_ERROR,
"%s: Bad offset 0x%x\n", __func__, (int)offset);
}
- bitbang_i2c_set(&s->bitbang, BITBANG_I2C_SCL, (s->out & 1) != 0);
- s->in = bitbang_i2c_set(&s->bitbang, BITBANG_I2C_SDA, (s->out & 2) != 0);
+ bitbang_i2c_set(&s->bitbang, BITBANG_I2C_SCL, (s->out & SCL) != 0);
+ s->in = bitbang_i2c_set(&s->bitbang, BITBANG_I2C_SDA, (s->out & SDA) != 0);
}
static const MemoryRegionOps versatile_i2c_ops = {