From: Titus Rwantare <titusr@google.com>
To: peter.maydell@linaro.org, minyard@acm.org, clg@redhat.com
Cc: qemu-arm@nongnu.org, qemu-devel@nongnu.org, philmd@linaro.org,
venture@google.com, wuhaotsh@google.com,
milesg@linux.vnet.ibm.com, Titus Rwantare <titusr@google.com>
Subject: [PATCH 3/6] hw/gpio: add PCA9536 i2c gpio expander
Date: Thu, 7 Nov 2024 19:54:50 +0000 [thread overview]
Message-ID: <20241107195453.2684138-4-titusr@google.com> (raw)
In-Reply-To: <20241107195453.2684138-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 initialised, and reuses
the pca9538 logic.
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Hao Wu <wuhaotsh@google.com>
Signed-off-by: Titus Rwantare <titusr@google.com>
---
hw/gpio/pca_i2c_gpio.c | 18 ++++++++++++++++++
include/hw/gpio/pca_i2c_gpio.h | 2 ++
2 files changed, 20 insertions(+)
diff --git a/hw/gpio/pca_i2c_gpio.c b/hw/gpio/pca_i2c_gpio.c
index 2486c620e3..b911187e34 100644
--- a/hw/gpio/pca_i2c_gpio.c
+++ b/hw/gpio/pca_i2c_gpio.c
@@ -336,6 +336,19 @@ static void pca9538_gpio_class_init(ObjectClass *klass, void *data)
k->send = pca953x_send;
}
+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";
+ pc->num_pins = PCA9536_NUM_PINS;
+
+ k->recv = pca953x_recv;
+ k->send = pca953x_send;
+}
+
static void pca_i2c_gpio_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
@@ -386,6 +399,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 61e5853c24..f325563dc7 100644
--- a/include/hw/gpio/pca_i2c_gpio.h
+++ b/include/hw/gpio/pca_i2c_gpio.h
@@ -21,6 +21,7 @@
#define PCA_I2C_MAX_PINS 16
#define PCA6416_NUM_PINS 16
#define PCA9538_NUM_PINS 8
+#define PCA9536_NUM_PINS 4
typedef struct PCAGPIOClass {
I2CSlaveClass parent;
@@ -64,5 +65,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.47.0.277.g8800431eea-goog
next prev parent reply other threads:[~2024-11-07 19:56 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-07 19:54 [PATCH 0/6] Add Quanta GSZ BMC machine and PCA I2C GPIO expanders Titus Rwantare
2024-11-07 19:54 ` [PATCH 1/6] bitops.h: add deposit16 function Titus Rwantare
2024-11-11 22:03 ` Miles Glenn
2024-11-13 15:46 ` Peter Maydell
2024-11-07 19:54 ` [PATCH 2/6] hw/gpio: add PCA953x i2c GPIO expanders Titus Rwantare
2024-11-07 19:54 ` Titus Rwantare [this message]
2024-11-07 19:54 ` [PATCH 4/6] hw/i2c: add canonical path to i2c event traces Titus Rwantare
2024-11-08 14:23 ` Corey Minyard
2024-11-07 19:54 ` [PATCH 5/6] hw/arm: imply I2C_DEVICES on NPCM7xx Titus Rwantare
2024-11-07 19:54 ` [PATCH 6/6] hw/arm: add Quanta GSZ bmc machine Titus Rwantare
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=20241107195453.2684138-4-titusr@google.com \
--to=titusr@google.com \
--cc=clg@redhat.com \
--cc=milesg@linux.vnet.ibm.com \
--cc=minyard@acm.org \
--cc=peter.maydell@linaro.org \
--cc=philmd@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=venture@google.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.