From: Titus Rwantare <titusr@google.com>
To: peter.maydell@linaro.org
Cc: qemu-arm@nongnu.org, qemu-devel@nongnu.org,
Titus Rwantare <titusr@google.com>, Hao Wu <wuhaotsh@google.com>
Subject: [PATCH 3/3] hw/gpio: add PCA9536 i2c gpio expander
Date: Mon, 6 Feb 2023 19:49:36 +0000 [thread overview]
Message-ID: <20230206194936.168843-4-titusr@google.com> (raw)
In-Reply-To: <20230206194936.168843-1-titusr@google.com>
This device has the same register layout as the pca9538, but 4 fewer
gpio pins. This commit lowers the number of pins intialised, and reuses
the pca9539 logic.
Reviewed-by: Hao Wu <wuhaotsh@google.com>
Signed-off-by: Titus Rwantare <titusr@google.com>
---
hw/gpio/pca_i2c_gpio.c | 22 ++++++++++++++++++++++
include/hw/gpio/pca_i2c_gpio.h | 2 ++
2 files changed, 24 insertions(+)
diff --git a/hw/gpio/pca_i2c_gpio.c b/hw/gpio/pca_i2c_gpio.c
index f77d8d7e84..66dd1d3369 100644
--- a/hw/gpio/pca_i2c_gpio.c
+++ b/hw/gpio/pca_i2c_gpio.c
@@ -414,6 +414,23 @@ static void pca9538_gpio_class_init(ObjectClass *klass, void *data)
pc->num_pins = PCA9538_NUM_PINS;
}
+static void pca9536_gpio_class_init(ObjectClass *klass, void *data)
+{
+ DeviceClass *dc = DEVICE_CLASS(klass);
+ I2CSlaveClass *k = I2C_SLAVE_CLASS(klass);
+ PCAGPIOClass *pc = PCA_I2C_GPIO_CLASS(klass);
+
+ dc->desc = "PCA9536 4-bit I/O expander";
+ dc->realize = pca_i2c_realize;
+ dc->vmsd = &vmstate_pca_i2c_gpio;
+
+ k->event = pca_i2c_event;
+ k->recv = pca9538_recv;
+ k->send = pca9538_send;
+
+ pc->num_pins = PCA9536_NUM_PINS;
+}
+
static void pca_i2c_gpio_init(Object *obj)
{
PCAGPIOState *ps = PCA_I2C_GPIO(obj);
@@ -455,6 +472,11 @@ static const TypeInfo pca_gpio_types[] = {
.parent = TYPE_PCA_I2C_GPIO,
.class_init = pca9538_gpio_class_init,
},
+ {
+ .name = TYPE_PCA9536_GPIO,
+ .parent = TYPE_PCA_I2C_GPIO,
+ .class_init = pca9536_gpio_class_init,
+ },
};
DEFINE_TYPES(pca_gpio_types);
diff --git a/include/hw/gpio/pca_i2c_gpio.h b/include/hw/gpio/pca_i2c_gpio.h
index 8cd268e8f0..3d2a88ba7b 100644
--- a/include/hw/gpio/pca_i2c_gpio.h
+++ b/include/hw/gpio/pca_i2c_gpio.h
@@ -19,6 +19,7 @@
#define PCA6416_NUM_PINS 16
#define PCA9538_NUM_PINS 8
+#define PCA9536_NUM_PINS 4
typedef struct PCAGPIOClass {
I2CSlaveClass parent;
@@ -75,5 +76,6 @@ OBJECT_DECLARE_TYPE(PCAGPIOState, PCAGPIOClass, PCA_I2C_GPIO)
#define TYPE_PCA6416_GPIO "pca6416"
#define TYPE_PCA9538_GPIO "pca9538"
+#define TYPE_PCA9536_GPIO "pca9536"
#endif
--
2.39.1.519.gcb327c4b5f-goog
prev parent reply other threads:[~2023-02-06 19:50 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-06 19:49 [PATCH 0/3] PCA I2C GPIO expanders Titus Rwantare
2023-02-06 19:49 ` [PATCH 1/3] hw/gpio: add PCA6414 i2c GPIO expander Titus Rwantare
2023-02-06 21:38 ` Philippe Mathieu-Daudé
2023-02-08 22:40 ` Titus Rwantare
2023-02-09 7:17 ` Philippe Mathieu-Daudé
2023-02-06 22:27 ` Corey Minyard
2023-02-08 22:40 ` Titus Rwantare
2023-02-07 1:29 ` Dong, Eddie
2023-02-08 22:40 ` Titus Rwantare
2023-02-07 3:42 ` Joel Stanley
2023-02-08 22:40 ` Titus Rwantare
2023-02-06 19:49 ` [PATCH 2/3] hw/gpio: add PCA9538 8-bit " Titus Rwantare
2023-02-06 19:49 ` Titus Rwantare [this message]
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=20230206194936.168843-4-titusr@google.com \
--to=titusr@google.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=wuhaotsh@google.com \
/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).