From patchwork Fri Jun 28 07:01:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 808205 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp224619wrr; Fri, 28 Jun 2024 00:12:47 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCULBQFIYGisvfx+XK4uRfLnlIOcElvfXvJ/4HkyvUPUo7HrSjPQAHeNGfS7mkL08OL1kjGHhQKWrnX0Gp8B6adS X-Google-Smtp-Source: AGHT+IH5Gllc2O1ZhqK/nkFiBKiITKUALZvU+iLK04YBJBYCMZBkvYYJuRB7Y5B5WJzcNL9EqyIE X-Received: by 2002:a05:620a:2915:b0:79d:6ad0:d7db with SMTP id af79cd13be357-79d6ad0ddbdmr88805585a.43.1719558766992; Fri, 28 Jun 2024 00:12:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558766; cv=none; d=google.com; s=arc-20160816; b=u2HpSZq4XukCHViX5PQmtt9xMHX14XIzUYus0N8HbqRfRMvyeFe8fYVl0De0pKag4k sLeoju1kKaZ5TpOmmHcyoar7X12DpjkWPWeeIKcQECLe+JYkKRZjDV0J3gpXs9ai2eLB BvfwY29cKNnBLIKDnQXlSs7KluuZKcml173JP28+NqELnl1q0k852REbbb4IdiRZh+cd d4tRDefsJqwEYXwpJeD77bGuizIxGO0zTmYUTt3nW5J1ZOuFZjEiWJyI4OOkvlt7zJOt s9YgZa4j29fzug5tHLh1BCXeodw25BcnqDT0gFuB4e0RQeI6Io3WpdIeNCHOCpnnobCI Mfmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=vajGPnoCMySfBXhKCpWI2G0uKNcFQdTzNyXEs7BknL8=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=weBCVYEdpWAU/S9rTD8vUcpG0VqDCPBHA0e4CoY322W7HiZxyeQkOseiBp0ZmRl0XA Tw6l7Ky7uJosit4XJfU1nD6sVPa58UL9tigD0TV8agZLMNBkCAXULRiiEARyGTaevzwu R/gFAu63yyRF3MuXTxK8Cw/a7QupPoXCOujXjWN/zNXjy9MyQBln0bEvbWiQqWWz0UyF 2Ru+lyEStGIZFSvJZnUt125joZnHthIG3vQDt5+OO2Wdar2/P2DyRlsZ1CLkwmO2aoK4 qZieP3mWvnHlCJaRRZOyw758bqEZIcC6fxTiYtsBonuYkstftsvLUgoyZlHpoe5NQNeR f8NA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="REsP/mOA"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-79d6934bdfasi118267585a.713.2024.06.28.00.12.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:12:46 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="REsP/mOA"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sN5iY-0004Ux-3c; Fri, 28 Jun 2024 03:08: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 1sN5iU-00043o-Qm for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:08:19 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5iS-00043v-Fk for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:08:18 -0400 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-42567ddf099so2321025e9.3 for ; Fri, 28 Jun 2024 00:08:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558487; x=1720163287; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=vajGPnoCMySfBXhKCpWI2G0uKNcFQdTzNyXEs7BknL8=; b=REsP/mOAJMUta8qK0S8faM+Vx62fyMDUi0x+qqj+BqBo1huRPVw5RnukRKh0p+f/L3 V4hGmGOTnSppAotac0NWA5d5EHRkE+KsoZqNxblVzOMA0qSZPVlCVaOMRgMvxgS3/E7c OOrDxDWDMC5LAvVrOim03g016Hcz77JXi3PdfjeVDmZL+0OeMD0jlpPRVGkCMC0RWJBJ pYXusC+67Mfkme5oOPQh5ut8/vLIjLZHIeDGLGdjpH9cVZDKUpTXbHXbUFgjWrJIezRB FBQKk2FeyCEHyf/4i+xJSCDzjhqPzTmPK4hxAjYNRp26i+lyIJjgFCvMLWu30XoMrRgc A/oQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558487; x=1720163287; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vajGPnoCMySfBXhKCpWI2G0uKNcFQdTzNyXEs7BknL8=; b=JzKvlMwpQm/e/BV6QJezeFrRT/lcIl9psZg62+XO/mdqW4CBOTLxmDge0nnq/E3dNf pFnrDta2H+PKfLrW0J8fxNuCP206dGjx8rpGLvywFGS2Gt3+QQmKLpyD8lPk7T8fBH+V jiGmZ4TsysFH6XG4MhfJ7AgXf5FONN/VavevM4TteZrljlSz7xaAxK25r7ZU+wnZtb8r zgRs6LtdHqTH7Fi9Fj6ljMu/Hj3UcsR7oQ5zJyGzGLXYIggDKIXI98evemAw4bAcQw2L aWKrcnyvln4SnQlJaDG/AP2mIVvjhBgP3rIAfE6FxVLJ7lLx4duEUzg2mNszyyjTYZ8H GyeA== X-Gm-Message-State: AOJu0YzvlnDgWqYv6d0Le0DUv5xwU30esOhgKKNRbkm7d4ld6qIcyak7 vb29A6nhXXsm09x7PWHuYPckB+5AF8U5yZkgO6lMD2FACyWVJ1ZQot/A9NckkA0oEyoqU18ygsC /K/M= X-Received: by 2002:a05:600c:138e:b0:424:7bcf:2486 with SMTP id 5b1f17b1804b1-42489e3708fmr108897145e9.4.1719558487163; Fri, 28 Jun 2024 00:08:07 -0700 (PDT) Received: from m1x-phil.lan (cho94-h02-176-184-4-239.dsl.sta.abo.bbox.fr. [176.184.4.239]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256af37734sm22770345e9.10.2024.06.28.00.08.05 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:08:06 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v42 56/98] hw/sd/sdcard: Add sd_cmd_READ_SINGLE_BLOCK handler (CMD17) Date: Fri, 28 Jun 2024 09:01:32 +0200 Message-ID: <20240628070216.92609-57-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240628070216.92609-1-philmd@linaro.org> References: <20240628070216.92609-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=philmd@linaro.org; helo=mail-wm1-x334.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- 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] = { - [17] = "READ_SINGLE_BLOCK", [18] = "READ_MULTIPLE_BLOCK", [21] = "DPS_spec", [24] = "WRITE_BLOCK", [25] = "WRITE_MULTIPLE_BLOCK", @@ -1441,6 +1440,24 @@ static sd_rsp_type_t sd_cmd_SET_BLOCKLEN(SDState *sd, SDRequest req) return sd_r1; } +/* CMD17 */ +static sd_rsp_type_t sd_cmd_READ_SINGLE_BLOCK(SDState *sd, SDRequest req) +{ + uint64_t addr; + + if (sd->state != sd_transfer_state) { + return sd_invalid_state_for_cmd(sd, req); + } + + addr = 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) switch (req.cmd) { /* Block read commands (Class 2) */ - case 17: /* CMD17: READ_SINGLE_BLOCK */ - addr = sd_req_get_address(sd, req); - switch (sd->state) { - case sd_transfer_state: - - 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); - - default: - break; - } - break; - case 18: /* CMD18: READ_MULTIPLE_BLOCK */ addr = sd_req_get_address(sd, req); switch (sd->state) { @@ -2306,6 +2307,7 @@ static const SDProto sd_proto_spi = { [12] = {0, sd_spi, "STOP_TRANSMISSION", sd_cmd_STOP_TRANSMISSION}, [13] = {0, sd_spi, "SEND_STATUS", sd_cmd_SEND_STATUS}, [16] = {2, sd_spi, "SET_BLOCKLEN", sd_cmd_SET_BLOCKLEN}, + [17] = {2, sd_spi, "READ_SINGLE_BLOCK", sd_cmd_READ_SINGLE_BLOCK}, [34] = {10, sd_spi, "READ_SEC_CMD", sd_cmd_optional}, [35] = {10, sd_spi, "WRITE_SEC_CMD", sd_cmd_optional}, [36] = {10, sd_spi, "SEND_PSI", sd_cmd_optional}, @@ -2338,6 +2340,7 @@ static const SDProto sd_proto_sd = { [13] = {0, sd_ac, "SEND_STATUS", sd_cmd_SEND_STATUS}, [15] = {0, sd_ac, "GO_INACTIVE_STATE", sd_cmd_GO_INACTIVE_STATE}, [16] = {2, sd_ac, "SET_BLOCKLEN", sd_cmd_SET_BLOCKLEN}, + [17] = {2, sd_adtc, "READ_SINGLE_BLOCK", sd_cmd_READ_SINGLE_BLOCK}, [19] = {2, sd_adtc, "SEND_TUNING_BLOCK", sd_cmd_SEND_TUNING_BLOCK}, [20] = {2, sd_ac, "SPEED_CLASS_CONTROL", sd_cmd_optional}, [23] = {2, sd_ac, "SET_BLOCK_COUNT", sd_cmd_SET_BLOCK_COUNT},