From nobody Sun Nov 24 20:59:38 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1720014339; cv=none; d=zohomail.com; s=zohoarc; b=arzx2bBk1qcszr8w85bLCpAgf1PC7zZ8heX7ave5obh0+ABZDyOaFXVMw0sxEo0OlHxxEswsWebFYPUUQ7z8TGk70ijeSpcnE06VrWmPBzfxuG3lmHaRNGb0x/UirLCExS7shnC7EPPP0soI70DqiNcEAywSlYBHeMt3Rb2IVvw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1720014339; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ksCXrweICvZdx6I7fdFmk6nUZAJxdczj1oDiparfm0I=; b=K5ZyrvCxRlwJeStIFtlEthfb7Fsl4F3t8/7FuNnEV3cADmQLf012d2egU9mUlrDYsY4JApLm0z2cAz9r8F0nEQD0foL32Av5s2sMgU3NhUAezXr8x0bB11bt0uW1agBApDGKkf4ukkuWeBOV6wAC71LE6BV/ALkp5iJcKBGVAb4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1720014339465260.3031822420453; Wed, 3 Jul 2024 06:45:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP0HL-00038h-FY; Wed, 03 Jul 2024 09:44:11 -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 1sP0HI-00037Z-QK for qemu-devel@nongnu.org; Wed, 03 Jul 2024 09:44:08 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sP0HH-0005FT-8u for qemu-devel@nongnu.org; Wed, 03 Jul 2024 09:44:08 -0400 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-42579b60af1so31800655e9.2 for ; Wed, 03 Jul 2024 06:44:06 -0700 (PDT) Received: from m1x-phil.lan ([176.187.220.97]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-367908768b4sm2423037f8f.79.2024.07.03.06.44.03 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 03 Jul 2024 06:44:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720014245; x=1720619045; 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=ksCXrweICvZdx6I7fdFmk6nUZAJxdczj1oDiparfm0I=; b=rQKG4sOB5Q45U1BWziC5XjWgTPX+Y6vaMlIsX/D8q/h+7jNBeK8blWNH6RGidkY852 HfUwK3YF7QZoICfkIKI8+z/d4fGPkWQ4lQF1T80yfjPJWFMDr+8aQ5Z/KarNfcq91e7w D0nNdAyMDItR2XxFfnsX1DUwd3GAaqRwQyNCBXyeJPQopPHO+U/Bre0Y0TLB6D+89MXg 3J5euuNr4tqDGs7f7tYVa0qJ0Lrarpsi5YRdoiG0yqDa+7U+fTNY8se/kmRv7cQzGBZw RiPb8PHlIoKD/09pJh4O1S3s7Bs3UimHqx8AgGN8d2zsi2x0sUNvxg7l3BNwLxWTsmxf MOIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720014245; x=1720619045; 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=ksCXrweICvZdx6I7fdFmk6nUZAJxdczj1oDiparfm0I=; b=vbdHYRxQZjf+vOCWKeO58sS93dVcarv4qWVtK8HOrnfeZ7Y38cbQqr93o44HlwGXoL OX4cO2b97Z5ffo8MwlVIAV3E2KnCjHi32ZzDyyJ01KWFbJnzll2PafyKYprMh9pzB7u+ u1hUvtILmccAFEYM9ox3m8tF6xYqgONt6y2WQefRoaoOVQ1l1qSNYmIYBecz90NcHNzv 3YJyK2DhsHU0lS1LyFD4M/30bkEGbKR+W2HvGAFszikCdhD4tMiq4TAUiTj1DMLjbjlB AUQ7PQQxATYXKnPhn2RlhgpV5SuMnKD5EcoyJe/jBBXRZGVCSEvFO45LlYQvGwRenLVP WJYA== X-Gm-Message-State: AOJu0YzZKwCarZ1pTshPLRonMGRDIGHdgipmxsIT6Vjrt63fVMw+qPwU G/slWLhW53QPP8gp/DDZK9lvL6QGGDBKZHkOE4QnqXLlE2pjaQJrNyVfe7Tm1fyJFf+Q0LsN2q6 5 X-Google-Smtp-Source: AGHT+IERCRKXg5Zc25HhZE+waas+qAvjhaxApwatw41X0FEd+JkV5vBIy7WCkYHa0FLKo7FDbDnR3g== X-Received: by 2002:a05:6000:24d:b0:367:8f29:f7ae with SMTP id ffacd0b85a97d-3678f29f8f6mr2046634f8f.49.1720014245561; Wed, 03 Jul 2024 06:44:05 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Manos Pitsidianakis , Marcel Apfelbaum , Yanan Wang , Luc Michel , Bin Meng , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , qemu-block@nongnu.org, Eduardo Habkost , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= Subject: [PATCH v46 1/5] hw/sd/sdcard: Use spec v3.01 by default Date: Wed, 3 Jul 2024 15:43:52 +0200 Message-ID: <20240703134356.85972-2-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240703134356.85972-1-philmd@linaro.org> References: <20240703134356.85972-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=philmd@linaro.org; helo=mail-wm1-x334.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1720014341086100007 Recent SDHCI expect cards to support the v3.01 spec to negociate lower I/O voltage. Select it by default. Versioned machine types with a version of 9.0 or earlier retain the old default (spec v2.00). Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: C=C3=A9dric Le Goater Tested-by: Andrew Jeffery Tested-by: C=C3=A9dric Le Goater --- v43: update versioned machines (danpb) Cc: Daniel P . Berrang=C3=A9 --- hw/core/machine.c | 1 + hw/sd/sd.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/core/machine.c b/hw/core/machine.c index 655d75c21f..4377f943d5 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -38,6 +38,7 @@ GlobalProperty hw_compat_9_0[] =3D { {"arm-cpu", "backcompat-cntfrq", "true" }, {"scsi-disk-base", "migrate-emulated-scsi-request", "false" }, {"vfio-pci", "skip-vsc-check", "false" }, + {"sd-card", "spec_version", "2" }, }; const size_t hw_compat_9_0_len =3D G_N_ELEMENTS(hw_compat_9_0); =20 diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 53767beaf8..a08a452d81 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -2471,7 +2471,7 @@ static void sd_realize(DeviceState *dev, Error **errp) =20 static Property sd_properties[] =3D { DEFINE_PROP_UINT8("spec_version", SDState, - spec_version, SD_PHY_SPECv2_00_VERS), + spec_version, SD_PHY_SPECv3_01_VERS), DEFINE_PROP_DRIVE("drive", SDState, blk), DEFINE_PROP_END_OF_LIST() }; --=20 2.41.0 From nobody Sun Nov 24 20:59:38 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1720014328; cv=none; d=zohomail.com; s=zohoarc; b=OavD0Pf/Nk/RaegbYdvAy/LMXTzMfClghj3UMRej96gJG+yvS2T/64hiZvAql13QJ/flXBAVQatQo8SsFeWH2+S6QdN4z6q4FIUXTuVWxpReHIxdKgjE3c6GSXkT7fNpIexfNBjxk7MBGOnf8RACloH1Z71hR0usYvVQuL/bJyI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1720014328; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=lheN2UZMBb1e7Ny7MPY0NhL8/gxKGWw4Q5bOqqSNEG0=; b=fi3U+S6c4BuZo1EVefuelZmonnYyQ4FKe5FqTsGxkrEnAzqRjv7QGBQSFms6GHhIxze46jvNk+EtNPGbl1SIJXEmMz2iSYf327fW9Vrw0H+Gx4p+5DCr+lvMr+BsTPtYzm2Ge/tpioX/Mn28rbNdDbtxi7tR6msoA1H25la4sIE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1720014328269449.01168140963944; Wed, 3 Jul 2024 06:45:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP0Hh-0003HA-Mt; Wed, 03 Jul 2024 09:44:33 -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 1sP0HR-0003AP-D1 for qemu-devel@nongnu.org; Wed, 03 Jul 2024 09:44:20 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sP0HP-0005GR-AJ for qemu-devel@nongnu.org; Wed, 03 Jul 2024 09:44:17 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-42574064b16so34794525e9.2 for ; Wed, 03 Jul 2024 06:44:12 -0700 (PDT) Received: from m1x-phil.lan ([176.187.220.97]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256f55c4b5sm226785945e9.43.2024.07.03.06.44.09 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 03 Jul 2024 06:44:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720014251; x=1720619051; 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=lheN2UZMBb1e7Ny7MPY0NhL8/gxKGWw4Q5bOqqSNEG0=; b=G5uoSqEAuFgnaZ+pQEnatBiEKDi/CbZunsjE8X2GsGdP1s5AI25QeMG/sIOrkln456 JpY0Dva3h4maVR3ksJOh66p25gYoXM8KJZaUeG0Gch8u3jb1p4u2Zzr8sx01Gwk847Y7 +6s72sy0uoQ9OhwpBFa/sTVGTgmqKv3ES/sq1VkhUmnPPT3ODFNVZKADN0eDGm/uQQiS YhKQgYnepSmmYA+YEhXM1MQ5dst9EgGRydSYenOD4OITkAFWZ4sR0gyLo6c1ptmM2gP1 3evcIf7Vtgok5g9rFaJifOVHs9iqDLMpcLYGVs9C7UbwxrThzWeLJ/sBadkK72VNAT8u vf9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720014251; x=1720619051; 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=lheN2UZMBb1e7Ny7MPY0NhL8/gxKGWw4Q5bOqqSNEG0=; b=TK30HeN9YjU0GMIUUTw13B01v6O5cM3Qs/yRwXuz5IbsJDFLJwD4xhA+lV0exxw27R TWUNbBfsiZs+/Ee56sHBt/pQ5W14WlbFl3FlRphG158izzZIJUF3eB1NYuV5zdT+0LdG NOlOOmHzcyICRrmNTL79lW1mgB+mgeh+YRAYrL393N8+RCprA1sw5cI96Ld2fYlliCHi kalG8pIVEuipOAD0CrvRFhcSW5F9UlnMiR+A8c5xb39aNd1J0d7exTlFJo9ZUMfl8SIw MnqJa6n1PqUftMqwNuXtRZFGgdMbpR1MVolsqA3jhBMU/YIWfaAFN+2EgYu0dcBbsos6 VOog== X-Gm-Message-State: AOJu0Yx/n7D6iFlx37pKWBbx/opNxZK3UKcoV0q4MplQpy5M3tNkEGSO NGq3Ns+W5POepNHQwns+qHnC9CjrqxEF2Rp0tl3+G2sfPhNpZ4NNg08NC8nJp1J5OW0XDeI0dmA t X-Google-Smtp-Source: AGHT+IHoDcKo33dvtZqXfXPEKAOjiZErtanGSQmkn6kUcsmoCxHBrHfV9tcwtfTunA8iAMwrApsjLQ== X-Received: by 2002:a05:600c:1616:b0:425:6bea:8554 with SMTP id 5b1f17b1804b1-4257a05fa13mr77764985e9.27.1720014251349; Wed, 03 Jul 2024 06:44:11 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Manos Pitsidianakis , Marcel Apfelbaum , Yanan Wang , Luc Michel , Bin Meng , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , qemu-block@nongnu.org, Eduardo Habkost , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v46 2/5] hw/sd/sdcard: Add sd_cmd_GEN_CMD handler (CMD56) Date: Wed, 3 Jul 2024 15:43:53 +0200 Message-ID: <20240703134356.85972-3-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240703134356.85972-1-philmd@linaro.org> References: <20240703134356.85972-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=philmd@linaro.org; helo=mail-wm1-x32c.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1720014329271100001 "General command" (GEN_CMD, CMD56) is described as: GEN_CMD is the same as the single block read or write commands (CMD24 or CMD17). The difference is that [...] the data block is not a memory payload data but has a vendor specific format and meaning. Thus this block must not be stored overwriting data block on underlying storage drive. Handle as RAZ/WI. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Andrew Jeffery Tested-by: C=C3=A9dric Le Goater --- hw/sd/sd.c | 54 ++++++++++++++++++++---------------------------------- 1 file changed, 20 insertions(+), 34 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index a08a452d81..04e8fdb262 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -243,7 +243,6 @@ static const char *sd_cmd_name(SDState *sd, uint8_t cmd) [25] =3D "WRITE_MULTIPLE_BL= OCK", [26] =3D "MANUF_RSVD", [40] =3D "DPS_spec", - [56] =3D "GEN_CMD", [60] =3D "MANUF_RSVD", [61] =3D "MANUF_RSVD", [62] =3D "MANUF_RSVD", [63] =3D "MANUF_RSVD", }; @@ -902,9 +901,6 @@ static void sd_blk_write(SDState *sd, uint64_t addr, ui= nt32_t len) } } =20 -#define APP_READ_BLOCK(a, len) memset(sd->data, 0xec, len) -#define APP_WRITE_BLOCK(a, len) - static void sd_erase(SDState *sd) { uint64_t erase_start =3D sd->erase_start; @@ -1641,6 +1637,22 @@ static sd_rsp_type_t sd_cmd_APP_CMD(SDState *sd, SDR= equest req) return sd_r1; } =20 +/* CMD56 */ +static sd_rsp_type_t sd_cmd_GEN_CMD(SDState *sd, SDRequest req) +{ + if (sd->state !=3D sd_transfer_state) { + return sd_invalid_state_for_cmd(sd, req); + } + + /* Vendor specific command: our model is RAZ/WI */ + if (req.arg & 1) { + memset(sd->data, 0, sizeof(sd->data)); + return sd_cmd_to_sendingdata(sd, req, 0, NULL, 0); + } else { + return sd_cmd_to_receivingdata(sd, req, 0, 0); + } +} + /* CMD58 */ static sd_rsp_type_t spi_cmd_READ_OCR(SDState *sd, SDRequest req) { @@ -1836,22 +1848,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, = SDRequest req) case 26: /* CMD26: PROGRAM_CID */ return sd_cmd_to_receivingdata(sd, req, 0, sizeof(sd->cid)); =20 - /* Application specific commands (Class 8) */ - case 56: /* CMD56: GEN_CMD */ - switch (sd->state) { - case sd_transfer_state: - sd->data_offset =3D 0; - if (req.arg & 1) - sd->state =3D sd_sendingdata_state; - else - sd->state =3D sd_receivingdata_state; - return sd_r1; - - default: - break; - } - break; - default: qemu_log_mask(LOG_GUEST_ERROR, "SD: Unknown CMD%i\n", req.cmd); return sd_illegal; @@ -2187,11 +2183,7 @@ void sd_write_byte(SDState *sd, uint8_t value) break; =20 case 56: /* CMD56: GEN_CMD */ - sd->data[sd->data_offset ++] =3D value; - if (sd->data_offset >=3D sd->blk_len) { - APP_WRITE_BLOCK(sd->data_start, sd->data_offset); - sd->state =3D sd_transfer_state; - } + sd_generic_write_byte(sd, value); break; =20 default: @@ -2233,6 +2225,7 @@ uint8_t sd_read_byte(SDState *sd) case 22: /* ACMD22: SEND_NUM_WR_BLOCKS */ case 30: /* CMD30: SEND_WRITE_PROT */ case 51: /* ACMD51: SEND_SCR */ + case 56: /* CMD56: GEN_CMD */ sd_generic_read_byte(sd, &ret); break; =20 @@ -2260,15 +2253,6 @@ uint8_t sd_read_byte(SDState *sd) } break; =20 - case 56: /* CMD56: GEN_CMD */ - if (sd->data_offset =3D=3D 0) - APP_READ_BLOCK(sd->data_start, sd->blk_len); - ret =3D sd->data[sd->data_offset ++]; - - if (sd->data_offset >=3D sd->blk_len) - sd->state =3D sd_transfer_state; - break; - default: qemu_log_mask(LOG_GUEST_ERROR, "%s: unknown command\n", __func__); return 0x00; @@ -2323,6 +2307,7 @@ static const SDProto sd_proto_spi =3D { [52] =3D {9, sd_spi, "IO_RW_DIRECT", sd_cmd_optional}, [53] =3D {9, sd_spi, "IO_RW_EXTENDED", sd_cmd_optional}, [55] =3D {8, sd_spi, "APP_CMD", sd_cmd_APP_CMD}, + [56] =3D {8, sd_spi, "GEN_CMD", sd_cmd_GEN_CMD}, [57] =3D {10, sd_spi, "DIRECT_SECURE_WRITE", sd_cmd_optional}, [58] =3D {0, sd_spi, "READ_OCR", spi_cmd_READ_OCR}, [59] =3D {0, sd_spi, "CRC_ON_OFF", spi_cmd_CRC_ON_OFF}, @@ -2383,6 +2368,7 @@ static const SDProto sd_proto_sd =3D { [52] =3D {9, sd_bc, "IO_RW_DIRECT", sd_cmd_optional}, [53] =3D {9, sd_bc, "IO_RW_EXTENDED", sd_cmd_optional}, [55] =3D {8, sd_ac, "APP_CMD", sd_cmd_APP_CMD}, + [56] =3D {8, sd_adtc, "GEN_CMD", sd_cmd_GEN_CMD}, [57] =3D {10, sd_adtc, "DIRECT_SECURE_WRITE", sd_cmd_optional}, [58] =3D {11, sd_adtc, "READ_EXTR_MULTI", sd_cmd_optional}, [59] =3D {11, sd_adtc, "WRITE_EXTR_MULTI", sd_cmd_optional}, --=20 2.41.0 From nobody Sun Nov 24 20:59:38 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1720014338; cv=none; d=zohomail.com; s=zohoarc; b=LQ9Pa8V6SKNA/w6tRfLIe2k40ob6K0ipZCqPtfdwqUfyqGdGeqE8Dw1oJwh6ozhlUt50sX3d6UQIsiM8ViMZzb2y0rl1jkzmrs6YIq8oDc7aDDFWqSdpeAB2g9XHrykhUBXAhDeSBKk95DibT/ahUQnMcWeQBv4E4tODE12wxgE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1720014338; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=WFpYqp5rjxfqoVFNkV5ty1wgXIJxNR0gcKtNPqFEsXw=; b=hbmD8t97Tnjt13cw1D3ewywDmmkud5v1vByBfzFglQ7uSoQ7P5z77BegJYxPE4L3lyhSzGhdwH7XQmB7LkKIzqwOE6I92uTUT0Xg5T8rPp/AQUl2T0hoSUXhmF48//3RbMRhT0yIjFOQ454tawZwWz8suyiDmAzII8p7XmXpGDo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1720014338371999.3217491925279; Wed, 3 Jul 2024 06:45:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP0Hj-0003JB-9k; Wed, 03 Jul 2024 09:44:35 -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 1sP0HX-0003CE-Fj for qemu-devel@nongnu.org; Wed, 03 Jul 2024 09:44:28 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sP0HT-0005II-Ra for qemu-devel@nongnu.org; Wed, 03 Jul 2024 09:44:23 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-425624255f3so4533755e9.0 for ; Wed, 03 Jul 2024 06:44:18 -0700 (PDT) Received: from m1x-phil.lan ([176.187.220.97]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256b09a828sm242059345e9.37.2024.07.03.06.44.15 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 03 Jul 2024 06:44:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720014257; x=1720619057; 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=WFpYqp5rjxfqoVFNkV5ty1wgXIJxNR0gcKtNPqFEsXw=; b=wXAHU5Bfjvbyb9JCSPgSBajX1Vv3SjRV4nPwiPl4dTZNHoNw5Jy9leJ4HVDwF4F/qT IugLQ7goMSmFZz1tk8w9Pdhu4WqYOK449KdqgOsQkFr2fFl0FMd8azSXtNqJxeXU0uTJ sh6+PdYP8LaAOd6op6/UygesdD/IoWmhmsSTKtUv+4bAv3hwXtrUKipEELjjWE15uM5h nbBbkoxfbvEoropONc+NbRXQUm2NV74ePazBJhUz2GDGJnCdnDERsfnsKsHEM8z0A3sK gzTfRsF0F46r4m+kiYt03TZCXTE15aj/Ze8Upt0jz12Sa+nnRcYsahuI/rIetCLnelvS QXkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720014257; x=1720619057; 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=WFpYqp5rjxfqoVFNkV5ty1wgXIJxNR0gcKtNPqFEsXw=; b=FPFWhSPEX1WqLiLWByXWNpzGhJDAAY1V0uyjZ/7U5N7qHVpK8Mo4wRtFWSk6eN/mSn aU6feksgWNscMM1Hr8lZgYlxLkypt+9FFe3noi1hXXkqwTWuK5ggsJ0aIRZAWcqHt9P9 npOkpnx58XcA+nkslWfQy1xcOVuHQaWPYSYPX9xd2gLQXJfORYV79K1ISS1DPHHxIArM 2u1tdXOdJBemxD3x+QFeeS4bp+OYz1W46vISPdC0/XDxweHQ4OxKBLVgqWCG7EqWptwB cTSrHmwvYLA2kthewdvWW0aiAW4dAyIN4XGCNpgO0Bl2QjIdxSyKSvRi5wRPZ1Pun0sr umsw== X-Gm-Message-State: AOJu0YyBT5axLWO7geILjltmkZZ1lEZRXSynVk2nN9DIjZiHSYwXtLSA jjhvj74q7aPvk0LBQ2Siwc49v5oqX+zarJtNtLssKbSszT/94u2ED4vSZ3iEi9o4dqBNzXQVrG5 U X-Google-Smtp-Source: AGHT+IGB5fmbUyZ+e5pPcvXLTDHFRu7TNmlSd13DWNwN+iBDo+r53vjByqIwAqEtvJTTPMXsTKIqFw== X-Received: by 2002:a05:600c:6c8a:b0:424:8be4:f2c with SMTP id 5b1f17b1804b1-426408e507cmr18181915e9.2.1720014257141; Wed, 03 Jul 2024 06:44:17 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Manos Pitsidianakis , Marcel Apfelbaum , Yanan Wang , Luc Michel , Bin Meng , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , qemu-block@nongnu.org, Eduardo Habkost , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v46 3/5] hw/sd/sdcard: Rename sd_cmd_SEND_OP_COND handler Date: Wed, 3 Jul 2024 15:43:54 +0200 Message-ID: <20240703134356.85972-4-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240703134356.85972-1-philmd@linaro.org> References: <20240703134356.85972-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=philmd@linaro.org; helo=mail-wm1-x335.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1720014339144100003 The correct command name is 'SD SEND_OP_COND', rename accordingly. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: C=C3=A9dric Le Goater Tested-by: Andrew Jeffery Tested-by: C=C3=A9dric Le Goater --- hw/sd/sd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 04e8fdb262..10f2764a53 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1701,7 +1701,7 @@ static sd_rsp_type_t sd_acmd_SET_WR_BLK_ERASE_COUNT(S= DState *sd, SDRequest req) } =20 /* ACMD41 */ -static sd_rsp_type_t sd_acmd_SD_APP_OP_COND(SDState *sd, SDRequest req) +static sd_rsp_type_t sd_cmd_SEND_OP_COND(SDState *sd, SDRequest req) { if (sd->state !=3D sd_idle_state) { return sd_invalid_state_for_cmd(sd, req); @@ -2378,7 +2378,7 @@ static const SDProto sd_proto_sd =3D { [13] =3D {8, sd_adtc, "SD_STATUS", sd_acmd_SD_STATUS}, [22] =3D {8, sd_adtc, "SEND_NUM_WR_BLOCKS", sd_acmd_SEND_NUM_WR_B= LOCKS}, [23] =3D {8, sd_ac, "SET_WR_BLK_ERASE_COUNT", sd_acmd_SET_WR_BL= K_ERASE_COUNT}, - [41] =3D {8, sd_bcr, "SD_APP_OP_COND", sd_acmd_SD_APP_OP_COND}, + [41] =3D {8, sd_bcr, "SEND_OP_COND", sd_cmd_SEND_OP_COND}, [42] =3D {8, sd_ac, "SET_CLR_CARD_DETECT", sd_acmd_SET_CLR_CARD= _DETECT}, [51] =3D {8, sd_adtc, "SEND_SCR", sd_acmd_SEND_SCR}, }, --=20 2.41.0 From nobody Sun Nov 24 20:59:38 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1720014332; cv=none; d=zohomail.com; s=zohoarc; b=lwsFRx6uVIgU+O78VlGk/whtHSbB6SHm108PUZAU0YYT5mAAnFWoI1AEYchUmR5EUppBXvw2HrmSW033Ujl2YYFXclwIoUU1QyA8GAL7WJE53uZ6tqzgmrexpT2yFO73fhvS+xKZEtym88SZd31yh0ObxBeZOQ3iXsm47ckjTnA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1720014332; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=uCXkuyBkm/Q9MWnM3F9F2k54QT0LMAwCrOCsbWSEZjE=; b=BMAF0KdDXUiLiTsqFabiEn5spbY2rKQ9G/JAJWsM/pVZpDgaVjXXGlKInMft11YkLMGW/FFpoy2k/bI6/gS0DEXxo4IVP2w4ex3KRZmheFUw7Q3moGasZuO28wrMiE5bmaRk1KYSkIjFX6HtzstEdefNKG69lEUVHvXRHdC9T6w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1720014332563627.5813914981892; Wed, 3 Jul 2024 06:45:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP0IE-0003Px-3t; Wed, 03 Jul 2024 09:45:09 -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 1sP0Hc-0003FS-80 for qemu-devel@nongnu.org; Wed, 03 Jul 2024 09:44:31 -0400 Received: from mail-lj1-x230.google.com ([2a00:1450:4864:20::230]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sP0Ha-0005Jj-9c for qemu-devel@nongnu.org; Wed, 03 Jul 2024 09:44:27 -0400 Received: by mail-lj1-x230.google.com with SMTP id 38308e7fff4ca-2ee8911b451so3441991fa.2 for ; Wed, 03 Jul 2024 06:44:24 -0700 (PDT) Received: from m1x-phil.lan ([176.187.220.97]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36798e435c3sm35788f8f.72.2024.07.03.06.44.21 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 03 Jul 2024 06:44:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720014263; x=1720619063; 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=uCXkuyBkm/Q9MWnM3F9F2k54QT0LMAwCrOCsbWSEZjE=; b=p0ImoaOGjds0rybTcJD/nGpCHH6QBN51ZKu/hgJhQMMDyw+1szQK4Tq1hDSPS/VWG9 XpGLj8qlIEFHwQogu1Q+T3+6maA6t8ENIQclNnmF4bFt0ljH0Pt1cewG19jJtm6pi9eE 21Pp587590nGXaCVkVJjky/dcY0zyvlCRc/j84iJJGM0llwtCqIKU+kTcSPcaV+jY9HX 8y1HxMfGZAQBGYHr5A8ueAlqOEO0Bb14m1x2IVPFI/5PcJHo99d1fTeTP0DQ7WL9MH0Z 0JShd5dIBTt3rv2SBl/g/pGsK4IikD1obxUUUZi6SYL5W+wogK+I55nEAz1i2BkuQGOG FcgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720014263; x=1720619063; 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=uCXkuyBkm/Q9MWnM3F9F2k54QT0LMAwCrOCsbWSEZjE=; b=rpYRaXR5Qn8u+dAerQgJahbYqlQwFIq+6yRsC1WF9wrKGwziObTUqpyYE0mU9h/0B6 QD5d6a1bHQ5oXTT9/fjuvLAYQ/6+Iuz9Z4UYA0s/eez4UjH6u91Vrt5ruSHBIC+IHPuZ JhvufOJf8qMqCDdjXREd5+RjFPPL7k3TTd7/CxAUyjz+ISv6NMSjLyS2Q/t9OBOaFQbQ 3Yp5RIPQf05Hc7vgAghRvgZFkbcIM3lS9RXAd0vYoZXp0I2sbk+a7X5IU+dbBiReeveT b2K1tgJNiF2fvE2Tfag24Xnj27bMWLAKdIUCAUneTmHhtpV08GAvmEBP/vlXzejwZ2Xo PDgQ== X-Gm-Message-State: AOJu0YzM0ujhuzOu8LywbFmfd2TNmOKvB5gs56oHTbox82tlcTPaN0v4 pgzm/hnIyp0uI7hWfapHtMxVuAfZsZnNzU0d/83wYK4wdZAr1i5BV9ogArNXwaEQOI78ejTy+hZ / X-Google-Smtp-Source: AGHT+IHRXSOa5ydgTUtQzAV5bTn6jAiy8z//xNgoeSJsqoy6U3Up2a2cEiOPNPsqQ7CuO51GynCXZg== X-Received: by 2002:a2e:8958:0:b0:2ee:854f:45be with SMTP id 38308e7fff4ca-2ee854f46eemr11466191fa.12.1720014263227; Wed, 03 Jul 2024 06:44:23 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Manos Pitsidianakis , Marcel Apfelbaum , Yanan Wang , Luc Michel , Bin Meng , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , qemu-block@nongnu.org, Eduardo Habkost , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v46 4/5] hw/sd/sdcard: Introduce set_csd/set_cid handlers Date: Wed, 3 Jul 2024 15:43:55 +0200 Message-ID: <20240703134356.85972-5-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240703134356.85972-1-philmd@linaro.org> References: <20240703134356.85972-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::230; envelope-from=philmd@linaro.org; helo=mail-lj1-x230.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1720014333080100009 In preparation of introducing eMMC support which have different CSD/CID structures, introduce a pair of handlers in SDCardClass. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Andrew Jeffery Tested-by: C=C3=A9dric Le Goater --- include/hw/sd/sd.h | 2 ++ hw/sd/sd.c | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/include/hw/sd/sd.h b/include/hw/sd/sd.h index 29c76935a0..bfbc83c110 100644 --- a/include/hw/sd/sd.h +++ b/include/hw/sd/sd.h @@ -128,6 +128,8 @@ struct SDCardClass { void (*enable)(SDState *sd, bool enable); bool (*get_inserted)(SDState *sd); bool (*get_readonly)(SDState *sd); + void (*set_cid)(SDState *sd); + void (*set_csd)(SDState *sd, uint64_t size); =20 const struct SDProto *proto; }; diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 10f2764a53..d46be50760 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -689,6 +689,7 @@ static inline uint64_t sd_addr_to_wpnum(uint64_t addr) static void sd_reset(DeviceState *dev) { SDState *sd =3D SD_CARD(dev); + SDCardClass *sc =3D SD_CARD_GET_CLASS(sd); uint64_t size; uint64_t sect; =20 @@ -709,8 +710,8 @@ static void sd_reset(DeviceState *dev) sd->size =3D size; sd_set_ocr(sd); sd_set_scr(sd); - sd_set_cid(sd); - sd_set_csd(sd, size); + sc->set_cid(sd); + sc->set_csd(sd, size); sd_set_cardstatus(sd); sd_set_sdstatus(sd); =20 @@ -2485,6 +2486,8 @@ static void sd_class_init(ObjectClass *klass, void *d= ata) sc->enable =3D sd_enable; sc->get_inserted =3D sd_get_inserted; sc->get_readonly =3D sd_get_readonly; + sc->set_cid =3D sd_set_cid; + sc->set_csd =3D sd_set_csd; sc->proto =3D &sd_proto_sd; } =20 --=20 2.41.0 From nobody Sun Nov 24 20:59:38 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1720014331; cv=none; d=zohomail.com; s=zohoarc; b=WhjLIH1q9KAiP/kE+8w3x6nQH1KWx3ieRcbWMNPrMHpsyGk03eU4JStsNQ6lCAFB/BuT2/ONsZle/t1FnRq9rocyHb5s2RmhRjWKW1l3zu4WQ5W1d6UaCYFrX++XNLY/Xe4jbx6s8Qwmajjmn54cY7kKTWpjxhROBFDONlhpalc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1720014331; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ZetNPh08FbXJX+EqxjCsBWE0Fy6SjwqilI4jzRk1S1Y=; b=KKGnGwUoGowntYpw+Bh7u3Pj6DMKVPNsErXK9fgEU4uSjWu/ecJInvB4wF1STwsHqCPRrWqzH7Txtad5+QZFLwV2MEla4AP/E/CNBAJAIEEK4Gmg8GrItM9cpRS8oE11bN4bsHUHxDJ2OYcZSyh8YHACy5dJBPg5VzzLLmACsic= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1720014331708873.1310741913265; Wed, 3 Jul 2024 06:45:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP0IM-0003WZ-1F; Wed, 03 Jul 2024 09:45:14 -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 1sP0Hi-0003II-55 for qemu-devel@nongnu.org; Wed, 03 Jul 2024 09:44:34 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sP0Hf-0005KX-OA for qemu-devel@nongnu.org; Wed, 03 Jul 2024 09:44:33 -0400 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-362f62ae4c5so416039f8f.1 for ; Wed, 03 Jul 2024 06:44:30 -0700 (PDT) Received: from m1x-phil.lan ([176.187.220.97]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36794954c97sm1575090f8f.32.2024.07.03.06.44.27 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 03 Jul 2024 06:44:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720014269; x=1720619069; 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=ZetNPh08FbXJX+EqxjCsBWE0Fy6SjwqilI4jzRk1S1Y=; b=z1IB7vv/oC2TTpjTty0gY/PLaYIeYV0HZiFJ3xUTYKQD9C9WE7f5dMjxpET1L9ziK+ erj0r6yFqpPp5eXubciMXqVW64/8/ageRHfrzVJ0bLxwGEhfKaKAbzWwguW7MznC6yr8 XoC0vKkTWMULdMxF29dIh5uAvlRy106kXYOkATXckLkC3OBzAGPl2zW2CppeF/EOH0eT y22Sx4DCM2wIo8IZ//s/lRCZtwLpvSQyhSCy4Lr5Dvr3zSIUSQkBHyTDkgUckTYLyGFG RD2TnRbq+eJgyu2IsoNWUDc/SoEco2Bz1nXFznu+1OOllfNkuh8KBxzvDH/fFOWzoBT+ unDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720014269; x=1720619069; 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=ZetNPh08FbXJX+EqxjCsBWE0Fy6SjwqilI4jzRk1S1Y=; b=fmYED07GLC7b+MiAUq03lXo9WvRpjHsW+W1BGzD7xQKJ/TiH29pPIAUzKx4jHdLQL5 reK1we5DalikESvRV4fywzwTlOLj7eKeQKoqLZRWll7Pgn9URTdK7vfewkWKUqewgzpX t5IF81rZaasAIRxjV+7zuUC8y0fQyx3JQFEn1s85wq2nzFZ8TsWT3dzYJLnt2ms8rJqk XK4SPt+gsEiTbr1rJyyVI+60NmssjSigkZbX0XYYwufJTzisYmI3AYWiDu2Pz7/ePN2z MzIhXtKnDBVjT+bTo4N6qJhgQa+baxoWrQSzaKrWgXHEe/AK1joHwPzuQzTrBe8C39tU 8eGQ== X-Gm-Message-State: AOJu0Yx1vRyuUXChKn0/pwAfD/OiEdnDuA+zqtNExr9aYrl3o5TmB7x7 PjxQV/wP4Aha4jN9QnJAE83ThZGAU97lTo0R05w7O5InbnZnkpA6mdq/evU8MEexvp4784UB1JY v X-Google-Smtp-Source: AGHT+IEyEeYWSa4I3C5+9UufWqhWH2kNj0ymaVZSJtn949y3c9cC1c20UE98O/XBFkCtt5TY6annlw== X-Received: by 2002:adf:e7cb:0:b0:363:ac4d:c44f with SMTP id ffacd0b85a97d-367947a5374mr1615601f8f.17.1720014269031; Wed, 03 Jul 2024 06:44:29 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Manos Pitsidianakis , Marcel Apfelbaum , Yanan Wang , Luc Michel , Bin Meng , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , qemu-block@nongnu.org, Eduardo Habkost , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v46 5/5] hw/sd/sdcard: Extract TYPE_SDMMC_COMMON from TYPE_SD_CARD Date: Wed, 3 Jul 2024 15:43:56 +0200 Message-ID: <20240703134356.85972-6-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240703134356.85972-1-philmd@linaro.org> References: <20240703134356.85972-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::436; envelope-from=philmd@linaro.org; helo=mail-wr1-x436.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1720014333148100011 In order to keep eMMC model simpler to maintain, extract common properties and the common code from class_init to the (internal) TYPE_SDMMC_COMMON. Update the corresponding QOM cast macros. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Andrew Jeffery Tested-by: C=C3=A9dric Le Goater --- hw/sd/sdmmc-internal.h | 3 +++ hw/sd/core.c | 29 ++++++++++++------------ hw/sd/sd.c | 50 ++++++++++++++++++++++++++++-------------- 3 files changed, 52 insertions(+), 30 deletions(-) diff --git a/hw/sd/sdmmc-internal.h b/hw/sd/sdmmc-internal.h index cc0b69e834..91eb5b6b2f 100644 --- a/hw/sd/sdmmc-internal.h +++ b/hw/sd/sdmmc-internal.h @@ -11,6 +11,9 @@ #ifndef SDMMC_INTERNAL_H #define SDMMC_INTERNAL_H =20 +#define TYPE_SDMMC_COMMON "sdmmc-common" +DECLARE_OBJ_CHECKERS(SDState, SDCardClass, SDMMC_COMMON, TYPE_SDMMC_COMMON) + /* * EXT_CSD Modes segment * diff --git a/hw/sd/core.c b/hw/sd/core.c index 52d5d90045..4b30218b52 100644 --- a/hw/sd/core.c +++ b/hw/sd/core.c @@ -24,6 +24,7 @@ #include "hw/sd/sd.h" #include "qemu/module.h" #include "qapi/error.h" +#include "sdmmc-internal.h" #include "trace.h" =20 static inline const char *sdbus_name(SDBus *sdbus) @@ -39,7 +40,7 @@ static SDState *get_card(SDBus *sdbus) if (!kid) { return NULL; } - return SD_CARD(kid->child); + return SDMMC_COMMON(kid->child); } =20 uint8_t sdbus_get_dat_lines(SDBus *sdbus) @@ -48,7 +49,7 @@ uint8_t sdbus_get_dat_lines(SDBus *sdbus) uint8_t dat_lines =3D 0b1111; /* 4 bit bus width */ =20 if (slave) { - SDCardClass *sc =3D SD_CARD_GET_CLASS(slave); + SDCardClass *sc =3D SDMMC_COMMON_GET_CLASS(slave); =20 if (sc->get_dat_lines) { dat_lines =3D sc->get_dat_lines(slave); @@ -65,7 +66,7 @@ bool sdbus_get_cmd_line(SDBus *sdbus) bool cmd_line =3D true; =20 if (slave) { - SDCardClass *sc =3D SD_CARD_GET_CLASS(slave); + SDCardClass *sc =3D SDMMC_COMMON_GET_CLASS(slave); =20 if (sc->get_cmd_line) { cmd_line =3D sc->get_cmd_line(slave); @@ -82,7 +83,7 @@ void sdbus_set_voltage(SDBus *sdbus, uint16_t millivolts) =20 trace_sdbus_set_voltage(sdbus_name(sdbus), millivolts); if (card) { - SDCardClass *sc =3D SD_CARD_GET_CLASS(card); + SDCardClass *sc =3D SDMMC_COMMON_GET_CLASS(card); =20 assert(sc->set_voltage); sc->set_voltage(card, millivolts); @@ -95,7 +96,7 @@ int sdbus_do_command(SDBus *sdbus, SDRequest *req, uint8_= t *response) =20 trace_sdbus_command(sdbus_name(sdbus), req->cmd, req->arg); if (card) { - SDCardClass *sc =3D SD_CARD_GET_CLASS(card); + SDCardClass *sc =3D SDMMC_COMMON_GET_CLASS(card); =20 return sc->do_command(card, req, response); } @@ -109,7 +110,7 @@ void sdbus_write_byte(SDBus *sdbus, uint8_t value) =20 trace_sdbus_write(sdbus_name(sdbus), value); if (card) { - SDCardClass *sc =3D SD_CARD_GET_CLASS(card); + SDCardClass *sc =3D SDMMC_COMMON_GET_CLASS(card); =20 sc->write_byte(card, value); } @@ -121,7 +122,7 @@ void sdbus_write_data(SDBus *sdbus, const void *buf, si= ze_t length) const uint8_t *data =3D buf; =20 if (card) { - SDCardClass *sc =3D SD_CARD_GET_CLASS(card); + SDCardClass *sc =3D SDMMC_COMMON_GET_CLASS(card); =20 for (size_t i =3D 0; i < length; i++) { trace_sdbus_write(sdbus_name(sdbus), data[i]); @@ -136,7 +137,7 @@ uint8_t sdbus_read_byte(SDBus *sdbus) uint8_t value =3D 0; =20 if (card) { - SDCardClass *sc =3D SD_CARD_GET_CLASS(card); + SDCardClass *sc =3D SDMMC_COMMON_GET_CLASS(card); =20 value =3D sc->read_byte(card); } @@ -151,7 +152,7 @@ void sdbus_read_data(SDBus *sdbus, void *buf, size_t le= ngth) uint8_t *data =3D buf; =20 if (card) { - SDCardClass *sc =3D SD_CARD_GET_CLASS(card); + SDCardClass *sc =3D SDMMC_COMMON_GET_CLASS(card); =20 for (size_t i =3D 0; i < length; i++) { data[i] =3D sc->read_byte(card); @@ -165,7 +166,7 @@ bool sdbus_receive_ready(SDBus *sdbus) SDState *card =3D get_card(sdbus); =20 if (card) { - SDCardClass *sc =3D SD_CARD_GET_CLASS(card); + SDCardClass *sc =3D SDMMC_COMMON_GET_CLASS(card); =20 return sc->receive_ready(card); } @@ -178,7 +179,7 @@ bool sdbus_data_ready(SDBus *sdbus) SDState *card =3D get_card(sdbus); =20 if (card) { - SDCardClass *sc =3D SD_CARD_GET_CLASS(card); + SDCardClass *sc =3D SDMMC_COMMON_GET_CLASS(card); =20 return sc->data_ready(card); } @@ -191,7 +192,7 @@ bool sdbus_get_inserted(SDBus *sdbus) SDState *card =3D get_card(sdbus); =20 if (card) { - SDCardClass *sc =3D SD_CARD_GET_CLASS(card); + SDCardClass *sc =3D SDMMC_COMMON_GET_CLASS(card); =20 return sc->get_inserted(card); } @@ -204,7 +205,7 @@ bool sdbus_get_readonly(SDBus *sdbus) SDState *card =3D get_card(sdbus); =20 if (card) { - SDCardClass *sc =3D SD_CARD_GET_CLASS(card); + SDCardClass *sc =3D SDMMC_COMMON_GET_CLASS(card); =20 return sc->get_readonly(card); } @@ -250,7 +251,7 @@ void sdbus_reparent_card(SDBus *from, SDBus *to) return; } =20 - sc =3D SD_CARD_GET_CLASS(card); + sc =3D SDMMC_COMMON_GET_CLASS(card); readonly =3D sc->get_readonly(card); =20 sdbus_set_inserted(from, false); diff --git a/hw/sd/sd.c b/hw/sd/sd.c index d46be50760..9fcb2b9e89 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -688,8 +688,8 @@ static inline uint64_t sd_addr_to_wpnum(uint64_t addr) =20 static void sd_reset(DeviceState *dev) { - SDState *sd =3D SD_CARD(dev); - SDCardClass *sc =3D SD_CARD_GET_CLASS(sd); + SDState *sd =3D SDMMC_COMMON(dev); + SDCardClass *sc =3D SDMMC_COMMON_GET_CLASS(sd); uint64_t size; uint64_t sect; =20 @@ -2387,8 +2387,8 @@ static const SDProto sd_proto_sd =3D { =20 static void sd_instance_init(Object *obj) { - SDState *sd =3D SD_CARD(obj); - SDCardClass *sc =3D SD_CARD_GET_CLASS(sd); + SDState *sd =3D SDMMC_COMMON(obj); + SDCardClass *sc =3D SDMMC_COMMON_GET_CLASS(sd); =20 sd->proto =3D sc->proto; sd->last_cmd_name =3D "UNSET"; @@ -2398,14 +2398,14 @@ static void sd_instance_init(Object *obj) =20 static void sd_instance_finalize(Object *obj) { - SDState *sd =3D SD_CARD(obj); + SDState *sd =3D SDMMC_COMMON(obj); =20 timer_free(sd->ocr_power_timer); } =20 static void sd_realize(DeviceState *dev, Error **errp) { - SDState *sd =3D SD_CARD(dev); + SDState *sd =3D SDMMC_COMMON(dev); int ret; =20 switch (sd->spec_version) { @@ -2456,20 +2456,23 @@ static void sd_realize(DeviceState *dev, Error **er= rp) } } =20 -static Property sd_properties[] =3D { - DEFINE_PROP_UINT8("spec_version", SDState, - spec_version, SD_PHY_SPECv3_01_VERS), +static Property sdmmc_common_properties[] =3D { DEFINE_PROP_DRIVE("drive", SDState, blk), DEFINE_PROP_END_OF_LIST() }; =20 -static void sd_class_init(ObjectClass *klass, void *data) +static Property sd_properties[] =3D { + DEFINE_PROP_UINT8("spec_version", SDState, + spec_version, SD_PHY_SPECv3_01_VERS), + DEFINE_PROP_END_OF_LIST() +}; + +static void sdmmc_common_class_init(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); - SDCardClass *sc =3D SD_CARD_CLASS(klass); + SDCardClass *sc =3D SDMMC_COMMON_CLASS(klass); =20 - dc->realize =3D sd_realize; - device_class_set_props(dc, sd_properties); + device_class_set_props(dc, sdmmc_common_properties); dc->vmsd =3D &sd_vmstate; dc->reset =3D sd_reset; dc->bus_type =3D TYPE_SD_BUS; @@ -2486,6 +2489,16 @@ static void sd_class_init(ObjectClass *klass, void *= data) sc->enable =3D sd_enable; sc->get_inserted =3D sd_get_inserted; sc->get_readonly =3D sd_get_readonly; +} + +static void sd_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + SDCardClass *sc =3D SDMMC_COMMON_CLASS(klass); + + dc->realize =3D sd_realize; + device_class_set_props(dc, sd_properties); + sc->set_cid =3D sd_set_cid; sc->set_csd =3D sd_set_csd; sc->proto =3D &sd_proto_sd; @@ -2500,7 +2513,7 @@ static void sd_class_init(ObjectClass *klass, void *d= ata) static void sd_spi_class_init(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); - SDCardClass *sc =3D SD_CARD_CLASS(klass); + SDCardClass *sc =3D SDMMC_COMMON_CLASS(klass); =20 dc->desc =3D "SD SPI"; sc->proto =3D &sd_proto_spi; @@ -2508,14 +2521,19 @@ static void sd_spi_class_init(ObjectClass *klass, v= oid *data) =20 static const TypeInfo sd_types[] =3D { { - .name =3D TYPE_SD_CARD, + .name =3D TYPE_SDMMC_COMMON, .parent =3D TYPE_DEVICE, .instance_size =3D sizeof(SDState), .class_size =3D sizeof(SDCardClass), - .class_init =3D sd_class_init, + .class_init =3D sdmmc_common_class_init, .instance_init =3D sd_instance_init, .instance_finalize =3D sd_instance_finalize, }, + { + .name =3D TYPE_SD_CARD, + .parent =3D TYPE_SDMMC_COMMON, + .class_init =3D sd_class_init, + }, { .name =3D TYPE_SD_CARD_SPI, .parent =3D TYPE_SD_CARD, --=20 2.41.0