From patchwork Thu Jun 27 16:43:31 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: 807863 Delivered-To: patch@linaro.org Received: by 2002:adf:e842:0:b0:362:4979:7f74 with SMTP id d2csp899147wrn; Thu, 27 Jun 2024 09:45:36 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXQLxBBd2ayk6U/9NPOPyLh8cCWfUT9XwWkjwQn4PlINGZNE+zDfn5T0KK5uTem379a4I1ojaItZ8Pu4i+foymd X-Google-Smtp-Source: AGHT+IEv51NyPrRDyCEUYWxh2ZEpeBThmL3E4/JT88QzEk3lWGBLqxrzRGKvtbiWKTnCOSTcLC+N X-Received: by 2002:a67:e257:0:b0:48f:40be:3a9e with SMTP id ada2fe7eead31-48f52b52b3cmr12818851137.21.1719506736514; Thu, 27 Jun 2024 09:45:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719506736; cv=none; d=google.com; s=arc-20160816; b=LiT2Qu4I8FKrjnhOEJrr5NP5dFX16uet8bHBny2R+SjCaO9xU72qH/NSiWDshV6HCM s3JQNNXqHhA1msh5uPxALsFdyAFcnqZER2Ga9Jxib5KR4Alm82O9E1j53/qnY9Dz6W2T jmywonMkU7Hyqjnmli6YoDcwyYuVuPY6WlM6swA2BhrprO0Wf0/G9bq+3KnbelBAkGzd wT3PA0NGVn1aV7XkwVYdQ2lG/ZFfk9/Psr49cGQ7xHG5MAe5yqWsIuwqEToL3AqxTzn3 vqDlAiAkGSLi0YF4PDF398kCA+AgiU7KcfMLYW4/XncLdEunz/yMe8YgWrn7wN3uLVuP ggBg== 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=wED9lVuSIJVna4+aCIAwx+9S/4ApkNiJ+n4u5rDB9Rw=; fh=v4x9Oqm5dSIIGNwhX3iTRsusFrFNP2dDaR6uZLPgHBY=; b=MNN3bdBmBlQ6GgV7zOCvgm1fU+hlJsqhUfqK3lD/gxIai9VoYboRuo1D7gFt73JrZH z+txEosP4rHpT32tEp/BMxSw+EAAF7Sl+XYzeaUU3DUCxs4767+02OnrIDviTq0OsA/0 tafRRk3IkCG/+XzVui3ZlfiRQLROF+PhcWf7nuuudhixoecCy/mCvstGtxbGoTOSzKMT XKsvnYCjT6j80nhade9DKm/VBwu5C6mxyw8MwuSmzCpO3i/KOw9VfS/Qe15amWTFQoci 1wQ5bS6vJbppcdZVn5oCgslL+j+wR3XdZ5h9PzkE99bSvJmRtcNECPejzUl2F6qDUCNr DDtQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wmXIVJpN; 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 ada2fe7eead31-48f8e450d7csi321554137.37.2024.06.27.09.45.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 27 Jun 2024 09:45:36 -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=wmXIVJpN; 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 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-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?P?= =?utf-8?q?hilippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= , 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Philippe Mathieu-Daudé --- 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] = { - [15] = "GO_INACTIVE_STATE", [16] = "SET_BLOCKLEN", [17] = "READ_SINGLE_BLOCK", [18] = "READ_MULTIPLE_BLOCK", [21] = "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; } +/* CMD15 */ +static sd_rsp_type_t sd_cmd_GO_INACTIVE_STATE(SDState *sd, SDRequest req) +{ + if (sd->mode != 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 = 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) } switch (req.cmd) { - /* Basic commands (Class 0 and Class 1) */ - case 15: /* CMD15: GO_INACTIVE_STATE */ - if (sd->mode != sd_data_transfer_mode) { - return sd_invalid_mode_for_cmd(sd, req); - } - rca = sd_req_get_rca(sd, req); - if (sd->rca == rca) { - sd->state = 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 = { [11] = {0, sd_ac, "VOLTAGE_SWITCH", sd_cmd_optional}, [12] = {0, sd_ac, "STOP_TRANSMISSION", sd_cmd_STOP_TRANSMISSION}, [13] = {0, sd_ac, "SEND_STATUS", sd_cmd_SEND_STATUS}, + [15] = {0, sd_ac, "GO_INACTIVE_STATE", sd_cmd_GO_INACTIVE_STATE}, [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},