[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v5 13/13] hw/gpio/bcm2835_gpio: Update to resettable
From: |
Damien Hedde |
Subject: |
[PATCH v5 13/13] hw/gpio/bcm2835_gpio: Update to resettable |
Date: |
Fri, 18 Oct 2019 17:06:30 +0200 |
Transition the bcm2835_gpio device class to Resettable.
The sdbus reparenting is delayed in hold phase to respect
resettable side-effect rules.
Signed-off-by: Damien Hedde <address@hidden>
---
Cc: Peter Maydell <address@hidden>
Cc: Andrew Baumann <address@hidden>
Cc: Philippe Mathieu-Daudé <address@hidden>
Cc: address@hidden
---
hw/gpio/bcm2835_gpio.c | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/hw/gpio/bcm2835_gpio.c b/hw/gpio/bcm2835_gpio.c
index 81fe07132f..24e39eac5e 100644
--- a/hw/gpio/bcm2835_gpio.c
+++ b/hw/gpio/bcm2835_gpio.c
@@ -262,24 +262,29 @@ err_out:
__func__, offset);
}
-static void bcm2835_gpio_reset(DeviceState *dev)
+static void bcm2835_gpio_reset_enter(Object *obj, ResetType type)
{
- BCM2835GpioState *s = BCM2835_GPIO(dev);
+ BCM2835GpioState *s = BCM2835_GPIO(obj);
int i;
for (i = 0; i < 6; i++) {
gpfsel_set(s, i, 0);
}
+ s->lev0 = 0;
+ s->lev1 = 0;
+}
+
+static void bcm2835_gpio_reset_hold(Object *obj)
+{
+ BCM2835GpioState *s = BCM2835_GPIO(obj);
/*
* Setup the right sdbus (put 1 in sd_fsel to force reparenting
- * the sd). It will be SDHCI because of the gpfsel_set() above.
+ * the sd). It will be SDHCI because of the gpfsel_set() done
+ * in bcm2835_gpio_reset_enter().
*/
s->sd_fsel = 1;
gpfsel_update_sdbus(s);
-
- s->lev0 = 0;
- s->lev1 = 0;
}
static const MemoryRegionOps bcm2835_gpio_ops = {
@@ -342,10 +347,12 @@ static void bcm2835_gpio_realize(DeviceState *dev, Error
**errp)
static void bcm2835_gpio_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
+ ResettableClass *rc = RESETTABLE_CLASS(klass);
dc->vmsd = &vmstate_bcm2835_gpio;
dc->realize = &bcm2835_gpio_realize;
- dc->reset = &bcm2835_gpio_reset;
+ rc->phases.enter = &bcm2835_gpio_reset_enter;
+ rc->phases.hold = &bcm2835_gpio_reset_hold;
}
static const TypeInfo bcm2835_gpio_info = {
--
2.23.0
- [PATCH v5 08/13] hw/core: deprecate old reset functions and introduce new ones, (continued)
- [PATCH v5 08/13] hw/core: deprecate old reset functions and introduce new ones, Damien Hedde, 2019/10/18
- [PATCH v5 04/13] hw/core: add Resettable support to BusClass and DeviceClass, Damien Hedde, 2019/10/18
- [PATCH v5 06/13] hw/core/qdev: handle parent bus change regarding resettable, Damien Hedde, 2019/10/18
- [PATCH v5 03/13] hw/core: create Resettable QOM interface, Damien Hedde, 2019/10/18
- [PATCH v5 09/13] docs/devel/reset.txt: add doc about Resettable interface, Damien Hedde, 2019/10/18
- [PATCH v5 12/13] hw/gpio/bcm2835_gpio: Isolate sdbus reparenting, Damien Hedde, 2019/10/18
- [PATCH v5 11/13] hw/s390x/ipl: replace deprecated qdev_reset_all registration, Damien Hedde, 2019/10/18
- [PATCH v5 13/13] hw/gpio/bcm2835_gpio: Update to resettable,
Damien Hedde <=
- Re: [PATCH v5 00/13] Multi-phase reset mechanism, no-reply, 2019/10/19
- Re: [PATCH v5 00/13] Multi-phase reset mechanism, Damien Hedde, 2019/10/29