From patchwork Mon Mar 10 00:06:11 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 871982 Delivered-To: patch@linaro.org Received: by 2002:a5d:64ce:0:b0:38f:210b:807b with SMTP id f14csp745199wri; Sun, 9 Mar 2025 17:08:27 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWYJs5nzt2JcFp5hJinlh+ItcDpeV6sgUqFe+s9H4tAKC4xowKhUeSxcdThZG8zYRQot8gUcQ==@linaro.org X-Google-Smtp-Source: AGHT+IFUyDGC0n/vHbh6kiQ+iujKWCvEv9syCrLGXvaztOyZuSXibgjl5rsAZ40bBtA2EkPoXPzh X-Received: by 2002:a05:620a:2811:b0:7c5:3c62:804c with SMTP id af79cd13be357-7c53c6281demr1276940785a.21.1741565307782; Sun, 09 Mar 2025 17:08:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1741565307; cv=none; d=google.com; s=arc-20240605; b=PBmOMQ6//tFvNnaWh2a/VWdbV9BKbFsMeWF6ogIaHeUENuzG5uL9kyWBQ+qjKdW7P2 qMIh7mCNmP+w3/V9bSRk+rAX2ma8LSPPE1q3aOHqQYt3PshOQ503nVD9bphUGnlhBRDK NN2yrIWKQm/GfcVzxy388T/mUIsW5y35apwrC3jNIlT+SLKq1saVTQgjSa03gBHHKJXz u95d5mXkurxULtgSficMGYldTN6h+LXUNiPEBV7Nor4Wy6sBwgYHpJO3Gpe/wlTBL74p fRN1oHDs6nrbYgxLSt5AdTT4U3OZDfGinuy9+kOnhN+Oc+d/Thi1ZQBJGdYdjQUwCWRI MhxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=vtO10CroBFmuxTQ9PueWoinPmmKwM9K54hdlvVGKzAE=; fh=0ncRnzIv9ontU6ZIxsExrpi+jJTl2Gw4vu9iiR8W9Uc=; b=Q7xDY/zHa+6MG25KL0R5HJBKnizMMgEa2giKf/faV/S2QyKtmIonBIBsNz4r+unWtZ iSnfPTSjXWTaS+s92RPQUM8ZB9s8YoeBjuxOlev+hx0Eh5gSDtmjZq9VapTfX5N7Dkjs AFV3IQ9ot1ChZz8JyIhAqIJRH6llNMb40HjknH5+xch6Kykbk8xjaIy3cCI/lKfW65ct oJGpkSvl+Dgdl5RvGLI+/k25ZuPYApH4RAGvTmnFroWt7+QhzJzQ0+MeOC01bt9qzH1w kLGB1HB8Fl3y61ZQoLFl9V1AXv0MRP9svxTLA3hBclzuogXxiVayvyewuUfcPI9WAUtp an9A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BCNszlUo; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7c556a50a21si35153585a.588.2025.03.09.17.08.27 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 Mar 2025 17:08:27 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BCNszlUo; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1trQfb-00022b-LB; Sun, 09 Mar 2025 20:07:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1trQfX-00020f-7c for qemu-devel@nongnu.org; Sun, 09 Mar 2025 20:06:55 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1trQfT-0007MJ-OM for qemu-devel@nongnu.org; Sun, 09 Mar 2025 20:06:54 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-43ce70f9afbso12639525e9.0 for ; Sun, 09 Mar 2025 17:06:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1741565210; x=1742170010; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vtO10CroBFmuxTQ9PueWoinPmmKwM9K54hdlvVGKzAE=; b=BCNszlUosgkoC0FflU7TUIVgnJwJEjU70ZlfSChey97FnYKWjbcnJp9hHIL7ob7nCj i3IIeLieE4oX0uMr/tR6xKqrxucI0mHWiptKlx2P4SoAa6aYa+DW3CJYgAU7fkwRGrwq TThsrhVIgN69nP4V6ibRomM4QQPJodZptrrHN5oaD+vLuDft+xl3cQGvtltjLPWJD/8D 4FJZbDIFhefL9f9wkJ1IwcGJ2YQUi1CRkh0vxOcEJWfpHxpaeAy/WI/c9wfyKkATciTa kir5AylEdZqfTzw81u3jKHDTMX7FfbAryDFpHZsuFph6C5zx2frdD/YwGMfN0X0Glnu0 240w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741565210; x=1742170010; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vtO10CroBFmuxTQ9PueWoinPmmKwM9K54hdlvVGKzAE=; b=Ks9Z7fe326/AvMZOP6yZcLTjb3LxGOxJpIQ82mDESE9ZGlThwqvV1IfFZO1p/vofD9 IhqjwqQlJoViqWiZWMZX8bbApo0jjOdxU2rhDApsft7KGCyKjV4kLFW8BT9FRyYfbjkv VDS0SKoPY9bPXsbUWXJjZNGOvjIl+x0U7s7u7UYaluFAvFs6WsYaB8dz93PvVWfNXkcO q+08uHkwDTAAr4lJK++AXTL7dEmilKv2XxkPtfoYjZT11gqJnZrnYr8lW54UovBWACZB gQCOWkgH4nozmgH125AVW2ZUak++mh/Fkuwem4rOau4CcyuC1hApxwRY/nGn0vRYXFN9 /mYA== X-Forwarded-Encrypted: i=1; AJvYcCVbtRvJRNMX2N8rEwqFHlcRrUF2ifXNW80/qlongrwqZN6YZdI9pUBYPZExMjGFdWQNHICmPm9pODsW@nongnu.org X-Gm-Message-State: AOJu0Yw0LqRsY5kTK6m2HX5GZMOLgrSMloG2bxAvSjwGum6DOKYQ09TQ 3Ck6JVz8fCcIWa43RzZ2XF2tB2+tgZ21rYKIDv1SH0UwTBMaEN8QHf/UZOdt+yjbvpj7o1Id5uq MsFc= X-Gm-Gg: ASbGncsJs6lec8ETNJ81Rtppni3DZ456pQZvcIU/xCEtyH99bgSrdBMd5RySZjoFesh h6esMn1qTTY4rCbVKUT3iKYPjNIcBUpMxhdSV8NPJGtFeYvUCiQUQBcQf2E22UiSK1XX994RJb0 ClqRFaZHtgoZhy7mk9qBtSrRMDERcJtXQIvuBSbbEOpOhDjQZ6ux3RBbS9VnrKa+1iMpWeCp5Kb fp37DDHbp99dkjCqzmHAYsBepdwwtLCq5YHPm+DMuCn+9mbpIKCU5u8ab68Ezmr9nMUi+JT/HOH Op9dUkRP6pd8IoVTQa3Kr6/95NA8IisqTDqVPzjzT/OjqAu+ATycyNKZbs0yKuMfQH3CRB9H7Fh 9bnxHbtVCXMtvbcj/FAE= X-Received: by 2002:a05:600c:3ba1:b0:43c:fbbf:7bf1 with SMTP id 5b1f17b1804b1-43cfbbf7eb2mr1844265e9.30.1741565210286; Sun, 09 Mar 2025 17:06:50 -0700 (PDT) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3912bfdfad7sm13082199f8f.26.2025.03.09.17.06.48 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 09 Mar 2025 17:06:48 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: BALATON Zoltan , qemu-devel@nongnu.org Cc: Steven Lee , Joel Stanley , Bernhard Beschow , Peter Maydell , qemu-arm@nongnu.org, Andrey Smirnov , Paolo Bonzini , Bin Meng , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Eduardo Habkost , qemu-ppc@nongnu.org, =?utf-8?q?Danie?= =?utf-8?q?l_P=2E_Berrang=C3=A9?= , Guenter Roeck , Andrew Jeffery , Troy Lee , Jean-Christophe Dubois , =?utf-8?q?Philippe_Mathieu-Da?= =?utf-8?q?ud=C3=A9?= , qemu-block@nongnu.org, Jamin Lin Subject: [PATCH v5 05/14] hw/sd/sdhci: Include 'pending-insert-quirk' property in quirk bitmask Date: Mon, 10 Mar 2025 01:06:11 +0100 Message-ID: <20250310000620.70120-6-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250310000620.70120-1-philmd@linaro.org> References: <20250310000620.70120-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=philmd@linaro.org; helo=mail-wm1-x32a.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=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Import Linux's SDHCI_QUIRK_RESTORE_IRQS_AFTER_RESET quirk definition. Replace 'pending_insert_quirk' boolean (originally introduce in commit 0a7ac9f9e72 "sdhci: quirk property for card insert interrupt status on Raspberry Pi") by a bit in quirk bitmask. Signed-off-by: Philippe Mathieu-Daudé --- include/hw/sd/sdhci.h | 5 ++++- hw/sd/sdhci.c | 8 ++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/include/hw/sd/sdhci.h b/include/hw/sd/sdhci.h index d2e4f0f0050..2e6e719df7b 100644 --- a/include/hw/sd/sdhci.h +++ b/include/hw/sd/sdhci.h @@ -34,6 +34,8 @@ * SD/MMC host controller state * * QEMU interface: + * + QOM property "pending-insert-quirk" re-enables pending "card inserted" + * IRQ after reset (used by the Raspberry Pi controllers). * + QOM property "wp-inverted-quirk" inverts the Write Protect pin * polarity (by default the polarity is active low for detecting SD * card to be protected). @@ -101,7 +103,6 @@ struct SDHCIState { /* RO Host Controller Version Register always reads as 0x2401 */ /* Configurable properties */ - bool pending_insert_quirk; /* Quirk for Raspberry Pi card insert int */ uint32_t quirks; uint8_t endianness; uint8_t sd_spec_version; @@ -118,6 +119,8 @@ enum { SDHCI_QUIRK_NO_BUSY_IRQ = 14, /* Controller reports inverted write-protect state */ SDHCI_QUIRK_INVERTED_WRITE_PROTECT = 16, + /* Controller losing signal/interrupt enable states after reset */ + SDHCI_QUIRK_RESTORE_IRQS_AFTER_RESET = 19, }; #define TYPE_PCI_SDHCI "sdhci-pci" diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c index 19c600d5bfc..d1b1b187874 100644 --- a/hw/sd/sdhci.c +++ b/hw/sd/sdhci.c @@ -320,7 +320,7 @@ static void sdhci_poweron_reset(DeviceState *dev) sdhci_reset(s); - if (s->pending_insert_quirk) { + if (s->quirks & BIT(SDHCI_QUIRK_RESTORE_IRQS_AFTER_RESET)) { s->pending_insert_state = true; } } @@ -1307,7 +1307,7 @@ sdhci_write(void *opaque, hwaddr offset, uint64_t val, unsigned size) * appears when first enabled after power on */ if ((s->norintstsen & SDHC_NISEN_INSERT) && s->pending_insert_state) { - assert(s->pending_insert_quirk); + assert(s->quirks & BIT(SDHCI_QUIRK_RESTORE_IRQS_AFTER_RESET)); s->norintsts |= SDHC_NIS_INSERT; s->pending_insert_state = false; } @@ -1557,8 +1557,8 @@ static const Property sdhci_sysbus_properties[] = { DEFINE_SDHCI_COMMON_PROPERTIES(SDHCIState), DEFINE_PROP_BIT("wp-inverted-quirk", SDHCIState, quirks, SDHCI_QUIRK_INVERTED_WRITE_PROTECT, false), - DEFINE_PROP_BOOL("pending-insert-quirk", SDHCIState, pending_insert_quirk, - false), + DEFINE_PROP_BIT("pending-insert-quirk", SDHCIState, quirks, + SDHCI_QUIRK_RESTORE_IRQS_AFTER_RESET, false), DEFINE_PROP_LINK("dma", SDHCIState, dma_mr, TYPE_MEMORY_REGION, MemoryRegion *), };