Skip to contentSkip to conversation

hw/i2c: add pca9543 i2c-mux switch

PATCH In review Potin Lai 3 participants 5 messages Nov 13, 2023 – Dec 6, 2023

lore
Share & tools
lore

Potin Lai

author
#0 lore raw

PATCH 1/1 hw/i2c: add pca9543 i2c-mux switch

Add pca9543 2-channel i2c-mux switch support.

---
 hw/i2c/i2c_mux_pca954x.c         | 12 ++++++++++++
 include/hw/i2c/i2c_mux_pca954x.h |  1 +
 2 files changed, 13 insertions(+)
hw/i2c/i2c_mux_pca954x.c +12 -0
index db5db956a6..6aace0fc47 100644
@@ -30,6 +30,7 @@
 
 #define PCA9548_CHANNEL_COUNT 8
 #define PCA9546_CHANNEL_COUNT 4
+#define PCA9543_CHANNEL_COUNT 2
 
 /*
  * struct Pca954xState - The pca954x state object.
@@ -172,6 +173,12 @@ I2CBus *pca954x_i2c_get_bus(I2CSlave *mux, uint8_t channel)
     return pca954x->bus[channel];
 }
 
+static void pca9543_class_init(ObjectClass *klass, void *data)
+{
+    Pca954xClass *s = PCA954X_CLASS(klass);
+    s->nchans = PCA9543_CHANNEL_COUNT;
+}
+
 static void pca9546_class_init(ObjectClass *klass, void *data)
 {
     Pca954xClass *s = PCA954X_CLASS(klass);
@@ -246,6 +253,11 @@ static const TypeInfo pca954x_info[] = {
         .class_init    = pca954x_class_init,
         .abstract      = true,
     },
+    {
+        .name          = TYPE_PCA9543,
+        .parent        = TYPE_PCA954X,
+        .class_init    = pca9543_class_init,
+    },
     {
         .name          = TYPE_PCA9546,
         .parent        = TYPE_PCA954X,
include/hw/i2c/i2c_mux_pca954x.h +1 -0
index 3dd25ec983..1da5508ed5 100644
@@ -3,6 +3,7 @@
 
 #include "hw/i2c/i2c.h"
 
+#define TYPE_PCA9543 "pca9543"
 #define TYPE_PCA9546 "pca9546"
 #define TYPE_PCA9548 "pca9548"
 
Signature · 1 line
2.31.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Potin Lai

Add pca9543 2-channel i2c-mux switch support.

Quoted 60 lines
---
 hw/i2c/i2c_mux_pca954x.c         | 12 ++++++++++++
 include/hw/i2c/i2c_mux_pca954x.h |  1 +
 2 files changed, 13 insertions(+)
hw/i2c/i2c_mux_pca954x.c +7 -0
index db5db956a6..6aace0fc47 100644
@@ -30,6 +30,7 @@
 
 #define PCA9548_CHANNEL_COUNT 8
 #define PCA9546_CHANNEL_COUNT 4
+#define PCA9543_CHANNEL_COUNT 2
 
 /*
  * struct Pca954xState - The pca954x state object.
@@ -172,6 +173,12 @@ I2CBus *pca954x_i2c_get_bus(I2CSlave *mux, uint8_t
 channel)
     return pca954x->bus[channel];
 }
 
+static void pca9543_class_init(ObjectClass *klass, void *data)
+{
+    Pca954xClass *s = PCA954X_CLASS(klass);
+    s->nchans = PCA9543_CHANNEL_COUNT;
+}
+
 static void pca9546_class_init(ObjectClass *klass, void *data)
 {
     Pca954xClass *s = PCA954X_CLASS(klass);
hw/i2c/i2c_mux_pca954x.c +5 -0
@@ -246,6 +253,11 @@ static const TypeInfo pca954x_info[] = {
         .class_init    = pca954x_class_init,
         .abstract      = true,
     },
+    {
+        .name          = TYPE_PCA9543,
+        .parent        = TYPE_PCA954X,
+        .class_init    = pca9543_class_init,
+    },
     {
         .name          = TYPE_PCA9546,
         .parent        = TYPE_PCA954X,
include/hw/i2c/i2c_mux_pca954x.h +1 -1
index 3dd25ec983..1da5508ed5 100644
@@ -3,6 +3,7 @@
 
 #include "hw/i2c/i2c.h"
 
+#define TYPE_PCA9543 "pca9543"
 #define TYPE_PCA9546 "pca9546"
 #define TYPE_PCA9548 "pca9548"
 
--

2.31.1

Acked-by on v1 1/1
#2 lore raw
In reply to Potin Lai
Quoted 3 lines · Potin Lai

Add pca9543 2-channel i2c-mux switch support.

Looks good to me.

Quoted 58 lines
---
 hw/i2c/i2c_mux_pca954x.c         | 12 ++++++++++++
 include/hw/i2c/i2c_mux_pca954x.h |  1 +
 2 files changed, 13 insertions(+)
hw/i2c/i2c_mux_pca954x.c +12 -0
index db5db956a6..6aace0fc47 100644
@@ -30,6 +30,7 @@
 
 #define PCA9548_CHANNEL_COUNT 8
 #define PCA9546_CHANNEL_COUNT 4
+#define PCA9543_CHANNEL_COUNT 2
 
 /*
  * struct Pca954xState - The pca954x state object.
@@ -172,6 +173,12 @@ I2CBus *pca954x_i2c_get_bus(I2CSlave *mux, uint8_t channel)
     return pca954x->bus[channel];
 }
 
+static void pca9543_class_init(ObjectClass *klass, void *data)
+{
+    Pca954xClass *s = PCA954X_CLASS(klass);
+    s->nchans = PCA9543_CHANNEL_COUNT;
+}
+
 static void pca9546_class_init(ObjectClass *klass, void *data)
 {
     Pca954xClass *s = PCA954X_CLASS(klass);
@@ -246,6 +253,11 @@ static const TypeInfo pca954x_info[] = {
         .class_init    = pca954x_class_init,
         .abstract      = true,
     },
+    {
+        .name          = TYPE_PCA9543,
+        .parent        = TYPE_PCA954X,
+        .class_init    = pca9543_class_init,
+    },
     {
         .name          = TYPE_PCA9546,
         .parent        = TYPE_PCA954X,
include/hw/i2c/i2c_mux_pca954x.h +1 -0
index 3dd25ec983..1da5508ed5 100644
@@ -3,6 +3,7 @@
 
 #include "hw/i2c/i2c.h"
 
+#define TYPE_PCA9543 "pca9543"
 #define TYPE_PCA9546 "pca9546"
 #define TYPE_PCA9548 "pca9548"
 
Signature · 1 line
2.31.1
#3 lore raw
Quoted 61 lines · Corey Minyard
Quoted 3 lines · Potin Lai

Add pca9543 2-channel i2c-mux switch support.

Looks good to me.

hw/i2c/i2c_mux_pca954x.c I2CBus *pca954x_i2c_get_bus(I2CSlave *mux, uint8_t

Quoted 18 lines
---
 hw/i2c/i2c_mux_pca954x.c         | 12 ++++++++++++
 include/hw/i2c/i2c_mux_pca954x.h |  1 +
 2 files changed, 13 insertions(+)
hw/i2c/i2c_mux_pca954x.c +1 -0
index db5db956a6..6aace0fc47 100644
@@ -30,6 +30,7 @@
 
 #define PCA9548_CHANNEL_COUNT 8
 #define PCA9546_CHANNEL_COUNT 4
+#define PCA9543_CHANNEL_COUNT 2
 
 /*
  * struct Pca954xState - The pca954x state object.
@@ -172,6 +173,12 @@ I2CBus *pca954x_i2c_get_bus(I2CSlave *mux, uint8_t

channel)

Review

Quoted 25 lines
hw/i2c/i2c_mux_pca954x.c +11 -0
     return pca954x->bus[channel];
 }
 
+static void pca9543_class_init(ObjectClass *klass, void *data)
+{
+    Pca954xClass *s = PCA954X_CLASS(klass);
+    s->nchans = PCA9543_CHANNEL_COUNT;
+}
+
 static void pca9546_class_init(ObjectClass *klass, void *data)
 {
     Pca954xClass *s = PCA954X_CLASS(klass);
@@ -246,6 +253,11 @@ static const TypeInfo pca954x_info[] = {
         .class_init    = pca954x_class_init,
         .abstract      = true,
     },
+    {
+        .name          = TYPE_PCA9543,
+        .parent        = TYPE_PCA954X,
+        .class_init    = pca9543_class_init,
+    },
     {
         .name          = TYPE_PCA9546,
         .parent        = TYPE_PCA954X,
(quoted diff) +0 -0

b/include/hw/i2c/i2c_mux_pca954x.h

Quoted 7 lines

index 3dd25ec983..1da5508ed5 100644

include/hw/i2c/i2c_mux_pca954x.h +0 -0
@@ -3,6 +3,7 @@
 
 #include "hw/i2c/i2c.h"
 
Quoted 8 lines
Quoted 8 lines
include/hw/i2c/i2c_mux_pca954x.h +1 -1
+#define TYPE_PCA9543 "pca9543"
 #define TYPE_PCA9546 "pca9546"
 #define TYPE_PCA9548 "pca9548"
 
--

2.31.1

Corey, can you include this in a pull email? I don't quite have that set up at present, Titus is going to help me figure it out.

Patrick

#4 lore raw
Quoted 67 lines · Patrick Venture
Quoted 65 lines · Corey Minyard
Quoted 3 lines · Potin Lai

Add pca9543 2-channel i2c-mux switch support.

Looks good to me.

hw/i2c/i2c_mux_pca954x.c I2CBus *pca954x_i2c_get_bus(I2CSlave *mux, uint8_t

Quoted 18 lines
---
 hw/i2c/i2c_mux_pca954x.c         | 12 ++++++++++++
 include/hw/i2c/i2c_mux_pca954x.h |  1 +
 2 files changed, 13 insertions(+)
hw/i2c/i2c_mux_pca954x.c +1 -0
index db5db956a6..6aace0fc47 100644
@@ -30,6 +30,7 @@
 
 #define PCA9548_CHANNEL_COUNT 8
 #define PCA9546_CHANNEL_COUNT 4
+#define PCA9543_CHANNEL_COUNT 2
 
 /*
  * struct Pca954xState - The pca954x state object.
@@ -172,6 +173,12 @@ I2CBus *pca954x_i2c_get_bus(I2CSlave *mux, uint8_t

channel)

Review

Quoted 25 lines
hw/i2c/i2c_mux_pca954x.c +11 -0
     return pca954x->bus[channel];
 }
 
+static void pca9543_class_init(ObjectClass *klass, void *data)
+{
+    Pca954xClass *s = PCA954X_CLASS(klass);
+    s->nchans = PCA9543_CHANNEL_COUNT;
+}
+
 static void pca9546_class_init(ObjectClass *klass, void *data)
 {
     Pca954xClass *s = PCA954X_CLASS(klass);
@@ -246,6 +253,11 @@ static const TypeInfo pca954x_info[] = {
         .class_init    = pca954x_class_init,
         .abstract      = true,
     },
+    {
+        .name          = TYPE_PCA9543,
+        .parent        = TYPE_PCA954X,
+        .class_init    = pca9543_class_init,
+    },
     {
         .name          = TYPE_PCA9546,
         .parent        = TYPE_PCA954X,
(quoted diff) +0 -0

b/include/hw/i2c/i2c_mux_pca954x.h

Quoted 11 lines

index 3dd25ec983..1da5508ed5 100644

include/hw/i2c/i2c_mux_pca954x.h +1 -0
@@ -3,6 +3,7 @@
 
 #include "hw/i2c/i2c.h"
 
+#define TYPE_PCA9543 "pca9543"
 #define TYPE_PCA9546 "pca9546"
 #define TYPE_PCA9548 "pca9548"
 
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines

--
2.31.1

Corey, can you include this in a pull email? I don't quite have that set up at present, Titus is going to help me figure it out.

Ok, I'm running tests now, I'll get a pull request in assuming everything is ok.

-corey