Skip to contentSkip to conversation

misc/pca9552: Fix for pca9552 not getting reset

PATCH Superseded Glenn Miles 2 participants 3 messages Oct 5, 2023 – Oct 10, 2023

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 misc/pca9552: Fix for pca9552 not getting reset

Testing of the pca9552 device on the powernv platform showed that the reset method was not being called when an instance of the device was realized. This was causing the INPUT0/INPUT1 POR values to be incorrect.

Fixed by overriding the parent pca955x_realize method with a new pca9552_realize method which first calls
the parent pca955x_realize method followed by the pca9552_reset function.

---
 hw/misc/pca9552.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
hw/misc/pca9552.c +7 -1
index fff19e369a..bc12dced7f 100644
@@ -384,6 +384,12 @@ static void pca955x_realize(DeviceState *dev, Error **errp)
     qdev_init_gpio_out(dev, s->gpio, k->pin_count);
 }
 
+static void pca9552_realize(DeviceState *dev, Error **errp)
+{
+    pca955x_realize(dev, errp);
+    pca9552_reset(dev);
+}
+
 static Property pca955x_properties[] = {
     DEFINE_PROP_STRING("description", PCA955xState, description),
     DEFINE_PROP_END_OF_LIST(),
@@ -416,7 +422,7 @@ static void pca9552_class_init(ObjectClass *oc, void *data)
     DeviceClass *dc = DEVICE_CLASS(oc);
     PCA955xClass *pc = PCA955X_CLASS(oc);
 
-    dc->reset = pca9552_reset;
+    dc->realize = pca9552_realize;
     dc->vmsd = &pca9552_vmstate;
     pc->max_reg = PCA9552_LS3;
     pc->pin_count = 16;
Signature · 1 line
2.31.1
#1 lore raw

Hello Glenn,

Quoted 20 lines · Glenn Miles

Testing of the pca9552 device on the powernv platform showed that the reset method was not being called when an instance of the device was realized. This was causing the INPUT0/INPUT1 POR values to be incorrect.

Fixed by overriding the parent pca955x_realize method with a new pca9552_realize method which first calls
the parent pca955x_realize method followed by the pca9552_reset function.

---
  hw/misc/pca9552.c | 8 +++++++-
  1 file changed, 7 insertions(+), 1 deletion(-)
hw/misc/pca9552.c +0 -0
index fff19e369a..bc12dced7f 100644

hw/misc/pca9552.c static void pca955x_realize(DeviceState *dev, Error **errp) · line 391

Quoted 8 lines
hw/misc/pca9552.c +5 -0
@@ -384,6 +384,12 @@ static void pca955x_realize(DeviceState *dev, Error **errp)
      qdev_init_gpio_out(dev, s->gpio, k->pin_count);
  }
 
+static void pca9552_realize(DeviceState *dev, Error **errp)
+{
+    pca955x_realize(dev, errp);
+    pca9552_reset(dev);
+}

This looks wrong. You need both handlers, a realize and a reset.

Thanks,

C.

Quoted 13 lines
hw/misc/pca9552.c +2 -1
+
  static Property pca955x_properties[] = {
      DEFINE_PROP_STRING("description", PCA955xState, description),
      DEFINE_PROP_END_OF_LIST(),
@@ -416,7 +422,7 @@ static void pca9552_class_init(ObjectClass *oc, void *data)
      DeviceClass *dc = DEVICE_CLASS(oc);
      PCA955xClass *pc = PCA955X_CLASS(oc);
 
-    dc->reset = pca9552_reset;
+    dc->realize = pca9552_realize;
      dc->vmsd = &pca9552_vmstate;
      pc->max_reg = PCA9552_LS3;
      pc->pin_count = 16;
#2 lore raw
Quoted 35 lines · Cédric Le Goater

Hello Glenn,

Quoted 20 lines · Glenn Miles

Testing of the pca9552 device on the powernv platform showed that the reset method was not being called when an instance of the device was realized. This was causing the INPUT0/INPUT1 POR values to be incorrect.

Fixed by overriding the parent pca955x_realize method with a new pca9552_realize method which first calls
the parent pca955x_realize method followed by the pca9552_reset function.

---
  hw/misc/pca9552.c | 8 +++++++-
  1 file changed, 7 insertions(+), 1 deletion(-)
hw/misc/pca9552.c +0 -0
index fff19e369a..bc12dced7f 100644

hw/misc/pca9552.c static void pca955x_realize(DeviceState *dev, · line 392

Quoted 9 lines
hw/misc/pca9552.c +5 -0
@@ -384,6 +384,12 @@ static void pca955x_realize(DeviceState *dev,
 Error **errp)
      qdev_init_gpio_out(dev, s->gpio, k->pin_count);
  }
 
+static void pca9552_realize(DeviceState *dev, Error **errp)
+{
+    pca955x_realize(dev, errp);
+    pca9552_reset(dev);
+}

This looks wrong. You need both handlers, a realize and a reset.

Quoted 4 lines

Thanks,

C.

Ok, sent version 3.

Thanks,

Glenn

Quoted 15 lines
Quoted 15 lines
hw/misc/pca9552.c +1 -0
+
  static Property pca955x_properties[] = {
      DEFINE_PROP_STRING("description", PCA955xState, description),
      DEFINE_PROP_END_OF_LIST(),
hw/misc/pca9552.c +1 -1
@@ -416,7 +422,7 @@ static void pca9552_class_init(ObjectClass *oc,
 void *data)
      DeviceClass *dc = DEVICE_CLASS(oc);
      PCA955xClass *pc = PCA955X_CLASS(oc);
 
-    dc->reset = pca9552_reset;
+    dc->realize = pca9552_realize;
      dc->vmsd = &pca9552_vmstate;
      pc->max_reg = PCA9552_LS3;
      pc->pin_count = 16;