From patchwork Fri Oct 18 15:06:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Damien Hedde X-Patchwork-Id: 11198693 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A4680112C for ; Fri, 18 Oct 2019 15:30:23 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7B497222BD for ; Fri, 18 Oct 2019 15:30:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=greensocs.com header.i=@greensocs.com header.b="jt6EpsvI" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7B497222BD Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=greensocs.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:41860 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iLUCs-0000L9-Fs for patchwork-qemu-devel@patchwork.kernel.org; Fri, 18 Oct 2019 11:30:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39421) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iLTrm-0007Li-DA for qemu-devel@nongnu.org; Fri, 18 Oct 2019 11:08:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iLTrl-0000Vq-8P for qemu-devel@nongnu.org; Fri, 18 Oct 2019 11:08:34 -0400 Received: from beetle.greensocs.com ([5.135.226.135]:38788) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iLTrg-0000J2-Sp; Fri, 18 Oct 2019 11:08:29 -0400 Received: from crumble.bar.greensocs.com (crumble.bar.greensocs.com [172.16.11.102]) by beetle.greensocs.com (Postfix) with ESMTPS id 3C82596F5C; Fri, 18 Oct 2019 15:07:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=greensocs.com; s=mail; t=1571411277; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=csiJwmDDJ1X+h08zqd88vO2yIGi07AvaeJFvRK/uExA=; b=jt6EpsvItqPtYrND3cd2USeJTJWV4JJPUsOPBPDmu9PkmB2nAUuYxNwh+jJMJ9q1stQ8K4 gh2ShTgwIZeL2x3n2x4Vkn69ul/1t9wFGjWIJCAGbQyWjY+8b0k4FdI5Q4dhTsxrcg6x/W mQX65ZHl2CuBYl5nCa6vlSn+8peUZnU= From: Damien Hedde To: qemu-devel@nongnu.org Subject: [PATCH v5 13/13] hw/gpio/bcm2835_gpio: Update to resettable Date: Fri, 18 Oct 2019 17:06:30 +0200 Message-Id: <20191018150630.31099-14-damien.hedde@greensocs.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191018150630.31099-1-damien.hedde@greensocs.com> References: <20191018150630.31099-1-damien.hedde@greensocs.com> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=greensocs.com; s=mail; t=1571411277; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=csiJwmDDJ1X+h08zqd88vO2yIGi07AvaeJFvRK/uExA=; b=bzg6srUUN146O1kBjWNa+dQxm2BTQ4HkIFB8ji4n0FkC1f6l1aCV1adG5STLSYD/9g+74K 515cUHzsQdJX/XSPQOoA1bhTOa4pZm7/KbgcJyCx+iGiiEg6Nr93QTWxwzlVzP8wJjcAsq 3V2XvVSb6ID7/ZeTFGClqzBS87PV5Qw= ARC-Seal: i=1; s=mail; d=greensocs.com; t=1571411277; a=rsa-sha256; cv=none; b=RNRVpJU3OFVN3KcsIrG7xkzeJd+qIG8iBGF+8vHZBHrEeibMwNFyj0DfkuJN+4WXF7ltsm RUVF6NPH7cgXiIxO01N/T4SYCpD2XYYxupBT/zDQX7hVrQ/I4sba/EAPnYvBVrGnBefxTi iapbvFnDNY8QAOx4FPy15L7jqMc+Y48= ARC-Authentication-Results: i=1; beetle.greensocs.com; none X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 5.135.226.135 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Damien Hedde , peter.maydell@linaro.org, berrange@redhat.com, ehabkost@redhat.com, cohuck@redhat.com, mark.burton@greensocs.com, qemu-s390x@nongnu.org, Andrew Baumann , edgari@xilinx.com, qemu-arm@nongnu.org, pbonzini@redhat.com, philmd@redhat.com, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" 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 Reviewed-by: Peter Maydell --- Cc: Peter Maydell Cc: Andrew Baumann Cc: Philippe Mathieu-Daudé Cc: qemu-arm@nongnu.org --- 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 = {