qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] hw/i2c: add pca9543 i2c-mux switch
@ 2023-11-13  6:31 Potin Lai
  2023-11-14 21:47 ` Patrick Venture
  2023-11-14 23:30 ` Corey Minyard
  0 siblings, 2 replies; 5+ messages in thread
From: Potin Lai @ 2023-11-13  6:31 UTC (permalink / raw)
  To: Patrick Venture; +Cc: qemu-devel, Potin Lai

Add pca9543 2-channel i2c-mux switch support.

Signed-off-by: Potin Lai <potin.lai.pt@gmail.com>
---
 hw/i2c/i2c_mux_pca954x.c         | 12 ++++++++++++
 include/hw/i2c/i2c_mux_pca954x.h |  1 +
 2 files changed, 13 insertions(+)

diff --git a/hw/i2c/i2c_mux_pca954x.c b/hw/i2c/i2c_mux_pca954x.c
index db5db956a6..6aace0fc47 100644
--- a/hw/i2c/i2c_mux_pca954x.c
+++ b/hw/i2c/i2c_mux_pca954x.c
@@ -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,
diff --git a/include/hw/i2c/i2c_mux_pca954x.h b/include/hw/i2c/i2c_mux_pca954x.h
index 3dd25ec983..1da5508ed5 100644
--- a/include/hw/i2c/i2c_mux_pca954x.h
+++ b/include/hw/i2c/i2c_mux_pca954x.h
@@ -3,6 +3,7 @@
 
 #include "hw/i2c/i2c.h"
 
+#define TYPE_PCA9543 "pca9543"
 #define TYPE_PCA9546 "pca9546"
 #define TYPE_PCA9548 "pca9548"
 
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/1] hw/i2c: add pca9543 i2c-mux switch
  2023-11-13  6:31 [PATCH 1/1] hw/i2c: add pca9543 i2c-mux switch Potin Lai
@ 2023-11-14 21:47 ` Patrick Venture
  2023-11-14 23:30 ` Corey Minyard
  1 sibling, 0 replies; 5+ messages in thread
From: Patrick Venture @ 2023-11-14 21:47 UTC (permalink / raw)
  To: Potin Lai; +Cc: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 1999 bytes --]

On Sun, Nov 12, 2023 at 10:34 PM Potin Lai <potin.lai.pt@gmail.com> wrote:

> Add pca9543 2-channel i2c-mux switch support.
>
> Signed-off-by: Potin Lai <potin.lai.pt@gmail.com>
>

Reviewed-by: Patrick Venture <venture@google.com>


> ---
>  hw/i2c/i2c_mux_pca954x.c         | 12 ++++++++++++
>  include/hw/i2c/i2c_mux_pca954x.h |  1 +
>  2 files changed, 13 insertions(+)
>
> diff --git a/hw/i2c/i2c_mux_pca954x.c b/hw/i2c/i2c_mux_pca954x.c
> index db5db956a6..6aace0fc47 100644
> --- a/hw/i2c/i2c_mux_pca954x.c
> +++ b/hw/i2c/i2c_mux_pca954x.c
> @@ -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,
> diff --git a/include/hw/i2c/i2c_mux_pca954x.h
> b/include/hw/i2c/i2c_mux_pca954x.h
> index 3dd25ec983..1da5508ed5 100644
> --- a/include/hw/i2c/i2c_mux_pca954x.h
> +++ b/include/hw/i2c/i2c_mux_pca954x.h
> @@ -3,6 +3,7 @@
>
>  #include "hw/i2c/i2c.h"
>
> +#define TYPE_PCA9543 "pca9543"
>  #define TYPE_PCA9546 "pca9546"
>  #define TYPE_PCA9548 "pca9548"
>
> --
> 2.31.1
>
>

[-- Attachment #2: Type: text/html, Size: 2841 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/1] hw/i2c: add pca9543 i2c-mux switch
  2023-11-13  6:31 [PATCH 1/1] hw/i2c: add pca9543 i2c-mux switch Potin Lai
  2023-11-14 21:47 ` Patrick Venture
@ 2023-11-14 23:30 ` Corey Minyard
  2023-12-05 19:05   ` Patrick Venture
  1 sibling, 1 reply; 5+ messages in thread
From: Corey Minyard @ 2023-11-14 23:30 UTC (permalink / raw)
  To: Potin Lai; +Cc: Patrick Venture, qemu-devel

On Mon, Nov 13, 2023 at 02:31:56PM +0800, Potin Lai wrote:
> Add pca9543 2-channel i2c-mux switch support.
> 
> Signed-off-by: Potin Lai <potin.lai.pt@gmail.com>

Looks good to me.

Acked-by: Corey Minyard <cminyard@mvista.com>

> ---
>  hw/i2c/i2c_mux_pca954x.c         | 12 ++++++++++++
>  include/hw/i2c/i2c_mux_pca954x.h |  1 +
>  2 files changed, 13 insertions(+)
> 
> diff --git a/hw/i2c/i2c_mux_pca954x.c b/hw/i2c/i2c_mux_pca954x.c
> index db5db956a6..6aace0fc47 100644
> --- a/hw/i2c/i2c_mux_pca954x.c
> +++ b/hw/i2c/i2c_mux_pca954x.c
> @@ -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,
> diff --git a/include/hw/i2c/i2c_mux_pca954x.h b/include/hw/i2c/i2c_mux_pca954x.h
> index 3dd25ec983..1da5508ed5 100644
> --- a/include/hw/i2c/i2c_mux_pca954x.h
> +++ b/include/hw/i2c/i2c_mux_pca954x.h
> @@ -3,6 +3,7 @@
>  
>  #include "hw/i2c/i2c.h"
>  
> +#define TYPE_PCA9543 "pca9543"
>  #define TYPE_PCA9546 "pca9546"
>  #define TYPE_PCA9548 "pca9548"
>  
> -- 
> 2.31.1
> 
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/1] hw/i2c: add pca9543 i2c-mux switch
  2023-11-14 23:30 ` Corey Minyard
@ 2023-12-05 19:05   ` Patrick Venture
  2023-12-06 14:38     ` Corey Minyard
  0 siblings, 1 reply; 5+ messages in thread
From: Patrick Venture @ 2023-12-05 19:05 UTC (permalink / raw)
  To: minyard; +Cc: Potin Lai, qemu-devel

[-- Attachment #1: Type: text/plain, Size: 2344 bytes --]

On Tue, Nov 14, 2023 at 3:30 PM Corey Minyard <minyard@acm.org> wrote:

> On Mon, Nov 13, 2023 at 02:31:56PM +0800, Potin Lai wrote:
> > Add pca9543 2-channel i2c-mux switch support.
> >
> > Signed-off-by: Potin Lai <potin.lai.pt@gmail.com>
>
> Looks good to me.
>
> Acked-by: Corey Minyard <cminyard@mvista.com>
>
> > ---
> >  hw/i2c/i2c_mux_pca954x.c         | 12 ++++++++++++
> >  include/hw/i2c/i2c_mux_pca954x.h |  1 +
> >  2 files changed, 13 insertions(+)
> >
> > diff --git a/hw/i2c/i2c_mux_pca954x.c b/hw/i2c/i2c_mux_pca954x.c
> > index db5db956a6..6aace0fc47 100644
> > --- a/hw/i2c/i2c_mux_pca954x.c
> > +++ b/hw/i2c/i2c_mux_pca954x.c
> > @@ -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,
> > diff --git a/include/hw/i2c/i2c_mux_pca954x.h
> b/include/hw/i2c/i2c_mux_pca954x.h
> > index 3dd25ec983..1da5508ed5 100644
> > --- a/include/hw/i2c/i2c_mux_pca954x.h
> > +++ b/include/hw/i2c/i2c_mux_pca954x.h
> > @@ -3,6 +3,7 @@
> >
> >  #include "hw/i2c/i2c.h"
> >
> > +#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

[-- Attachment #2: Type: text/html, Size: 3293 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/1] hw/i2c: add pca9543 i2c-mux switch
  2023-12-05 19:05   ` Patrick Venture
@ 2023-12-06 14:38     ` Corey Minyard
  0 siblings, 0 replies; 5+ messages in thread
From: Corey Minyard @ 2023-12-06 14:38 UTC (permalink / raw)
  To: Patrick Venture; +Cc: Potin Lai, qemu-devel

On Tue, Dec 05, 2023 at 11:05:33AM -0800, Patrick Venture wrote:
> On Tue, Nov 14, 2023 at 3:30 PM Corey Minyard <minyard@acm.org> wrote:
> 
> > On Mon, Nov 13, 2023 at 02:31:56PM +0800, Potin Lai wrote:
> > > Add pca9543 2-channel i2c-mux switch support.
> > >
> > > Signed-off-by: Potin Lai <potin.lai.pt@gmail.com>
> >
> > Looks good to me.
> >
> > Acked-by: Corey Minyard <cminyard@mvista.com>
> >
> > > ---
> > >  hw/i2c/i2c_mux_pca954x.c         | 12 ++++++++++++
> > >  include/hw/i2c/i2c_mux_pca954x.h |  1 +
> > >  2 files changed, 13 insertions(+)
> > >
> > > diff --git a/hw/i2c/i2c_mux_pca954x.c b/hw/i2c/i2c_mux_pca954x.c
> > > index db5db956a6..6aace0fc47 100644
> > > --- a/hw/i2c/i2c_mux_pca954x.c
> > > +++ b/hw/i2c/i2c_mux_pca954x.c
> > > @@ -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,
> > > diff --git a/include/hw/i2c/i2c_mux_pca954x.h
> > b/include/hw/i2c/i2c_mux_pca954x.h
> > > index 3dd25ec983..1da5508ed5 100644
> > > --- a/include/hw/i2c/i2c_mux_pca954x.h
> > > +++ b/include/hw/i2c/i2c_mux_pca954x.h
> > > @@ -3,6 +3,7 @@
> > >
> > >  #include "hw/i2c/i2c.h"
> > >
> > > +#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.

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

-corey


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-12-06 14:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-13  6:31 [PATCH 1/1] hw/i2c: add pca9543 i2c-mux switch Potin Lai
2023-11-14 21:47 ` Patrick Venture
2023-11-14 23:30 ` Corey Minyard
2023-12-05 19:05   ` Patrick Venture
2023-12-06 14:38     ` Corey Minyard

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).