From nobody Thu Dec 18 22:25:42 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1625848488; cv=none; d=zohomail.com; s=zohoarc; b=SdeEuedgZTFZxW5j/UVm1knL5pcPlk4ca1Lh3hGiPfy8wuQ3IAF5jF/bgYuvhVgmdaAHHyR9qa0UJ5icHd+X/DhjmWqjWrr4q2orLJa1JuXDvGdBIxnkYykbCaw0hFe+aVMklmhJ276+Kv1r1iO+ZhW5/Q7nAuDttUW7lMDo5tE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1625848488; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=g5RTMo3cZi5CJpdjcBxAxRPO+ziLZygfzXi5BsAwtdU=; b=cGgYlI+aoQeFm00k8ZGiHOr5ok69t2t4JffJWHoSuzPr2X2TNaURakXoMN8WUA5VXRFIHSlHlK5hxA9C+40Ngy0pvx76qPbG35d1e2RQAeq/fuYr607vWEgE352kIapOA+eBm4IlFjrqeZbiaDANmt/EOu9f6DcgAq6iy7ym3WY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1625848488053295.8785522181299; Fri, 9 Jul 2021 09:34:48 -0700 (PDT) Received: from localhost ([::1]:41918 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m1tSg-0003W3-VU for importer@patchew.org; Fri, 09 Jul 2021 12:34:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37656) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1t57-0001c2-WC for qemu-devel@nongnu.org; Fri, 09 Jul 2021 12:10:26 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]:43801) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m1t4x-0000wr-Pp for qemu-devel@nongnu.org; Fri, 09 Jul 2021 12:10:25 -0400 Received: by mail-wr1-x435.google.com with SMTP id a13so12819079wrf.10 for ; Fri, 09 Jul 2021 09:10:15 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id x19sm5232277wmi.10.2021.07.09.09.10.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jul 2021 09:10:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=g5RTMo3cZi5CJpdjcBxAxRPO+ziLZygfzXi5BsAwtdU=; b=nYPSSlWm2EF0O1qqle987sSYtMkTDJNvV41p51RQI3NcJ7qgEtybkm84/QpWBac2r7 dF29cakrs2va8pBE+LWTloMpJ1j9RIZx9QKyrgaw9t1rFF53Q8t0X3JqPUH6o3HMNhMZ Yg1qlcZ+4+4X+wtJMXnpx+fSDXV8ECaZQxl5tlo8fFKcUW9u0bbuP3Yr/8zlQidfrwbq HNyRndrM2pwIpZl+JiUObJNg6LfUKir2ZuiGAjfQBG7fOlVsRlLNuHzHybvGqw/J+dYJ X3EJstpajc179PCdZNkWb8mFEM1OGrBmJd4dE4OjXMAz5lgGnmh9FrBRiVpH0yQSgTyb fmjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=g5RTMo3cZi5CJpdjcBxAxRPO+ziLZygfzXi5BsAwtdU=; b=Z3z2ImvD42WhPk2wLPa8XRniYq7FCPQsJXbA3TODffAF1idAnQgT4FQc+7MbtDN+cF 9st2EfOMdzlukcmlrEQkxai/YLFyL/ByjxBJuh+QFBGGL5pQkF5kvJHmqcVXjuXz3oKi 8vDgchRg9tlFBlfQKC75K2qtOtTY9wP+ig6X0msgLNKxy+htbIk2ujUrSGnfuLqzSwwW UUpEdF9HOpVUgvpaUHXtxRjrNURPNe/t3FK+uZY/2vIbnpBNHqLReNNnjzEW6UFoymEs taFFi9mECrgzg4GpnUs5yhaFy/zNthfRvABtECRvJald1+pT26oHk6FxYMQIYZq4ZqjB Bx+w== X-Gm-Message-State: AOAM530D0hNUUNdiGwDG6JxdjSof+in5PK9gelYqO40WBJAKmOka5BZ/ 4iRmfrCC2//3yIi/SmytbNX4/XyRHjwA7qrF X-Google-Smtp-Source: ABdhPJynDQS5nzVI8wekz3siPX2KEyMrNjTgYh7q+cVQ4euNDf89TqFyM19ITD0GdMlB6dOcZaHn9g== X-Received: by 2002:adf:f2d1:: with SMTP id d17mr24440230wrp.254.1625847014466; Fri, 09 Jul 2021 09:10:14 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 13/17] hw/gpio/pl061: Convert to 3-phase reset and assert GPIO lines correctly on reset Date: Fri, 9 Jul 2021 17:09:59 +0100 Message-Id: <20210709161003.25874-14-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210709161003.25874-1-peter.maydell@linaro.org> References: <20210709161003.25874-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x435.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1625848490286100001 The PL061 comes out of reset with all its lines configured as input, which means they might need to be pulled to 0 or 1 depending on the 'pullups' and 'pulldowns' properties. Currently we do not assert these lines on reset; they will only be set whenever the guest first touches a register that triggers a call to pl061_update(). Convert the device to three-phase reset so we have a place where we can safely call qemu_set_irq() to set the floating lines to their correct values. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- hw/gpio/pl061.c | 29 +++++++++++++++++++++++++---- hw/gpio/trace-events | 1 + 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/hw/gpio/pl061.c b/hw/gpio/pl061.c index 5ba398fcd42..4002ab51544 100644 --- a/hw/gpio/pl061.c +++ b/hw/gpio/pl061.c @@ -446,13 +446,14 @@ static void pl061_write(void *opaque, hwaddr offset, return; } =20 -static void pl061_reset(DeviceState *dev) +static void pl061_enter_reset(Object *obj, ResetType type) { - PL061State *s =3D PL061(dev); + PL061State *s =3D PL061(obj); + + trace_pl061_reset(DEVICE(s)->canonical_path); =20 /* reset values from PL061 TRM, Stellaris LM3S5P31 & LM3S8962 Data She= et */ s->data =3D 0; - s->old_out_data =3D 0; s->old_in_data =3D 0; s->dir =3D 0; s->isense =3D 0; @@ -474,6 +475,24 @@ static void pl061_reset(DeviceState *dev) s->amsel =3D 0; } =20 +static void pl061_hold_reset(Object *obj) +{ + PL061State *s =3D PL061(obj); + int i, level; + uint8_t floating =3D pl061_floating(s); + uint8_t pullups =3D pl061_pullups(s); + + for (i =3D 0; i < N_GPIOS; i++) { + if (extract32(floating, i, 1)) { + continue; + } + level =3D extract32(pullups, i, 1); + trace_pl061_set_output(DEVICE(s)->canonical_path, i, level); + qemu_set_irq(s->out[i], level); + } + s->old_out_data =3D pullups; +} + static void pl061_set_irq(void * opaque, int irq, int level) { PL061State *s =3D (PL061State *)opaque; @@ -543,11 +562,13 @@ static Property pl061_props[] =3D { static void pl061_class_init(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); + ResettableClass *rc =3D RESETTABLE_CLASS(klass); =20 dc->vmsd =3D &vmstate_pl061; - dc->reset =3D &pl061_reset; dc->realize =3D pl061_realize; device_class_set_props(dc, pl061_props); + rc->phases.enter =3D pl061_enter_reset; + rc->phases.hold =3D pl061_hold_reset; } =20 static const TypeInfo pl061_info =3D { diff --git a/hw/gpio/trace-events b/hw/gpio/trace-events index eb5fb4701c6..1dab99c5604 100644 --- a/hw/gpio/trace-events +++ b/hw/gpio/trace-events @@ -20,6 +20,7 @@ pl061_input_change(const char *id, int gpio, int level) "= %s input %d changed to pl061_update_istate(const char *id, uint32_t istate, uint32_t im, int leve= l) "%s GPIORIS 0x%x GPIOIE 0x%x interrupt level %d" pl061_read(const char *id, uint64_t offset, uint64_t r) "%s offset 0x%" PR= Ix64 " value 0x%" PRIx64 pl061_write(const char *id, uint64_t offset, uint64_t value) "%s offset 0x= %" PRIx64 " value 0x%" PRIx64 +pl061_reset(const char *id) "%s reset" =20 # sifive_gpio.c sifive_gpio_read(uint64_t offset, uint64_t r) "offset 0x%" PRIx64 " value = 0x%" PRIx64 --=20 2.20.1