From nobody Mon Nov 25 00:25:54 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=1719506884; cv=none; d=zohomail.com; s=zohoarc; b=c6m2/LqxIQ6Grpo1qrqkolS5WbmlQoxP+IaD17Kxkoa90Z6kTWxFQ+EOoBo0wrMlVBKeTOoslvYf8+3lNrg002HSc25p8xwumNGKCgH5GSCTpXpdqd3sAOymauE3X0RPWmZhvzkEKGfDy4ZJsM3JAGngpV2HPpX2qV/BomvugSQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719506884; 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=ES2XtVxvIqjJs8DitaxtSgSyTv7mRCAuBoO550B/vrE=; b=MCd/ZaUJ/WLU/tDaQuaMWSruCrJ/oFZLFOOy/erRslLW/4WJ3ivaDkflyVZYDFM7Nq/TR65bza9gVTJwj7AM4XR62I2ZG6PV5rVJ+c9odZK3ztJXZo+5QPr/ogCVn2Zilmjp5TKV9ZjaxT5CweFORISAVbswHXpGlpB4iG+CMoQ= 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 1719506884555894.6608250666553; Thu, 27 Jun 2024 09:48:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMsEN-00019d-JA; Thu, 27 Jun 2024 12:44:19 -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 1sMsEA-000143-35 for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:44:09 -0400 Received: from mail-lj1-x231.google.com ([2a00:1450:4864:20::231]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMsE8-000889-B9 for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:44:05 -0400 Received: by mail-lj1-x231.google.com with SMTP id 38308e7fff4ca-2ec1620a956so97015531fa.1 for ; Thu, 27 Jun 2024 09:44:03 -0700 (PDT) Received: from localhost.localdomain (33.red-95-127-46.staticip.rima-tde.net. [95.127.46.33]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42564bc5af8sm35072135e9.43.2024.06.27.09.43.57 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:44:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719506641; x=1720111441; 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=ES2XtVxvIqjJs8DitaxtSgSyTv7mRCAuBoO550B/vrE=; b=YTnYjj71caiQW28Jthawae0FkjipBB1Rk6VfeeDfdGGcQb61cK0JYdkWQpqUpxREsd Ix4Tzjw+H7YUnd5CkZ2lRMiMYCrqGP98qEtxCgTti7P3cDzYRJqQcteEVMEF6PWRpK3M jsmdAgeZXOCLYAPjMbF/W3t/sGPGgXw9n0TImBljOs6GZ+XH1U1yc7jJQii5L7+hMMfk SlypoyhbE3mc9mG86FtSZ8d49o+DnSnQIQJ6J6HV1hwJXFVi59hsaJXh4WpZ6fXOxlWI QMrm5Mgx3GVuSAyrp1HkELDQBVAqcPZ0Mdu6q8GCe3k6MBMQrftnjDoltWCynzrfYHfF 8nkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719506641; x=1720111441; 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=ES2XtVxvIqjJs8DitaxtSgSyTv7mRCAuBoO550B/vrE=; b=Y0K6ejESoNHN2YPcDJxrRXmGv2q15Bxpk1/+i1Bu6A2Em5BDSgSa5mYfJdjBN+59b2 ZfqWY9n7wyfNdIv/6pB2/dLtnZldQTSyWMvsk7hBs/HvleqL7PAkbVEWTe3kPT9uI/Vm 96EK/YlXPKnhgQ1MUt8EYHNbiv+jQOnNRwv4pO16y6SYGP50Sff8Wybyp1F+YNJujfqb RrMzbR9kKo6eylyw4ryaVZKzbneRT6nZcl5nMVGP1ZUJ/3yrrkyPmiEI/I8SE2uGwfJr Dl1qOSLcH0sT8eAiFTA1f7QRuRLjT7RhYWOqwQZNgK47M5xhwjUeU3kh5FM8wohwfmV8 XmcA== X-Gm-Message-State: AOJu0YzGROFdCGn6SLQP7vF+QbWFh3T2YlM9BsUQwCPbnUzmvjXsMB1v aqrl+lkNd0oo9M0YyI5Ybll9sWSQ+Vh7Krplq+3Z5F30rZejKM1aM5ZVzprycf9lJ9Vp1r6X6us 1p9o= X-Google-Smtp-Source: AGHT+IEpCYbOodIODQp4YbQdXTPlc0Yp8MHoqPfEQplT+Gf8x13rTRq3Z6Tyczzu8l5G8HgJO4lfWg== X-Received: by 2002:a05:651c:1991:b0:2ec:5bb2:c236 with SMTP id 38308e7fff4ca-2ec5bb2c276mr111947761fa.33.1719506641466; Thu, 27 Jun 2024 09:44:01 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Sai Pavan Boddu , Francisco Iglesias , Joel Stanley , Luc Michel , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Bin Meng Subject: [PATCH 01/21] hw/sd/sdcard: Add sd_cmd_SWITCH_FUNCTION handler (CMD6) Date: Thu, 27 Jun 2024 18:43:24 +0200 Message-ID: <20240627164345.82192-2-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627164345.82192-1-philmd@linaro.org> References: <20240627164345.82192-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::231; envelope-from=philmd@linaro.org; helo=mail-lj1-x231.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1719506885474100001 Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sd.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index e4941cfdab..61c9aff2fb 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -240,7 +240,7 @@ static const char *sd_response_name(sd_rsp_type_t rsp) static const char *sd_cmd_name(SDState *sd, uint8_t cmd) { static const char *cmd_abbrev[SDMMC_CMD_MAX] =3D { - [6] =3D "SWITCH_FUNC", [7] =3D "SELECT/DESELECT= _CARD", + [7] =3D "SELECT/DESELECT_C= ARD", [8] =3D "SEND_IF_COND", [9] =3D "SEND_CSD", [10] =3D "SEND_CID", [12] =3D "STOP_TRANSMISSION", [13] =3D "SEND_STATUS", @@ -1244,6 +1244,20 @@ static sd_rsp_type_t sd_cmd_SEND_RELATIVE_ADDR(SDSta= te *sd, SDRequest req) } } =20 +/* CMD6 */ +static sd_rsp_type_t sd_cmd_SWITCH_FUNCTION(SDState *sd, SDRequest req) +{ + if (sd->mode !=3D sd_data_transfer_mode) { + return sd_invalid_mode_for_cmd(sd, req); + } + if (sd->state !=3D sd_transfer_state) { + return sd_invalid_state_for_cmd(sd, req); + } + + sd_function_switch(sd, req.arg); + return sd_cmd_to_sendingdata(sd, req, 0, NULL, 64); +} + /* CMD19 */ static sd_rsp_type_t sd_cmd_SEND_TUNING_BLOCK(SDState *sd, SDRequest req) { @@ -1310,17 +1324,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, = SDRequest req) =20 switch (req.cmd) { /* Basic commands (Class 0 and Class 1) */ - case 6: /* CMD6: SWITCH_FUNCTION */ - if (sd->mode !=3D sd_data_transfer_mode) { - return sd_invalid_mode_for_cmd(sd, req); - } - if (sd->state !=3D sd_transfer_state) { - return sd_invalid_state_for_cmd(sd, req); - } - - sd_function_switch(sd, req.arg); - return sd_cmd_to_sendingdata(sd, req, 0, NULL, 64); - case 7: /* CMD7: SELECT/DESELECT_CARD */ rca =3D sd_req_get_rca(sd, req); switch (sd->state) { @@ -2266,6 +2269,7 @@ static const SDProto sd_proto_spi =3D { [0] =3D {0, sd_spi, "GO_IDLE_STATE", sd_cmd_GO_IDLE_STATE}, [1] =3D {0, sd_spi, "SEND_OP_COND", spi_cmd_SEND_OP_COND}, [5] =3D {9, sd_spi, "IO_SEND_OP_COND", sd_cmd_optional}, + [6] =3D {10, sd_spi, "SWITCH_FUNCTION", sd_cmd_SWITCH_FUNCTION}, [34] =3D {10, sd_spi, "READ_SEC_CMD", sd_cmd_optional}, [35] =3D {10, sd_spi, "WRITE_SEC_CMD", sd_cmd_optional}, [36] =3D {10, sd_spi, "SEND_PSI", sd_cmd_optional}, @@ -2288,6 +2292,7 @@ static const SDProto sd_proto_sd =3D { [3] =3D {0, sd_bcr, "SEND_RELATIVE_ADDR", sd_cmd_SEND_RELATIVE_= ADDR}, [4] =3D {0, sd_bc, "SEND_DSR", sd_cmd_unimplemented}, [5] =3D {9, sd_bc, "IO_SEND_OP_COND", sd_cmd_optional}, + [6] =3D {10, sd_adtc, "SWITCH_FUNCTION", sd_cmd_SWITCH_FUNCTION}, [11] =3D {0, sd_ac, "VOLTAGE_SWITCH", sd_cmd_optional}, [19] =3D {2, sd_adtc, "SEND_TUNING_BLOCK", sd_cmd_SEND_TUNING_BLO= CK}, [20] =3D {2, sd_ac, "SPEED_CLASS_CONTROL", sd_cmd_optional}, --=20 2.41.0 From nobody Mon Nov 25 00:25:54 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=1719506684; cv=none; d=zohomail.com; s=zohoarc; b=JOPv3gDE+es30lXJwc1CGCiltQqQ0JXOz1xZyLwkf8f5zltNX166cAsDfHGSxCLTyZhpIHOBVmNkP2TmrTp3USBdM2JmxLvmFJX4/+VbfLSVrhOtkjXVwEBPx8oSEXQoH3Of4lAeUIKkvMLyIp71+8AfHGVloFAdJGxpglomYA8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719506684; 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=Jc7tRSVNH3DRf6qJ+0mDK79EZ4kJyviqTLrANC5etLY=; b=ar297kFDwJ/u9YMfd7F2eHA/HwZc7FFMg6dEqxd6cCeCez90c+K7YQqgDOB9cqOArHpb6hQW+07oxGjwGYGBxt8BCCdwyW7yXN5IO2+2qySWehgUfh3+EIb6qiqgNF+byUVU2Joxmcuz9PMxGKwacudC68Dsjo6dSTNndsvRQcE= 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 1719506684298920.1954213664937; Thu, 27 Jun 2024 09:44:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMsEQ-0001GZ-Op; Thu, 27 Jun 2024 12:44:22 -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 1sMsEJ-0001Ba-KO for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:44:17 -0400 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMsEH-000897-5I for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:44:14 -0400 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-364cdfdaf91so5711219f8f.1 for ; Thu, 27 Jun 2024 09:44:12 -0700 (PDT) Received: from localhost.localdomain (33.red-95-127-46.staticip.rima-tde.net. [95.127.46.33]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36743699ae0sm2370485f8f.66.2024.06.27.09.44.07 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:44:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719506651; x=1720111451; 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=Jc7tRSVNH3DRf6qJ+0mDK79EZ4kJyviqTLrANC5etLY=; b=DeROVQRInWWHS2lugoLkHBgCEcdo8VxLNzIP8fbcUBHGX0mZn8n0MklV5MC952HFxf 23WziK6PVoht1PtNshCyEAweQ5fELKIMySn9O0KBe71MOxTSpZxQx+kh9OuGnMkXEA7u 5VLyBEGXah8lolFvcSkzxF7jo7hPh9ZiMmnLDBUn9smwpwG6lUOH6B15+3im7IfhH8s2 mygtQEMg3WE7XtyNzKu0DcqjYXCMAdN41x8jsHzrXxXfFrlJdeR2b3CtPIyB+dSoLrWp xb/62Cs7pQa7nlENS8CCjKKvS2efLqu07W65VTg6bNbPCM/Nz+UK1He5mQd+l4fKcExn XqQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719506651; x=1720111451; 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=Jc7tRSVNH3DRf6qJ+0mDK79EZ4kJyviqTLrANC5etLY=; b=QQa2rIc6Ynd8qYza7gdspEw4RxCtBjZ8D1k0YxCg15V7tABeFV7tDCSQYDp8dMUKd6 IjgUFKjeYjyiBdcRFTQ0iiLo5o9RFpyvV38Etap/RLHnCT48v3Tz6y9Fsk2fS8lI/xFt ZFj1xtv37mt6oeW5V3e2HDGOohuAiigDN604x7ys5eG+d9BXo84e/FBHoNX1n4v9OiPS q5v9ieXJn6+jfIccmkMeOjqd4eJbPmOEspob6IQgME/yO53azzPiqEAkIrsXRlcMIHD1 Ep4jCYTSs95JgBa8SB47WWU0Yr0UzPcN0ewaABrHHaeh7dbfpS84loAYRjjIAKK3CvOS Y0iQ== X-Gm-Message-State: AOJu0YzpgWYlCq8AFx1kjEd5XpVgyFR1yaP0KIsGY8r9kU13lsNgGiDM sMEWtQvPvzVOmh01xKqmVHYwRLshw/tGdaVs7zptLMTAhPKEXxl/UH2oKCR52OX8UlFca2cLPMi YFjQ= X-Google-Smtp-Source: AGHT+IGQD55REmzYWv+7IymkGTRx1MyLJbRyZ39xNnWJwQDmwHylYsF13ycPguaANLllCA0d9gjD8g== X-Received: by 2002:a05:6000:1448:b0:367:4e05:bb7b with SMTP id ffacd0b85a97d-3674e05bca5mr1734006f8f.53.1719506651290; Thu, 27 Jun 2024 09:44:11 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Sai Pavan Boddu , Francisco Iglesias , Joel Stanley , Luc Michel , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Bin Meng Subject: [PATCH 02/21] hw/sd/sdcard: Add sd_cmd_DE/SELECT_CARD handler (CMD7) Date: Thu, 27 Jun 2024 18:43:25 +0200 Message-ID: <20240627164345.82192-3-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627164345.82192-1-philmd@linaro.org> References: <20240627164345.82192-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::42a; envelope-from=philmd@linaro.org; helo=mail-wr1-x42a.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1719506684630100001 Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sd.c | 85 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 47 insertions(+), 38 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 61c9aff2fb..6ad98db981 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -240,7 +240,6 @@ static const char *sd_response_name(sd_rsp_type_t rsp) static const char *sd_cmd_name(SDState *sd, uint8_t cmd) { static const char *cmd_abbrev[SDMMC_CMD_MAX] =3D { - [7] =3D "SELECT/DESELECT_C= ARD", [8] =3D "SEND_IF_COND", [9] =3D "SEND_CSD", [10] =3D "SEND_CID", [12] =3D "STOP_TRANSMISSION", [13] =3D "SEND_STATUS", @@ -558,6 +557,11 @@ static uint16_t sd_req_get_rca(SDState *s, SDRequest r= eq) } } =20 +static bool sd_req_rca_same(SDState *s, SDRequest req) +{ + return sd_req_get_rca(s, req) =3D=3D s->rca; +} + /* Card Status register */ =20 FIELD(CSR, AKE_SEQ_ERROR, 3, 1) @@ -1258,6 +1262,47 @@ static sd_rsp_type_t sd_cmd_SWITCH_FUNCTION(SDState = *sd, SDRequest req) return sd_cmd_to_sendingdata(sd, req, 0, NULL, 64); } =20 +/* CMD7 */ +static sd_rsp_type_t sd_cmd_DE_SELECT_CARD(SDState *sd, SDRequest req) +{ + bool same_rca =3D sd_req_rca_same(sd, req); + + switch (sd->state) { + case sd_standby_state: + if (!same_rca) { + return sd_r0; + } + sd->state =3D sd_transfer_state; + return sd_r1b; + + case sd_transfer_state: + case sd_sendingdata_state: + if (same_rca) { + break; + } + sd->state =3D sd_standby_state; + return sd_r1b; + + case sd_disconnect_state: + if (!same_rca) { + return sd_r0; + } + sd->state =3D sd_programming_state; + return sd_r1b; + + case sd_programming_state: + if (same_rca) { + break; + } + sd->state =3D sd_disconnect_state; + return sd_r1b; + + default: + break; + } + return sd_invalid_state_for_cmd(sd, req); +} + /* CMD19 */ static sd_rsp_type_t sd_cmd_SEND_TUNING_BLOCK(SDState *sd, SDRequest req) { @@ -1324,43 +1369,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, = SDRequest req) =20 switch (req.cmd) { /* Basic commands (Class 0 and Class 1) */ - case 7: /* CMD7: SELECT/DESELECT_CARD */ - rca =3D sd_req_get_rca(sd, req); - switch (sd->state) { - case sd_standby_state: - if (sd->rca !=3D rca) - return sd_r0; - - sd->state =3D sd_transfer_state; - return sd_r1b; - - case sd_transfer_state: - case sd_sendingdata_state: - if (sd->rca =3D=3D rca) - break; - - sd->state =3D sd_standby_state; - return sd_r1b; - - case sd_disconnect_state: - if (sd->rca !=3D rca) - return sd_r0; - - sd->state =3D sd_programming_state; - return sd_r1b; - - case sd_programming_state: - if (sd->rca =3D=3D rca) - break; - - sd->state =3D sd_disconnect_state; - return sd_r1b; - - default: - break; - } - break; - case 8: /* CMD8: SEND_IF_COND */ if (sd->spec_version < SD_PHY_SPECv2_00_VERS) { break; @@ -2293,6 +2301,7 @@ static const SDProto sd_proto_sd =3D { [4] =3D {0, sd_bc, "SEND_DSR", sd_cmd_unimplemented}, [5] =3D {9, sd_bc, "IO_SEND_OP_COND", sd_cmd_optional}, [6] =3D {10, sd_adtc, "SWITCH_FUNCTION", sd_cmd_SWITCH_FUNCTION}, + [7] =3D {0, sd_ac, "(DE)SELECT_CARD", sd_cmd_DE_SELECT_CARD}, [11] =3D {0, sd_ac, "VOLTAGE_SWITCH", sd_cmd_optional}, [19] =3D {2, sd_adtc, "SEND_TUNING_BLOCK", sd_cmd_SEND_TUNING_BLO= CK}, [20] =3D {2, sd_ac, "SPEED_CLASS_CONTROL", sd_cmd_optional}, --=20 2.41.0 From nobody Mon Nov 25 00:25:54 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=1719506684; cv=none; d=zohomail.com; s=zohoarc; b=aswE59CTGHpTq/qiZ/q6w2q62Pz9GWQNhHsLwHM1voVYFTF9YPsBJtMwFNQ/YbUN8dFWhzIX8l1ZHCWSfi0MfW6hrF8qv+9IjOc6DhNZfmyvIKm0ZErEdtS2lhByUsxm6RvGljyZWf1Nsy+rN63myccKKSXURBjHuNZAawX6Hqo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719506684; 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=stDFUWod5392Ne89qirOgTqrrl6jkkp2/YnCFIJD5bc=; b=RhkVRex5e0TT9t98lFhJ69xp2EJtNtFRSzdRwLaj1lyVTDvNqk2lljMa3PsUaDDyBzsQhdbkdXV9iuHO7bv4yQmWawvt3trLrI5oF9Loy27aDLNX6cy0/Fi2N7KbVTgcveIInaWCcl8NmxV3Z6exBn3VmiwYH8PLH8W323gmE6U= 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 1719506684437240.47843335733546; Thu, 27 Jun 2024 09:44:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMsEX-0001i4-Kl; Thu, 27 Jun 2024 12:44:29 -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 1sMsEV-0001a0-Gn for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:44:27 -0400 Received: from mail-lf1-x12d.google.com ([2a00:1450:4864:20::12d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMsET-0008Au-NA for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:44:27 -0400 Received: by mail-lf1-x12d.google.com with SMTP id 2adb3069b0e04-52cd8897c73so7311177e87.2 for ; Thu, 27 Jun 2024 09:44:25 -0700 (PDT) Received: from localhost.localdomain (33.red-95-127-46.staticip.rima-tde.net. [95.127.46.33]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-424c8469016sm73473605e9.41.2024.06.27.09.44.18 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:44:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719506663; x=1720111463; 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=stDFUWod5392Ne89qirOgTqrrl6jkkp2/YnCFIJD5bc=; b=uR8iUqh/rxJK6fhXos8edbhZSqRkR0UFQ9VftEQ8O7xZOtt8IRROLcpGczkZidLpZe ajg/xACH3XCosB21kf4bQRJTyFpHlsOnvholhbsFWgxw3lq4qbXoK1fqFSP+Z6O1I3n5 MjWjab0eru/Z/d38qVFOa5WlgkyuMAeUN0QXIGBOCLrmALEQaQTwwuLBUrmZci4aSwJs mKJ17QgOT/x9mNnwgonvtiz6AQRn6jd5fvpeaV4Z7n0OCpePhfRYLocTLBrrfYARAUlS 1km0fUX1UN2REJsnhnCacd0IvvRIudASZ5ubGpA/ceHTQl8WDz1f7js5crnuB3/RLrqN UgaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719506663; x=1720111463; 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=stDFUWod5392Ne89qirOgTqrrl6jkkp2/YnCFIJD5bc=; b=Q7Ab5LxeQ8jnuudcgFOt43GJIHuO01DRf6hx4UEOloHVmjlVr6Ha/i84nN3/0IukgP oV5LFc9V1SKHOEW069gdyP0QHXrSOQijUvoaKbOeXpY3yqzpJjIF5Ll5Vg12qojM3bwi xk4uq2UY0LgJ+JZqsu2LBOHFKuaF4zjxb60Fs3CMIXx+CFMW0WYlpJCt/SL1GEcPrjOT czR0KZ/K5ABa9/tkUV1cI9Lxk09yntoM5A530uIb1BI5L9vbbB9bB86/ZBWIxQUxFKUN 2yqh3o4twIUDXfsaqQNP1e/G3TkR7j+tP9HC6P0SYQJNhbUUhveynhpzFYBs4Dh2Pdx3 T8gQ== X-Gm-Message-State: AOJu0YxGkGoPkmzPxBYvj6LvBme5FI3Pp2O1nqHq1gRx39N7B+Pp+ho0 ltu3unhPErPGDo8to9mW/QurQG8yBwrAhLgzPjjXUXXUr/457h0fyGT+Il+LNPq/WTadfbhsPIc UXVQ= X-Google-Smtp-Source: AGHT+IHK5BHUTYakSbe85zRjUcpk17gxZivMQkq41xJ8x/KtCgBwBbg4bElSk35l8tbD2jJf2P2Pvg== X-Received: by 2002:a05:6512:324a:b0:52c:818c:13b8 with SMTP id 2adb3069b0e04-52ce1832529mr7940761e87.4.1719506661337; Thu, 27 Jun 2024 09:44:21 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Sai Pavan Boddu , Francisco Iglesias , Joel Stanley , Luc Michel , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Bin Meng Subject: [PATCH 03/21] hw/sd/sdcard: Add sd_cmd_SEND_IF_COND handler (CMD8) Date: Thu, 27 Jun 2024 18:43:26 +0200 Message-ID: <20240627164345.82192-4-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627164345.82192-1-philmd@linaro.org> References: <20240627164345.82192-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::12d; envelope-from=philmd@linaro.org; helo=mail-lf1-x12d.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: 1719506686672100007 Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sd.c | 43 ++++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 6ad98db981..e2f7e99ea2 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -240,7 +240,7 @@ static const char *sd_response_name(sd_rsp_type_t rsp) static const char *sd_cmd_name(SDState *sd, uint8_t cmd) { static const char *cmd_abbrev[SDMMC_CMD_MAX] =3D { - [8] =3D "SEND_IF_COND", [9] =3D "SEND_CSD", + [9] =3D "SEND_CSD", [10] =3D "SEND_CID", [12] =3D "STOP_TRANSMISSION", [13] =3D "SEND_STATUS", [15] =3D "GO_INACTIVE_STATE= ", @@ -1303,6 +1303,27 @@ static sd_rsp_type_t sd_cmd_DE_SELECT_CARD(SDState *= sd, SDRequest req) return sd_invalid_state_for_cmd(sd, req); } =20 +/* CMD8 */ +static sd_rsp_type_t sd_cmd_SEND_IF_COND(SDState *sd, SDRequest req) +{ + if (sd->spec_version < SD_PHY_SPECv2_00_VERS) { + return sd_cmd_illegal(sd, req); + } + if (sd->state !=3D sd_idle_state) { + return sd_invalid_state_for_cmd(sd, req); + } + sd->vhs =3D 0; + + /* No response if not exactly one VHS bit is set. */ + if (!(req.arg >> 8) || (req.arg >> (ctz32(req.arg & ~0xff) + 1))) { + return sd_is_spi(sd) ? sd_r7 : sd_r0; + } + + /* Accept. */ + sd->vhs =3D req.arg; + return sd_r7; +} + /* CMD19 */ static sd_rsp_type_t sd_cmd_SEND_TUNING_BLOCK(SDState *sd, SDRequest req) { @@ -1369,24 +1390,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, = SDRequest req) =20 switch (req.cmd) { /* Basic commands (Class 0 and Class 1) */ - case 8: /* CMD8: SEND_IF_COND */ - if (sd->spec_version < SD_PHY_SPECv2_00_VERS) { - break; - } - if (sd->state !=3D sd_idle_state) { - break; - } - sd->vhs =3D 0; - - /* No response if not exactly one VHS bit is set. */ - if (!(req.arg >> 8) || (req.arg >> (ctz32(req.arg & ~0xff) + 1))) { - return sd_is_spi(sd) ? sd_r7 : sd_r0; - } - - /* Accept. */ - sd->vhs =3D req.arg; - return sd_r7; - case 9: /* CMD9: SEND_CSD */ rca =3D sd_req_get_rca(sd, req); switch (sd->state) { @@ -2278,6 +2281,7 @@ static const SDProto sd_proto_spi =3D { [1] =3D {0, sd_spi, "SEND_OP_COND", spi_cmd_SEND_OP_COND}, [5] =3D {9, sd_spi, "IO_SEND_OP_COND", sd_cmd_optional}, [6] =3D {10, sd_spi, "SWITCH_FUNCTION", sd_cmd_SWITCH_FUNCTION}, + [8] =3D {0, sd_spi, "SEND_IF_COND", sd_cmd_SEND_IF_COND}, [34] =3D {10, sd_spi, "READ_SEC_CMD", sd_cmd_optional}, [35] =3D {10, sd_spi, "WRITE_SEC_CMD", sd_cmd_optional}, [36] =3D {10, sd_spi, "SEND_PSI", sd_cmd_optional}, @@ -2302,6 +2306,7 @@ static const SDProto sd_proto_sd =3D { [5] =3D {9, sd_bc, "IO_SEND_OP_COND", sd_cmd_optional}, [6] =3D {10, sd_adtc, "SWITCH_FUNCTION", sd_cmd_SWITCH_FUNCTION}, [7] =3D {0, sd_ac, "(DE)SELECT_CARD", sd_cmd_DE_SELECT_CARD}, + [8] =3D {0, sd_bcr, "SEND_IF_COND", sd_cmd_SEND_IF_COND}, [11] =3D {0, sd_ac, "VOLTAGE_SWITCH", sd_cmd_optional}, [19] =3D {2, sd_adtc, "SEND_TUNING_BLOCK", sd_cmd_SEND_TUNING_BLO= CK}, [20] =3D {2, sd_ac, "SPEED_CLASS_CONTROL", sd_cmd_optional}, --=20 2.41.0 From nobody Mon Nov 25 00:25:54 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=1719506733; cv=none; d=zohomail.com; s=zohoarc; b=fNXm/rWq4Wt0982Ci7WkHQv8VpUVDHqwpQ/9TQkR60VWR/Bh18aGyamYwv8zyoHZ67UckdsJsSiohVBewoQsksFnOuno7Rc/Qw4zwU+zXFOEXaXht2hqaRQI/DdEu2wg6nGJUzRdHNbLNO0mVu8DkPRj9CNQZo2r+zySjNyMRf4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719506733; 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=XRCv4iSMQzY9gbLa0i76FE3UzK8b0j6S+r+3bKGRI48=; b=NUYT4Sp+q5f/Qz88AsgnJ84//vAe1FqqgoOpV3zQhqooQtYjsmub179eO/1c45Fk74UsuXEIYB545OvGTkvZcfaaNr3oQ6qcGqDgVtz+JqkJbiFBy+PsYuMXbgNpBaEF3FEcQq8WZGJDJ0nfqercU8gBnWm44w0Ivx8UPwckA7k= 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 1719506733343632.9547966162487; Thu, 27 Jun 2024 09:45:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMsEc-00022A-SM; Thu, 27 Jun 2024 12:44:34 -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 1sMsEa-0001tH-Nx for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:44:32 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMsEZ-0008Bf-06 for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:44:32 -0400 Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-35f06861ae6so6152198f8f.2 for ; Thu, 27 Jun 2024 09:44:30 -0700 (PDT) Received: from localhost.localdomain (33.red-95-127-46.staticip.rima-tde.net. [95.127.46.33]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-424c8251dc1sm74315795e9.17.2024.06.27.09.44.27 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:44:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719506669; x=1720111469; 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=XRCv4iSMQzY9gbLa0i76FE3UzK8b0j6S+r+3bKGRI48=; b=TqIuMSbi+27TP3tS2J2+MoHiRVuBUs/aUGpHwloam7zdQaZRDHx2AVvXcKQg1TgaNo UIzXVdi81KwIONCES3WfYNlUBOcWnSMqQOI2VTaJmTKN1B1oJzFphtFf4TL/GlWXok6B Dzr8UZsETmncGbnq+vsjhukwVKA8oiAEjuaW34mdao/qzHw1EhEU8tL3TzCLoPHAJpi+ hYghPeAyNVnyA5LMrnohA22By+qzH+1MoLNOVwAzVZaNBVIPkdfAHrw4cAtLHr8s2Rs4 1dn0pAFAz2GD3q52krp5ce8pdkeSQIQCfxvwJSESZJ8FT7PUGcrjWfwcQu2J9Y4/kje9 Kn5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719506669; x=1720111469; 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=XRCv4iSMQzY9gbLa0i76FE3UzK8b0j6S+r+3bKGRI48=; b=rppdgoK/gRv1pXU5+FrbwZVaXXi6Nz/0i19MSxnF93m0DjI3F8twqt/iLKLkpY5utU S2PNVjsGpRVJHcn2ySBmcaSGOXObrk6A1xUOth2JlD5rbX3UHuBFOLWrpl5HtoKinjpK LnryJNKJftax3e0nt0/6zYYJ9767y00yzhQ5zXE4pqQBpYo9zWgTAjgC07N4z+Jy8ZgU v9Fi5AvoGFbJtAm/3JhuqP6MsQl0rXL/FvGTaAIWUcmTbzL5/sFjgCEH6anH+babvRjM yKVdRrgMlSghVZGxomKSOEURNPWvVicbDMHIIp7ssX7xAZo60NMU7b2N5WdIRwGRM8x9 sW9Q== X-Gm-Message-State: AOJu0YxGSVslNd4sOw6pdeGEMHiE0lDmzt6JwzpkJw3EIt/Qpat3NAVr MXmvxD0sjfS3WkNanl3Jsl14Ih1JDfKacmupf9nrjYwHiWJjGV1BkKIOkEyksHcunfw19JZTwGG hx94= X-Google-Smtp-Source: AGHT+IGURTpalTnmgQ3zk2gHgGiZScRcjIb5Jomw70YGorp6z7VhZlUHLxMHgofMtedELOUBXw8NKA== X-Received: by 2002:a5d:59a8:0:b0:365:aad:2f5f with SMTP id ffacd0b85a97d-366e9569f3fmr13621867f8f.29.1719506669304; Thu, 27 Jun 2024 09:44:29 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Sai Pavan Boddu , Francisco Iglesias , Joel Stanley , Luc Michel , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Bin Meng Subject: [PATCH 04/21] hw/sd/sdcard: Add sd_cmd_SEND_CSD/CID handlers (CMD9 & CMD10) Date: Thu, 27 Jun 2024 18:43:27 +0200 Message-ID: <20240627164345.82192-5-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627164345.82192-1-philmd@linaro.org> References: <20240627164345.82192-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::431; envelope-from=philmd@linaro.org; helo=mail-wr1-x431.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: 1719506734893100003 Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sd.c | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index e2f7e99ea2..bd7c7cf518 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -240,8 +240,6 @@ static const char *sd_response_name(sd_rsp_type_t rsp) static const char *sd_cmd_name(SDState *sd, uint8_t cmd) { static const char *cmd_abbrev[SDMMC_CMD_MAX] =3D { - [9] =3D "SEND_CSD", - [10] =3D "SEND_CID", [12] =3D "STOP_TRANSMISSION", [13] =3D "SEND_STATUS", [15] =3D "GO_INACTIVE_STATE= ", [16] =3D "SET_BLOCKLEN", [17] =3D "READ_SINGLE_BLO= CK", @@ -1324,6 +1322,26 @@ static sd_rsp_type_t sd_cmd_SEND_IF_COND(SDState *sd= , SDRequest req) return sd_r7; } =20 +/* CMD9 */ +static sd_rsp_type_t sd_cmd_SEND_CSD(SDState *sd, SDRequest req) +{ + if (sd->state !=3D sd_standby_state) { + return sd_invalid_state_for_cmd(sd, req); + } + + return sd_req_rca_same(sd, req) ? sd_r2_s : sd_r0; +} + +/* CMD10 */ +static sd_rsp_type_t sd_cmd_SEND_CID(SDState *sd, SDRequest req) +{ + if (sd->state !=3D sd_standby_state) { + return sd_invalid_state_for_cmd(sd, req); + } + + return sd_req_rca_same(sd, req) ? sd_r2_i : sd_r0; +} + /* CMD19 */ static sd_rsp_type_t sd_cmd_SEND_TUNING_BLOCK(SDState *sd, SDRequest req) { @@ -1393,12 +1411,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, = SDRequest req) case 9: /* CMD9: SEND_CSD */ rca =3D sd_req_get_rca(sd, req); switch (sd->state) { - case sd_standby_state: - if (sd->rca !=3D rca) - return sd_r0; - - return sd_r2_s; - case sd_transfer_state: if (!sd_is_spi(sd)) { break; @@ -1414,12 +1426,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, = SDRequest req) case 10: /* CMD10: SEND_CID */ rca =3D sd_req_get_rca(sd, req); switch (sd->state) { - case sd_standby_state: - if (sd->rca !=3D rca) - return sd_r0; - - return sd_r2_i; - case sd_transfer_state: if (!sd_is_spi(sd)) { break; @@ -2307,6 +2313,8 @@ static const SDProto sd_proto_sd =3D { [6] =3D {10, sd_adtc, "SWITCH_FUNCTION", sd_cmd_SWITCH_FUNCTION}, [7] =3D {0, sd_ac, "(DE)SELECT_CARD", sd_cmd_DE_SELECT_CARD}, [8] =3D {0, sd_bcr, "SEND_IF_COND", sd_cmd_SEND_IF_COND}, + [9] =3D {0, sd_ac, "SEND_CSD", sd_cmd_SEND_CSD}, + [10] =3D {0, sd_ac, "SEND_CID", sd_cmd_SEND_CID}, [11] =3D {0, sd_ac, "VOLTAGE_SWITCH", sd_cmd_optional}, [19] =3D {2, sd_adtc, "SEND_TUNING_BLOCK", sd_cmd_SEND_TUNING_BLO= CK}, [20] =3D {2, sd_ac, "SPEED_CLASS_CONTROL", sd_cmd_optional}, --=20 2.41.0 From nobody Mon Nov 25 00:25:54 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=1719506715; cv=none; d=zohomail.com; s=zohoarc; b=ONKHbWtVYQ93pZDtACac4Dc1OPzpWOI+K2jLTfEabYIY5EzNqS4oikdVKKvCiIjK57fsCIF1Q3B3igU4XL5Pslw/tPJMOtJvdLZXiRdnxmpIDLddCR3li2cqkNEhhnsk3ZKfmptx9gtA3EOaimet4MWpoUJAInYChQMW4f/Vn5c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719506715; 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=H/Bi9vrwnFZ+zmmMgAN2Gfm5YG78pw+o1VPUAn34pig=; b=bUKwTrrdDLwJJQ3LT2HuxnmD4e7SO8J6wGGagCuT19jp67w8Rz6FYPpu+FZMQpV63TgFNc+I0AKgQjSQfeUTT4nXJWOBI2EFjDrr1tiIRLnFrWdtWcfWITplaldB5eWdC4T4txkXS/yDbovKBYDmN6Tn7Zt09i4pdZZiTXpC29g= 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 1719506715379296.1106655281661; Thu, 27 Jun 2024 09:45:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMsEk-0002B2-OG; Thu, 27 Jun 2024 12:44:42 -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 1sMsEj-0002AI-M5 for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:44:41 -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 1sMsEi-0008CW-1q for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:44:41 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-424720e73e1so65655415e9.1 for ; Thu, 27 Jun 2024 09:44:39 -0700 (PDT) Received: from localhost.localdomain (33.red-95-127-46.staticip.rima-tde.net. [95.127.46.33]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42564a4daeasm36031835e9.10.2024.06.27.09.44.34 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:44:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719506678; x=1720111478; 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=H/Bi9vrwnFZ+zmmMgAN2Gfm5YG78pw+o1VPUAn34pig=; b=Co8Mx0QEPef7SgA6w0wRk1+trpAJ55gaKcsKDEtur0k0LZ9UdvnCgcj8WdivxhOw91 l9Tou8Jrqg3tHiTMEUfrD0M3OYpNUnEhB8/mMKK6ZGL4F3d0cgdbK0jwX/I2s7uMqWMA wPeLmXcco0ZCOaEYqjrWv+pyC+H8ywk9vLu9hp/BCLyJAVP014WpuEXXt91NZZ18oY3x SkQD/lvOk2vcOUDUUlleoO+UoUzSsyr0kfGBV7xyzN0E/59gU697xDCEox/UbGul9l3s /xz4k+siuhlOp9xXzxVHKfJ3JUHlZnnUIWvorRKMpMq4VmGpqGN9BqFDU0ewLtPmBpc2 7ynA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719506678; x=1720111478; 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=H/Bi9vrwnFZ+zmmMgAN2Gfm5YG78pw+o1VPUAn34pig=; b=ZSpPae0ArmyMSLy/kqT2m5SsNU8GPtbTmU+zE6RRRpmqLPgyeu77+lEK5rVzvztdFI X0SC9aClTcn84ocUXrwfmkV70EFw7u+uS6JDCq8ccAYBIVan+WCtFtTNlJfG+Wl/rJPa ao0c1YUMij+qWi63Nu9uMCMMvrmzwGG9RIFWLf8822bX9qvDkgM6su4G0ND8pMu0ZkeV WAFyqwp1sF3OPCHs0gA5vCMAf7M0ajVGYeXTHYBJfuT9rugjHBt+knx2ZY3g5gW8AUWw hE8Eih4Qp1pkbt+cJKbtUOQLin9VyO/rBeokeuWIaNlngJLi7niM8Vb+Fcy9OZlKdO/v XBLA== X-Gm-Message-State: AOJu0YzjVze2Byyjz0nTZfR0PRobCG+SvjIKC/M8Pr/f2D8BkjNDL4ph 3NvSdU3rvawgPyOD/gD+Z9qV0KgmerEqJVb8Ky7CMJM/7gjFpwiMPTzit9jTu/7Xmlmwljc80Fo cShw= X-Google-Smtp-Source: AGHT+IGo+iurNMuugMYHcDNaCgEQVKpZ/2peMUXFTbfmO95K3zjPGfNhhMu+ZWR54DDEZGvSGffRnA== X-Received: by 2002:a05:600c:a:b0:424:ad14:6b79 with SMTP id 5b1f17b1804b1-424ad146e41mr34593085e9.8.1719506678429; Thu, 27 Jun 2024 09:44:38 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Sai Pavan Boddu , Francisco Iglesias , Joel Stanley , Luc Michel , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Bin Meng Subject: [PATCH 05/21] hw/sd/sdcard: Add spi_cmd_SEND_CSD/CID handlers (CMD9 & CMD10) Date: Thu, 27 Jun 2024 18:43:28 +0200 Message-ID: <20240627164345.82192-6-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627164345.82192-1-philmd@linaro.org> References: <20240627164345.82192-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::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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1719506716808100001 Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sd.c | 50 ++++++++++++++++++++------------------------------ 1 file changed, 20 insertions(+), 30 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index bd7c7cf518..564e08709b 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1323,6 +1323,15 @@ static sd_rsp_type_t sd_cmd_SEND_IF_COND(SDState *sd= , SDRequest req) } =20 /* CMD9 */ +static sd_rsp_type_t spi_cmd_SEND_CSD(SDState *sd, SDRequest req) +{ + if (sd->state !=3D sd_standby_state) { + return sd_invalid_state_for_cmd(sd, req); + } + return sd_cmd_to_sendingdata(sd, req, sd_req_get_address(sd, req), + sd->csd, 16); +} + static sd_rsp_type_t sd_cmd_SEND_CSD(SDState *sd, SDRequest req) { if (sd->state !=3D sd_standby_state) { @@ -1333,6 +1342,15 @@ static sd_rsp_type_t sd_cmd_SEND_CSD(SDState *sd, SD= Request req) } =20 /* CMD10 */ +static sd_rsp_type_t spi_cmd_SEND_CID(SDState *sd, SDRequest req) +{ + if (sd->state !=3D sd_standby_state) { + return sd_invalid_state_for_cmd(sd, req); + } + return sd_cmd_to_sendingdata(sd, req, sd_req_get_address(sd, req), + sd->cid, 16); +} + static sd_rsp_type_t sd_cmd_SEND_CID(SDState *sd, SDRequest req) { if (sd->state !=3D sd_standby_state) { @@ -1408,36 +1426,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, = SDRequest req) =20 switch (req.cmd) { /* Basic commands (Class 0 and Class 1) */ - case 9: /* CMD9: SEND_CSD */ - rca =3D sd_req_get_rca(sd, req); - switch (sd->state) { - case sd_transfer_state: - if (!sd_is_spi(sd)) { - break; - } - return sd_cmd_to_sendingdata(sd, req, sd_req_get_address(sd, r= eq), - sd->csd, 16); - - default: - break; - } - break; - - case 10: /* CMD10: SEND_CID */ - rca =3D sd_req_get_rca(sd, req); - switch (sd->state) { - case sd_transfer_state: - if (!sd_is_spi(sd)) { - break; - } - return sd_cmd_to_sendingdata(sd, req, sd_req_get_address(sd, r= eq), - sd->cid, 16); - - default: - break; - } - break; - case 12: /* CMD12: STOP_TRANSMISSION */ switch (sd->state) { case sd_sendingdata_state: @@ -2288,6 +2276,8 @@ static const SDProto sd_proto_spi =3D { [5] =3D {9, sd_spi, "IO_SEND_OP_COND", sd_cmd_optional}, [6] =3D {10, sd_spi, "SWITCH_FUNCTION", sd_cmd_SWITCH_FUNCTION}, [8] =3D {0, sd_spi, "SEND_IF_COND", sd_cmd_SEND_IF_COND}, + [9] =3D {0, sd_spi, "SEND_CSD", spi_cmd_SEND_CSD}, + [10] =3D {0, sd_spi, "SEND_CID", spi_cmd_SEND_CID}, [34] =3D {10, sd_spi, "READ_SEC_CMD", sd_cmd_optional}, [35] =3D {10, sd_spi, "WRITE_SEC_CMD", sd_cmd_optional}, [36] =3D {10, sd_spi, "SEND_PSI", sd_cmd_optional}, --=20 2.41.0 From nobody Mon Nov 25 00:25:54 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=1719506741; cv=none; d=zohomail.com; s=zohoarc; b=VrNiiQGkzByeBvPJkrsNvOAjgtf6al0bCm8jf3jGitKKODmHvjW+CXl2kfPSzHbXQlgeA2URb0lrZAm9A5rIgETsH2ZTXCdymF9mPpieqjJRrJcVlFsvHhFXjkVwEghDoHTxL3H50nMKrs2JCiEIwsc1n9yIvHFBvCj/fjEFMxg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719506741; 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=FsxLv41oI+lmhCr+srqJP++Hluvz2oWQHhnQB9fyk4M=; b=dSYbaknkXmkVHPbn30vOjQFh/3lYjSJeA0dzRTTF0pgB5TYfR8GH7OGQWrChvJGdj+C8lJ1e+6uPHXPYexN9FbjCZlwKhkDQVEBDRgesY4+mxl1o820txdV+Uj5Sbdr/r93yu1Cv8nf+oVvY2GPRVVV/1mzj5erwctkZCVqBbyk= 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 1719506741445797.2749988021449; Thu, 27 Jun 2024 09:45:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMsEx-0002eg-Ql; Thu, 27 Jun 2024 12:44:55 -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 1sMsEu-0002an-Tc for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:44:52 -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 1sMsEs-0008Dh-4L for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:44:52 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-425624255f3so9725545e9.0 for ; Thu, 27 Jun 2024 09:44:49 -0700 (PDT) Received: from localhost.localdomain (33.red-95-127-46.staticip.rima-tde.net. [95.127.46.33]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256aed237dsm253045e9.0.2024.06.27.09.44.44 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:44:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719506688; x=1720111488; 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=FsxLv41oI+lmhCr+srqJP++Hluvz2oWQHhnQB9fyk4M=; b=dy3eJZB5UuDGbae4hsbuRdObjqZRrRVX7iLSuoKSJyCXOOMoMV+Z2u1qZI5l6WxFW9 VAuWBUiKeF0Mt1+y1wJBjGm3+j739je8MU1gW7Xdzc1Y1cdbGcyd/COnvv26x0buHnC3 1eARCQFL8LHTWNKgX1jTKyw3+S4hDV94JwXkX5MHpLV++oByVnPlnwP5osJARx2nmxft 0qV1++AAyBm0QBiMgxHyZVvD0A3ZK78lOcMaN/yn6OStK77HJ+dbFkJRDGr13dqLrc5j 9Kz/MkeLNNBCXpunfDwAcSGOWvgjrnwVIIRh/GIQAZBSfCrM3a01lizYetedjYlJMdzf 9mAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719506688; x=1720111488; 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=FsxLv41oI+lmhCr+srqJP++Hluvz2oWQHhnQB9fyk4M=; b=L2QUtENB0aeUY5fmgAU+kAtliVZefJhULfRFOTja0+hzOntSbL9qm/GANghTCCnz1h FOEKBfDhd67mKT7SKgtfpGP2FtQTy12r8irN6mn536cNW1NFYa6WivQ3Aan/1f4/qk6H 5ETqQU9/nS91LtIwgxxFgnWv9I/bS6X3/eedBhkrstowrY6xK2EY3dllqw0s8LgTZpDn qQsX6d73Ezq4widHPffi9BYhOShs/OfHqX3UGSzB1Ue7n3RSU4jr8QfYG8fGk0qrgHBI njQYk0gpogNSV0t6T/hsOQKUby7TWVBXei+mzAXkCnmKhEtcZVNX3OOfcm/DO5d6vob/ 1hpw== X-Gm-Message-State: AOJu0Yw0CMqeMIIS81oDSw0PTQWC6f6HhpjDAoM5fjT58tcKxmmqnp7/ I1v5T50pW1BZXvs3JjFGxRFY4d77+cUVQlF65gPyqrgNjQFjz4ypap8AruvXlw1ka0zTVfigxrw xfo0= X-Google-Smtp-Source: AGHT+IFFPs8bqwNbCaE+4Q2Mmg4JCMHfas6N+kurOKMdIhES3IlvIIEUw3KToXJAiYP+wClxEM1sxA== X-Received: by 2002:a05:600c:4f11:b0:424:a7f1:ba2 with SMTP id 5b1f17b1804b1-42564377c89mr25554745e9.17.1719506688381; Thu, 27 Jun 2024 09:44:48 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Sai Pavan Boddu , Francisco Iglesias , Joel Stanley , Luc Michel , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Bin Meng Subject: [PATCH 06/21] hw/sd/sdcard: Add sd_cmd_STOP_TRANSMISSION handler (CMD12) Date: Thu, 27 Jun 2024 18:43:29 +0200 Message-ID: <20240627164345.82192-7-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627164345.82192-1-philmd@linaro.org> References: <20240627164345.82192-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: 1719506742857100001 Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sd.c | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 564e08709b..1c092ab43c 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -240,7 +240,7 @@ static const char *sd_response_name(sd_rsp_type_t rsp) static const char *sd_cmd_name(SDState *sd, uint8_t cmd) { static const char *cmd_abbrev[SDMMC_CMD_MAX] =3D { - [12] =3D "STOP_TRANSMISSION", [13] =3D "SEND_STATUS", + [13] =3D "SEND_STATUS", [15] =3D "GO_INACTIVE_STATE= ", [16] =3D "SET_BLOCKLEN", [17] =3D "READ_SINGLE_BLO= CK", [18] =3D "READ_MULTIPLE_BLOCK", @@ -1360,6 +1360,23 @@ static sd_rsp_type_t sd_cmd_SEND_CID(SDState *sd, SD= Request req) return sd_req_rca_same(sd, req) ? sd_r2_i : sd_r0; } =20 +/* CMD12 */ +static sd_rsp_type_t sd_cmd_STOP_TRANSMISSION(SDState *sd, SDRequest req) +{ + switch (sd->state) { + case sd_sendingdata_state: + sd->state =3D sd_transfer_state; + return sd_r1b; + case sd_receivingdata_state: + sd->state =3D sd_programming_state; + /* Bzzzzzzztt .... Operation complete. */ + sd->state =3D sd_transfer_state; + return sd_r1; + default: + return sd_invalid_state_for_cmd(sd, req); + } +} + /* CMD19 */ static sd_rsp_type_t sd_cmd_SEND_TUNING_BLOCK(SDState *sd, SDRequest req) { @@ -1426,23 +1443,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, = SDRequest req) =20 switch (req.cmd) { /* Basic commands (Class 0 and Class 1) */ - case 12: /* CMD12: STOP_TRANSMISSION */ - switch (sd->state) { - case sd_sendingdata_state: - sd->state =3D sd_transfer_state; - return sd_r1b; - - case sd_receivingdata_state: - sd->state =3D sd_programming_state; - /* Bzzzzzzztt .... Operation complete. */ - sd->state =3D sd_transfer_state; - return sd_r1b; - - default: - break; - } - break; - case 13: /* CMD13: SEND_STATUS */ rca =3D sd_req_get_rca(sd, req); if (sd->mode !=3D sd_data_transfer_mode) { @@ -2278,6 +2278,7 @@ static const SDProto sd_proto_spi =3D { [8] =3D {0, sd_spi, "SEND_IF_COND", sd_cmd_SEND_IF_COND}, [9] =3D {0, sd_spi, "SEND_CSD", spi_cmd_SEND_CSD}, [10] =3D {0, sd_spi, "SEND_CID", spi_cmd_SEND_CID}, + [12] =3D {0, sd_spi, "STOP_TRANSMISSION", sd_cmd_STOP_TRANSMISSIO= N}, [34] =3D {10, sd_spi, "READ_SEC_CMD", sd_cmd_optional}, [35] =3D {10, sd_spi, "WRITE_SEC_CMD", sd_cmd_optional}, [36] =3D {10, sd_spi, "SEND_PSI", sd_cmd_optional}, @@ -2306,6 +2307,7 @@ static const SDProto sd_proto_sd =3D { [9] =3D {0, sd_ac, "SEND_CSD", sd_cmd_SEND_CSD}, [10] =3D {0, sd_ac, "SEND_CID", sd_cmd_SEND_CID}, [11] =3D {0, sd_ac, "VOLTAGE_SWITCH", sd_cmd_optional}, + [12] =3D {0, sd_ac, "STOP_TRANSMISSION", sd_cmd_STOP_TRANSMISSI= ON}, [19] =3D {2, sd_adtc, "SEND_TUNING_BLOCK", sd_cmd_SEND_TUNING_BLO= CK}, [20] =3D {2, sd_ac, "SPEED_CLASS_CONTROL", sd_cmd_optional}, [23] =3D {2, sd_ac, "SET_BLOCK_COUNT", sd_cmd_SET_BLOCK_COUNT}, --=20 2.41.0 From nobody Mon Nov 25 00:25:54 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=1719506749; cv=none; d=zohomail.com; s=zohoarc; b=DnYEJE2STY9y70RUCu1Za/sagrCRhsVrgEYhi0/BvrFNJFD2Rr6D6d7tb8essd+qJhMJ5Ze5qbJBeashoSX209g6PrEB2BQs681p6isdDY5C2rxWh/3pQuvVv0zVQUVnOkraoWTQAOU8Du3UYmBISRKhqtV20KYi23z0uThasOo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719506749; 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=4nsIUIKAxv1jJ77cujJiWISIWdMZfiLK/guukYvkLv0=; b=IEDNUpxF1QZifGS8UJQeaTYTzp9Ylo4f3CXNE2NZpi0ZqU4H8xte/axnk+PAYwpJOSiSCuEBOwwtHkWY9XlVC1DifEMBYpjYzc2+yrxBvtZ9a/UKWIQP2re1tele3H0b0UiJlbI8UgaTK+DPICO3mov6nKZToHR/ec6AtWg0xnI= 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 1719506749150675.0468751018198; Thu, 27 Jun 2024 09:45:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMsFD-000322-En; Thu, 27 Jun 2024 12:45: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 1sMsF4-0002kj-Hn for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:45:03 -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 1sMsF1-0008GC-Oe for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:45:02 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-42562fde108so11889375e9.0 for ; Thu, 27 Jun 2024 09:44:59 -0700 (PDT) Received: from localhost.localdomain (33.red-95-127-46.staticip.rima-tde.net. [95.127.46.33]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256aed237dsm260235e9.0.2024.06.27.09.44.55 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:44:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719506698; x=1720111498; 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=4nsIUIKAxv1jJ77cujJiWISIWdMZfiLK/guukYvkLv0=; b=UruQF5cbgeA/L5pCkB3DUxvS9DQk4tL4W4GNTHhDhATFJ6nhL8Ydk2hI4jfbRaAQ/Z SeT8FWC2KBAB6OslKmyRBdJmkQ/0S214VLQWIznsunNEQ7suXqnmh+Dh6SF/DSv0TVm4 s9p59KN+02fpQJtFj2xIj3w3TDAb/Uj4NSt//tf9wNYgJiHbGCNp2Ewu+lDQYnC830ab v+ssFVvRQxpDsb5KkOessV6YCvOwcBccnZ0uJ6Q3biwG1UpfyAbL5E3wbDnaN0gTLRCH /nw5LV9rng+a5zMCExWecIot0E0k/mPnxOZ+1GCsR+6V0MYyUM0NAa6Eiby0o0/6i/Z/ eh7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719506698; x=1720111498; 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=4nsIUIKAxv1jJ77cujJiWISIWdMZfiLK/guukYvkLv0=; b=VEgh1QXoqunA0rNAMMYSIyJeWP8A8KqO7ZBh8I/FcPltBEt8L61BEEg2V7sV8Bwzzl VL/G8s16CDYa0JT0Iq4gnT0+kQxzMdJKFeta9BIon4Q9Q2w4p0sunNnJD9dnNbr4rbea QpNqdrq9HvDxm6Bf5KJ421G8uUB9j0rXmAcORqNBDZUSaT7h63xqgYkcEyaVkqpX6EjS zsvbz1DxXsz1eF5VT/pdHMmDSmQIcSwMf9PYMjNQnNfrxrl4Fjg6TrmAvko8d0h+OsST CNorg6ISDuYbX+PK+eBeD8vUz0DD2xX4UhCSMgGHqCJrXS0Hzw9DgLrGVGo15+SjHD6B uaSw== X-Gm-Message-State: AOJu0YyUxn81As+XkJZK3wycG8L8xqUD8zWP9j8Ytnzjv13KHkxEQXNG QOHq78/B3vfacVPjhghIPaS6Mgzk82yuFVoeFCF0GTJHuF+7qL/Szlo4u33TaphKpSLlR+Dpjrq Z8cU= X-Google-Smtp-Source: AGHT+IFJlrbc+L9YIL2JP6ybIuDikfbOScRuF4/dcK+k+qk6V8XzJaBC2hotD2O2AugyWh5HjZqsUg== X-Received: by 2002:a7b:cb56:0:b0:423:6957:89bd with SMTP id 5b1f17b1804b1-4248cc287b0mr104621225e9.12.1719506697908; Thu, 27 Jun 2024 09:44:57 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Sai Pavan Boddu , Francisco Iglesias , Joel Stanley , Luc Michel , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Bin Meng Subject: [PATCH 07/21] hw/sd/sdcard: Add sd_cmd_SEND_STATUS handler (CMD13) Date: Thu, 27 Jun 2024 18:43:30 +0200 Message-ID: <20240627164345.82192-8-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627164345.82192-1-philmd@linaro.org> References: <20240627164345.82192-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: 1719506750929100003 Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sd.c | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 1c092ab43c..bb80d11f87 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -240,7 +240,6 @@ static const char *sd_response_name(sd_rsp_type_t rsp) static const char *sd_cmd_name(SDState *sd, uint8_t cmd) { static const char *cmd_abbrev[SDMMC_CMD_MAX] =3D { - [13] =3D "SEND_STATUS", [15] =3D "GO_INACTIVE_STATE= ", [16] =3D "SET_BLOCKLEN", [17] =3D "READ_SINGLE_BLO= CK", [18] =3D "READ_MULTIPLE_BLOCK", @@ -1377,6 +1376,32 @@ static sd_rsp_type_t sd_cmd_STOP_TRANSMISSION(SDStat= e *sd, SDRequest req) } } =20 +/* CMD13 */ +static sd_rsp_type_t sd_cmd_SEND_STATUS(SDState *sd, SDRequest req) +{ + if (sd->mode !=3D sd_data_transfer_mode) { + return sd_invalid_mode_for_cmd(sd, req); + } + + switch (sd->state) { + case sd_standby_state: + case sd_transfer_state: + case sd_sendingdata_state: + case sd_receivingdata_state: + case sd_programming_state: + case sd_disconnect_state: + break; + default: + return sd_invalid_state_for_cmd(sd, req); + } + + if (sd_is_spi(sd)) { + return sd_r2_s; + } + + return sd_req_rca_same(sd, req) ? sd_r1 : sd_r0; +} + /* CMD19 */ static sd_rsp_type_t sd_cmd_SEND_TUNING_BLOCK(SDState *sd, SDRequest req) { @@ -1443,17 +1468,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, = SDRequest req) =20 switch (req.cmd) { /* Basic commands (Class 0 and Class 1) */ - case 13: /* CMD13: SEND_STATUS */ - rca =3D sd_req_get_rca(sd, req); - if (sd->mode !=3D sd_data_transfer_mode) { - return sd_invalid_mode_for_cmd(sd, req); - } - if (!sd_is_spi(sd) && sd->rca !=3D rca) { - return sd_r0; - } - - return sd_r1; - case 15: /* CMD15: GO_INACTIVE_STATE */ if (sd->mode !=3D sd_data_transfer_mode) { return sd_invalid_mode_for_cmd(sd, req); @@ -2279,6 +2293,7 @@ static const SDProto sd_proto_spi =3D { [9] =3D {0, sd_spi, "SEND_CSD", spi_cmd_SEND_CSD}, [10] =3D {0, sd_spi, "SEND_CID", spi_cmd_SEND_CID}, [12] =3D {0, sd_spi, "STOP_TRANSMISSION", sd_cmd_STOP_TRANSMISSIO= N}, + [13] =3D {0, sd_spi, "SEND_STATUS", sd_cmd_SEND_STATUS}, [34] =3D {10, sd_spi, "READ_SEC_CMD", sd_cmd_optional}, [35] =3D {10, sd_spi, "WRITE_SEC_CMD", sd_cmd_optional}, [36] =3D {10, sd_spi, "SEND_PSI", sd_cmd_optional}, @@ -2308,6 +2323,7 @@ static const SDProto sd_proto_sd =3D { [10] =3D {0, sd_ac, "SEND_CID", sd_cmd_SEND_CID}, [11] =3D {0, sd_ac, "VOLTAGE_SWITCH", sd_cmd_optional}, [12] =3D {0, sd_ac, "STOP_TRANSMISSION", sd_cmd_STOP_TRANSMISSI= ON}, + [13] =3D {0, sd_ac, "SEND_STATUS", sd_cmd_SEND_STATUS}, [19] =3D {2, sd_adtc, "SEND_TUNING_BLOCK", sd_cmd_SEND_TUNING_BLO= CK}, [20] =3D {2, sd_ac, "SPEED_CLASS_CONTROL", sd_cmd_optional}, [23] =3D {2, sd_ac, "SET_BLOCK_COUNT", sd_cmd_SET_BLOCK_COUNT}, --=20 2.41.0 From nobody Mon Nov 25 00:25:54 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=1719506736; cv=none; d=zohomail.com; s=zohoarc; b=gpk+QKCEdxuS0WJt+zVrf07n7euH0Lc/joAl7W795KcJ+cbIWjNCqtUKyUhAWT6WFAriHfbErjZFy+ZurYyM21YYA3wrdJDeLPCGTcTv3hQ0Zifjc1MOy0a3zBUbri2H0MZQHNXwlejLXyvUqT3vW6M7CqTYHQKYZBPibF2scr8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719506736; 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=wED9lVuSIJVna4+aCIAwx+9S/4ApkNiJ+n4u5rDB9Rw=; b=htcc/JPpobvtZNfUCcA0ou4SLNnyWUbR3RjH9aSA+OIkdc9TWOdLPQ6OcNDGSwVSJPUN2acB4HH6UCqebYDzHlo9zznZkvIr7D8R0aLbkRiEi9X7zzkRaOdDoWOfchVAqluOc2J9efbmRV2XZ3mISHQ6CvTWYPBsfPtmcbslbIs= 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 1719506736901728.2232615107091; Thu, 27 Jun 2024 09:45:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMsFL-0003SN-NR; Thu, 27 Jun 2024 12:45:19 -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 1sMsFF-0003CW-Ks for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:45:15 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMsFC-0008SQ-RW for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:45:12 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-4256aee6d4fso11015e9.3 for ; Thu, 27 Jun 2024 09:45:09 -0700 (PDT) Received: from localhost.localdomain (33.red-95-127-46.staticip.rima-tde.net. [95.127.46.33]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-424c8251149sm72983295e9.11.2024.06.27.09.45.03 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:45:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719506707; x=1720111507; 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=wED9lVuSIJVna4+aCIAwx+9S/4ApkNiJ+n4u5rDB9Rw=; b=wmXIVJpN7btns5qwTxXrM3N5lSqD+MziS9Evc8M2zMcHOJ1jFmMoBjXSBbG9K5WUL3 yZxZ6KTg4VnbaZnHNeCcpPZPly0cvWaJhjYgk52uMUxwFnhuumsCKVE0SMKRnbCUIxVf NgWe/FCv7bGnlo6ddKcrTvWsAp1k6r8bSa+tJ1FX3n0J9QaF1/IVgQzb4ak8tWmr1bW4 fpcLnbxN9RZBPt153WoynzXOk2GJjXgNs72SdHTL6GdCT2kFi0/debzRmJHfiE3/qOLh ZgS/BWWKIbrYr+PDBjnhfoRTmT4R5PNRNH0lQaUBobU58lnzerLKb1F+rndd4bLQ5qLB gXWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719506707; x=1720111507; 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=wED9lVuSIJVna4+aCIAwx+9S/4ApkNiJ+n4u5rDB9Rw=; b=oWBERopdtb/S2S3K7Rf6ddrtfWxkWwMXj1riWhCJk05k/nQ+ZnnvsyXMjFPTUHT9tj YOE5XJ6KUB11IW2bBaktGjV3k3kSTE5AzJ4Z1LVQTYZfgP5waoxBNSlMUEVh+GwyxIpc dCMgfJh3F7n5qXMyxLUbm+G9zlBHIXwAhHr3siW0D2c7+awmZHi4qgRGt8dX2jEF5wUW PnZMMk744bUkb3kfKo1ub+SmkigAI6S28YS+Nl+sAMcy70q35FWUIFvsUhG6u2rW9Glc IPpNhqzJJCPTuM3+HHWezCfqd3HJ10Uzvcwz1cR15Bqo6JY5CHKorw2VDRoa6Pft00s7 MiTw== X-Gm-Message-State: AOJu0Yy9nGIjoiZ8Xf0MxsnjAbcAsJhLrqjM+KtTbELvwHpCUBf4JBKn VtclHp4FP5uTL54nKQhXBzvJfGxrrzBKAr++6bBaMAiqwmSf9lfvdgbdcWqzuja2g4LTK49UFs0 NxGo= X-Google-Smtp-Source: AGHT+IHzmc8y2pQilKecexD3dNw+fvmZuQWI1UZ05Q6Cr0V2Zt8AmjzpDRWtPJCBkeIpMDfuVmDl+Q== X-Received: by 2002:a05:600c:6b0b:b0:424:ac32:afa9 with SMTP id 5b1f17b1804b1-424ac32b059mr45878805e9.22.1719506707516; Thu, 27 Jun 2024 09:45:07 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Sai Pavan Boddu , Francisco Iglesias , Joel Stanley , Luc Michel , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Bin Meng Subject: [PATCH 08/21] hw/sd/sdcard: Add sd_cmd_GO_INACTIVE_STATE handler (CMD15) Date: Thu, 27 Jun 2024 18:43:31 +0200 Message-ID: <20240627164345.82192-9-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627164345.82192-1-philmd@linaro.org> References: <20240627164345.82192-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::32f; envelope-from=philmd@linaro.org; helo=mail-wm1-x32f.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: 1719506738864100003 Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sd.c | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index bb80d11f87..d7ed8aee73 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -240,7 +240,6 @@ static const char *sd_response_name(sd_rsp_type_t rsp) static const char *sd_cmd_name(SDState *sd, uint8_t cmd) { static const char *cmd_abbrev[SDMMC_CMD_MAX] =3D { - [15] =3D "GO_INACTIVE_STATE= ", [16] =3D "SET_BLOCKLEN", [17] =3D "READ_SINGLE_BLO= CK", [18] =3D "READ_MULTIPLE_BLOCK", [21] =3D "DPS_spec", @@ -1402,6 +1401,30 @@ static sd_rsp_type_t sd_cmd_SEND_STATUS(SDState *sd,= SDRequest req) return sd_req_rca_same(sd, req) ? sd_r1 : sd_r0; } =20 +/* CMD15 */ +static sd_rsp_type_t sd_cmd_GO_INACTIVE_STATE(SDState *sd, SDRequest req) +{ + if (sd->mode !=3D sd_data_transfer_mode) { + return sd_invalid_mode_for_cmd(sd, req); + } + switch (sd->state) { + case sd_standby_state: + case sd_transfer_state: + case sd_sendingdata_state: + case sd_receivingdata_state: + case sd_programming_state: + case sd_disconnect_state: + break; + default: + return sd_invalid_state_for_cmd(sd, req); + } + if (sd_req_rca_same(sd, req)) { + sd->state =3D sd_inactive_state; + } + + return sd_r0; +} + /* CMD19 */ static sd_rsp_type_t sd_cmd_SEND_TUNING_BLOCK(SDState *sd, SDRequest req) { @@ -1467,17 +1490,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, = SDRequest req) } =20 switch (req.cmd) { - /* Basic commands (Class 0 and Class 1) */ - case 15: /* CMD15: GO_INACTIVE_STATE */ - if (sd->mode !=3D sd_data_transfer_mode) { - return sd_invalid_mode_for_cmd(sd, req); - } - rca =3D sd_req_get_rca(sd, req); - if (sd->rca =3D=3D rca) { - sd->state =3D sd_inactive_state; - } - return sd_r0; - /* Block read commands (Class 2) */ case 16: /* CMD16: SET_BLOCKLEN */ switch (sd->state) { @@ -2324,6 +2336,7 @@ static const SDProto sd_proto_sd =3D { [11] =3D {0, sd_ac, "VOLTAGE_SWITCH", sd_cmd_optional}, [12] =3D {0, sd_ac, "STOP_TRANSMISSION", sd_cmd_STOP_TRANSMISSI= ON}, [13] =3D {0, sd_ac, "SEND_STATUS", sd_cmd_SEND_STATUS}, + [15] =3D {0, sd_ac, "GO_INACTIVE_STATE", sd_cmd_GO_INACTIVE_STA= TE}, [19] =3D {2, sd_adtc, "SEND_TUNING_BLOCK", sd_cmd_SEND_TUNING_BLO= CK}, [20] =3D {2, sd_ac, "SPEED_CLASS_CONTROL", sd_cmd_optional}, [23] =3D {2, sd_ac, "SET_BLOCK_COUNT", sd_cmd_SET_BLOCK_COUNT}, --=20 2.41.0 From nobody Mon Nov 25 00:25:54 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=1719506733; cv=none; d=zohomail.com; s=zohoarc; b=g47pRnX29cCL7Pl6TTNFAO4M47xX/hBqVXfjLfhniY1Jtbs/48JfgOrPSD82MzENGh8mztx6oIyU19tbMBU5+p97LIJq3HPXn9WoAuxLT9Gt+Q/MtlFJZfoGpwqqouxRoOTPy2djWvT5MqIYYFa+oE1A0vf9Kpnx/Z7B6f+F63A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719506733; 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=/x47xZoGwEv6OAz6MBmyY9zpVBzbWRJPcmwD+bMVYlw=; b=N8d9qdEPg1huMvIOUIL0oYRBPQNZ4mOZEakJemCCpbm+i0Z7t5Trcrvm7zTZ3C+PTp4NyAXRDEHidNxcYWNGAJLrtLrDSjeiwdVuwE7xaamduwhHcIDemlwUkr5GJs5lNXtS6yrAL68E+K7ON+S8mtiDTJQAZ9epX36dv3n/Mso= 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 1719506733096262.9385693165623; Thu, 27 Jun 2024 09:45:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMsFT-0003uL-O8; Thu, 27 Jun 2024 12:45:27 -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 1sMsFO-0003bR-KT for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:45:24 -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 1sMsFL-0008Uk-Al for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:45:22 -0400 Received: by mail-lj1-x230.google.com with SMTP id 38308e7fff4ca-2eaa89464a3so92254721fa.3 for ; Thu, 27 Jun 2024 09:45:18 -0700 (PDT) Received: from localhost.localdomain (33.red-95-127-46.staticip.rima-tde.net. [95.127.46.33]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42564bb6d28sm35291065e9.31.2024.06.27.09.45.13 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:45:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719506717; x=1720111517; 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=/x47xZoGwEv6OAz6MBmyY9zpVBzbWRJPcmwD+bMVYlw=; b=SbOMYOx5MAvlT7xfXBfWPXJqzZelgjFJZndZ4xCxemYh62UMUKMX3HjOzDYux/G4Nl HhA+99i7GomZ3wOghdigkm2Xhi/90eq4BtG1bFDyinL4bYn2YGaBTEfuLgi6uN0dyDqe 2U4slS0fQaTzUDXinwrS25tCbXOtavz+A9qGkyn65YUYlvtHynfhuNd4/2EOkJDxrdT1 gI6X9N/haKKy368Qvy4DZ0stC0lbNVey9JpNAa+/k0YYqPKDRIPQD22ZOsu2RNlUdhH+ J0mHAnW3y6YqG/OW8kM7quf/AGWCRFjpjoFnhOrrjBLZYfpALl0AN2zF+htndkOvqTre DOoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719506717; x=1720111517; 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=/x47xZoGwEv6OAz6MBmyY9zpVBzbWRJPcmwD+bMVYlw=; b=FIN5Kjo+24fXGt+4Moo5Mu1EgK+lByhCN7vrOGrG2FvPVajTWsitGbSL8dAF4gj3yX F1c/09CXTpdYmoGkcyWH1JS+FzLY7MQhCJOWq83OLJ0oSTd9ih6qPWBYwxOOCPuO56/e MuxIENNvR7kVcsBzDm6wWzT6HurUgtEGWDFesOcqrnS3qRBkzWT6k8+mI4AKqgXErp7s pwPaQPyv1dZ10yMcZiV3TPDQ941eKUuUGEbaKz6CsERxZplHQa55mXerToeXUNmMqdvi 3JBlFAyaMdpeASys2IEKPPiJ3dHhQndwnDdGeYYhFg25sdl5Bg8kWJM1FEgBpa5nTcKC KagQ== X-Gm-Message-State: AOJu0YwSfDuZhyiNc/VwYAqi5cz4T48vXz2wTUzpCKVEQK2rNt45SN2S n20OsLeaVmqC3xRCGY31l0Hc2UkhXMpblNC2OLRnqskqJnua+Y6CSI32miBFLdG8dxpaytpfLoD WvzM= X-Google-Smtp-Source: AGHT+IH1wOqUlvz5b9iIVUERP+SxXCWF0mXK6iHjr6bNOwMzdbGragyXOFp/dj7Z0ULB3I7aL3bJrA== X-Received: by 2002:a2e:800a:0:b0:2ec:4e59:a3de with SMTP id 38308e7fff4ca-2ec57967be5mr94810931fa.10.1719506717191; Thu, 27 Jun 2024 09:45:17 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Sai Pavan Boddu , Francisco Iglesias , Joel Stanley , Luc Michel , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Bin Meng Subject: [PATCH 09/21] hw/sd/sdcard: Add sd_cmd_SET_BLOCKLEN handler (CMD16) Date: Thu, 27 Jun 2024 18:43:32 +0200 Message-ID: <20240627164345.82192-10-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627164345.82192-1-philmd@linaro.org> References: <20240627164345.82192-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: 1719506734899100004 Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sd.c | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index d7ed8aee73..d731c3df58 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -240,7 +240,7 @@ static const char *sd_response_name(sd_rsp_type_t rsp) static const char *sd_cmd_name(SDState *sd, uint8_t cmd) { static const char *cmd_abbrev[SDMMC_CMD_MAX] =3D { - [16] =3D "SET_BLOCKLEN", [17] =3D "READ_SINGLE_BLO= CK", + [17] =3D "READ_SINGLE_BLOCK= ", [18] =3D "READ_MULTIPLE_BLOCK", [21] =3D "DPS_spec", [24] =3D "WRITE_BLOCK", [25] =3D "WRITE_MULTIPLE_= BLOCK", @@ -1425,6 +1425,22 @@ static sd_rsp_type_t sd_cmd_GO_INACTIVE_STATE(SDStat= e *sd, SDRequest req) return sd_r0; } =20 +/* CMD16 */ +static sd_rsp_type_t sd_cmd_SET_BLOCKLEN(SDState *sd, SDRequest req) +{ + if (sd->state !=3D sd_transfer_state) { + return sd_invalid_state_for_cmd(sd, req); + } + if (req.arg > (1 << HWBLOCK_SHIFT)) { + sd->card_status |=3D BLOCK_LEN_ERROR; + } else { + trace_sdcard_set_blocklen(req.arg); + sd->blk_len =3D req.arg; + } + + return sd_r1; +} + /* CMD19 */ static sd_rsp_type_t sd_cmd_SEND_TUNING_BLOCK(SDState *sd, SDRequest req) { @@ -1491,23 +1507,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, = SDRequest req) =20 switch (req.cmd) { /* Block read commands (Class 2) */ - case 16: /* CMD16: SET_BLOCKLEN */ - switch (sd->state) { - case sd_transfer_state: - if (req.arg > (1 << HWBLOCK_SHIFT)) { - sd->card_status |=3D BLOCK_LEN_ERROR; - } else { - trace_sdcard_set_blocklen(req.arg); - sd->blk_len =3D req.arg; - } - - return sd_r1; - - default: - break; - } - break; - case 17: /* CMD17: READ_SINGLE_BLOCK */ addr =3D sd_req_get_address(sd, req); switch (sd->state) { @@ -2306,6 +2305,7 @@ static const SDProto sd_proto_spi =3D { [10] =3D {0, sd_spi, "SEND_CID", spi_cmd_SEND_CID}, [12] =3D {0, sd_spi, "STOP_TRANSMISSION", sd_cmd_STOP_TRANSMISSIO= N}, [13] =3D {0, sd_spi, "SEND_STATUS", sd_cmd_SEND_STATUS}, + [16] =3D {2, sd_spi, "SET_BLOCKLEN", sd_cmd_SET_BLOCKLEN}, [34] =3D {10, sd_spi, "READ_SEC_CMD", sd_cmd_optional}, [35] =3D {10, sd_spi, "WRITE_SEC_CMD", sd_cmd_optional}, [36] =3D {10, sd_spi, "SEND_PSI", sd_cmd_optional}, @@ -2337,6 +2337,7 @@ static const SDProto sd_proto_sd =3D { [12] =3D {0, sd_ac, "STOP_TRANSMISSION", sd_cmd_STOP_TRANSMISSI= ON}, [13] =3D {0, sd_ac, "SEND_STATUS", sd_cmd_SEND_STATUS}, [15] =3D {0, sd_ac, "GO_INACTIVE_STATE", sd_cmd_GO_INACTIVE_STA= TE}, + [16] =3D {2, sd_ac, "SET_BLOCKLEN", sd_cmd_SET_BLOCKLEN}, [19] =3D {2, sd_adtc, "SEND_TUNING_BLOCK", sd_cmd_SEND_TUNING_BLO= CK}, [20] =3D {2, sd_ac, "SPEED_CLASS_CONTROL", sd_cmd_optional}, [23] =3D {2, sd_ac, "SET_BLOCK_COUNT", sd_cmd_SET_BLOCK_COUNT}, --=20 2.41.0 From nobody Mon Nov 25 00:25:54 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=1719506898; cv=none; d=zohomail.com; s=zohoarc; b=DnZb2eOk/1Slrdad4942G80ab1Scey2rGHgNlPHsdBCDkbLYaOwZJM5cW7HE58Y6ohd1Q/XQfLTJvTZvCa4PXSnqyNu7N4XqtFlPd4QamdXXcTuA4SzjYdDALo6bvtrc7n8oobsANsVbHRdu6OYFinZpM/XnHVQij58Fqljs2F8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719506898; 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=vajGPnoCMySfBXhKCpWI2G0uKNcFQdTzNyXEs7BknL8=; b=a3fgM612iXbs+2yDB7vWh9gEr0g7iNar9xiL1IfjicBBeNRzmarAUpJuGEdIbF33h9QupH6lComBhVgz7Vv/K1F1gojzOIdVH9T/S67JDkQBR2xHwF/BgDfCrHfKzp1gl4CFBcyM07IY8Pc5V0xniHAyLPTyHmSpRt0h6nregsE= 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 171950689885745.56255717480917; Thu, 27 Jun 2024 09:48:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMsFa-0004aL-8Y; Thu, 27 Jun 2024 12:45:34 -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 1sMsFX-0004O0-Jt for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:45:31 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMsFV-000097-Sg for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:45:31 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-42562a984d3so11699445e9.3 for ; Thu, 27 Jun 2024 09:45:29 -0700 (PDT) Received: from localhost.localdomain (33.red-95-127-46.staticip.rima-tde.net. [95.127.46.33]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36743699a8csm2459238f8f.78.2024.06.27.09.45.22 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:45:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719506727; x=1720111527; 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=vajGPnoCMySfBXhKCpWI2G0uKNcFQdTzNyXEs7BknL8=; b=QDtB5SaHqjz97rDRqfAqOmYo0U7u9C+9bI74EDd9DCL1EDfhVH7JsDd9Gk+fREDPe9 5ta6rqFQZGYy+1/Q/YcLePV7bXS/yv659fh6ySOAOBUJNx8r7amrmhAUhDPRu7qWHTiz y45JGE3PtjP2P7mAxyGrDis+7MyyIy6RgPvyMLgm2RR/ku/gSX5zQHsnzv2GQqpd78di MYf0XRwjsxwIu0ZuLGzkGMvvxvivdKGqj6iii/ZZDcMSwAkuVJ0jQSNVFi9w4SXAQhiN t38EKkAJ9LADLNZVsfcbU6bgAgf3za1LzZJPQwMXNfjgWvZWxp4TCPooPjoidfqDyBxJ fHlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719506727; x=1720111527; 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=vajGPnoCMySfBXhKCpWI2G0uKNcFQdTzNyXEs7BknL8=; b=cQj+Yqfl5OSOlsXHMEDmZn7oGYs78/D+kXs5/9XFGiMLiWjng0YWhnv+QjOSJjRXKR GehDbHWZsC1+Qjv9b6in1ndTs1tyA1EKfaocYZTgHFSYWqKUmu78KMm82/owvMcPF2P1 W5QctsUeHF53UXk5EsW5werM+w4s3ciR4Ttyz51vQxgZKXE1HtgLsaC805gHdiR09bur ib7C1M7uIwyKYx05XPLZ5TfLeE0UeB2YuWsuo+KaKUaqb9iikPBlJlUmPYrEJC9I1rt1 qMx2IM1iagDRjwCMwvefhvsckXgUlbFnsRVxF4rPymXvrNJKo/ZXpcbKFYTMmzFn2rm2 1eHQ== X-Gm-Message-State: AOJu0YyQ46D8EucMd9y4nMHliP4pP0DCEPbFrsbWN73ylknJnbfE4eiu 9gaTP6rUYeDoE3322zDm2yjSK10jS93D41Ey7n4GB+6hhysfA0fGRyJw887Mf3mUQ/uM4gCBgKM 9yJk= X-Google-Smtp-Source: AGHT+IFajDSTOjQRK81WtD7GfKbnpFHt+3JmotbK081RWOrL4gtHRVh52XqtQF0L3w1czxkbC4PhVA== X-Received: by 2002:a5d:46c2:0:b0:360:9cf4:58ce with SMTP id ffacd0b85a97d-366e96b22damr8635597f8f.46.1719506726806; Thu, 27 Jun 2024 09:45:26 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Sai Pavan Boddu , Francisco Iglesias , Joel Stanley , Luc Michel , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Bin Meng Subject: [PATCH 10/21] hw/sd/sdcard: Add sd_cmd_READ_SINGLE_BLOCK handler (CMD17) Date: Thu, 27 Jun 2024 18:43:33 +0200 Message-ID: <20240627164345.82192-11-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627164345.82192-1-philmd@linaro.org> References: <20240627164345.82192-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::32b; envelope-from=philmd@linaro.org; helo=mail-wm1-x32b.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: 1719506899505100001 Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sd.c | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index d731c3df58..e2a7ed8b45 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -240,7 +240,6 @@ static const char *sd_response_name(sd_rsp_type_t rsp) static const char *sd_cmd_name(SDState *sd, uint8_t cmd) { static const char *cmd_abbrev[SDMMC_CMD_MAX] =3D { - [17] =3D "READ_SINGLE_BLOCK= ", [18] =3D "READ_MULTIPLE_BLOCK", [21] =3D "DPS_spec", [24] =3D "WRITE_BLOCK", [25] =3D "WRITE_MULTIPLE_= BLOCK", @@ -1441,6 +1440,24 @@ static sd_rsp_type_t sd_cmd_SET_BLOCKLEN(SDState *sd= , SDRequest req) return sd_r1; } =20 +/* CMD17 */ +static sd_rsp_type_t sd_cmd_READ_SINGLE_BLOCK(SDState *sd, SDRequest req) +{ + uint64_t addr; + + if (sd->state !=3D sd_transfer_state) { + return sd_invalid_state_for_cmd(sd, req); + } + + addr =3D sd_req_get_address(sd, req); + if (!address_in_range(sd, "READ_SINGLE_BLOCK", addr, sd->blk_len)) { + return sd_r1; + } + + sd_blk_read(sd, addr, sd->blk_len); + return sd_cmd_to_sendingdata(sd, req, addr, NULL, sd->blk_len); +} + /* CMD19 */ static sd_rsp_type_t sd_cmd_SEND_TUNING_BLOCK(SDState *sd, SDRequest req) { @@ -1507,22 +1524,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, = SDRequest req) =20 switch (req.cmd) { /* Block read commands (Class 2) */ - case 17: /* CMD17: READ_SINGLE_BLOCK */ - addr =3D sd_req_get_address(sd, req); - switch (sd->state) { - case sd_transfer_state: - - if (!address_in_range(sd, "READ_SINGLE_BLOCK", addr, sd->blk_l= en)) { - return sd_r1; - } - sd_blk_read(sd, addr, sd->blk_len); - return sd_cmd_to_sendingdata(sd, req, addr, NULL, sd->blk_len); - - default: - break; - } - break; - case 18: /* CMD18: READ_MULTIPLE_BLOCK */ addr =3D sd_req_get_address(sd, req); switch (sd->state) { @@ -2306,6 +2307,7 @@ static const SDProto sd_proto_spi =3D { [12] =3D {0, sd_spi, "STOP_TRANSMISSION", sd_cmd_STOP_TRANSMISSIO= N}, [13] =3D {0, sd_spi, "SEND_STATUS", sd_cmd_SEND_STATUS}, [16] =3D {2, sd_spi, "SET_BLOCKLEN", sd_cmd_SET_BLOCKLEN}, + [17] =3D {2, sd_spi, "READ_SINGLE_BLOCK", sd_cmd_READ_SINGLE_BLOC= K}, [34] =3D {10, sd_spi, "READ_SEC_CMD", sd_cmd_optional}, [35] =3D {10, sd_spi, "WRITE_SEC_CMD", sd_cmd_optional}, [36] =3D {10, sd_spi, "SEND_PSI", sd_cmd_optional}, @@ -2338,6 +2340,7 @@ static const SDProto sd_proto_sd =3D { [13] =3D {0, sd_ac, "SEND_STATUS", sd_cmd_SEND_STATUS}, [15] =3D {0, sd_ac, "GO_INACTIVE_STATE", sd_cmd_GO_INACTIVE_STA= TE}, [16] =3D {2, sd_ac, "SET_BLOCKLEN", sd_cmd_SET_BLOCKLEN}, + [17] =3D {2, sd_adtc, "READ_SINGLE_BLOCK", sd_cmd_READ_SINGLE_BLO= CK}, [19] =3D {2, sd_adtc, "SEND_TUNING_BLOCK", sd_cmd_SEND_TUNING_BLO= CK}, [20] =3D {2, sd_ac, "SPEED_CLASS_CONTROL", sd_cmd_optional}, [23] =3D {2, sd_ac, "SET_BLOCK_COUNT", sd_cmd_SET_BLOCK_COUNT}, --=20 2.41.0 From nobody Mon Nov 25 00:25:54 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=1719506792; cv=none; d=zohomail.com; s=zohoarc; b=dcuK+SNwxnXCF4cGC6XvYpBp2XC08ohnt6+f1aerlA0aBXbb5TuZBfI0u6REPGZjbi8C63bVPh6EKcjThPm/iRJqJNNN/xQL/YTfYEg6EbCBlBo0/FnMXrMhVzyIXIkbU1SSJyZtDqZ9nAIu1IBrGNPm1Zml+bL9Nz1CAfjrxDY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719506792; 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=QJ6b4+TolgSwbj9JxT9jbN1DwNz8KwrcgVlUMC5kG7c=; b=Kfh7nh7EBFUBtqV3Cc554QDUFLnqoBMYipZf+NIRV/K0G1irnenWg2VErc0FchxClrW9yltXUab46MUWtG8uFDADT5G3FckIZ4zxDSKj7fDko70RoCuCUyBvAHdlVFKCV4pMq89ho/hCHZak5NKUxUVPCcebsNrFeelJE5HK0E4= 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 1719506792919146.79851838006493; Thu, 27 Jun 2024 09:46:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMsGF-0005jZ-LX; Thu, 27 Jun 2024 12:46:17 -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 1sMsFv-0005Wu-Ci for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:46:02 -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 1sMsFf-0000B2-6o for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:45:50 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-421f4d1c057so63900445e9.3 for ; Thu, 27 Jun 2024 09:45:38 -0700 (PDT) Received: from localhost.localdomain (33.red-95-127-46.staticip.rima-tde.net. [95.127.46.33]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-424c837dc4csm73263165e9.26.2024.06.27.09.45.33 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:45:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719506737; x=1720111537; 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=QJ6b4+TolgSwbj9JxT9jbN1DwNz8KwrcgVlUMC5kG7c=; b=qml8qiv0FaaoRFxhaHOPfjCs8c7hMvMgh8BCXEwbH2+gs3ruLjs985tRO+sTUzeKVq GWO9o4z01xTrF6bvx6Tqozcsy4TaaNEtqHmNhEp9pv3rXssJ98b5OqnXlbR0ZYnHCaTv PUel36uzmNFDS3EPRLuazL2+ZaZ5djuSiOD9cbGZ86xchwHR3dsnr1YygOjM6LnB27dq t6l5NXUYaGGUBQmov4trMtrFI3ZA+YW5aJT/ITxvngE8Gtk+vqn8MK33ndoAR0fJ6763 pC65MTkfS5NtYQp9y7NELNYSf2BBntBvGadISXKyUpUOgtWqGaFINY4HsPfL2OpHAE8Z /0lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719506737; x=1720111537; 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=QJ6b4+TolgSwbj9JxT9jbN1DwNz8KwrcgVlUMC5kG7c=; b=n1iQC0hnPeyCDC3lhDzVUp4cb+OdVtXK3msD1iqsvgVLfvYbYrgHToIT4b9Ybobu3N LRFQLcVHZqGrrROmZ87gkR2B+k9EW+AuHgki5QZVvG+qx+DaPHRaephsC3mwpo9Sbpxl pYKtKzECe8eJV96KG/DYuW84D4fIAAPs1IqY8AK5ckz/dGmy1jafwKuxWl/6W8y7VSdr 8ucQGYRk4Sz7bzWklTh2wc8OsTHbMjNAG0PxDvTCsbymb9cwpi9oLhfzTor4JwGiMP3T 6SkceEKut3Q8gUoVP4hU5qjfKx3AZS5dZSsVGVBQmvk0iMRzGHsQS2gfhIBRlpKQGGnN 1xeQ== X-Gm-Message-State: AOJu0Yz2x2MpPPv7zOH7rj4NFJU/wmw8vAlIVj0XQmLvSqc9EY5GOCz+ /xFT/f5FvzFlg5SsH/efhf08zwndmwpEhUhNjUG/DU1D48AB7H6Odg4aCWR7U3n77xiXafrNfzn tdv4= X-Google-Smtp-Source: AGHT+IHyDP0ZOgwnbNPDUGbuOCUznyCdRSz3DIV5mdoYYKlGDE8tb5bLrQaeLh61iORQKFHHQ+3saA== X-Received: by 2002:a05:600c:2e4a:b0:425:5e9a:5958 with SMTP id 5b1f17b1804b1-4255e9a59b3mr38061485e9.22.1719506737617; Thu, 27 Jun 2024 09:45:37 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Sai Pavan Boddu , Francisco Iglesias , Joel Stanley , Luc Michel , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Bin Meng Subject: [PATCH 11/21] hw/sd/sdcard: Add sd_cmd_WRITE_SINGLE_BLOCK handler (CMD24) Date: Thu, 27 Jun 2024 18:43:34 +0200 Message-ID: <20240627164345.82192-12-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627164345.82192-1-philmd@linaro.org> References: <20240627164345.82192-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, 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: 1719506793109100001 Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sd.c | 57 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 30 insertions(+), 27 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index e2a7ed8b45..4650d20ee7 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -242,7 +242,7 @@ static const char *sd_cmd_name(SDState *sd, uint8_t cmd) static const char *cmd_abbrev[SDMMC_CMD_MAX] =3D { [18] =3D "READ_MULTIPLE_BLOCK", [21] =3D "DPS_spec", - [24] =3D "WRITE_BLOCK", [25] =3D "WRITE_MULTIPLE_= BLOCK", + [25] =3D "WRITE_MULTIPLE_BL= OCK", [26] =3D "MANUF_RSVD", [27] =3D "PROGRAM_CSD", [28] =3D "SET_WRITE_PROT", [29] =3D "CLR_WRITE_PROT", [30] =3D "SEND_WRITE_PROT", @@ -1487,6 +1487,33 @@ static sd_rsp_type_t sd_cmd_SET_BLOCK_COUNT(SDState = *sd, SDRequest req) return sd_r1; } =20 +/* CMD24 */ +static sd_rsp_type_t sd_cmd_WRITE_SINGLE_BLOCK(SDState *sd, SDRequest req) +{ + uint64_t addr; + + if (sd->state !=3D sd_transfer_state) { + return sd_invalid_state_for_cmd(sd, req); + } + + addr =3D sd_req_get_address(sd, req); + if (!address_in_range(sd, "WRITE_SINGLE_BLOCK", addr, sd->blk_len)) { + return sd_r1; + } + + if (sd->size <=3D SDSC_MAX_CAPACITY) { + if (sd_wp_addr(sd, addr)) { + sd->card_status |=3D WP_VIOLATION; + } + } + if (sd->csd[14] & 0x30) { + sd->card_status |=3D WP_VIOLATION; + } + + sd->blk_written =3D 0; + return sd_cmd_to_receivingdata(sd, req, addr, sd->blk_len); +} + static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) { uint16_t rca; @@ -1544,32 +1571,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, = SDRequest req) break; =20 /* Block write commands (Class 4) */ - case 24: /* CMD24: WRITE_SINGLE_BLOCK */ - addr =3D sd_req_get_address(sd, req); - switch (sd->state) { - case sd_transfer_state: - - if (!address_in_range(sd, "WRITE_SINGLE_BLOCK", addr, - sd->blk_len)) { - return sd_r1; - } - - if (sd->size <=3D SDSC_MAX_CAPACITY) { - if (sd_wp_addr(sd, sd->data_start)) { - sd->card_status |=3D WP_VIOLATION; - } - } - if (sd->csd[14] & 0x30) { - sd->card_status |=3D WP_VIOLATION; - } - sd->blk_written =3D 0; - return sd_cmd_to_receivingdata(sd, req, addr, sd->blk_len); - - default: - break; - } - break; - case 25: /* CMD25: WRITE_MULTIPLE_BLOCK */ addr =3D sd_req_get_address(sd, req); switch (sd->state) { @@ -2308,6 +2309,7 @@ static const SDProto sd_proto_spi =3D { [13] =3D {0, sd_spi, "SEND_STATUS", sd_cmd_SEND_STATUS}, [16] =3D {2, sd_spi, "SET_BLOCKLEN", sd_cmd_SET_BLOCKLEN}, [17] =3D {2, sd_spi, "READ_SINGLE_BLOCK", sd_cmd_READ_SINGLE_BLOC= K}, + [24] =3D {4, sd_spi, "WRITE_SINGLE_BLOCK", sd_cmd_WRITE_SINGLE_BL= OCK}, [34] =3D {10, sd_spi, "READ_SEC_CMD", sd_cmd_optional}, [35] =3D {10, sd_spi, "WRITE_SEC_CMD", sd_cmd_optional}, [36] =3D {10, sd_spi, "SEND_PSI", sd_cmd_optional}, @@ -2344,6 +2346,7 @@ static const SDProto sd_proto_sd =3D { [19] =3D {2, sd_adtc, "SEND_TUNING_BLOCK", sd_cmd_SEND_TUNING_BLO= CK}, [20] =3D {2, sd_ac, "SPEED_CLASS_CONTROL", sd_cmd_optional}, [23] =3D {2, sd_ac, "SET_BLOCK_COUNT", sd_cmd_SET_BLOCK_COUNT}, + [24] =3D {4, sd_adtc, "WRITE_SINGLE_BLOCK", sd_cmd_WRITE_SINGLE_B= LOCK}, [34] =3D {10, sd_adtc, "READ_SEC_CMD", sd_cmd_optional}, [35] =3D {10, sd_adtc, "WRITE_SEC_CMD", sd_cmd_optional}, [36] =3D {10, sd_adtc, "SEND_PSI", sd_cmd_optional}, --=20 2.41.0 From nobody Mon Nov 25 00:25:54 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=1719506855; cv=none; d=zohomail.com; s=zohoarc; b=V4IDxwgRPN70xDno0rHYuMV4xgQIJdpRI1wkfX+1xmOlHL+wfommOcTwnAwmfgXC9GG9/ByJjmXNZlHppnuyWSFz65XM6xvCTZ1Hbitj/QqCzhED3ifFXh8K7LbOoo3gqXUU+32m/Qu+Oro1I8385CsLuus4iZbr18WR+1fnZEs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719506855; 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=e77sqfrLYi9SLwpkQhHOa0XqG0+lUrwsgw9mW5fMvkQ=; b=TSJFT0m+9i559sbBLDYqrKHNmBYtl6V56SC1vvgbHYIK0umL/kS3nMF8U2vRb6Ar1RhNt5y62HF5FE+DIKRqL8ICRHBo1enW4n7bH7xuknLArtAHVDzXz5wzmy9DjrPc1nO1gCaY+vpas9D3jRr/aznORIH812R2H1CRHPMC1Ys= 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 1719506855584320.20282739832305; Thu, 27 Jun 2024 09:47:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMsGT-0005zi-JG; Thu, 27 Jun 2024 12:46:31 -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 1sMsFw-0005X4-Jj for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:46:02 -0400 Received: from mail-lf1-x136.google.com ([2a00:1450:4864:20::136]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMsFt-0000CX-Ik for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:45:56 -0400 Received: by mail-lf1-x136.google.com with SMTP id 2adb3069b0e04-52e764bb3fbso666207e87.3 for ; Thu, 27 Jun 2024 09:45:48 -0700 (PDT) Received: from localhost.localdomain (33.red-95-127-46.staticip.rima-tde.net. [95.127.46.33]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-424c842468dsm76663905e9.36.2024.06.27.09.45.43 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:45:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719506747; x=1720111547; 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=e77sqfrLYi9SLwpkQhHOa0XqG0+lUrwsgw9mW5fMvkQ=; b=ggc2P4u3IjOoU4JlTkRifQ4Sm+phW9ER/OujPh5fOZJ8420FMX/nWeG+XikkPn/0D4 0Dx/XOhatIb/JVd9Qc6L+qETZseyIz6pD/ArDdXOt4S0FDrSAZFA1ZR5nRCYd+KATf8c L5RPxx/CkLUJUEkKHImaTc5gaiNm29n61ZbwCUCHVLLB219W2kvuvtxv+3EKT/Q33HMq A9k9TCnQTUEoj8J1FZtxH2XOBatn5lUomEFroBoEa11alDAgd5YYZde8XdqixIpH0JJu 9GA02bM6vYEMINMh9d7Skvlzj+3yzHa+InZliHghCI7DpXJBfZ/boMIE+qLA3a0/dYOF 95rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719506747; x=1720111547; 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=e77sqfrLYi9SLwpkQhHOa0XqG0+lUrwsgw9mW5fMvkQ=; b=OjBVkggICJIueJYDMggihbIGTaxygjliZfuwFQN4hLO7YRDCxXKcRo6VgQWOuXblZH uvf5z6efiPK0qJRTQSA0s+yixtkns3co/EpeTdCGQtjTAQEELpKeIVY6pot2wyN/ZC4A jsVGYvG7WSPHs3bHZF6DwNeFnvF28x0kP2YR3ONbI3b4T9otvO8tgTt+3eCUChpyz2sb h4/CFEcwlDX6pjTi7r7TSxY372Mi3FbnHa0uvWnVqKR5aOhJhz6qSLS9Mf+9JoKYqBww SqO5EkqoGPKf/+Janir/ZqwqGKgv87cUH5TTiSamSzDSUoUWT5B12vQya1rf8AJLBLOW r0ug== X-Gm-Message-State: AOJu0YzJ28tccxrFQBlaEcoxlGTG8GJ7JxiEQ4sgJM6Qk++eYFJMM+CG UMu9N18XUpdmZxKpNEK52K3cfmniF/XqJtDQ72tEMx3Wu5HsouUTAuzpQ5hP9GmSkcJeIEhOpSW wYAs= X-Google-Smtp-Source: AGHT+IHTnYCAfH2gNGtq0Tnnwhf5aI2xB7gln1vrqJ/79CVpeaFepuwA45inXRvwNjoII3lJR63KKg== X-Received: by 2002:a05:6512:3e24:b0:52c:dff5:8087 with SMTP id 2adb3069b0e04-52ce185f998mr10762836e87.51.1719506746977; Thu, 27 Jun 2024 09:45:46 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Sai Pavan Boddu , Francisco Iglesias , Joel Stanley , Luc Michel , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Bin Meng Subject: [PATCH 12/21] hw/sd/sdcard: Add sd_cmd_PROGRAM_CSD handler (CMD27) Date: Thu, 27 Jun 2024 18:43:35 +0200 Message-ID: <20240627164345.82192-13-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627164345.82192-1-philmd@linaro.org> References: <20240627164345.82192-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::136; envelope-from=philmd@linaro.org; helo=mail-lf1-x136.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1719506857390100001 Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sd.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 4650d20ee7..9d33113f11 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -243,7 +243,7 @@ static const char *sd_cmd_name(SDState *sd, uint8_t cmd) [18] =3D "READ_MULTIPLE_BLOCK", [21] =3D "DPS_spec", [25] =3D "WRITE_MULTIPLE_BL= OCK", - [26] =3D "MANUF_RSVD", [27] =3D "PROGRAM_CSD", + [26] =3D "MANUF_RSVD", [28] =3D "SET_WRITE_PROT", [29] =3D "CLR_WRITE_PROT", [30] =3D "SEND_WRITE_PROT", [32] =3D "ERASE_WR_BLK_START", [33] =3D "ERASE_WR_BLK_EN= D", @@ -1514,6 +1514,12 @@ static sd_rsp_type_t sd_cmd_WRITE_SINGLE_BLOCK(SDSta= te *sd, SDRequest req) return sd_cmd_to_receivingdata(sd, req, addr, sd->blk_len); } =20 +/* CMD27 */ +static sd_rsp_type_t sd_cmd_PROGRAM_CSD(SDState *sd, SDRequest req) +{ + return sd_cmd_to_receivingdata(sd, req, 0, sizeof(sd->csd)); +} + static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) { uint16_t rca; @@ -1603,9 +1609,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, S= DRequest req) case 26: /* CMD26: PROGRAM_CID */ return sd_cmd_to_receivingdata(sd, req, 0, sizeof(sd->cid)); =20 - case 27: /* CMD27: PROGRAM_CSD */ - return sd_cmd_to_receivingdata(sd, req, 0, sizeof(sd->csd)); - /* Write protection (Class 6) */ case 28: /* CMD28: SET_WRITE_PROT */ if (sd->size > SDSC_MAX_CAPACITY) { @@ -2310,6 +2313,7 @@ static const SDProto sd_proto_spi =3D { [16] =3D {2, sd_spi, "SET_BLOCKLEN", sd_cmd_SET_BLOCKLEN}, [17] =3D {2, sd_spi, "READ_SINGLE_BLOCK", sd_cmd_READ_SINGLE_BLOC= K}, [24] =3D {4, sd_spi, "WRITE_SINGLE_BLOCK", sd_cmd_WRITE_SINGLE_BL= OCK}, + [27] =3D {4, sd_spi, "PROGRAM_CSD", sd_cmd_PROGRAM_CSD}, [34] =3D {10, sd_spi, "READ_SEC_CMD", sd_cmd_optional}, [35] =3D {10, sd_spi, "WRITE_SEC_CMD", sd_cmd_optional}, [36] =3D {10, sd_spi, "SEND_PSI", sd_cmd_optional}, @@ -2347,6 +2351,7 @@ static const SDProto sd_proto_sd =3D { [20] =3D {2, sd_ac, "SPEED_CLASS_CONTROL", sd_cmd_optional}, [23] =3D {2, sd_ac, "SET_BLOCK_COUNT", sd_cmd_SET_BLOCK_COUNT}, [24] =3D {4, sd_adtc, "WRITE_SINGLE_BLOCK", sd_cmd_WRITE_SINGLE_B= LOCK}, + [27] =3D {4, sd_adtc, "PROGRAM_CSD", sd_cmd_PROGRAM_CSD}, [34] =3D {10, sd_adtc, "READ_SEC_CMD", sd_cmd_optional}, [35] =3D {10, sd_adtc, "WRITE_SEC_CMD", sd_cmd_optional}, [36] =3D {10, sd_adtc, "SEND_PSI", sd_cmd_optional}, --=20 2.41.0 From nobody Mon Nov 25 00:25:54 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=1719506844; cv=none; d=zohomail.com; s=zohoarc; b=Mm8uoZ2q3WDRh4+hJmkXL2b4ip5vaeigIK9KoPsAEm/d6m+G0PYde5SF/uAZpw9r6umqpH6wyo6KpGHUQUOBN3hwmph9VH2plAM4K87UgEY/QVopdZG8HLCYEZj2rXZSWp4vXDnT3PzeGx+jE+BtGAVPrVxvWhM+uXfmwczRptM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719506844; 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=F6oigTn0Q2A4tjfIsZSpx2Wne2arec43lvnPbuSKAbM=; b=W0cEiKvu4VO0dupWLU1rqUWgwYEJhX7ikP7oa6VU4Tk7nRKExNALB9cOTjYoWj2fMZOSlTIiC5sM2nLlo+E6ISWnWUIdtDD+2KEvWXNxZ8u2wdVbXMXTAwTfchVTSzIaLd1i9eR9ZHskmDiDVcPDSjrdh9cpTBiZOuRQ31PpYW0= 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 1719506844869763.3093869838015; Thu, 27 Jun 2024 09:47:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMsGp-0006HO-JK; Thu, 27 Jun 2024 12:46:54 -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 1sMsG4-0005bZ-RT for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:46:06 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMsG0-0000HV-Bx for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:46:02 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-424ad289912so17749735e9.2 for ; Thu, 27 Jun 2024 09:45:59 -0700 (PDT) Received: from localhost.localdomain (33.red-95-127-46.staticip.rima-tde.net. [95.127.46.33]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3674357ff4fsm2405881f8f.42.2024.06.27.09.45.53 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:45:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719506758; x=1720111558; 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=F6oigTn0Q2A4tjfIsZSpx2Wne2arec43lvnPbuSKAbM=; b=wYheyhJTyO76RBw01CuScM9mNw4uZzudnHzGOi27w4bxLkp+lBuaZUIKiBBb/9aiQp k99rjauM0ayRDdNNF6rAMiOdGu0qLEClwTOatZRyfBSw4HC6Dy5P7Htw7KOqdaDI/qXm XJhaZkpmVhR/7rI/UtpVsfNahvGFMQxnBAQSlbAIRIqkxVGeIDDDfqM+HX7wEotbdHB4 tNkstZ5jOEx4azwfDSkv15zsYdf25PZz/md+s/xb7uL2Zpj3napwgGG5npinj/AJ01gN PwB2xRJkpEsNR6X3oosx/m5wA0GeNSq4Y5koJlcE1Tao8Oclg+qDVZW3JdWCrZ840wym aFxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719506758; x=1720111558; 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=F6oigTn0Q2A4tjfIsZSpx2Wne2arec43lvnPbuSKAbM=; b=ZD1K6BrNcrwkE9vhQ0ukGmPM2Sgtr+wqf5P/wBeNmlM8XEFX3ywIG+TzY4v3UdtqCr YIG/ooFGgCsEVJrWhN6Mv7bj4ccyC013y/PdT27IRQX03OTb0L6utBqk4kFv5hRg3fKw 421BcVHPTKHCjLoqccs0DyubmzhI3mclISj6N1ewS+prdoNhTZLG3WTCfdLfMbmZgkt4 ynjwgFp3par8hpeMyStFdIHBb38nZ2K9VRhyyX4rRRdvro9JHiB6gxYSwBDvA3smyXGl Gx8Tl78EHdl2iL/CPEsEemnbJCJQCzciifqzHiqFvhxa//FRx9W1Lz0FVYMoywOnNhJE crFQ== X-Gm-Message-State: AOJu0YxnZjUAaiQZ7SSQNXxy+owyD3+zJEYVh2/sR03UgJGHGcjBMKQ8 vuLOKZ5ahKDX9OwZOGSMVu0F/0MYn8XaurrnJbuzQCJhBWPMDxfNZXNLbUOQtQCTJpvRKvodGRu Pf60= X-Google-Smtp-Source: AGHT+IGymQesBd6k53e+ir8M4bkAt1fWceEIGwr4LA3ang+Ib3Zh6jzLdgEZ3rQHrG7yolTfgETJqg== X-Received: by 2002:a05:600c:5599:b0:424:ac90:8571 with SMTP id 5b1f17b1804b1-424ac9085damr39082635e9.18.1719506757939; Thu, 27 Jun 2024 09:45:57 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Sai Pavan Boddu , Francisco Iglesias , Joel Stanley , Luc Michel , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Bin Meng Subject: [PATCH 13/21] hw/sd/sdcard: Add sd_cmd_SET/CLR_WRITE_PROT handler (CMD28 & CMD29) Date: Thu, 27 Jun 2024 18:43:36 +0200 Message-ID: <20240627164345.82192-14-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627164345.82192-1-philmd@linaro.org> References: <20240627164345.82192-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::333; envelope-from=philmd@linaro.org; helo=mail-wm1-x333.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: 1719506845321100001 Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sd.c | 91 +++++++++++++++++++++++++++--------------------------- 1 file changed, 46 insertions(+), 45 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 9d33113f11..a63213613b 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -244,7 +244,6 @@ static const char *sd_cmd_name(SDState *sd, uint8_t cmd) [21] =3D "DPS_spec", [25] =3D "WRITE_MULTIPLE_BL= OCK", [26] =3D "MANUF_RSVD", - [28] =3D "SET_WRITE_PROT", [29] =3D "CLR_WRITE_PROT", [30] =3D "SEND_WRITE_PROT", [32] =3D "ERASE_WR_BLK_START", [33] =3D "ERASE_WR_BLK_EN= D", [38] =3D "ERASE", @@ -1520,6 +1519,48 @@ static sd_rsp_type_t sd_cmd_PROGRAM_CSD(SDState *sd,= SDRequest req) return sd_cmd_to_receivingdata(sd, req, 0, sizeof(sd->csd)); } =20 +static sd_rsp_type_t sd_cmd_SET_CLR_WRITE_PROT(SDState *sd, SDRequest req, + bool is_write) +{ + uint64_t addr; + + if (sd->size > SDSC_MAX_CAPACITY) { + return sd_illegal; + } + + if (sd->state !=3D sd_transfer_state) { + return sd_invalid_state_for_cmd(sd, req); + } + + addr =3D sd_req_get_address(sd, req); + if (!address_in_range(sd, is_write ? "SET_WRITE_PROT" : "CLR_WRITE_PRO= T", + addr, 1)) { + return sd_r1b; + } + + sd->state =3D sd_programming_state; + if (is_write) { + set_bit(sd_addr_to_wpnum(addr), sd->wp_group_bmap); + } else { + clear_bit(sd_addr_to_wpnum(addr), sd->wp_group_bmap); + } + /* Bzzzzzzztt .... Operation complete. */ + sd->state =3D sd_transfer_state; + return sd_r1; +} + +/* CMD28 */ +static sd_rsp_type_t sd_cmd_SET_WRITE_PROT(SDState *sd, SDRequest req) +{ + return sd_cmd_SET_CLR_WRITE_PROT(sd, req, true); +} + +/* CMD29 */ +static sd_rsp_type_t sd_cmd_CLR_WRITE_PROT(SDState *sd, SDRequest req) +{ + return sd_cmd_SET_CLR_WRITE_PROT(sd, req, false); +} + static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) { uint16_t rca; @@ -1610,50 +1651,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, = SDRequest req) return sd_cmd_to_receivingdata(sd, req, 0, sizeof(sd->cid)); =20 /* Write protection (Class 6) */ - case 28: /* CMD28: SET_WRITE_PROT */ - if (sd->size > SDSC_MAX_CAPACITY) { - return sd_illegal; - } - addr =3D sd_req_get_address(sd, req); - switch (sd->state) { - case sd_transfer_state: - if (!address_in_range(sd, "SET_WRITE_PROT", addr, 1)) { - return sd_r1b; - } - - sd->state =3D sd_programming_state; - set_bit(sd_addr_to_wpnum(addr), sd->wp_group_bmap); - /* Bzzzzzzztt .... Operation complete. */ - sd->state =3D sd_transfer_state; - return sd_r1b; - - default: - break; - } - break; - - case 29: /* CMD29: CLR_WRITE_PROT */ - if (sd->size > SDSC_MAX_CAPACITY) { - return sd_illegal; - } - addr =3D sd_req_get_address(sd, req); - switch (sd->state) { - case sd_transfer_state: - if (!address_in_range(sd, "CLR_WRITE_PROT", addr, 1)) { - return sd_r1b; - } - - sd->state =3D sd_programming_state; - clear_bit(sd_addr_to_wpnum(addr), sd->wp_group_bmap); - /* Bzzzzzzztt .... Operation complete. */ - sd->state =3D sd_transfer_state; - return sd_r1b; - - default: - break; - } - break; - case 30: /* CMD30: SEND_WRITE_PROT */ if (sd->size > SDSC_MAX_CAPACITY) { return sd_illegal; @@ -2314,6 +2311,8 @@ static const SDProto sd_proto_spi =3D { [17] =3D {2, sd_spi, "READ_SINGLE_BLOCK", sd_cmd_READ_SINGLE_BLOC= K}, [24] =3D {4, sd_spi, "WRITE_SINGLE_BLOCK", sd_cmd_WRITE_SINGLE_BL= OCK}, [27] =3D {4, sd_spi, "PROGRAM_CSD", sd_cmd_PROGRAM_CSD}, + [28] =3D {6, sd_spi, "SET_WRITE_PROT", sd_cmd_SET_WRITE_PROT}, + [29] =3D {6, sd_spi, "CLR_WRITE_PROT", sd_cmd_CLR_WRITE_PROT}, [34] =3D {10, sd_spi, "READ_SEC_CMD", sd_cmd_optional}, [35] =3D {10, sd_spi, "WRITE_SEC_CMD", sd_cmd_optional}, [36] =3D {10, sd_spi, "SEND_PSI", sd_cmd_optional}, @@ -2352,6 +2351,8 @@ static const SDProto sd_proto_sd =3D { [23] =3D {2, sd_ac, "SET_BLOCK_COUNT", sd_cmd_SET_BLOCK_COUNT}, [24] =3D {4, sd_adtc, "WRITE_SINGLE_BLOCK", sd_cmd_WRITE_SINGLE_B= LOCK}, [27] =3D {4, sd_adtc, "PROGRAM_CSD", sd_cmd_PROGRAM_CSD}, + [28] =3D {6, sd_ac, "SET_WRITE_PROT", sd_cmd_SET_WRITE_PROT}, + [29] =3D {6, sd_ac, "CLR_WRITE_PROT", sd_cmd_CLR_WRITE_PROT}, [34] =3D {10, sd_adtc, "READ_SEC_CMD", sd_cmd_optional}, [35] =3D {10, sd_adtc, "WRITE_SEC_CMD", sd_cmd_optional}, [36] =3D {10, sd_adtc, "SEND_PSI", sd_cmd_optional}, --=20 2.41.0 From nobody Mon Nov 25 00:25:54 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=1719506911; cv=none; d=zohomail.com; s=zohoarc; b=KvxOqMJ+4DRjgAgsw6Ukhi2H/CTqIglWm987vzlC4SPAs1rjGVpQjzKSTfl1hom+4ESiXIRyBKMV4Dv2aUxkJgfkf4CiKYcJYTwWxAxl+SBNy9KLO9kfDSR0wOqDk6JU/VtLXaaY1Oe/o5MDz2LbXJ3C06n22wmQhFII5YLUvqw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719506911; 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=PF/YVa5FANPMIRP5k1k++097xYJKGaWnEtemmw/L2o0=; b=Y6UMhC2iB6GxRocsh43iyrljHMQmp1NbE2OOswXT/nZ6L2aBo0hsU5R+8oro9Z5NNODUUWRuWOJq3QCUDfovgrP2KGWlzhYoO1gdK7SGzdwd4uKNtv/cWUHYc2M06BHl7JuwQel69UdLnxtdTvtB+xTnpjdaFMIJJVnqRT4qAKk= 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 1719506911536733.3032213298222; Thu, 27 Jun 2024 09:48:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMsHv-0007HO-Lv; Thu, 27 Jun 2024 12:48:00 -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 1sMsGC-0005ha-IV for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:46:13 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMsGA-0000NT-5I for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:46:11 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-4248ff53f04so35439305e9.0 for ; Thu, 27 Jun 2024 09:46:09 -0700 (PDT) Received: from localhost.localdomain (33.red-95-127-46.staticip.rima-tde.net. [95.127.46.33]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42564bc59f5sm36290285e9.42.2024.06.27.09.46.04 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:46:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719506768; x=1720111568; 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=PF/YVa5FANPMIRP5k1k++097xYJKGaWnEtemmw/L2o0=; b=n7ygKGp4qVPs1HX5Dj5EWG0whhVVCSO4N4IVLuFhfBlB0TeCChYFBSvbJHEpeWHhkU oqABBu2zsnWG7Rl0J728WU/LLi0v+tSR739SpzRNqoPR5raksPOCH3sKbOJA4/1lMTLw tMd2YV3BU4M4SSNx3gdUT7CknCgqS4FxqkLzmJqGq8BFygYlsojqRQYvM8sKNzHVD7ua bphIKNuk1s3Q3c3ZUAjct+PYrZ3iKchzQBZ/N4Mh87KK/o7RZ1kdmPeLumC/tvQqB76i pl/AwLB4gNO1O6/uHy85KqvkcYLP382MZMmN1g6r/nJYczDCNg3o/z2IeKhgofKiQEnr M6+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719506768; x=1720111568; 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=PF/YVa5FANPMIRP5k1k++097xYJKGaWnEtemmw/L2o0=; b=bgjGX6Nr/7tHuqTtIbq3YG/wpY/b1E8avWGHjW3gCmJPom5RnG6jcRRLciOKmM4vLP FgROurGiIFFll6acKO4BrmLTv/tjYh0K5ZsmeKJ3KPP5oDfIzobQJxBainq+8+9pU+fP ncNlY+jqza7o1XkEPFzucVejWGnGzbUaVlsbxU7XrstYlQ7CPLjn+96YrE4yvb0b59gt S/kfJ9D7mgapmquv1YBD+Wnx6IuWacn5Ng4XKhi4EC6YhBNgnqdcJ9baBJ9ia1jNjSIG PmmXd9bbNzwFJT9vca55PLp5d+Pp+2U2HaOIeT61Z2swsQYZCuo9Fb3/fDVVKzKHBKVE q40w== X-Gm-Message-State: AOJu0YzeBNitCZ/zXsIx+myG2bnfoKRrwRVpbBZRtTx15DPgRUvYlFj7 n2dEYkBKaxyjhKaIs6JlSCSwfceDNVlRqanwUcEoRxtvsWh1HN6+vqhDJVCQ9gOWxLAYsof1s2n KAy0= X-Google-Smtp-Source: AGHT+IGwfdpxsHRDwgPLQszqf/rH9dbxEKRzhTG1v5PmX+d0oyjpn81tTf+4dyQBlVv9qg+K/yhoOA== X-Received: by 2002:a05:600c:4c06:b0:424:a822:7846 with SMTP id 5b1f17b1804b1-424a82278e7mr47403555e9.28.1719506768292; Thu, 27 Jun 2024 09:46:08 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Sai Pavan Boddu , Francisco Iglesias , Joel Stanley , Luc Michel , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Bin Meng Subject: [PATCH 14/21] hw/sd/sdcard: Add sd_cmd_SEND_WRITE_PROT handler (CMD30) Date: Thu, 27 Jun 2024 18:43:37 +0200 Message-ID: <20240627164345.82192-15-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627164345.82192-1-philmd@linaro.org> References: <20240627164345.82192-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::32a; envelope-from=philmd@linaro.org; helo=mail-wm1-x32a.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: 1719506913583100009 Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sd.c | 47 +++++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index a63213613b..bf9975e9b1 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -244,7 +244,6 @@ static const char *sd_cmd_name(SDState *sd, uint8_t cmd) [21] =3D "DPS_spec", [25] =3D "WRITE_MULTIPLE_BL= OCK", [26] =3D "MANUF_RSVD", - [30] =3D "SEND_WRITE_PROT", [32] =3D "ERASE_WR_BLK_START", [33] =3D "ERASE_WR_BLK_EN= D", [38] =3D "ERASE", [40] =3D "DPS_spec", @@ -1561,11 +1560,33 @@ static sd_rsp_type_t sd_cmd_CLR_WRITE_PROT(SDState = *sd, SDRequest req) return sd_cmd_SET_CLR_WRITE_PROT(sd, req, false); } =20 +/* CMD30 */ +static sd_rsp_type_t sd_cmd_SEND_WRITE_PROT(SDState *sd, SDRequest req) +{ + uint64_t addr; + uint32_t data; + + if (sd->size > SDSC_MAX_CAPACITY) { + return sd_illegal; + } + + if (sd->state !=3D sd_transfer_state) { + return sd_invalid_state_for_cmd(sd, req); + } + + addr =3D sd_req_get_address(sd, req); + if (!address_in_range(sd, "SEND_WRITE_PROT", addr, sd->blk_len)) { + return sd_r1; + } + + data =3D sd_wpbits(sd, req.arg); + return sd_cmd_to_sendingdata(sd, req, addr, &data, sizeof(data)); +} + static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) { uint16_t rca; uint64_t addr; - uint32_t data; =20 sd->last_cmd_name =3D sd_cmd_name(sd, req.cmd); /* CMD55 precedes an ACMD, so we are not interested in tracing it. @@ -1650,26 +1671,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 - /* Write protection (Class 6) */ - case 30: /* CMD30: SEND_WRITE_PROT */ - if (sd->size > SDSC_MAX_CAPACITY) { - return sd_illegal; - } - addr =3D sd_req_get_address(sd, req); - switch (sd->state) { - case sd_transfer_state: - if (!address_in_range(sd, "SEND_WRITE_PROT", - req.arg, sd->blk_len)) { - return sd_r1; - } - data =3D sd_wpbits(sd, req.arg); - return sd_cmd_to_sendingdata(sd, req, addr, &data, sizeof(data= )); - - default: - break; - } - break; - /* Erase commands (Class 5) */ case 32: /* CMD32: ERASE_WR_BLK_START */ switch (sd->state) { @@ -2313,6 +2314,7 @@ static const SDProto sd_proto_spi =3D { [27] =3D {4, sd_spi, "PROGRAM_CSD", sd_cmd_PROGRAM_CSD}, [28] =3D {6, sd_spi, "SET_WRITE_PROT", sd_cmd_SET_WRITE_PROT}, [29] =3D {6, sd_spi, "CLR_WRITE_PROT", sd_cmd_CLR_WRITE_PROT}, + [30] =3D {6, sd_spi, "SEND_WRITE_PROT", sd_cmd_SEND_WRITE_PROT}, [34] =3D {10, sd_spi, "READ_SEC_CMD", sd_cmd_optional}, [35] =3D {10, sd_spi, "WRITE_SEC_CMD", sd_cmd_optional}, [36] =3D {10, sd_spi, "SEND_PSI", sd_cmd_optional}, @@ -2353,6 +2355,7 @@ static const SDProto sd_proto_sd =3D { [27] =3D {4, sd_adtc, "PROGRAM_CSD", sd_cmd_PROGRAM_CSD}, [28] =3D {6, sd_ac, "SET_WRITE_PROT", sd_cmd_SET_WRITE_PROT}, [29] =3D {6, sd_ac, "CLR_WRITE_PROT", sd_cmd_CLR_WRITE_PROT}, + [30] =3D {6, sd_adtc, "SEND_WRITE_PROT", sd_cmd_SEND_WRITE_PROT}, [34] =3D {10, sd_adtc, "READ_SEC_CMD", sd_cmd_optional}, [35] =3D {10, sd_adtc, "WRITE_SEC_CMD", sd_cmd_optional}, [36] =3D {10, sd_adtc, "SEND_PSI", sd_cmd_optional}, --=20 2.41.0 From nobody Mon Nov 25 00:25:54 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=1719506892; cv=none; d=zohomail.com; s=zohoarc; b=k7I8zOiwP2tPQsEVRopDncqL6ThslOwLIWyKWsZOjIqxRKTI92gG0XdBu4KvdyAPbw6UqNibdARbYAjxLxCjeVzPjQIs5T011DkmYgfkW2P+7BfC7Jz4S9+9LAXi6Ql3xJ0jzG7uA6Yy23xmuGu6q+Lcf/ExBrATryK/1TOcp9c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719506892; 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=HkQna1pAjg6GCvSqtEv1yfUmIYCR6WFUzViVX0SSBYo=; b=Y1o7id7NPipSDfv8atx8e8OgFugpKcJHv/JJNoGkbLhOi2/+VhRDSVFODIvHXWWjNBUXVMT7uq1xC1e9x0nAqLCZP+a4mtecEbk0ElWpYJboGmCBz91A2la5m5G+cmsWKpb8SqkcibrU22t+/7Eylu5amOQMMIxKpR5K03qKB9I= 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 1719506892594267.59621300198296; Thu, 27 Jun 2024 09:48:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMsHr-0007G0-Pl; Thu, 27 Jun 2024 12:47:57 -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 1sMsGO-00061T-7k for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:46:28 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMsGI-0000RJ-W7 for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:46:23 -0400 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-36701e6c6e8so1795920f8f.1 for ; Thu, 27 Jun 2024 09:46:18 -0700 (PDT) Received: from localhost.localdomain (33.red-95-127-46.staticip.rima-tde.net. [95.127.46.33]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3674357fdcasm2427191f8f.36.2024.06.27.09.46.14 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:46:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719506777; x=1720111577; 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=HkQna1pAjg6GCvSqtEv1yfUmIYCR6WFUzViVX0SSBYo=; b=SUkdSze/CirXXV1UgrDF4D/BMSRnbyu2vFRwIjx7C2RUNnsei6CesSMVz0fNIk6DeE shQ5N5W8eSt5C19VDhPbntgXcivY4Seos9Qe0XCTCOopiQXJJ98IkJTxU7MDfMVZ5tWX qCExT06w8KXYb3tWCfbm5aTDMlJM0UT1YxPUqgWS4/EXEWyT917QprEmcWd6fxV0/Xam +okRqmcGGVeAdhYdbdYM65WUh11eiUktf7zRLR32hQbWS6L5UkiBFDJmTnmapRkl4IN+ fjXPW08h1KJeFb/EJo7qjgE/c7zrp8/ONXC2Z8qLs5XCIHoD3hBfwEwLYL0XwbKV8ECS HR7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719506777; x=1720111577; 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=HkQna1pAjg6GCvSqtEv1yfUmIYCR6WFUzViVX0SSBYo=; b=uSNAcfpErzf9+K0aEudT0xcba5FfevToLJUr3uqVDvMztxPxWu1m6JIJ0sAhj6gxKI w6cpeD2snBIzITTo2U+p6MIDrypY8HEuueLS2QAFb8q5IM6FOZ6K+pNQBmkKS3oXacIo Iw6q6G2053KcyaBbtLfDEB4+TjW9cFiCaQIAXSUo39oQ6YUN67UDPmh2HGgzd7V31IA0 JtWVxCTyz1W8e60mzXmdKXybbxA7NF4VIn9H+VxnCc1m5ESvJwhotS9trGcPXYDercN6 56jHNS8/D/XAztZk510zBK4LVgWf0aFXfDb40RFCEZC8KeGL2dmHCjTrUhH0yt4Uj98h H7tQ== X-Gm-Message-State: AOJu0Yyopc6spSEL7XpFnl1XhWnPeesnu/HsC86n/3KjkB7GTE56s1ow FETM7yAEHh7ar+B6kGgzi8Q0FgEjveqLcuT9h95/6c3Eo/9oUFrGlhbenIFYhSAyr+CdPvHe93r khuE= X-Google-Smtp-Source: AGHT+IE0HWcXaJLgbKu8us/Sc81KYVyEoD+Qm0sHvrpgwCpCRYfn+UVMR1MtpTH+LyTCl9ZWWOAl1Q== X-Received: by 2002:a05:6000:184f:b0:366:ee84:6a79 with SMTP id ffacd0b85a97d-366ee846c15mr12701374f8f.51.1719506777014; Thu, 27 Jun 2024 09:46:17 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Sai Pavan Boddu , Francisco Iglesias , Joel Stanley , Luc Michel , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Bin Meng Subject: [PATCH 15/21] hw/sd/sdcard: Add sd_cmd_ERASE_WR_BLK_START/END handlers (CMD32 & CMD33) Date: Thu, 27 Jun 2024 18:43:38 +0200 Message-ID: <20240627164345.82192-16-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627164345.82192-1-philmd@linaro.org> References: <20240627164345.82192-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::42c; envelope-from=philmd@linaro.org; helo=mail-wr1-x42c.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: 1719506893566100002 Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sd.c | 47 ++++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index bf9975e9b1..4e31dfe18f 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -244,7 +244,6 @@ static const char *sd_cmd_name(SDState *sd, uint8_t cmd) [21] =3D "DPS_spec", [25] =3D "WRITE_MULTIPLE_BL= OCK", [26] =3D "MANUF_RSVD", - [32] =3D "ERASE_WR_BLK_START", [33] =3D "ERASE_WR_BLK_EN= D", [38] =3D "ERASE", [40] =3D "DPS_spec", [42] =3D "LOCK_UNLOCK", @@ -1583,6 +1582,26 @@ static sd_rsp_type_t sd_cmd_SEND_WRITE_PROT(SDState = *sd, SDRequest req) return sd_cmd_to_sendingdata(sd, req, addr, &data, sizeof(data)); } =20 +/* CMD32 */ +static sd_rsp_type_t sd_cmd_ERASE_WR_BLK_START(SDState *sd, SDRequest req) +{ + if (sd->state !=3D sd_transfer_state) { + return sd_invalid_state_for_cmd(sd, req); + } + sd->erase_start =3D req.arg; + return sd_r1; +} + +/* CMD33 */ +static sd_rsp_type_t sd_cmd_ERASE_WR_BLK_END(SDState *sd, SDRequest req) +{ + if (sd->state !=3D sd_transfer_state) { + return sd_invalid_state_for_cmd(sd, req); + } + sd->erase_end =3D req.arg; + return sd_r1; +} + static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) { uint16_t rca; @@ -1672,28 +1691,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, = SDRequest req) return sd_cmd_to_receivingdata(sd, req, 0, sizeof(sd->cid)); =20 /* Erase commands (Class 5) */ - case 32: /* CMD32: ERASE_WR_BLK_START */ - switch (sd->state) { - case sd_transfer_state: - sd->erase_start =3D req.arg; - return sd_r1; - - default: - break; - } - break; - - case 33: /* CMD33: ERASE_WR_BLK_END */ - switch (sd->state) { - case sd_transfer_state: - sd->erase_end =3D req.arg; - return sd_r1; - - default: - break; - } - break; - case 38: /* CMD38: ERASE */ switch (sd->state) { case sd_transfer_state: @@ -2315,6 +2312,8 @@ static const SDProto sd_proto_spi =3D { [28] =3D {6, sd_spi, "SET_WRITE_PROT", sd_cmd_SET_WRITE_PROT}, [29] =3D {6, sd_spi, "CLR_WRITE_PROT", sd_cmd_CLR_WRITE_PROT}, [30] =3D {6, sd_spi, "SEND_WRITE_PROT", sd_cmd_SEND_WRITE_PROT}, + [32] =3D {5, sd_spi, "ERASE_WR_BLK_START", sd_cmd_ERASE_WR_BLK_ST= ART}, + [33] =3D {5, sd_spi, "ERASE_WR_BLK_END", sd_cmd_ERASE_WR_BLK_END}, [34] =3D {10, sd_spi, "READ_SEC_CMD", sd_cmd_optional}, [35] =3D {10, sd_spi, "WRITE_SEC_CMD", sd_cmd_optional}, [36] =3D {10, sd_spi, "SEND_PSI", sd_cmd_optional}, @@ -2356,6 +2355,8 @@ static const SDProto sd_proto_sd =3D { [28] =3D {6, sd_ac, "SET_WRITE_PROT", sd_cmd_SET_WRITE_PROT}, [29] =3D {6, sd_ac, "CLR_WRITE_PROT", sd_cmd_CLR_WRITE_PROT}, [30] =3D {6, sd_adtc, "SEND_WRITE_PROT", sd_cmd_SEND_WRITE_PROT}, + [32] =3D {5, sd_ac, "ERASE_WR_BLK_START", sd_cmd_ERASE_WR_BLK_S= TART}, + [33] =3D {5, sd_ac, "ERASE_WR_BLK_END", sd_cmd_ERASE_WR_BLK_END= }, [34] =3D {10, sd_adtc, "READ_SEC_CMD", sd_cmd_optional}, [35] =3D {10, sd_adtc, "WRITE_SEC_CMD", sd_cmd_optional}, [36] =3D {10, sd_adtc, "SEND_PSI", sd_cmd_optional}, --=20 2.41.0 From nobody Mon Nov 25 00:25:54 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=1719506892; cv=none; d=zohomail.com; s=zohoarc; b=CqszXGBYIAtfVRANTtq1J8euquScSYRziV0mSUZK+zMkjwffM1LSn1voKD5XC3rENphQVGEzwhhQXcBYfEGXOMq0itTfI+rYOnUh6UFmm43aAms88Hufz3mEZ4jjqXw7sYmFT1uVtDEfrgwk7+8GJo4vQsBbSv2UWVlJ9Xq1yKc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719506892; 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=CoQCzUzxa0YFMI6eXkkGrxD2M8eC5JzJPZMXnDtnM4A=; b=MZVpTFkIR992S0/NbhSSVqmmHOqA3laJfjQIWBWyD5s9xcH3arvsLovSLnMCpTjJBSaZJtOHYYPPjo2VPBjs8kvdHV+ieLwHpNK+kRxwRwOaSy7S0OmHO+BfIbUzwjVkYDIsFXyaPW+e5XJeS2WDrgzAl6G/rZJg4NcyBtnMPlw= 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 171950689246042.05892783344632; Thu, 27 Jun 2024 09:48:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMsI2-0007rQ-WE; Thu, 27 Jun 2024 12:48:07 -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 1sMsGV-0006GW-C5 for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:46:33 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMsGT-0000SY-OI for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:46:31 -0400 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-42565697036so5415265e9.1 for ; Thu, 27 Jun 2024 09:46:28 -0700 (PDT) Received: from localhost.localdomain (33.red-95-127-46.staticip.rima-tde.net. [95.127.46.33]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-367435850e0sm2385833f8f.50.2024.06.27.09.46.23 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:46:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719506787; x=1720111587; 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=CoQCzUzxa0YFMI6eXkkGrxD2M8eC5JzJPZMXnDtnM4A=; b=pYw59Msc0eaoW9SrZLgBAXXXsRXcb77FOygEE390KPYf3Gq/fwq1GJ5G5nfnOa8Piu lD6UO7+CsKBybqezq98SACTE8WBFwwdiM1n5ujUTF/u48CAHfDfBGsDAQZjDy1ZGodvg 9UwqLKZ+L4QL7a9tDHVfEOXF6ijHG6GNtAy2iw3HDcknV5K1i1W58SZspKsX7I3KJ/xS zg1LUedPGryhhBdxv4jYTU1zTOlG2n894efrKfT8LN/7g+UNUF+oFwvC6P6KHXKq6tlP wdF9C307qMC7fuIe9b3OdaH+LzNGDajx6wv4RgnOFnD2WkmLEBS2IyFapJSurjr7eJQ7 V4Kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719506787; x=1720111587; 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=CoQCzUzxa0YFMI6eXkkGrxD2M8eC5JzJPZMXnDtnM4A=; b=duJlI3ofwZakuyzb29PqzzDb6sbmJ+c/e4iY9SReJlrghvVngKtf9a878NJRR7C1He 3+zzfqG9cbMkHyr1r5TQC84ScVQbTegzFMOBQmwdu/qwZFeGx4XDgvesRePOyulvsKuE brhG7AWYp62BnBBwUmDfv0Mk36/39RrBSDsyqj8OHNMQCoaIKw0p3Y70GjIGmbkTqE53 lM6mkQPv+ZDyIFM23wqP5BQCD1mi4THsZbPwlHBdGqrKP69t57WdBRK0xRpOmHktYqch PbAQKvq6lT80LykN6RZP1Aihg9a5ozySi29p+wh0muwR1CRaF/4k3naaxWTFBSCxI2Ln aHYw== X-Gm-Message-State: AOJu0Yyi6IxZSeJHN3JIFltIKy6++bYIzLuB8MXRHWFNqDKLzlDwUJoP UBKd9OFbgn1pttsb/MtubO8D1jW7R5ihOAirIN68pHPsBrIETT5EDP/qZGKDcOpcimAbXRqhXAq 5SFk= X-Google-Smtp-Source: AGHT+IEhLDTzYytyt1CZL/6C7wOMe94F80QiJ0Smue2O3Nux4m0d+OjfBmDRId5tFbOa16mtyfVrAw== X-Received: by 2002:a05:600c:25a:b0:424:7871:2e9e with SMTP id 5b1f17b1804b1-425630e946bmr28704815e9.6.1719506787368; Thu, 27 Jun 2024 09:46:27 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Sai Pavan Boddu , Francisco Iglesias , Joel Stanley , Luc Michel , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Bin Meng Subject: [PATCH 16/21] hw/sd/sdcard: Add sd_cmd_ERASE handler (CMD38) Date: Thu, 27 Jun 2024 18:43:39 +0200 Message-ID: <20240627164345.82192-17-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627164345.82192-1-philmd@linaro.org> References: <20240627164345.82192-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::332; envelope-from=philmd@linaro.org; helo=mail-wm1-x332.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: 1719506893549100001 Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sd.c | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 4e31dfe18f..17fec612eb 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -244,7 +244,6 @@ static const char *sd_cmd_name(SDState *sd, uint8_t cmd) [21] =3D "DPS_spec", [25] =3D "WRITE_MULTIPLE_BL= OCK", [26] =3D "MANUF_RSVD", - [38] =3D "ERASE", [40] =3D "DPS_spec", [42] =3D "LOCK_UNLOCK", [54] =3D "SDIO_RSVD", [55] =3D "APP_CMD", @@ -1602,6 +1601,24 @@ static sd_rsp_type_t sd_cmd_ERASE_WR_BLK_END(SDState= *sd, SDRequest req) return sd_r1; } =20 +/* CMD38 */ +static sd_rsp_type_t sd_cmd_ERASE(SDState *sd, SDRequest req) +{ + if (sd->state !=3D sd_transfer_state) { + return sd_invalid_state_for_cmd(sd, req); + } + if (sd->csd[14] & 0x30) { + sd->card_status |=3D WP_VIOLATION; + return sd_r1b; + } + + sd->state =3D sd_programming_state; + sd_erase(sd); + /* Bzzzzzzztt .... Operation complete. */ + sd->state =3D sd_transfer_state; + return sd_r1b; +} + static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) { uint16_t rca; @@ -1690,26 +1707,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 - /* Erase commands (Class 5) */ - case 38: /* CMD38: ERASE */ - switch (sd->state) { - case sd_transfer_state: - if (sd->csd[14] & 0x30) { - sd->card_status |=3D WP_VIOLATION; - return sd_r1b; - } - - sd->state =3D sd_programming_state; - sd_erase(sd); - /* Bzzzzzzztt .... Operation complete. */ - sd->state =3D sd_transfer_state; - return sd_r1b; - - default: - break; - } - break; - /* Lock card commands (Class 7) */ case 42: /* CMD42: LOCK_UNLOCK */ return sd_cmd_to_receivingdata(sd, req, 0, 0); @@ -2318,6 +2315,7 @@ static const SDProto sd_proto_spi =3D { [35] =3D {10, sd_spi, "WRITE_SEC_CMD", sd_cmd_optional}, [36] =3D {10, sd_spi, "SEND_PSI", sd_cmd_optional}, [37] =3D {10, sd_spi, "CONTROL_ASSD_SYSTEM", sd_cmd_optional}, + [38] =3D {5, sd_spi, "ERASE", sd_cmd_ERASE}, [50] =3D {10, sd_spi, "DIRECT_SECURE_READ", sd_cmd_optional}, [52] =3D {9, sd_spi, "IO_RW_DIRECT", sd_cmd_optional}, [53] =3D {9, sd_spi, "IO_RW_EXTENDED", sd_cmd_optional}, @@ -2361,6 +2359,7 @@ static const SDProto sd_proto_sd =3D { [35] =3D {10, sd_adtc, "WRITE_SEC_CMD", sd_cmd_optional}, [36] =3D {10, sd_adtc, "SEND_PSI", sd_cmd_optional}, [37] =3D {10, sd_ac, "CONTROL_ASSD_SYSTEM", sd_cmd_optional}, + [38] =3D {5, sd_ac, "ERASE", sd_cmd_ERASE}, [43] =3D {1, sd_ac, "Q_MANAGEMENT", sd_cmd_optional}, [44] =3D {1, sd_ac, "Q_TASK_INFO_A", sd_cmd_optional}, [45] =3D {1, sd_ac, "Q_TASK_INFO_B", sd_cmd_optional}, --=20 2.41.0 From nobody Mon Nov 25 00:25:54 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=1719506948; cv=none; d=zohomail.com; s=zohoarc; b=PbsOYATf7cb3D1AJPUJngj5ypkCZGIuqkw9n/vIub4IrgSYI0oEUHtSOmfe+KPp5GFVjUghVhY6IYEbtKKdpRycJq4vwkZetVeWOKfyCwPk7eOH4QGIs5hpdeq8+PsmvtAl/+sIOQvm5iXNhRJx0LAARYXM8zFCODimkmQ+iLPw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719506948; 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=HYHB8+xaBcVQbVKgp+p9kpTdDb0kmp4G0ZMulayNcv0=; b=PxwDZ3yynYTNKM1OOx8cV8/cog0Lscr+niQo1ih+hMBVni5vIJF18m+tVsraJHpFSPMTgnLwhLSAHlwQcDw5kbT678b0AjIUgjNXQ46fuYnYIJGuY0rxZWIgX9Ee3a+PnJziy9YQ3V43ELGz4tb0FpyLULERz8wBLhhRnaMeJ4Y= 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 1719506948171336.4495916647902; Thu, 27 Jun 2024 09:49:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMsI4-0007uG-3n; Thu, 27 Jun 2024 12:48:08 -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 1sMsGe-0006Sd-AY for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:46:51 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMsGc-0000TW-DQ for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:46:39 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-424acf3226fso19283835e9.1 for ; Thu, 27 Jun 2024 09:46:38 -0700 (PDT) Received: from localhost.localdomain (33.red-95-127-46.staticip.rima-tde.net. [95.127.46.33]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-424c8246b1dsm77780835e9.6.2024.06.27.09.46.34 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:46:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719506796; x=1720111596; 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=HYHB8+xaBcVQbVKgp+p9kpTdDb0kmp4G0ZMulayNcv0=; b=zY997UVoiEH42cj//KM8OfVSqGqIMwXqJBGXCnOfXoIc1B2Sv1Yq7D5p5uOZ/3+6cB AQCbNGoW9OWo6PDi8LBH5rHtD7WSDVGcrUzEh6qFj95Gznu+iTjCugFd/mAGIbM7Nj2B NhoDSjXUzUmGRyTqyPIeT9DIWZ1ID82tC9nCsVG1p5c6BNtd6xT7HiIrSkaUOvqlKLBG fHyuDY9oD+YO77jRf3LcNQbzlUVxyfSUZvbcd9bliPOHgzzMUVLhwJn0DVDa+tKDuohD B19dKPm1A2mhWQvSVHp6WsO0GJLYkJaAE2q9HewSW234y1uPRMe8Tz0QRgtDtQ7oUCVs fP1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719506796; x=1720111596; 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=HYHB8+xaBcVQbVKgp+p9kpTdDb0kmp4G0ZMulayNcv0=; b=hyvoCQQ+w7lA4HhD/rlmcWS3lArlMUFxb13GrbK56HE6/D3HQSlCoGJyOrwn3mzVKM kPeuIzJP5CBYp6jBeZ/36wzglUSgs1h3gghtrRudsghkVFw8Xg7X0vovo9zqjh2vOVKE 5vbzm/6mgwVV54mL+Kva2uF8pFBqeUkdBLlieaPjlJJ0KpQyg+4Tmi2jc3qIqH37asAZ mEzkzmLsZEsLSjGjztDvP1CnVNQZhwlxzkPypyVY9GYcNtK8iEeWSR4wpK053dLvVZiz 4wfdALtpIxZYXN3zcYoimxM6YFd7niiJvsLxm3thoBMc8oSnDrM4dI3abRicmOq/Eoqj ahUA== X-Gm-Message-State: AOJu0YzBWu9nF+lz3EvL17wxG/Thg7x9shqYFwDF/h62xv39VCTLfVxI c7Xh3dBs2a1aFKGEkSszPkZPzZjy/8o5CEKyoKUc9CD5kFeRwtjSc98G1X+BeM622jq2b2wAmI7 Dneg= X-Google-Smtp-Source: AGHT+IG6rB8XeieU+MdEOqPoGSIvk6YMxGoNWWfJv+jUoyeMOqO9h64EXqtZOFzvqE6dAU5JSeOLwQ== X-Received: by 2002:a05:600c:2192:b0:424:bb45:cdea with SMTP id 5b1f17b1804b1-424bb45cedbmr39589435e9.22.1719506796696; Thu, 27 Jun 2024 09:46:36 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Sai Pavan Boddu , Francisco Iglesias , Joel Stanley , Luc Michel , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Bin Meng Subject: [PATCH 17/21] hw/sd/sdcard: Add sd_cmd_LOCK_UNLOCK handler (CMD42) Date: Thu, 27 Jun 2024 18:43:40 +0200 Message-ID: <20240627164345.82192-18-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627164345.82192-1-philmd@linaro.org> References: <20240627164345.82192-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::32f; envelope-from=philmd@linaro.org; helo=mail-wm1-x32f.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: 1719506949733100001 Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sd.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 17fec612eb..4d78ac5b59 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -245,7 +245,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", - [42] =3D "LOCK_UNLOCK", [54] =3D "SDIO_RSVD", [55] =3D "APP_CMD", [56] =3D "GEN_CMD", [60] =3D "MANUF_RSVD", [61] =3D "MANUF_RSVD", @@ -1619,6 +1618,12 @@ static sd_rsp_type_t sd_cmd_ERASE(SDState *sd, SDReq= uest req) return sd_r1b; } =20 +/* CMD42 */ +static sd_rsp_type_t sd_cmd_LOCK_UNLOCK(SDState *sd, SDRequest req) +{ + return sd_cmd_to_receivingdata(sd, req, 0, 0); +} + static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) { uint16_t rca; @@ -1707,10 +1712,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 - /* Lock card commands (Class 7) */ - case 42: /* CMD42: LOCK_UNLOCK */ - return sd_cmd_to_receivingdata(sd, req, 0, 0); - /* Application specific commands (Class 8) */ case 55: /* CMD55: APP_CMD */ rca =3D sd_req_get_rca(sd, req); @@ -2316,6 +2317,7 @@ static const SDProto sd_proto_spi =3D { [36] =3D {10, sd_spi, "SEND_PSI", sd_cmd_optional}, [37] =3D {10, sd_spi, "CONTROL_ASSD_SYSTEM", sd_cmd_optional}, [38] =3D {5, sd_spi, "ERASE", sd_cmd_ERASE}, + [42] =3D {7, sd_spi, "LOCK_UNLOCK", sd_cmd_LOCK_UNLOCK}, [50] =3D {10, sd_spi, "DIRECT_SECURE_READ", sd_cmd_optional}, [52] =3D {9, sd_spi, "IO_RW_DIRECT", sd_cmd_optional}, [53] =3D {9, sd_spi, "IO_RW_EXTENDED", sd_cmd_optional}, @@ -2360,6 +2362,7 @@ static const SDProto sd_proto_sd =3D { [36] =3D {10, sd_adtc, "SEND_PSI", sd_cmd_optional}, [37] =3D {10, sd_ac, "CONTROL_ASSD_SYSTEM", sd_cmd_optional}, [38] =3D {5, sd_ac, "ERASE", sd_cmd_ERASE}, + [42] =3D {7, sd_adtc, "LOCK_UNLOCK", sd_cmd_LOCK_UNLOCK}, [43] =3D {1, sd_ac, "Q_MANAGEMENT", sd_cmd_optional}, [44] =3D {1, sd_ac, "Q_TASK_INFO_A", sd_cmd_optional}, [45] =3D {1, sd_ac, "Q_TASK_INFO_B", sd_cmd_optional}, --=20 2.41.0 From nobody Mon Nov 25 00:25:54 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=1719506942; cv=none; d=zohomail.com; s=zohoarc; b=jMJzgXf+r11T3n1pNrOf9eyrgqxLyrX2G6OER6AqWHTEwMOXt0a0J8K9Tasd2rrDFzSalMENF5Anfdup9oS1EEDVlNmlSYEzG5Eje2cf6OjevAXepbePcs16/++YLK5beasyqgjvIcjCC8lMWQHeqYML6G8LsBTUg2+Ki5nvJAI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719506942; 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=jmktXx8YFnfnnA13QTx+BBHRiUUuhl67+QJQQVhLdE0=; b=Rk59a+0D8dZJfuMFSY+x5W8GTOJngoWTGcDjGStZzUZ8fKZFublbhogSugg45OUAZP+xCFP9o6f/9nv47RXrXty2ZX1pJJh/tL0bWzsyY+T6APbNbaJ37cFSgJ90U1Na7J+ja1FqajE7tlLqp00f7WfMFZ0UkhjfuQMrEVAJ6iM= 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 1719506942423299.9491732905126; Thu, 27 Jun 2024 09:49:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMsHw-0007Sw-TH; Thu, 27 Jun 2024 12:48:00 -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 1sMsGp-0006V5-Kc for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:46:54 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMsGn-0000UV-Vz for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:46:51 -0400 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-42138eadf64so69478395e9.3 for ; Thu, 27 Jun 2024 09:46:48 -0700 (PDT) Received: from localhost.localdomain (33.red-95-127-46.staticip.rima-tde.net. [95.127.46.33]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256798ce18sm22530645e9.23.2024.06.27.09.46.44 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:46:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719506807; x=1720111607; 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=jmktXx8YFnfnnA13QTx+BBHRiUUuhl67+QJQQVhLdE0=; b=F7BB2z5YkaS/+odxUjra9tzOgYOrIV6Ou/kh2OnWNPnCRywOK/hTF6KX+ox+IJcswQ fyCmtR1snKfwf15BkVy7CaRjmKj/rjLR5ldNKTzYz0TLsy/6nzkQrveXH/L7011r5Xzj fYOah0IU1Ybem8DymsWLihsgD6dVfEuB55oyYdhbVWOHyH8461wp5VJWHcdr4WXfpj1J hPMNiRiHvEmsYlB8OtsTS+PtIUhuOv2e+jLR3DRkwO6xfhyJFYFg72j5DUsu8slYtHMD hXUY8v0z2+6VLwpRjF32Dx0BSCLjqfK9lbOCZMB8/mot/ImEwvz/CuusfPws5OFhwC2u ZefQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719506807; x=1720111607; 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=jmktXx8YFnfnnA13QTx+BBHRiUUuhl67+QJQQVhLdE0=; b=Xh+RBfEMjjXzFQnlDKQVMcy2HcgROkqCay7IfeZ7j15So1H5e3fUuStwUIOGKXKTlW XFYVc8phgFT+tu65/D4oJ2P3pW2FFsX1hiwgBHq9rdhvVnJ8wdJWteBKhmFbNV9Vam1g NXwmjvxV2PVi502kXiFkZiL8sCFSkZWURyHpoM+edDywE3yvuv5mQsy1DEDh24wdoTHR VO1QQbk/zXWnITmFr65MQG66ElU9lQwDRzKIIcpLCApmYJzIV5fQTjJ8CNxCJo3Vl1FG 795FST/u2O/l6l2LpXYnX6rFwjG3/bkalLuWuPAASHh0ljmfUexRYB7FJS2Yg26fEPd2 2bcg== X-Gm-Message-State: AOJu0YxpYUZ/YHFD1NJJP9q0l3xHD2ScTZpDVZObXrCBNuNqGeyv0oth fgx8u1wH7pQZS9fGlAMOI1I0OVewByPOT4XLB7P1s5rRVaJeEng/ohKFqtzUwSrQpygZ4lkQpsV fan8= X-Google-Smtp-Source: AGHT+IHcgQzjgnOMQfbRnlxVQv5zw6hkqX/mYMRFo74YdXbpGq6lkt3mWsXR8BdpkYnaF04lk91Hgg== X-Received: by 2002:a05:600c:458d:b0:424:781a:188b with SMTP id 5b1f17b1804b1-4248cc58a63mr105770785e9.31.1719506807564; Thu, 27 Jun 2024 09:46:47 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Sai Pavan Boddu , Francisco Iglesias , Joel Stanley , Luc Michel , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Bin Meng Subject: [PATCH 18/21] hw/sd/sdcard: Add sd_cmd_APP_CMD handler (CMD55) Date: Thu, 27 Jun 2024 18:43:41 +0200 Message-ID: <20240627164345.82192-19-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627164345.82192-1-philmd@linaro.org> References: <20240627164345.82192-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::332; envelope-from=philmd@linaro.org; helo=mail-wm1-x332.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: 1719506943734100003 Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sd.c | 53 ++++++++++++++++++++++++++++------------------------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 4d78ac5b59..5461e56e17 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -245,7 +245,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", - [54] =3D "SDIO_RSVD", [55] =3D "APP_CMD", [56] =3D "GEN_CMD", [60] =3D "MANUF_RSVD", [61] =3D "MANUF_RSVD", [62] =3D "MANUF_RSVD", [63] =3D "MANUF_RSVD", @@ -1624,9 +1623,34 @@ static sd_rsp_type_t sd_cmd_LOCK_UNLOCK(SDState *sd,= SDRequest req) return sd_cmd_to_receivingdata(sd, req, 0, 0); } =20 +/* CMD55 */ +static sd_rsp_type_t sd_cmd_APP_CMD(SDState *sd, SDRequest req) +{ + switch (sd->state) { + case sd_ready_state: + case sd_identification_state: + case sd_inactive_state: + return sd_invalid_state_for_cmd(sd, req); + case sd_idle_state: + if (!sd_is_spi(sd) && sd_req_get_rca(sd, req) !=3D 0x0000) { + qemu_log_mask(LOG_GUEST_ERROR, + "SD: illegal RCA 0x%04x for APP_CMD\n", req.cmd); + } + /* fall-through */ + default: + break; + } + if (!sd_is_spi(sd) && !sd_req_rca_same(sd, req)) { + return sd_r0; + } + sd->expecting_acmd =3D true; + sd->card_status |=3D APP_CMD; + + return sd_r1; +} + static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) { - uint16_t rca; uint64_t addr; =20 sd->last_cmd_name =3D sd_cmd_name(sd, req.cmd); @@ -1713,29 +1737,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, = SDRequest req) return sd_cmd_to_receivingdata(sd, req, 0, sizeof(sd->cid)); =20 /* Application specific commands (Class 8) */ - case 55: /* CMD55: APP_CMD */ - rca =3D sd_req_get_rca(sd, req); - switch (sd->state) { - case sd_ready_state: - case sd_identification_state: - return sd_illegal; - case sd_idle_state: - if (rca) { - qemu_log_mask(LOG_GUEST_ERROR, - "SD: illegal RCA 0x%04x for APP_CMD\n", req.= cmd); - } - default: - break; - } - if (!sd_is_spi(sd)) { - if (sd->rca !=3D rca) { - return sd_r0; - } - } - sd->expecting_acmd =3D true; - sd->card_status |=3D APP_CMD; - return sd_r1; - case 56: /* CMD56: GEN_CMD */ switch (sd->state) { case sd_transfer_state: @@ -2321,6 +2322,7 @@ static const SDProto sd_proto_spi =3D { [50] =3D {10, sd_spi, "DIRECT_SECURE_READ", sd_cmd_optional}, [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}, [57] =3D {10, sd_spi, "DIRECT_SECURE_WRITE", sd_cmd_optional}, }, .acmd =3D { @@ -2373,6 +2375,7 @@ static const SDProto sd_proto_sd =3D { [50] =3D {10, sd_adtc, "DIRECT_SECURE_READ", sd_cmd_optional}, [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}, [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 Mon Nov 25 00:25:54 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=1719507018; cv=none; d=zohomail.com; s=zohoarc; b=Rv0YcwSGqt0fObXHgp/sqQq/iZ76oXnlQnezx0grBsGksD2vvazWxnjSsjbXoGZJmAe0S73IjyrlaychF/0EoVaxp7K0hrI0+mxBfKuomk9Ouyf+57jYP6fNs/mp94+rthcXZmfiLlQ/FxFFg8l8FPs0Z/rGDgpvY0wK8/Qfk84= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719507018; 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=h6DmY6CGyXMJfzQtpsncnrmxkBN2T3nvO/hOHeba5R0=; b=T71bIc0KFI2vK6KCkd4k9F2mrJpAB0NJvEakPAS8f2Z/kSLP3DFMWwMHr2gxmKCSMinJpD11mRGfaC/WcGc/XqQsiwEVMC3qVva7vKnorqSqjSOZkv63E2BaQ40HJxJAlZ2A4gwa1aBWaY6rF/hm2xmPkyJA6QQgMdyItgK91Bc= 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 171950701871758.717641505345796; Thu, 27 Jun 2024 09:50:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMsI5-0007yC-K8; Thu, 27 Jun 2024 12:48:10 -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 1sMsH2-0006aW-7I for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:47:11 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMsH0-0000Wz-DV for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:47:03 -0400 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-361785bfa71so6178464f8f.2 for ; Thu, 27 Jun 2024 09:47:01 -0700 (PDT) Received: from localhost.localdomain (33.red-95-127-46.staticip.rima-tde.net. [95.127.46.33]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3674357c173sm2458889f8f.18.2024.06.27.09.46.54 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:46:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719506818; x=1720111618; 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=h6DmY6CGyXMJfzQtpsncnrmxkBN2T3nvO/hOHeba5R0=; b=MqPxBVp8I62O4EIDgFhykYvSoglO/gG+VPeRFXViwR7/1rQZpYl87O1gcinGAh5cPB 7GaD864UkE9mNrCEoIqBdsARN7wz8STNCnDGfqzsmwmu/MvlFvREV8rMgv/CGfaY2IqL 1Ek4vr0HDJE6YTiszw7gyH4xjRjshBSF6u8lD3/G/kDHsch+2dJ788uNoKnkM/UFh+jV MweoEyz4RWc/pZZKyoS14UU8Y+bcdFzi7txMf3lo4QBZD89F3Jk2nUFc+ZvLc9fVdGjR 7EDlVub3WGhaU/M1SETo1lm79g406Vot1r8PzmADL2w3O3EbParUc5U93/yD1MFKlK0c pMZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719506818; x=1720111618; 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=h6DmY6CGyXMJfzQtpsncnrmxkBN2T3nvO/hOHeba5R0=; b=qMcT9oo03GiUnYA5FX+fLTchLHPMj2yS+5C4ULO0ektgaSeDrKoNXUPIKqDstcFNkR WiaY9GYFAPt/5tc7GIrvjwYXntpA3q2ebsQxR3CzF6tsWcE0FvTI7lYyq4zinhjyliX2 5dcahE3XxivE/NOyZ/uZg8rZezzTmrneMV6jmWBNlUml1pm2HKKZAfNvK1SonnfvQgOb jbjAkGWp1H+66VbCcaw0y8jIrWlt60PfdtB1XbwQC9+/BWY8Wj3vIwClco9Yl9qawBIM P/fPzu+jZ8AbKa0GkzfdTTkH+LLWi87lXvoy54pvC3k1JcHxrMlN2evtTwmrC9q3ya8X xsNg== X-Gm-Message-State: AOJu0YyPwb1d8+4xsdxWhHJKFTFZo/lSOINZM17v/vWpcSdprnWUaWBq 6S1twQxs8HfwGvGqVTf6HHokQ8bQfQbHQB/6Aeyu+ArSauVeHO4n4xz+JOj3w9WG8PHWm3aZaZ6 McY4= X-Google-Smtp-Source: AGHT+IEy91KAsYZOW+ce9WLe8WFS5a/erVD373Kk7+ZZoaJfJ534wVWLYccPyx0Ex/eQ1P2svOoKuA== X-Received: by 2002:adf:f043:0:b0:362:ebf5:3fd with SMTP id ffacd0b85a97d-366e7a0fc8bmr8917928f8f.30.1719506818516; Thu, 27 Jun 2024 09:46:58 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Sai Pavan Boddu , Francisco Iglesias , Joel Stanley , Luc Michel , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Bin Meng Subject: [PATCH 19/21] hw/sd/sdcard: Add sd_cmd_GEN_CMD handler (CMD56) Date: Thu, 27 Jun 2024 18:43:42 +0200 Message-ID: <20240627164345.82192-20-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627164345.82192-1-philmd@linaro.org> References: <20240627164345.82192-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::434; envelope-from=philmd@linaro.org; helo=mail-wr1-x434.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: 1719507020152100001 Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sd.c | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 5461e56e17..50cee5ac40 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -245,7 +245,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", }; @@ -910,9 +909,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; @@ -1649,6 +1645,21 @@ 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); + } + + if (req.arg & 1) { + return sd_cmd_to_sendingdata(sd, req, 0, + sd->vendor_data, sizeof(sd->vendor_da= ta)); + } else { + return sd_cmd_to_receivingdata(sd, req, 0, sizeof(sd->vendor_data)= ); + } +} + static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) { uint64_t addr; @@ -1737,21 +1748,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, = SDRequest req) 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: - if (req.arg & 1) { - return sd_cmd_to_sendingdata(sd, req, 0, - sd->vendor_data, - sizeof(sd->vendor_data)); - } - return sd_cmd_to_receivingdata(sd, req, 0, sizeof(sd->vendor_d= ata)); - - default: - break; - } - break; - case 58: /* CMD58: READ_OCR (SPI) */ return sd_r3; =20 @@ -2323,6 +2319,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}, }, .acmd =3D { @@ -2376,6 +2373,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 Mon Nov 25 00:25:54 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=1719506901; cv=none; d=zohomail.com; s=zohoarc; b=dFMnJ18hQjZik88DP0ntpv1qn94k6+MOYvibFYNLB3jp+Xaj9viOXKHYgaTLPlt8efqTZ0pZ1ozM6oQtM/JDpRixC9dhmm77G3S6QtjerCjmt3HvET1lNHNDPfdd1Evjx7gtF008VxzZIsWhMtx4P94ecsCGw8i/M6A5yTg8lL0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719506901; 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=K1hpuhYvD8c8zKzHH2qCf+bpB7ESZQppXpuiPvi8zTE=; b=JCRndNcgLFpczRym3ckNNLIyIJeyY54sk2t18zD1/zs0YDpWhTJrMuN/ZV7oXy/DEEFR10ZJbOQxdE8DYQUV3K5utmd4+tnlwb8HoTbmnZ0/Y7bEmMBoUtZZQqo/1LkSrrLsZ8ehrqXX87b85u77hDjieR4oM6+16uUSIS6qZ4I= 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 1719506901907836.784208695268; Thu, 27 Jun 2024 09:48:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMsI6-0007yj-HJ; Thu, 27 Jun 2024 12:48:10 -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 1sMsHF-0006gb-9t for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:47:22 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMsH8-0000Xo-NO for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:47:15 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-4249196a361so37213685e9.0 for ; Thu, 27 Jun 2024 09:47:09 -0700 (PDT) Received: from localhost.localdomain (33.red-95-127-46.staticip.rima-tde.net. [95.127.46.33]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42564b63ed6sm36993885e9.13.2024.06.27.09.47.06 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:47:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719506828; x=1720111628; 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=K1hpuhYvD8c8zKzHH2qCf+bpB7ESZQppXpuiPvi8zTE=; b=ZnQ+IFg3GeNE8erzfV7DiEE2v0aN3sBsZwqF4cGyJn6ZsFmPjiX3fL4YmWNNSWlIKm P5nuUUjzE9eQeujs70fENyW0LmqS9ImQx92U5Jdh2scUUsUxpFIfYGJ76c/1lyYLZsCP v4gYh2xBEfP6gORTPmS9VZE9qbWpKYUJNd3DXHGUG6dAbihI+GPHFjy/P7ZBFTKhZ0RE 7tWHA3jRQaLBo17Ek5x6X6QV7CToNo6RqYvOdojZFUw4s7ib72opbQCsF+fcpYzQlC+r u0PgImbC8j/VgZXhgPnyiTz/NSvalMyB/6BDGasjJZiKKHbJ+WCWBC1zxcLd66tDxk8o Uh8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719506828; x=1720111628; 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=K1hpuhYvD8c8zKzHH2qCf+bpB7ESZQppXpuiPvi8zTE=; b=RSsSWhaetPl9aziCu5IMIX+choDym8FKXahD04Ordhi42LqgjsDpDBOskV0h1uwvYK cNKFAarXxct9K925/rZ8GN0z5QelEbnjFQnGvlLxkrcbskCtklROSwilN0PmR5OVTs0r UvVKoMygIpBxHjeQ1n63fhcy2OyOItudl8aZwloU6JjPW1DFQxq5nTn/wBR9h45BC5tD uXltjKhphXCCh0kVl+XZZQ95xRhc+85l4i4/kOaJhlFHUM6ynj2Xfj9dahVRXb8BgHpJ 8dgVjFEo5SSfVlDFYcAGUy+HYPt6uNKUpdncMEtnG6M3x3Y8PF9mhu49zzUrk0Nmt7gL Jj8g== X-Gm-Message-State: AOJu0Yx37ODj8ttjsP48GotJpRxRxLLsGF6VxFhcSfEHZKJtwtAilea3 FhE68neTu2tZsLlvWBL7HI/1jZOOscQZ3WNBSKQa7jjpkhb7zGtvFpitPtZgEUm0+ih/BAr30oH AD/w= X-Google-Smtp-Source: AGHT+IEP9ur16EZTFoNUvm+v/TfEIC6mNdrcuCyDDHVI6ZJnAbamqIQf4OdyLdiJOfGN7PbUXOGAYg== X-Received: by 2002:a05:600c:35c1:b0:425:678b:901d with SMTP id 5b1f17b1804b1-425678b923bmr10365825e9.21.1719506828603; Thu, 27 Jun 2024 09:47:08 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Sai Pavan Boddu , Francisco Iglesias , Joel Stanley , Luc Michel , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Bin Meng Subject: [PATCH 20/21] hw/sd/sdcard: Add spi_cmd_READ_OCR handler (CMD58) Date: Thu, 27 Jun 2024 18:43:43 +0200 Message-ID: <20240627164345.82192-21-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627164345.82192-1-philmd@linaro.org> References: <20240627164345.82192-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::333; envelope-from=philmd@linaro.org; helo=mail-wm1-x333.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, T_SPF_TEMPERROR=0.01 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: 1719506903514100003 Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sd.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 50cee5ac40..b3b4cd5a3a 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1660,6 +1660,12 @@ static sd_rsp_type_t sd_cmd_GEN_CMD(SDState *sd, SDR= equest req) } } =20 +/* CMD58 */ +static sd_rsp_type_t spi_cmd_READ_OCR(SDState *sd, SDRequest req) +{ + return sd_r3; +} + static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) { uint64_t addr; @@ -1748,9 +1754,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, S= DRequest req) return sd_cmd_to_receivingdata(sd, req, 0, sizeof(sd->cid)); =20 /* Application specific commands (Class 8) */ - case 58: /* CMD58: READ_OCR (SPI) */ - return sd_r3; - case 59: /* CMD59: CRC_ON_OFF (SPI) */ return sd_r1; =20 @@ -2321,6 +2324,7 @@ static const SDProto sd_proto_spi =3D { [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}, }, .acmd =3D { [41] =3D {8, sd_spi, "SEND_OP_COND", spi_cmd_SEND_OP_COND}, --=20 2.41.0 From nobody Mon Nov 25 00:25:54 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=1719506942; cv=none; d=zohomail.com; s=zohoarc; b=Rt49VKLnIcHaoLVF4nUGrFt7VGU61Au7EkFU9AXNQ3YOxEfTBM/PaZEKbUbaZ6KrAP4qO77Zk1HRNKvZraoaN32/km3YXb9uFvI99TP4mS8O50kgzLEF3TiOSjPVytOHHpVBNYkMr5AVBDZc1orpvJUmGwK1eFx/v4G+mt9KRVU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719506942; 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=Z4eT6ls1VgCOfFdDFeq72C/Jkjo1k0Xm3Q4yUyOE478=; b=b8+97saKIdPIIosltejJUQqGPxP2CpimuJhnYMR5ZEk5gzgL36dZPRHbbjLwLKIzdiEHY6Lw0YP717sscllx9QnzjBVUB0anIcdMgy2L+7rHUCGfUYBxDjONsr6NJ6WW1wLcBgfw52c2G+pvk9UUEzhZ9+Y41WE9Ac8I8qZnHUI= 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 1719506942264651.13472929638; Thu, 27 Jun 2024 09:49:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMsI8-0008Sd-Jr; Thu, 27 Jun 2024 12:48:12 -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 1sMsHL-0006qk-0P for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:47:33 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMsHI-0000Yh-3L for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:47:21 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-42566fb8302so5765925e9.0 for ; Thu, 27 Jun 2024 09:47:19 -0700 (PDT) Received: from localhost.localdomain (33.red-95-127-46.staticip.rima-tde.net. [95.127.46.33]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3674358548csm2458704f8f.64.2024.06.27.09.47.15 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:47:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719506838; x=1720111638; 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=Z4eT6ls1VgCOfFdDFeq72C/Jkjo1k0Xm3Q4yUyOE478=; b=DXHVP3NNIZ6JVrujgShShAYqOYN5JsXQgW9DCwVHbHFbnRn03inFi4KFxHI0iYkLOm qXZ3LernGLuteXuvRQpMnIGQZltNmGtvTw1g0SG4h4hgZxfSdWBN+waJSA7NEQPHra2F HdZO4ycqcc78VzTqoqqRtk1/2GdSINGqFSxVMKphiiYbXkAJZKnTly09P5AU0jTS0Kv0 5hslJM3OoeQGXsUMwWJyvk0bZxIllUL1lFlOIIwIqkTxDwnqMJuERNS3LiWJi3lXNgXU ZrZ6jsOzemeMS5HV++8QsCKk8sM0c8WbCRQ8/WHG4vfilZr76QuH+rCmvzmHkL6JZXUI q9hQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719506838; x=1720111638; 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=Z4eT6ls1VgCOfFdDFeq72C/Jkjo1k0Xm3Q4yUyOE478=; b=Lh3vQpPRCTRDeyOTcwb3K33Y8YrdBx3QLBKBwTJaa62MmCcemt12doLSxtboGxriVQ L/fr38RMqUGfdiGekWFOEpJrcGG2WI4d3zoALJmZphCmvwexXuP4DDUXtvH7PrBT7Myj mEcn1RfIy5/WlELPFroQxmMRXn3EW66jk5WR70pWZsqPpoJXi/CNiVzSECauqFFfOVqr gRtopLVpBUBRe7EjgrpT7kgx81Kxu2bqFJRA2I44ZvVAsCwOhF3BHdjILvi/PzlltdYZ 2zhwcY13055LW9WcrJPk/NqY2roeYIrA/xQBhcj/YxwVplbi3S787aeMIft0lCS7rvOC uLnw== X-Gm-Message-State: AOJu0YwQUJZVWOGs2ShF3qUhBqe2ABvhlecmnzvxtdN5EuTkC2CbuyQq zerxhlTIU8bPJAczLYzrYGb4G/nJufkzd3HR2M9+zNVhqqDWUgQzqpuoG3/GOwZZs7FfvcrRQoQ TU6M= X-Google-Smtp-Source: AGHT+IHd4zCcS3nCQASqfZh1q7Jo09zcvgQ3qWWsGjiMANaolcKnlCA1FqeP8s8xUiSlfBh4QOCwew== X-Received: by 2002:a05:600c:4c22:b0:424:ac9c:71f9 with SMTP id 5b1f17b1804b1-424ac9c7bdcmr38538235e9.39.1719506838266; Thu, 27 Jun 2024 09:47:18 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Sai Pavan Boddu , Francisco Iglesias , Joel Stanley , Luc Michel , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Bin Meng Subject: [PATCH 21/21] hw/sd/sdcard: Add spi_cmd_CRC_ON_OFF handler (CMD59) Date: Thu, 27 Jun 2024 18:43:44 +0200 Message-ID: <20240627164345.82192-22-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627164345.82192-1-philmd@linaro.org> References: <20240627164345.82192-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::32b; envelope-from=philmd@linaro.org; helo=mail-wm1-x32b.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: 1719506943711100001 Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sd.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index b3b4cd5a3a..2f853a89d1 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1666,6 +1666,12 @@ static sd_rsp_type_t spi_cmd_READ_OCR(SDState *sd, S= DRequest req) return sd_r3; } =20 +/* CMD59 */ +static sd_rsp_type_t spi_cmd_CRC_ON_OFF(SDState *sd, SDRequest req) +{ + return sd_r1; +} + static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) { uint64_t addr; @@ -1753,10 +1759,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 59: /* CMD59: CRC_ON_OFF (SPI) */ - return sd_r1; - default: qemu_log_mask(LOG_GUEST_ERROR, "SD: Unknown CMD%i\n", req.cmd); return sd_illegal; @@ -2325,6 +2327,7 @@ static const SDProto sd_proto_spi =3D { [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}, }, .acmd =3D { [41] =3D {8, sd_spi, "SEND_OP_COND", spi_cmd_SEND_OP_COND}, --=20 2.41.0