Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 943EFF9D0E8 for ; Tue, 14 Apr 2026 17:23:19 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wChSJ-0005v8-9v; Tue, 14 Apr 2026 13:21:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wChSB-0005sG-Er; Tue, 14 Apr 2026 13:21:38 -0400 Received: from mail-a.sr.ht ([46.23.81.152]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wChS7-0007IE-RH; Tue, 14 Apr 2026 13:21:34 -0400 DKIM-Signature: a=rsa-sha256; bh=Eb4E4n4zzzhOAaaGQsl9QPIPVsuIUn1rdNE7TxwA3Ns=; c=simple/simple; d=git.sr.ht; h=From:Date:Subject:Reply-to:In-Reply-To:To:Cc; q=dns/txt; s=20240113; t=1776187286; v=1; b=WjQoEXMzIxRhob6xDzTR2EhdBMRyfvz43O14h2fYV/Vy16RY1eTicZngdrDwIRv4rBLi6ctY ZREiNkzog98vqSjPUgsL1bTH32DOcQZKak1VE2tQAT07M4U/2s44g52ix7NGfMONbp/o/UOcvd3 1Y89X/dYWGcStjJlQIprYHe2fvD/8zSxZFKsWPqqAYJf5OSa5gCyUCGJBsPPKLXZfJGwPVDkgM1 bmySpZ4UiS0xcYPVifGnakIkMsrPwBbOIq6n0aTN9yqxLKbcwF7nYYqVkAdNK0pYrJ4XvrrSp5t J1R95oZg7ZK2RMAu2f+NM16y+jmSIUCQHSGq3HNmVXl6A== Received: from git.sr.ht (unknown [46.23.81.155]) by mail-a.sr.ht (Postfix) with ESMTPSA id EF3CC20A36; Tue, 14 Apr 2026 17:21:25 +0000 (UTC) From: ~lexbaileylowrisc Date: Tue, 07 Apr 2026 10:43:43 +0100 Subject: [PATCH qemu v3 02/10] ot_uart: move to new reset API Message-ID: <177618728515.4917.14466194789826252277-2@git.sr.ht> X-Mailer: git.sr.ht In-Reply-To: <177618728515.4917.14466194789826252277-0@git.sr.ht> To: qemu-riscv@nongnu.org, Alistair Francis Cc: Paolo Bonzini , =?utf-8?q?Marc-Andr=C3=A9?= Lureau , Palmer Dabbelt , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei , Chao Liu , qemu-devel@nongnu.org, qemu-riscv@nongnu.org, Amit Kumar-Hermosillo , nabihestefan Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Received-SPF: pass client-ip=46.23.81.152; envelope-from=outgoing@sr.ht; helo=mail-a.sr.ht X-Spam_score_int: 17 X-Spam_score: 1.7 X-Spam_bar: + X-Spam_report: (1.7 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_96_XX=3.405, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: ~lexbaileylowrisc Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Lex Bailey switch from legacy_reset to new ResettableClass for OpenTitan UART device Signed-off-by: Lex Bailey --- hw/char/ot_uart.c | 16 +++++++++++++--- include/hw/char/ot_uart.h | 8 +++++++- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/hw/char/ot_uart.c b/hw/char/ot_uart.c index b3eb619641..9478af40f9 100644 --- a/hw/char/ot_uart.c +++ b/hw/char/ot_uart.c @@ -227,9 +227,14 @@ static void uart_write_tx_fifo(OtUARTState *s, const uin= t8_t *buf, (s->char_tx_time * 4)); } =20 -static void ot_uart_reset(DeviceState *dev) +static void ot_uart_reset_enter(Object *obj, ResetType type) { - OtUARTState *s =3D OT_UART(dev); + OtUARTClass *c =3D OT_UART_GET_CLASS(obj); + OtUARTState *s =3D OT_UART(obj); + + if (c->parent_phases.enter) { + c->parent_phases.enter(obj, type); + } =20 s->uart_intr_state =3D 0x00000000; s->uart_intr_state =3D 0x00000000; @@ -544,12 +549,16 @@ static void ot_uart_realize(DeviceState *dev, Error **e= rrp) static void ot_uart_class_init(ObjectClass *klass, const void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); + OtUARTClass *uc =3D OT_UART_CLASS(klass); + ResettableClass *rc =3D RESETTABLE_CLASS(klass); =20 - device_class_set_legacy_reset(dc, ot_uart_reset); dc->realize =3D ot_uart_realize; dc->vmsd =3D &vmstate_ot_uart; device_class_set_props(dc, ot_uart_properties); set_bit(DEVICE_CATEGORY_INPUT, dc->categories); + + resettable_class_set_parent_phases(rc, &ot_uart_reset_enter, NULL, NULL, + &uc->parent_phases); } =20 static const TypeInfo ot_uart_info =3D { @@ -557,6 +566,7 @@ static const TypeInfo ot_uart_info =3D { .parent =3D TYPE_SYS_BUS_DEVICE, .instance_size =3D sizeof(OtUARTState), .instance_init =3D ot_uart_init, + .class_size =3D sizeof(OtUARTClass), .class_init =3D ot_uart_class_init, }; =20 diff --git a/include/hw/char/ot_uart.h b/include/hw/char/ot_uart.h index 517324b65d..fee2128f90 100644 --- a/include/hw/char/ot_uart.h +++ b/include/hw/char/ot_uart.h @@ -34,7 +34,7 @@ #define OT_UART_CLOCK 50000000 /* 50MHz clock */ =20 #define TYPE_OT_UART "ot-uart" -OBJECT_DECLARE_SIMPLE_TYPE(OtUARTState, OT_UART) +OBJECT_DECLARE_TYPE(OtUARTState, OtUARTClass, OT_UART) =20 struct OtUARTState { /* */ @@ -70,4 +70,10 @@ struct OtUARTState { qemu_irq tx_empty; qemu_irq rx_overflow; }; + +struct OtUARTClass { + SysBusDeviceClass parent_class; + ResettablePhases parent_phases; +}; + #endif /* HW_OT_UART_H */ --=20 2.49.1