From patchwork Mon Mar 10 00:06:10 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: 872077 Delivered-To: patch@linaro.org Received: by 2002:a5d:64ce:0:b0:38f:210b:807b with SMTP id f14csp746213wri; Sun, 9 Mar 2025 17:11:57 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXtywQbX8goolba/D0K35qOW6KZ20ADT6RFsKW6/0IuLcxjlk2gG8ofKajMpWiBJs0XqRnZBQ==@linaro.org X-Google-Smtp-Source: AGHT+IFcjPgkE1VthThMlE4ff7F8s3lvnDbe4iiMBWBjPcZDpvv8czm3NxQVco6hx7zzjBJ957aG X-Received: by 2002:ac8:580f:0:b0:475:6af:9fb4 with SMTP id d75a77b69052e-4761194a8a8mr195880811cf.39.1741565517324; Sun, 09 Mar 2025 17:11:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1741565517; cv=none; d=google.com; s=arc-20240605; b=BJ6fpQsZD5YO45RZFIF9V9ERv1aU3Di8uvOSHv0u1Ha8Us+lR+0ZDuvVCCZ4NhEmkX BLfv/mhI0a7spWwnG1ZHGQ/Wl6lZ89YB3I54uOzPj/g1FNjDaWSye7TjmnyK9BTvMd4J ThoUdqEsZhF/3DzuXTmiQfeit4b0l1mQN3cldiCqDuobrX38ZO24KA+vZmTAxG3UYcwp 4WCf7brLS8ceeFooiquldhkdqX4L9/Rpc3kX0kvBDZxhDfXb1+Lkf22fznveC0nTNE3a +usPO0oEm6pw1zy++29ynmuQfQ675sMNeICAqlKe8EVvW0ooBIw2X8zU928mjtv4NthN 2sxA== 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=dQS2FpqOs5TSI58lEsf5ODh6U5Cq4SEzmJ94sUa1jSg=; fh=Mc7GqdYGxuhtze4Ix3Y2Ixoy7fotiI2S1dtodmkpCto=; b=MSY7oIOXvI8QREMmZvhsWQfdbyUtI5XJ8Tybr8Q03SsGbgwHZ2mQHGrSFeClVHhcuD 1MLe93c/0imtKgPhi2wHYDCclaEPsNxBeOiYT3efUG5zslC21i41IOSEmmzAP9Jd6/ss kIw9Uo6cNbL8XB5UPqlFyPP51ErqCo+Z1GDDydKu3UlP43f4OaEzzIXaLfSFqIZz6y3D fJXLCdgr+480dRZ3zprP+kg8g+mK5mchQi5Uv14XZRMiL/+cpeace5yEPzrbeecVFwMg QhWVoLobVZIbtrqhQsIV3WpQJL//dJzqPfBu5bTgEzejtCR01vUEV6cY+BsvXt02dalO qpYQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hDtuaXB+; 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 d75a77b69052e-476704ef45csi34212511cf.566.2025.03.09.17.11.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 Mar 2025 17:11:57 -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=hDtuaXB+; 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 1trQfR-0001vK-3F; Sun, 09 Mar 2025 20:06:49 -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 1trQfP-0001ud-Uv for qemu-devel@nongnu.org; Sun, 09 Mar 2025 20:06:47 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1trQfO-0007L6-0m for qemu-devel@nongnu.org; Sun, 09 Mar 2025 20:06:47 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-43bcc85ba13so28999095e9.0 for ; Sun, 09 Mar 2025 17:06:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1741565204; x=1742170004; 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=dQS2FpqOs5TSI58lEsf5ODh6U5Cq4SEzmJ94sUa1jSg=; b=hDtuaXB+7emPGfX07HSZgKmQPenHFt1Ikhz69OYJPeMkJobeRLLTq+Ypf6ntonqor/ q86+VPYQG0lAKu12tQN4/i9fNN6XWdrslzIszwIj8Pl4WPKCBwUXHDXaRSjfDIn2qkul X67GUpq/VLP8Dp0EzkRIZ3AT6BaH8/2xMXw56cNUvEjs4kYGJPZMAtcbgNdUMs6869Lm z3ZW9MylhPNjOxqTRK+J3/YWJkSZCvuIeKIiTP4ZKAKoNL75Ds0yYdsTG1iUlt7jRwYO 24DK4+xSfuHXr/gCssgbhzYfjjWOUuakbaGkcdzKoUAWwDVnMHfrlQKYZI5MGJLbht0z hFXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741565204; x=1742170004; 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=dQS2FpqOs5TSI58lEsf5ODh6U5Cq4SEzmJ94sUa1jSg=; b=UZz1SMnG1owA2ck+aELL2/eABq6LoaxA3ra2c3DBGlEhM5XXVcpaCh3mK63f0gmkun Kong9JAKqgJISuAA9VhlJ0EZTK092gYEq4zDGbChu7/41Gsxdd+q1O92ZJWE3btsndWD S7S1n7sZ+oU/BWozmdP97/60wy7kdpaKkMmJK+9jLRh7Ca6eVYiC97vmHOwtA4K5oca8 v9MPT/5ga3r4okRnSY3nazN8rdFekzhzIOcknZ3wsATrclm8JQWQD7fcQvJBVkyltAu4 iEIa4ADJLP7nyFsYSQ9we2vcDMCrBGPx4FiMYHZ2DxoZw+Jb3Z3rGmGcLD6ue4ymVFLh sdSw== X-Forwarded-Encrypted: i=1; AJvYcCVwM9WqMp8GhSOUQ5CF0CIsdQ2YYytkt7eiNIVbpton9qwTfIuLC6PhNpG1LpFTvPOaSgG2hyvpXC/6@nongnu.org X-Gm-Message-State: AOJu0Yy8Xfro3JzL3V6+8XNcyP29O3vt8Uw1VqejP9jw6S1EsnZHuplP tUjMgUfFufaCWut5Wfhjv9fnvD1+gdOaEWVsRs8+OsFSxdPg7QXImUcJmHug7uA4CwdBbUTOV/5 asqQ= X-Gm-Gg: ASbGnct7RcJ7Emr90/AC7Ik6L+HXHku7KQlMOn5nnSTpG2cAXBqvqoD7eEYS8QhCaTp Ilja6mPktgsYXbRjXqeqlxcQNGZz16T/gkKSwje1nEiZb3ckfNg6rYL23zizsTlYG017Dw1+W7b Q/mZWjp2sLiMQ7uFXrQr4M5r0au6nL22NfWDO4LgsWHDPoX14CAPZrrCmOEwA7x5Mn0vturEAd7 vySGQzRqFpiW57TWLLqGQObf52n4CwSPk4v9EFquZQtKv+0qLLGGstfufebEo9yaFa1I008a16t AZOi42N7j512YPQeAe+RITctpwb5ZlTP2uxW/oPvZoEtPYAixqt3sj2/ywikUy4v1syoHJGouvp mUX1wTgwcVr0frxCHzwcIU2pppEFndw== X-Received: by 2002:a05:600c:5129:b0:43c:f689:88ce with SMTP id 5b1f17b1804b1-43cf6898affmr12074285e9.20.1741565204360; Sun, 09 Mar 2025 17:06:44 -0700 (PDT) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43bdd8db6c7sm127555375e9.22.2025.03.09.17.06.43 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 09 Mar 2025 17:06:43 -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 04/14] hw/sd/sdhci: Include 'wp-inverted' property in quirk bitmask Date: Mon, 10 Mar 2025 01:06:10 +0100 Message-ID: <20250310000620.70120-5-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::32e; envelope-from=philmd@linaro.org; helo=mail-wm1-x32e.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.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_INVERTED_WRITE_PROTECT quirk definition. Replace 'wp_inverted' boolean by a bit in quirk bitmask. Signed-off-by: Philippe Mathieu-Daudé --- include/hw/sd/sdhci.h | 16 ++++++++++------ hw/arm/aspeed.c | 2 +- hw/sd/sdhci.c | 6 +++--- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/include/hw/sd/sdhci.h b/include/hw/sd/sdhci.h index 096d607f4b7..d2e4f0f0050 100644 --- a/include/hw/sd/sdhci.h +++ b/include/hw/sd/sdhci.h @@ -30,7 +30,14 @@ #include "hw/sd/sd.h" #include "qom/object.h" -/* SD/MMC host controller state */ +/* + * SD/MMC host controller state + * + * QEMU interface: + * + 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). + */ struct SDHCIState { /*< private >*/ union { @@ -99,11 +106,6 @@ struct SDHCIState { uint8_t endianness; uint8_t sd_spec_version; uint8_t uhs_mode; - /* - * Write Protect pin default active low for detecting SD card - * to be protected. Set wp_inverted to invert the signal. - */ - bool wp_inverted; }; typedef struct SDHCIState SDHCIState; @@ -114,6 +116,8 @@ typedef struct SDHCIState SDHCIState; enum { /* Controller does not provide transfer-complete interrupt when not busy. */ SDHCI_QUIRK_NO_BUSY_IRQ = 14, + /* Controller reports inverted write-protect state */ + SDHCI_QUIRK_INVERTED_WRITE_PROTECT = 16, }; #define TYPE_PCI_SDHCI "sdhci-pci" diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c index 98bf071139b..daee2376d50 100644 --- a/hw/arm/aspeed.c +++ b/hw/arm/aspeed.c @@ -412,7 +412,7 @@ static void aspeed_machine_init(MachineState *machine) if (amc->sdhci_wp_inverted) { for (i = 0; i < bmc->soc->sdhci.num_slots; i++) { object_property_set_bool(OBJECT(&bmc->soc->sdhci.slots[i]), - "wp-inverted", true, &error_abort); + "wp-inverted-quirk", true, &error_abort); } } if (machine->kernel_filename) { diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c index 1dc942a0e06..19c600d5bfc 100644 --- a/hw/sd/sdhci.c +++ b/hw/sd/sdhci.c @@ -274,7 +274,7 @@ static void sdhci_set_readonly(DeviceState *dev, bool level) { SDHCIState *s = (SDHCIState *)dev; - if (s->wp_inverted) { + if (s->quirks & BIT(SDHCI_QUIRK_INVERTED_WRITE_PROTECT)) { level = !level; } @@ -1555,12 +1555,12 @@ void sdhci_common_class_init(ObjectClass *klass, const void *data) 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_LINK("dma", SDHCIState, dma_mr, TYPE_MEMORY_REGION, MemoryRegion *), - DEFINE_PROP_BOOL("wp-inverted", SDHCIState, - wp_inverted, false), }; static void sdhci_sysbus_init(Object *obj)