From nobody Tue Oct 28 01:56:38 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515704495957525.1674422694364; Thu, 11 Jan 2018 13:01:35 -0800 (PST) Received: from localhost ([::1]:42318 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZjyh-00017z-5D for importer@patchew.org; Thu, 11 Jan 2018 16:01:35 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58892) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZju7-0005AG-0F for qemu-devel@nongnu.org; Thu, 11 Jan 2018 15:56:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZju5-0002Af-Qu for qemu-devel@nongnu.org; Thu, 11 Jan 2018 15:56:51 -0500 Received: from mail-qk0-x241.google.com ([2607:f8b0:400d:c09::241]:44720) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eZju5-0002AR-M1; Thu, 11 Jan 2018 15:56:49 -0500 Received: by mail-qk0-x241.google.com with SMTP id u76so6046833qku.11; Thu, 11 Jan 2018 12:56:49 -0800 (PST) Received: from x1.local ([138.117.48.219]) by smtp.gmail.com with ESMTPSA id c1sm12818399qta.52.2018.01.11.12.56.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Jan 2018 12:56:48 -0800 (PST) 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=AA4lX2oy/5wotSIpkmi4A54FyuiV6UM7VS2dxaiLG8Q=; b=uI9nokc6UisdMbc8U1aJla3fOsL2aOi87kdEz7BqdFPeSs2JAaqgGMzrLBWpQ+2Xiu +oh+h8YmKkA8eGMQk1mrSd33/x+zbrJ7a9WYS333C3cE57RdIx4ENTgh9+cC0y1ww0wO chShyDnU/qFXZbwCYDzNaF0Iq2r3/MyWgHR717V3gU5sVxAYMqEFfDmddtTH1hPssxuk XW0H+IBfjRAozRDB2i/dzx02NDXPT/IIgRAYqST7qauJgcna34nWExZ2SjceLQuFV/R8 71aMkNZCBMDJLpX9oFawu+2NvFhWt8xGWNkzBc8DY+Gva3eQ87D6z/ibXhWqPNSb48Os bfgg== 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=AA4lX2oy/5wotSIpkmi4A54FyuiV6UM7VS2dxaiLG8Q=; b=K6+jTD/8HYCBL/huWSHeXt9qye8jCag9I1uBCDfGnoVzgtlBrX/bJmSSsoQM6Q+C4u wwO/iM00yDok7uQE8jd+tnTaC36nwwyZgsHhUtRMeZ8xGN/y+ysasOPQ6aP9Atd6lDrv bEWe1/zRFn0W9hR9NW2hSzhR+UyFT/527Tqmogqniwx3X+vw6ZZ53IAzVA1img3R3bYE XOlilPnWGcNjOOwSQVYROagEQG6RzueddHkKKL4UFNVLGx+lSdOZMezJKwA+VJcmVe47 zB1KUuSdYwpxAJm4O4Ijmr2jDNZmqenXhETyTUJsCm8DL+/Zb6WW123zU/veDDaaslCv 4mGQ== X-Gm-Message-State: AKwxytfgwzjMjYI1kyuCVIngivm0hDwx8RNCNoy+BR0L1KNcQ/JVG7kO rbL3mNaDSHX42guGgWNCrqk= X-Google-Smtp-Source: ACJfBotMQ6TNsfAR5VXaoaUXxAGBhfxH69dWxEejlvylYyRy1jayQoA4PjnKNPO7Ko7JZF3SbEM60g== X-Received: by 10.55.95.198 with SMTP id t189mr30910882qkb.171.1515704208994; Thu, 11 Jan 2018 12:56:48 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: Alistair Francis , Peter Maydell , Andrey Smirnov , Igor Mitsyanko Date: Thu, 11 Jan 2018 17:56:06 -0300 Message-Id: <20180111205626.23291-2-f4bug@amsat.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180111205626.23291-1-f4bug@amsat.org> References: <20180111205626.23291-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c09::241 Subject: [Qemu-devel] [PATCH v6 01/21] sdhci: add a 'spec_version property' (default to v2) X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Edgar E . Iglesias" , Prasad J Pandit , =?UTF-8?q?Gr=C3=A9gory=20Estrade?= , qemu-devel@nongnu.org, Peter Crosthwaite , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Krzysztof Kozlowski , Jean-Christophe Dubois , Sai Pavan Boddu , qemu-arm@nongnu.org, Clement Deschamps , Andrew Baumann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Alistair Francis --- hw/sd/sdhci-internal.h | 4 ++-- include/hw/sd/sdhci.h | 2 ++ hw/sd/sdhci.c | 19 +++++++++++++++++-- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/hw/sd/sdhci-internal.h b/hw/sd/sdhci-internal.h index fc807f08f3..b7751c815f 100644 --- a/hw/sd/sdhci-internal.h +++ b/hw/sd/sdhci-internal.h @@ -210,9 +210,9 @@ /* Slot interrupt status */ #define SDHC_SLOT_INT_STATUS 0xFC =20 -/* HWInit Host Controller Version Register 0x0401 */ +/* HWInit Host Controller Version Register */ #define SDHC_HCVER 0xFE -#define SD_HOST_SPECv2_VERS 0x2401 +#define SDHC_HCVER_VENDOR 0x24 =20 #define SDHC_REGISTERS_MAP_SIZE 0x100 #define SDHC_INSERTION_DELAY (NANOSECONDS_PER_SECOND) diff --git a/include/hw/sd/sdhci.h b/include/hw/sd/sdhci.h index 6117004949..8786676ac8 100644 --- a/include/hw/sd/sdhci.h +++ b/include/hw/sd/sdhci.h @@ -76,6 +76,7 @@ typedef struct SDHCIState { /* Read-only registers */ uint64_t capareg; /* Capabilities Register */ uint64_t maxcurr; /* Maximum Current Capabilities Register */ + uint16_t version; /* Host Controller Version Register */ =20 uint8_t *fifo_buffer; /* SD host i/o FIFO buffer */ uint32_t buf_maxsz; @@ -90,6 +91,7 @@ typedef struct SDHCIState { =20 /* Configurable properties */ bool pending_insert_quirk; /* Quirk for Raspberry Pi card insert int */ + uint8_t spec_version; } SDHCIState; =20 #define TYPE_PCI_SDHCI "sdhci-pci" diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c index 7a2901ae4a..c8f750451e 100644 --- a/hw/sd/sdhci.c +++ b/hw/sd/sdhci.c @@ -173,7 +173,8 @@ static void sdhci_reset(SDHCIState *s) =20 timer_del(s->insert_timer); timer_del(s->transfer_timer); - /* Set all registers to 0. Capabilities registers are not cleared + + /* Set all registers to 0. Capabilities/Version registers are not clea= red * and assumed to always preserve their value, given to them during * initialization */ memset(&s->sdmasysad, 0, (uintptr_t)&s->capareg - (uintptr_t)&s->sdmas= ysad); @@ -917,7 +918,7 @@ static uint64_t sdhci_read(void *opaque, hwaddr offset,= unsigned size) ret =3D (uint32_t)(s->admasysaddr >> 32); break; case SDHC_SLOT_INT_STATUS: - ret =3D (SD_HOST_SPECv2_VERS << 16) | sdhci_slotint(s); + ret =3D (s->version << 16) | sdhci_slotint(s); break; default: qemu_log_mask(LOG_UNIMP, "SDHC rd_%ub @0x%02" HWADDR_PRIx " " @@ -1173,6 +1174,15 @@ static inline unsigned int sdhci_get_fifolen(SDHCISt= ate *s) } } =20 +static void sdhci_init_readonly_registers(SDHCIState *s, Error **errp) +{ + if (s->spec_version !=3D 2) { + error_setg(errp, "Only Spec v2 is supported"); + return; + } + s->version =3D (SDHC_HCVER_VENDOR << 8) | (s->spec_version - 1); +} + static void sdhci_initfn(SDHCIState *s) { qbus_create_inplace(&s->sdbus, sizeof(s->sdbus), @@ -1184,6 +1194,10 @@ static void sdhci_initfn(SDHCIState *s) =20 static void sdhci_common_realize(SDHCIState *s, Error **errp) { + sdhci_init_readonly_registers(s, errp); + if (errp && *errp) { + return; + } s->buf_maxsz =3D sdhci_get_fifolen(s); s->fifo_buffer =3D g_malloc0(s->buf_maxsz); =20 @@ -1282,6 +1296,7 @@ const VMStateDescription sdhci_vmstate =3D { /* Capabilities registers provide information on supported features of this * specific host controller implementation */ static Property sdhci_properties[] =3D { + DEFINE_PROP_UINT8("sd-spec-version", SDHCIState, spec_version, 2), DEFINE_PROP_UINT64("capareg", SDHCIState, capareg, SDHC_CAPAB_REG_DEFAULT), DEFINE_PROP_UINT64("maxcurr", SDHCIState, maxcurr, 0), --=20 2.15.1