From patchwork Wed Jun 3 05:24:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 1302804 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=roeck-us.net Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=uHjHfLiM; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 49cHS830Fxz9sSd for ; Wed, 3 Jun 2020 15:25:44 +1000 (AEST) Received: from localhost ([::1]:43362 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jgLuI-0007Zc-5g for incoming@patchwork.ozlabs.org; Wed, 03 Jun 2020 01:25:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53328) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jgLsv-0005A1-9y; Wed, 03 Jun 2020 01:24:17 -0400 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]:42141) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jgLsu-0001mw-3Q; Wed, 03 Jun 2020 01:24:16 -0400 Received: by mail-pf1-x442.google.com with SMTP id b5so811133pfp.9; Tue, 02 Jun 2020 22:24:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=AB2Jl/wdvBv/H9RpxT3VIG2aEOzEOYj2DqVXmt1vkYw=; b=uHjHfLiMGUx0W+hwWN33p34274T0V9gS8guAM1hF770rKOTP+Y2/WtRJAO8dpG5ASu YcCJ85WdazBZvR9Sh1KdZhLXxCyZw9Ybysyfu6W0P/LZbNBf/TUOR75hKNHp0QJ3GIDk u2k/QVwzuBwpYVJNWf5lkqAYiD3Dp1qJROCMuckVwAKoSDViMdyys8O9/BRbQQX0J1W0 EqtQwYxIOswgw0+iH6ksKgI4c8zjZsWs+nQgV5dnA2x5/uJoJ0xOnLNP0SyGl8wybqZe 7I+EiM/PdHe1zupq0LfzTMNTOgki+C6CBG6N0SOP7lPvXYl36fFRqDs7ir63Wyc1YGmI MQvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=AB2Jl/wdvBv/H9RpxT3VIG2aEOzEOYj2DqVXmt1vkYw=; b=j2rpz40WK1/iOWigzSn19E0R5ItmkqJ8flVqMYzoS9Q6UJvvt/sq5Tiy/QZbrfhPld CKzNRY+UnBK09cJA0//wiE1KT0bXYliOKMDs5xi8snq4M5HEBF+k+X2ZAWlweJXf7IO0 1AEOsDdz6BNzKSmBQOGLtKg9VtldEgA1L/lLaP49590eRFzyz4HCTj2isuIyPhdxU4cY 4y+sZcUFKL5J5NeC05TOC4l7JockMzmTwc5jW7ZKqwGyywoa5X+i8DWa/GqDRqfTfAxs sGIx6m6Ogabmk18mvzG/IlzKuOK6UuqW+5wRF6aqwuLb0s7sxVWNExFYuHJYPJ/dZugi 3laQ== X-Gm-Message-State: AOAM532qZ2u9+BbRUUHUOELJxQ0tiNnrHCn8PuKCt5F58nurWb/k3Qq3 WwtWQLYW+elTMkTT9QXVM7k= X-Google-Smtp-Source: ABdhPJwwtbDhgIDC4ILXu1+RguxMoOozkfmoUteCMSeVCj7D6V1QZRqMRkKyRMwp2kLku0GLFH78hQ== X-Received: by 2002:a63:774d:: with SMTP id s74mr28305393pgc.315.1591161854170; Tue, 02 Jun 2020 22:24:14 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id h4sm882445pjq.55.2020.06.02.22.24.13 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jun 2020 22:24:13 -0700 (PDT) From: Guenter Roeck To: Peter Maydell Subject: [PATCH 1/2] sd: sdhci: Implement basic vendor specific register support Date: Tue, 2 Jun 2020 22:24:03 -0700 Message-Id: <20200603052404.30788-2-linux@roeck-us.net> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200603052404.30788-1-linux@roeck-us.net> References: <20200603052404.30788-1-linux@roeck-us.net> Received-SPF: pass client-ip=2607:f8b0:4864:20::442; envelope-from=groeck7@gmail.com; helo=mail-pf1-x442.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN 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: , Cc: Andrey Smirnov , qemu-devel@nongnu.org, Jean-Christophe Dubois , qemu-arm@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Guenter Roeck Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" The Linux kernel's IMX code now uses vendor specific commands. This results in endless warnings when booting the Linux kernel. sdhci-esdhc-imx 2194000.usdhc: esdhc_wait_for_card_clock_gate_off: card clock still not gate off in 100us!. Implement support for the vendor specific command implemented in IMX hardware to be able to avoid this warning. Signed-off-by: Guenter Roeck Acked-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé Reviewed-by: Philippe Mathieu-Daudé --- hw/sd/sdhci-internal.h | 5 +++++ hw/sd/sdhci.c | 18 +++++++++++++++++- include/hw/sd/sdhci.h | 5 +++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/hw/sd/sdhci-internal.h b/hw/sd/sdhci-internal.h index e7c8a523b5..e8c753d6d1 100644 --- a/hw/sd/sdhci-internal.h +++ b/hw/sd/sdhci-internal.h @@ -75,6 +75,7 @@ #define SDHC_CMD_INHIBIT 0x00000001 #define SDHC_DATA_INHIBIT 0x00000002 #define SDHC_DAT_LINE_ACTIVE 0x00000004 +#define SDHC_IMX_CLOCK_GATE_OFF 0x00000080 #define SDHC_DOING_WRITE 0x00000100 #define SDHC_DOING_READ 0x00000200 #define SDHC_SPACE_AVAILABLE 0x00000400 @@ -289,7 +290,10 @@ extern const VMStateDescription sdhci_vmstate; #define ESDHC_MIX_CTRL 0x48 + #define ESDHC_VENDOR_SPEC 0xc0 +#define ESDHC_IMX_FRC_SDCLK_ON (1 << 8) + #define ESDHC_DLL_CTRL 0x60 #define ESDHC_TUNING_CTRL 0xcc @@ -326,6 +330,7 @@ extern const VMStateDescription sdhci_vmstate; #define DEFINE_SDHCI_COMMON_PROPERTIES(_state) \ DEFINE_PROP_UINT8("sd-spec-version", _state, sd_spec_version, 2), \ DEFINE_PROP_UINT8("uhs", _state, uhs_mode, UHS_NOT_SUPPORTED), \ + DEFINE_PROP_UINT8("vendor", _state, vendor, SDHCI_VENDOR_NONE), \ \ /* Capabilities registers provide information on supported * features of this specific host controller implementation */ \ diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c index 1b75d7bab9..eb2be6529e 100644 --- a/hw/sd/sdhci.c +++ b/hw/sd/sdhci.c @@ -1569,11 +1569,13 @@ static uint64_t usdhc_read(void *opaque, hwaddr offset, unsigned size) } break; + case ESDHC_VENDOR_SPEC: + ret = s->vendor_spec; + break; case ESDHC_DLL_CTRL: case ESDHC_TUNE_CTRL_STATUS: case ESDHC_UNDOCUMENTED_REG27: case ESDHC_TUNING_CTRL: - case ESDHC_VENDOR_SPEC: case ESDHC_MIX_CTRL: case ESDHC_WTMK_LVL: ret = 0; @@ -1596,7 +1598,21 @@ usdhc_write(void *opaque, hwaddr offset, uint64_t val, unsigned size) case ESDHC_UNDOCUMENTED_REG27: case ESDHC_TUNING_CTRL: case ESDHC_WTMK_LVL: + break; + case ESDHC_VENDOR_SPEC: + s->vendor_spec = value; + switch (s->vendor) { + case SDHCI_VENDOR_IMX: + if (value & ESDHC_IMX_FRC_SDCLK_ON) { + s->prnsts &= ~SDHC_IMX_CLOCK_GATE_OFF; + } else { + s->prnsts |= SDHC_IMX_CLOCK_GATE_OFF; + } + break; + default: + break; + } break; case SDHC_HOSTCTL: diff --git a/include/hw/sd/sdhci.h b/include/hw/sd/sdhci.h index c6868c9699..5d9275f3d6 100644 --- a/include/hw/sd/sdhci.h +++ b/include/hw/sd/sdhci.h @@ -74,6 +74,7 @@ typedef struct SDHCIState { uint16_t acmd12errsts; /* Auto CMD12 error status register */ uint16_t hostctl2; /* Host Control 2 */ uint64_t admasysaddr; /* ADMA System Address Register */ + uint16_t vendor_spec; /* Vendor specific register */ /* Read-only registers */ uint64_t capareg; /* Capabilities Register */ @@ -96,8 +97,12 @@ typedef struct SDHCIState { uint32_t quirks; uint8_t sd_spec_version; uint8_t uhs_mode; + uint8_t vendor; /* For vendor specific functionality */ } SDHCIState; +#define SDHCI_VENDOR_NONE 0 +#define SDHCI_VENDOR_IMX 1 + /* * Controller does not provide transfer-complete interrupt when not * busy. From patchwork Wed Jun 3 05:24:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 1302807 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=roeck-us.net Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=hoE7ifJ1; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 49cHTP21zBz9sTD for ; Wed, 3 Jun 2020 15:26:49 +1000 (AEST) Received: from localhost ([::1]:46288 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jgLvL-0000Vx-35 for incoming@patchwork.ozlabs.org; Wed, 03 Jun 2020 01:26:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53332) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jgLsw-0005CK-5a; Wed, 03 Jun 2020 01:24:18 -0400 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:34007) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jgLsv-0001n5-DL; Wed, 03 Jun 2020 01:24:17 -0400 Received: by mail-pf1-x441.google.com with SMTP id z64so836214pfb.1; Tue, 02 Jun 2020 22:24:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=zAVf0eC1i4TO3oZMCKOs1PygTBx2n4QN+KOvIE2jWCE=; b=hoE7ifJ1CnaMm7b0C2B/35OGXnArj+qHcJ+t6LHEvO7OxEMf6f5viWFZWmd/BNbeOB 3GBLhPPQ7REZPZz7m2SWrzxne+KpIZeFQcXtgERS0GAKZJxu5C3czpBd739YUifTkQOX 0vhkit+xYNnA6ylkf76e8uwfcg5eLfZ2gvLOd1hwWb/K5EL7EOiHI4k+wymZUa8JkMyW pH8h8yGCnkGI6pGTWw9J98O7M3tUGf6dqno88kTHtgZkT7kHue3rzG1M0qxoKxNu1OzR v6wO8xj8J5rn1QSsSsVm4x0QoNZaAv1Ks7FrL0+96M+Bi2YpS/aXBaadQ9UD1D0TWGoN jJUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=zAVf0eC1i4TO3oZMCKOs1PygTBx2n4QN+KOvIE2jWCE=; b=RHavf/S8TTojzby6RVveH+CEYJMxTy+1oldEBCPmq+Ep0xe1g2oMUILmm7rq62Fk14 uQeoIK29F8Fb1xswkSqm1ANLaodzMyhcZUVwJrzhsNJa4n+UJWosGWl7og21bgpaUfpH rUQBwhDplfWStrd8K0PbHdH3G1/RI4+Ks2KXyjYcuy+Lp6IsHErweFormuAfDG5SuZMG uCCA8J5EkvFO+h9peL9Xkj+buuhr5mZ2lr1OYJe7ndg9SE+eoH+IxdEZPu+qhwanpf9F 46eKaUXHSAgMEb72n18U/+ERaPhHDL9V5dl2qbIQxYxir7WLLMB2R8yp64cI3aAxe/I0 Kv6A== X-Gm-Message-State: AOAM533++ZylU3sLFS1HOTakZcft5nZxEob3QXebXex4PudP2XqC3YLM IA0ZjmmOqvSCbwNmL10q74k= X-Google-Smtp-Source: ABdhPJyJFcw+mKlnH02h4cUeNyczdZvirF/04U55FNROhb2Ah8m8yG0LFc0nbPWRsUuQI1Vdwi1hLQ== X-Received: by 2002:a63:6dc2:: with SMTP id i185mr26677561pgc.250.1591161855764; Tue, 02 Jun 2020 22:24:15 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id t2sm719587pfb.64.2020.06.02.22.24.15 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jun 2020 22:24:15 -0700 (PDT) From: Guenter Roeck To: Peter Maydell Subject: [PATCH 2/2] hw: arm: Set vendor property for IMX SDHCI emulations Date: Tue, 2 Jun 2020 22:24:04 -0700 Message-Id: <20200603052404.30788-3-linux@roeck-us.net> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200603052404.30788-1-linux@roeck-us.net> References: <20200603052404.30788-1-linux@roeck-us.net> Received-SPF: pass client-ip=2607:f8b0:4864:20::441; envelope-from=groeck7@gmail.com; helo=mail-pf1-x441.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN 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: , Cc: Andrey Smirnov , qemu-devel@nongnu.org, Jean-Christophe Dubois , qemu-arm@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Guenter Roeck Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Set vendor property to IMX to enable IMX specific functionality in sdhci code. Signed-off-by: Guenter Roeck Tested-by: Philippe Mathieu-Daudé --- hw/arm/fsl-imx25.c | 2 ++ hw/arm/fsl-imx6.c | 2 ++ hw/arm/fsl-imx6ul.c | 2 ++ hw/arm/fsl-imx7.c | 2 ++ 4 files changed, 8 insertions(+) diff --git a/hw/arm/fsl-imx25.c b/hw/arm/fsl-imx25.c index cdaa79c26b..2cbd985e93 100644 --- a/hw/arm/fsl-imx25.c +++ b/hw/arm/fsl-imx25.c @@ -274,6 +274,8 @@ static void fsl_imx25_realize(DeviceState *dev, Error **errp) &err); object_property_set_uint(OBJECT(&s->esdhc[i]), IMX25_ESDHC_CAPABILITIES, "capareg", &err); + object_property_set_uint(OBJECT(&s->esdhc[i]), SDHCI_VENDOR_IMX, + "vendor", &err); object_property_set_bool(OBJECT(&s->esdhc[i]), true, "realized", &err); if (err) { error_propagate(errp, err); diff --git a/hw/arm/fsl-imx6.c b/hw/arm/fsl-imx6.c index f58c85aa8c..8e9a94e4d7 100644 --- a/hw/arm/fsl-imx6.c +++ b/hw/arm/fsl-imx6.c @@ -350,6 +350,8 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp) &err); object_property_set_uint(OBJECT(&s->esdhc[i]), IMX6_ESDHC_CAPABILITIES, "capareg", &err); + object_property_set_uint(OBJECT(&s->esdhc[i]), SDHCI_VENDOR_IMX, + "vendor", &err); object_property_set_bool(OBJECT(&s->esdhc[i]), true, "realized", &err); if (err) { error_propagate(errp, err); diff --git a/hw/arm/fsl-imx6ul.c b/hw/arm/fsl-imx6ul.c index 3ecb212da6..ce1462927c 100644 --- a/hw/arm/fsl-imx6ul.c +++ b/hw/arm/fsl-imx6ul.c @@ -505,6 +505,8 @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) FSL_IMX6UL_USDHC2_IRQ, }; + object_property_set_uint(OBJECT(&s->usdhc[i]), SDHCI_VENDOR_IMX, + "vendor", &error_abort); object_property_set_bool(OBJECT(&s->usdhc[i]), true, "realized", &error_abort); diff --git a/hw/arm/fsl-imx7.c b/hw/arm/fsl-imx7.c index 89c3b64c06..dbf16b2814 100644 --- a/hw/arm/fsl-imx7.c +++ b/hw/arm/fsl-imx7.c @@ -416,6 +416,8 @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp) FSL_IMX7_USDHC3_IRQ, }; + object_property_set_uint(OBJECT(&s->usdhc[i]), SDHCI_VENDOR_IMX, + "vendor", &error_abort); object_property_set_bool(OBJECT(&s->usdhc[i]), true, "realized", &error_abort);