qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
To: qemu-devel@nongnu.org
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
	"Joaquin de Andres" <me@xcancerberox.com.ar>,
	qemu-arm@nongnu.org, "Philippe Mathieu-Daudé" <f4bug@amsat.org>,
	"Esteban Bosse" <estebanbosse@gmail.com>
Subject: [PATCH v2 04/14] hw/i2c: Add header for ARM SBCon two-wire serial bus interface
Date: Wed, 17 Jun 2020 07:51:55 +0200	[thread overview]
Message-ID: <20200617055205.3576-5-f4bug@amsat.org> (raw)
In-Reply-To: <20200617055205.3576-1-f4bug@amsat.org>

'ARM SBCon two-wire serial bus interface' is the official
name describing the pair of registers used to bitbanging
I2C in the Versatile boards.

Make the private VersatileI2CState structure as public
ArmSbconI2CState.
Add the TYPE_ARM_SBCON_I2C, alias to our current
TYPE_VERSATILE_I2C model.
Rename the memory region description as 'arm_sbcon_i2c'.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 include/hw/i2c/arm_sbcon_i2c.h | 35 ++++++++++++++++++++++++++++++++++
 hw/i2c/versatile_i2c.c         | 17 +++++------------
 MAINTAINERS                    |  1 +
 3 files changed, 41 insertions(+), 12 deletions(-)
 create mode 100644 include/hw/i2c/arm_sbcon_i2c.h

diff --git a/include/hw/i2c/arm_sbcon_i2c.h b/include/hw/i2c/arm_sbcon_i2c.h
new file mode 100644
index 0000000000..5d96507ab6
--- /dev/null
+++ b/include/hw/i2c/arm_sbcon_i2c.h
@@ -0,0 +1,35 @@
+/*
+ * ARM SBCon two-wire serial bus interface (I2C bitbang)
+ *   a.k.a.
+ * ARM Versatile I2C controller
+ *
+ * Copyright (c) 2006-2007 CodeSourcery.
+ * Copyright (c) 2012 Oskar Andero <oskar.andero@gmail.com>
+ * Copyright (C) 2020 Philippe Mathieu-Daudé <f4bug@amsat.org>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+#ifndef HW_I2C_ARM_SBCON_H
+#define HW_I2C_ARM_SBCON_H
+
+#include "hw/sysbus.h"
+#include "hw/i2c/bitbang_i2c.h"
+
+#define TYPE_VERSATILE_I2C "versatile_i2c"
+#define TYPE_ARM_SBCON_I2C TYPE_VERSATILE_I2C
+
+#define ARM_SBCON_I2C(obj) \
+    OBJECT_CHECK(ArmSbconI2CState, (obj), TYPE_ARM_SBCON_I2C)
+
+typedef struct ArmSbconI2CState {
+    /*< private >*/
+    SysBusDevice parent_obj;
+    /*< public >*/
+
+    MemoryRegion iomem;
+    bitbang_i2c_interface bitbang;
+    int out;
+    int in;
+} ArmSbconI2CState;
+
+#endif /* HW_I2C_ARM_SBCON_H */
diff --git a/hw/i2c/versatile_i2c.c b/hw/i2c/versatile_i2c.c
index 0ce10a1bcc..da8cda2ec1 100644
--- a/hw/i2c/versatile_i2c.c
+++ b/hw/i2c/versatile_i2c.c
@@ -1,5 +1,6 @@
 /*
- * ARM Versatile I2C controller
+ * ARM SBCon two-wire serial bus interface (I2C bitbang)
+ * a.k.a. ARM Versatile I2C controller
  *
  * Copyright (c) 2006-2007 CodeSourcery.
  * Copyright (c) 2012 Oskar Andero <oskar.andero@gmail.com>
@@ -22,24 +23,16 @@
  */
 
 #include "qemu/osdep.h"
-#include "hw/sysbus.h"
-#include "hw/i2c/bitbang_i2c.h"
+#include "hw/i2c/arm_sbcon_i2c.h"
 #include "hw/registerfields.h"
 #include "qemu/log.h"
 #include "qemu/module.h"
 
-#define TYPE_VERSATILE_I2C "versatile_i2c"
 #define VERSATILE_I2C(obj) \
     OBJECT_CHECK(VersatileI2CState, (obj), TYPE_VERSATILE_I2C)
 
-typedef struct VersatileI2CState {
-    SysBusDevice parent_obj;
+typedef ArmSbconI2CState VersatileI2CState;
 
-    MemoryRegion iomem;
-    bitbang_i2c_interface bitbang;
-    int out;
-    int in;
-} VersatileI2CState;
 
 REG32(CONTROL_GET, 0)
 REG32(CONTROL_SET, 0)
@@ -99,7 +92,7 @@ static void versatile_i2c_init(Object *obj)
     bus = i2c_init_bus(dev, "i2c");
     bitbang_i2c_init(&s->bitbang, bus);
     memory_region_init_io(&s->iomem, obj, &versatile_i2c_ops, s,
-                          "versatile_i2c", 0x1000);
+                          "arm_sbcon_i2c", 0x1000);
     sysbus_init_mmio(sbd, &s->iomem);
 }
 
diff --git a/MAINTAINERS b/MAINTAINERS
index 955cc8dd5c..185d39e151 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -842,6 +842,7 @@ M: Peter Maydell <peter.maydell@linaro.org>
 L: qemu-arm@nongnu.org
 S: Maintained
 F: hw/*/versatile*
+F: include/hw/i2c/arm_sbcon_i2c.h
 F: hw/misc/arm_sysctl.c
 F: docs/system/arm/versatile.rst
 
-- 
2.21.3



  parent reply	other threads:[~2020-06-17  5:55 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-17  5:51 [PATCH v2 00/14] mps2: Add few more peripherals Philippe Mathieu-Daudé
2020-06-17  5:51 ` [PATCH v2 01/14] hw/watchdog/cmsdk-apb-watchdog: Add trace event for lock status Philippe Mathieu-Daudé
2020-06-17  5:51 ` [PATCH v2 02/14] hw/i2c/versatile_i2c: Add definitions for register addresses Philippe Mathieu-Daudé
2020-06-17  5:51 ` [PATCH v2 03/14] hw/i2c/versatile_i2c: Add SCL/SDA definitions Philippe Mathieu-Daudé
2020-06-17  5:51 ` Philippe Mathieu-Daudé [this message]
2020-06-17  5:51 ` [PATCH v2 05/14] hw/arm: Use TYPE_VERSATILE_I2C instead of hardcoded string Philippe Mathieu-Daudé
2020-06-17  5:51 ` [PATCH v2 06/14] hw/arm/mps2: Document CMSDK/FPGA APB subsystem sections Philippe Mathieu-Daudé
2020-06-17  5:51 ` [PATCH v2 07/14] hw/arm/mps2: Rename CMSDK AHB peripheral region Philippe Mathieu-Daudé
2020-06-17  5:51 ` [PATCH v2 08/14] hw/arm/mps2: Add CMSDK APB watchdog device Philippe Mathieu-Daudé
2020-06-17  5:52 ` [PATCH v2 09/14] hw/arm/mps2: Add CMSDK AHB GPIO peripherals as unimplemented devices Philippe Mathieu-Daudé
2020-06-17  5:52 ` [PATCH v2 10/14] hw/arm/mps2: Map the FPGA I/O block Philippe Mathieu-Daudé
2020-06-17  5:52 ` [PATCH v2 11/14] hw/arm/mps2: Add SPI devices Philippe Mathieu-Daudé
2020-06-17  5:52 ` [PATCH v2 12/14] hw/arm/mps2: Add I2C devices Philippe Mathieu-Daudé
2020-06-17  5:52 ` [PATCH v2 13/14] hw/arm/mps2: Add audio I2S interface as unimplemented device Philippe Mathieu-Daudé
2020-06-17  5:52 ` [PATCH v2 14/14] hw/arm/mps2-tz: Use the ARM SBCon two-wire serial bus interface Philippe Mathieu-Daudé
2020-06-17  6:27 ` [PATCH v2 00/14] mps2: Add few more peripherals no-reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200617055205.3576-5-f4bug@amsat.org \
    --to=f4bug@amsat.org \
    --cc=estebanbosse@gmail.com \
    --cc=me@xcancerberox.com.ar \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).