From patchwork Wed Jun 3 14:52:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 1303049 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=FTHGmDYx; 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 49cXB46VyPz9sRN for ; Thu, 4 Jun 2020 00:59:24 +1000 (AEST) Received: from localhost ([::1]:37928 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jgUrS-0002s0-LG for incoming@patchwork.ozlabs.org; Wed, 03 Jun 2020 10:59:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35740) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jgUlO-0007RQ-7c; Wed, 03 Jun 2020 10:53:06 -0400 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]:37382) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jgUlN-0000XH-Bd; Wed, 03 Jun 2020 10:53:05 -0400 Received: by mail-pg1-x544.google.com with SMTP id d10so1924123pgn.4; Wed, 03 Jun 2020 07:53:04 -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 :mime-version:content-transfer-encoding; bh=Kr3HUN5/YkECxPtjDxbpJDVaFQAB0Lcue4RVnkTaxI4=; b=FTHGmDYx15mPMYum2iUIhLJjAnlYqWq5IaLMBXrbMHu4Xm0PULiknnnuuR00P9+rsn iSUQhpn/6fLIsmSaH1nZMRACpDodQ6Y03AFKdqphOO8huPdzFom8ln6wjnWFW4FQKCfG jVQBCAo9ZbVrv6DkhG9t4sn2obDMFLcrnEGwhB0MxfsHAVIMICJXvVZMKi5ahvW/YXS1 xpylBEvsnO544QxUxv95pIJ66tO+CKtIuQ1P5r9bNwypO4/yvs+6tOjP/IbLo1KUWygb awM9JtJXe35VAXOdfIqa0w3/hX/m5Izsomd6jpx9aycVapjlmvfGtirUZ2x596NLaBtJ ZNcw== 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:mime-version:content-transfer-encoding; bh=Kr3HUN5/YkECxPtjDxbpJDVaFQAB0Lcue4RVnkTaxI4=; b=JnwVObRdNTp7H9KlFJ5ABzOuVIHxi3ZwOCKWmlmDhCfd9L8/mh9VFenVtNsz+ZCeEK kMmIA0avn/N00R6AisbveBg2Ii2GnDPukorxjXA5SXR5vdTntvobCYyaRymLo+7vUxcM CInVPNXqiPnaJF/oCvo6BmvRcBNAVYwSbaaVrdKCEhKEbDlNoNmtq3zOCadvx02+0R4c XTjJzGve1DIlYl701B53XG0AFEn12aOaXYY8X+ffn8vHiJeth9mY8qx/9/UVgxkZ1eEL gxIXseBcmUuf4tjG9JV9uURbLPFjL4ihdQ7fGL5VJlSzezbtAagq8Rz3mSQCuqslycos muDg== X-Gm-Message-State: AOAM532DcgpMuxuxzE3bmTo2VYKKGWjFgdy0+xSMBum7SIBAUf+SmczR EQTpsweC8PmTYZTdINZyJHg= X-Google-Smtp-Source: ABdhPJx7dCZhPOf7/dogx3NdQyPWlsYb0KRH8Kg4gmXSsvNSgCbMfPnO+SFKuYP3dBkbkH3FypgTuA== X-Received: by 2002:a63:e454:: with SMTP id i20mr28733828pgk.440.1591195983522; Wed, 03 Jun 2020 07:53:03 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id e124sm2141068pfh.140.2020.06.03.07.53.02 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 03 Jun 2020 07:53:03 -0700 (PDT) From: Guenter Roeck To: Peter Maydell Subject: [PATCH v2 1/2] sd: sdhci: Implement basic vendor specific register support Date: Wed, 3 Jun 2020 07:52:57 -0700 Message-Id: <20200603145258.195920-2-linux@roeck-us.net> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200603145258.195920-1-linux@roeck-us.net> References: <20200603145258.195920-1-linux@roeck-us.net> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::544; envelope-from=groeck7@gmail.com; helo=mail-pg1-x544.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. Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé Signed-off-by: Guenter Roeck --- v2: Added Philippe's Tested-by: and Reviewed-by: tags 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 14:52:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 1303058 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=FHv1hnt4; 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 49cXHs6Sw2z9sTN for ; Thu, 4 Jun 2020 01:04:25 +1000 (AEST) Received: from localhost ([::1]:55594 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jgUwJ-0002PG-LS for incoming@patchwork.ozlabs.org; Wed, 03 Jun 2020 11:04:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35748) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jgUlP-0007V5-KA; Wed, 03 Jun 2020 10:53:07 -0400 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]:41110) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jgUlO-0000XT-OF; Wed, 03 Jun 2020 10:53:07 -0400 Received: by mail-pf1-x443.google.com with SMTP id 64so1755875pfg.8; Wed, 03 Jun 2020 07:53:06 -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 :mime-version:content-transfer-encoding; bh=ZOFbPO8NF0Qt4pG213J4v1h/uFGzFUhLJULtgTQw8KA=; b=FHv1hnt4ZS4Y4rmRV1IDn8cKMySJHpNxxKmvFTfXnyjGXrgWsbvASSV+9bAgmTs0wL uxQXLTyDxZeZeHEv3v+bFP5SeMJCDvUYF2DxuChwqTC72oUd5fOv7dPPHyx6T6PLpwbe VgIb9I267EJcQF4rsqXf1o0aMEjRg0rQvfJPDDIFEl3OWRqWr3yyHsECP58J2H42hz0t SOzXpLH2bKdlDTWM8JkE4Yto9RM1s5BR4qHjv2jJKHXnozGqNc359Yt34IoNkmr3V3+k swsaI45DlaX2tvuJPTrY8fKn3giyD4elDLRoPHrmAlZgjnQVKv3YSPHAK6oV1u//m3ec zYZA== 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:mime-version:content-transfer-encoding; bh=ZOFbPO8NF0Qt4pG213J4v1h/uFGzFUhLJULtgTQw8KA=; b=UMEaBknKkZsujRZWp2vyR0jWQocvV3seeBoPIfq0t+vKxPo6xWOBIwcKZ3ZMq6dA1I ZEo7hu2lcKjydtziMgwdRi0C+CSl6fmleN5UfeqjS9DzsGgiklUwbfhicFcGy5siV4lb UGa+ZS0CdqNJq19kHq1ZWUbM4R+45UzWIABZ3oTJHzmfq7YR3nBiaXZ0tBTadmL0qGJs SSa7w4Y/C9xrZiE/3fIcIB5ZXb1ppqMacbfTmxR1yM7l4TP4lPsC6rzklixSX/Asv606 x99tmTzLeSoX9y4+ZRbG99CbTKW5foVcZ9cBaaSlAgeBIDO3gjfCC7UX4vMzTxIUP6CS gaPw== X-Gm-Message-State: AOAM533ul15S8SYX+GUARVSQWDdj3TaAzCMZYScjiYTzrKvZqYnczo0j NpYO1AiWStFLvGRwM/M1gxk= X-Google-Smtp-Source: ABdhPJwv+jGbLoBGvUGrS3dUV5BKN9DIaqcekDo5k672cRM1hMaaM3bJpo8VLBeZe2Q5/RUY8aFi5Q== X-Received: by 2002:a17:90a:8815:: with SMTP id s21mr53173pjn.154.1591195985044; Wed, 03 Jun 2020 07:53:05 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id m2sm2827173pjk.52.2020.06.03.07.53.04 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 03 Jun 2020 07:53:04 -0700 (PDT) From: Guenter Roeck To: Peter Maydell Subject: [PATCH v2 2/2] hw: arm: Set vendor property for IMX SDHCI emulations Date: Wed, 3 Jun 2020 07:52:58 -0700 Message-Id: <20200603145258.195920-3-linux@roeck-us.net> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200603145258.195920-1-linux@roeck-us.net> References: <20200603145258.195920-1-linux@roeck-us.net> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::443; envelope-from=groeck7@gmail.com; helo=mail-pf1-x443.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. Tested-by: Philippe Mathieu-Daudé Signed-off-by: Guenter Roeck Reviewed-by: Philippe Mathieu-Daudé --- v2: Added missing error checks Added Philippe's Tested-by: tag hw/arm/fsl-imx25.c | 6 ++++++ hw/arm/fsl-imx6.c | 6 ++++++ hw/arm/fsl-imx6ul.c | 2 ++ hw/arm/fsl-imx7.c | 2 ++ 4 files changed, 16 insertions(+) diff --git a/hw/arm/fsl-imx25.c b/hw/arm/fsl-imx25.c index cdaa79c26b..a853ffcc00 100644 --- a/hw/arm/fsl-imx25.c +++ b/hw/arm/fsl-imx25.c @@ -274,6 +274,12 @@ 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); + if (err) { + error_propagate(errp, err); + return; + } 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..29677cfd59 100644 --- a/hw/arm/fsl-imx6.c +++ b/hw/arm/fsl-imx6.c @@ -350,6 +350,12 @@ 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); + if (err) { + error_propagate(errp, err); + return; + } 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);