[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 03/14] hw/i2c/versatile_i2c: Add SCL/SDA definitions
From: |
Philippe Mathieu-Daudé |
Subject: |
[PATCH v2 03/14] hw/i2c/versatile_i2c: Add SCL/SDA definitions |
Date: |
Wed, 17 Jun 2020 07:51:54 +0200 |
Use self-explicit definitions instead of magic values.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
hw/i2c/versatile_i2c.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/hw/i2c/versatile_i2c.c b/hw/i2c/versatile_i2c.c
index 040139d701..0ce10a1bcc 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 = {
--
2.21.3
- [PATCH v2 00/14] mps2: Add few more peripherals, Philippe Mathieu-Daudé, 2020/06/17
- [PATCH v2 02/14] hw/i2c/versatile_i2c: Add definitions for register addresses, Philippe Mathieu-Daudé, 2020/06/17
- [PATCH v2 01/14] hw/watchdog/cmsdk-apb-watchdog: Add trace event for lock status, Philippe Mathieu-Daudé, 2020/06/17
- [PATCH v2 03/14] hw/i2c/versatile_i2c: Add SCL/SDA definitions,
Philippe Mathieu-Daudé <=
- [PATCH v2 04/14] hw/i2c: Add header for ARM SBCon two-wire serial bus interface, Philippe Mathieu-Daudé, 2020/06/17
- [PATCH v2 05/14] hw/arm: Use TYPE_VERSATILE_I2C instead of hardcoded string, Philippe Mathieu-Daudé, 2020/06/17
- [PATCH v2 06/14] hw/arm/mps2: Document CMSDK/FPGA APB subsystem sections, Philippe Mathieu-Daudé, 2020/06/17
- [PATCH v2 08/14] hw/arm/mps2: Add CMSDK APB watchdog device, Philippe Mathieu-Daudé, 2020/06/17
- [PATCH v2 07/14] hw/arm/mps2: Rename CMSDK AHB peripheral region, Philippe Mathieu-Daudé, 2020/06/17
- [PATCH v2 11/14] hw/arm/mps2: Add SPI devices, Philippe Mathieu-Daudé, 2020/06/17
- [PATCH v2 10/14] hw/arm/mps2: Map the FPGA I/O block, Philippe Mathieu-Daudé, 2020/06/17
- [PATCH v2 09/14] hw/arm/mps2: Add CMSDK AHB GPIO peripherals as unimplemented devices, Philippe Mathieu-Daudé, 2020/06/17
- [PATCH v2 12/14] hw/arm/mps2: Add I2C devices, Philippe Mathieu-Daudé, 2020/06/17
- [PATCH v2 13/14] hw/arm/mps2: Add audio I2S interface as unimplemented device, Philippe Mathieu-Daudé, 2020/06/17