From patchwork Tue Jul 2 09:20:29 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: 809087 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp118060wru; Tue, 2 Jul 2024 02:28:19 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVcdRN9Ghr5gRRzRuoaNfrq6+eUFhvQgIRtNTaN8/fAxZeRmO8PU7WrQuc0HsmKC+AF+NYQThQGyQNHN1fcwFLd X-Google-Smtp-Source: AGHT+IEeIpbw63bMTNpD+5DPotZQfHKhkWYiWmzwq3qB+bs9APtHGARE7fgrvAnY4wAt8Tyr/E76 X-Received: by 2002:a05:6122:3712:b0:4ef:5db8:fe15 with SMTP id 71dfb90a1353d-4f2a5687c6fmr9040000e0c.9.1719912499722; Tue, 02 Jul 2024 02:28:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719912499; cv=none; d=google.com; s=arc-20160816; b=zLyK9N9cFI+3g+GB2vYegPVZQQlvCDebbBA47EE76cwcMr4Hiil/fy/ju1zEW8/yeu tCoxWsC2sA+1EkJSOrhnJaOoJe5lCW7Z3Yrro2GiA5/C12ffc+WgVzUaipVkBm6o+LzX F93r2HU1bqYWih/1f0DwWvTB49Z9eK7n2QdkM8dLbD19tmWO4sV7myBlqYOiB4OB1sXD TuW7ZBYVKd4XZybL+kyAsyVDheFt4sKp+0DkQSv7/4XxQ8+P5Qbo2IoosU4hb/mg2Jpj ZfpAGFrBiqvyMH9m8YGYegpRdpomboOLCkvOBFEi1wWKu3djF+Jv+YG00dzcRyzE/0sF 4vSw== 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:cc:to :from:dkim-signature; bh=01K5Fpbyc/Wo8G4gat2aNkWhP6GApv43W9gex3KjoA4=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=Nprt+jk2fsNBv9P8C6ujEKk/SDmb0altjc3ggxwUU+j9/PSVptv15zkI8OpKPss6Iy /TQDYp20KElVNykJMN8RbOXKGjLj5IzoPFx+qFpP4BxKpDUSscoebRsUtXVhTzVmkxbc pxM+M+6p7yxBEyOU8XKUyFjbJUrjCNIg+me5h/qrgsJXTp/YKXLAMQYt5yHVEQIrtJQZ SxP6GWSgSbmH7POms5QAGqoNx9RJ3HSgFk2bUiJxsatYdnY7zyTUAL/lh4tHf/OYdqFp oU754i8Hydgm+FfQYEUpME4yLmyOrBUpjSAhoAreCYUFAbsG/IM/yQengYhChufLPFp7 I01A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="l/7Zckfm"; 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 d75a77b69052e-44651485f23si98360581cf.276.2024.07.02.02.28.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 02:28:19 -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="l/7Zckfm"; 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 1sOZlY-0007Iz-2j; Tue, 02 Jul 2024 05:25:36 -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 1sOZlV-0007Gp-P0 for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:25: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 1sOZlR-0000Kh-Ip for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:25:33 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-42562a984d3so27643685e9.3 for ; Tue, 02 Jul 2024 02:25:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719912326; x=1720517126; 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=01K5Fpbyc/Wo8G4gat2aNkWhP6GApv43W9gex3KjoA4=; b=l/7ZckfmQuOxDaDpadrInrH27qXXzF7C0GsJ/Kw7hCtQ6JigmKQkxIOKE00kP8N7rU z+oNwLaqaMSAuNsYgWMRb7ysphIKUgybhrAZZD3gpO6vVtAy6JMiWJNt1U4B0nzbR2nu kU2L55MvVgbrODAnyXOqLYPrBdAr7TCI2FMJNeZdoOgx5aJdmEGDLSecvhiUlqypS2vD vpzlEJS0UrpApAwks8dcDmL89x8N+kDnz8338AaC+w3z5X8XTPxufF0fa69mlv+zOclM hUUqRitfcy8rbYfrpSwhB0JLR+WyKDuSDvVUrsNH2YfAt8iH17vHRtZb5kx/W07bBvCY GYVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719912326; x=1720517126; 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=01K5Fpbyc/Wo8G4gat2aNkWhP6GApv43W9gex3KjoA4=; b=gwIWL4xvcwyP0vTp/u4nbLrigfi3TXJ7JKytX+8Sg5Xfo3AnM5hyy+ovcQ7op4/XHx gnv/ERYmwpQGH4/Ynz1LNJJY9/tP9kWGw/hetmaUzPLPA2SoWJzU9PnZgIYLDJYHm8zI iE3k9Szvdjv6wvEnkq9XFss765NCzWMzjc47ZKzGrfgFaxyXwX8ciEuuzmg7pRxbbVfO e3eJo1vXfblxGFnZNSnJBOZgT1/zfs+Qgq6hyoGxj9bFowy5u/S6MFPpd+v2usCk+NH6 lOgVLZzcEy3vRtoAE1OIE6HXRcJ2L60/cstBh5MUM2/RLuQmaiyBA2dljGczNfm4O2D+ wSBA== X-Gm-Message-State: AOJu0YzrCg3JAHHX8op5uqgfGpn6WtuwPahYcPsYQIpIYdmWmiNAWEBP k6y5M5tmCukNqEx15rGRowcNveZTrvy08Fmqv5otRFZOA1oBaqMnFh9/e8Nem3vBkgA0nX0aphX g X-Received: by 2002:a05:6000:2c5:b0:365:32e0:f757 with SMTP id ffacd0b85a97d-367757214bdmr4490900f8f.50.1719912325832; Tue, 02 Jul 2024 02:25:25 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.58]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675f9dfbdbsm12298117f8f.103.2024.07.02.02.25.24 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jul 2024 02:25:25 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 46/67] hw/sd/sdcard: Add sd_cmd_STOP_TRANSMISSION handler (CMD12) Date: Tue, 2 Jul 2024 11:20:29 +0200 Message-ID: <20240702092051.45754-47-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240702092051.45754-1-philmd@linaro.org> References: <20240702092051.45754-1-philmd@linaro.org> MIME-Version: 1.0 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=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é Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Message-Id: <20240628070216.92609-53-philmd@linaro.org> --- 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 49fc79cf8a..0a554d30a2 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -237,7 +237,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] = { - [12] = "STOP_TRANSMISSION", [13] = "SEND_STATUS", + [13] = "SEND_STATUS", [15] = "GO_INACTIVE_STATE", [16] = "SET_BLOCKLEN", [17] = "READ_SINGLE_BLOCK", [18] = "READ_MULTIPLE_BLOCK", @@ -1352,6 +1352,23 @@ static sd_rsp_type_t sd_cmd_SEND_CID(SDState *sd, SDRequest req) return sd_req_rca_same(sd, req) ? sd_r2_i : sd_r0; } +/* CMD12 */ +static sd_rsp_type_t sd_cmd_STOP_TRANSMISSION(SDState *sd, SDRequest req) +{ + switch (sd->state) { + case sd_sendingdata_state: + sd->state = sd_transfer_state; + return sd_r1b; + case sd_receivingdata_state: + sd->state = sd_programming_state; + /* Bzzzzzzztt .... Operation complete. */ + sd->state = 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) { @@ -1418,23 +1435,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) switch (req.cmd) { /* Basic commands (Class 0 and Class 1) */ - case 12: /* CMD12: STOP_TRANSMISSION */ - switch (sd->state) { - case sd_sendingdata_state: - sd->state = sd_transfer_state; - return sd_r1b; - - case sd_receivingdata_state: - sd->state = sd_programming_state; - /* Bzzzzzzztt .... Operation complete. */ - sd->state = sd_transfer_state; - return sd_r1b; - - default: - break; - } - break; - case 13: /* CMD13: SEND_STATUS */ rca = sd_req_get_rca(sd, req); if (sd->mode != sd_data_transfer_mode) { @@ -2280,6 +2280,7 @@ static const SDProto sd_proto_spi = { [8] = {0, sd_spi, "SEND_IF_COND", sd_cmd_SEND_IF_COND}, [9] = {0, sd_spi, "SEND_CSD", spi_cmd_SEND_CSD}, [10] = {0, sd_spi, "SEND_CID", spi_cmd_SEND_CID}, + [12] = {0, sd_spi, "STOP_TRANSMISSION", sd_cmd_STOP_TRANSMISSION}, [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}, @@ -2308,6 +2309,7 @@ static const SDProto sd_proto_sd = { [9] = {0, sd_ac, "SEND_CSD", sd_cmd_SEND_CSD}, [10] = {0, sd_ac, "SEND_CID", sd_cmd_SEND_CID}, [11] = {0, sd_ac, "VOLTAGE_SWITCH", sd_cmd_optional}, + [12] = {0, sd_ac, "STOP_TRANSMISSION", sd_cmd_STOP_TRANSMISSION}, [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},