From patchwork Fri Jun 28 07:01:23 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: 808186 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp223746wrr; Fri, 28 Jun 2024 00:09:55 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWB1qqM2bEVggxbp9xsmdV/QCzWZ1wrQEMfgTuYI49TSzLYcLZO03KX5Drmm3e4+vHffZJVPOTR5jDGvx8HalcS X-Google-Smtp-Source: AGHT+IFH3hhiSMlspV5PQPN8FwRJP3Why8D5xnaVcUH0uaZ8UySxmDBSLNfapxy+Yi9in9NqtgEh X-Received: by 2002:a05:622a:1314:b0:446:43e1:ae49 with SMTP id d75a77b69052e-44643e1b2e9mr38756401cf.57.1719558595140; Fri, 28 Jun 2024 00:09:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719558595; cv=none; d=google.com; s=arc-20160816; b=sXiyqBJTT3+V3cWfm5NOgqkJpqk7KB0FqkqhNqyEsPjBh73i219C2fuMkxKicY58b3 3DceLsAV2qLlZlzvB5r60P4s8HoM3BQDrbZEX+jLryBc0ac3IMyTvyeKdHXzTsog2Ttt ReAy/V1ekr9P9nX4tNIxWdNGlxR1yt8dsJWLR2uFCmIgcEKgM25IKbkdHf5u1RkDm29j r44otldYIlTWP7WVCZqlqiSD9oMm+pRApT1DJRDAc4pcUVMhpnTYuUIr6EL9HugOZRGh w2WMGgFLXTQgG3uYQPuayYyGg3+lcCa8KRL2ZRHqyIc75Mc4+AGuYQ6G81ViF6jiaKum u8dQ== 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=slgYteJmLjr8pI8aCW+CqOWuh6a3YgyVMIwY4xDIlZ4=; fh=Vqz0ILX7NeXJwCG5xiS+Wtk94IhOmAmLtOfN3kRbil4=; b=TJ+xfdoJb+bS08oBHZ13b7KhrNEN4rd+Nf75C0BcuYZxgRMTVHzqFNpvpLwSU1E7Ei Gj/F2Z6lgmRHxVD4FXW0yL17xsX3Ax+dur+i/dzb0g1y7G18NK/mDcQJeEcz48j01EM4 LjOGXdQriR7QIrWwhA336u9Y7x9FsdVl/iU5/WVrNsc+dL0/CKnHzwtOKp01/HPabhOC Y640kZBSvdN3PpbMWLlLXfqxm/hDculGJy+PWcSI67+j7rBiy/ZfQpdLcHkVrCDjpuTx FS+mrFn8W235Y1AbhRZjJCEUCJ8ezHS/WlGm4z3boyFYg3JqSfsrkfl7i6V7QOEbnBXF ah7w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=S23vbEg+; 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-446515eff4asi12789051cf.798.2024.06.28.00.09.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Jun 2024 00:09:55 -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=S23vbEg+; 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 1sN5hA-0005b2-OQ; Fri, 28 Jun 2024 03:06:56 -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 1sN5h9-0005Rn-Jr for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:06:55 -0400 Received: from mail-lf1-x132.google.com ([2a00:1450:4864:20::132]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5h7-0003LJ-MM for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:06:55 -0400 Received: by mail-lf1-x132.google.com with SMTP id 2adb3069b0e04-52cd628f21cso267719e87.3 for ; Fri, 28 Jun 2024 00:06:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558411; x=1720163211; 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=slgYteJmLjr8pI8aCW+CqOWuh6a3YgyVMIwY4xDIlZ4=; b=S23vbEg+XdRW0wj99fkHeskBPIiq98fmQTR1eJRcg3kakmUIxWTqdY/KBa9VoRb2tJ NlbepcIR+VNg72+9S+5ORWetZAOxLg4clvWFc0NZ7bQ9YJy8TrAhH+RW6UhYoxHqelke MnCEdV3lFWqoocYEReUf78wWq+Wvs8Qk0EbwFBZGSkUz9uTAUr3XqbAifc7HW2NVbVAW xA5CEvfAbRHnEMaVuPlw0E4VbcCgYlPP4C1KXu+osFTbVngjzIk6o/SgIQFspr2eN4pd LORd8e0F4md4NWkqbDCwGOKokm58PVwF/ZWlFzVRNMTYWcWcjTDZy/NFarK44UWSTXWP H25g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558411; x=1720163211; 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=slgYteJmLjr8pI8aCW+CqOWuh6a3YgyVMIwY4xDIlZ4=; b=RQh4+tpY7CMgg2ZLAfkgKQQPLex1WlD9DvsN1n5XIB0ZrFZcLRgH8DPFG7275AHEA0 DWXlwMz/ncPhqJoj2rEKMQvmzjNgqYt9OWGpWc3kHVQ5ockrBh/1sfn6BWBQpa2uzDYr c+5PAiAPWeuNUFuzqWIZfRmk98Rklv6cFuD6tk5c+ZJG08IClzcWvpxtAEfsdLKgqgKE d3sKZ0OmsgepGN0Os/OmgLw2UWtucwZDdK2XE26L4OQqLU0Z+E6U44RUsEATSS9X6N0v xes4ppQCHX6Y3epBece4fAqspAWO9sb5HsV92OXXhVglUevTAGaovNJmilfvFayIoBcT 5kyg== X-Gm-Message-State: AOJu0YxBid5tzw8UpCq6v0/x0lQwbJgbeQfeG3CnW0rvjsHMwvVuaTdo fk8vS1jB6Cd/tRTpbptY0DpWbKMn+58U+lCJrQWDJNB0ECp144ZFSvSM/gt8BCFI18P7SGCS8GD h6PM= X-Received: by 2002:ac2:4437:0:b0:52c:c9d1:ad32 with SMTP id 2adb3069b0e04-52ce1835a80mr10135394e87.22.1719558411281; Fri, 28 Jun 2024 00:06:51 -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-4256b09890dsm21401375e9.36.2024.06.28.00.06.50 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:06:50 -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 47/98] hw/sd/sdcard: Add sd_cmd_SWITCH_FUNCTION handler (CMD6) Date: Fri, 28 Jun 2024 09:01:23 +0200 Message-ID: <20240628070216.92609-48-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::132; envelope-from=philmd@linaro.org; helo=mail-lf1-x132.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 From: Philippe Mathieu-Daudé Signed-off-by: Philippe Mathieu-Daudé Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- 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] = { - [6] = "SWITCH_FUNC", [7] = "SELECT/DESELECT_CARD", + [7] = "SELECT/DESELECT_CARD", [8] = "SEND_IF_COND", [9] = "SEND_CSD", [10] = "SEND_CID", [12] = "STOP_TRANSMISSION", [13] = "SEND_STATUS", @@ -1244,6 +1244,20 @@ static sd_rsp_type_t sd_cmd_SEND_RELATIVE_ADDR(SDState *sd, SDRequest req) } } +/* CMD6 */ +static sd_rsp_type_t sd_cmd_SWITCH_FUNCTION(SDState *sd, SDRequest req) +{ + if (sd->mode != sd_data_transfer_mode) { + return sd_invalid_mode_for_cmd(sd, req); + } + if (sd->state != 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) switch (req.cmd) { /* Basic commands (Class 0 and Class 1) */ - case 6: /* CMD6: SWITCH_FUNCTION */ - if (sd->mode != sd_data_transfer_mode) { - return sd_invalid_mode_for_cmd(sd, req); - } - if (sd->state != 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 = sd_req_get_rca(sd, req); switch (sd->state) { @@ -2266,6 +2269,7 @@ static const SDProto sd_proto_spi = { [0] = {0, sd_spi, "GO_IDLE_STATE", sd_cmd_GO_IDLE_STATE}, [1] = {0, sd_spi, "SEND_OP_COND", spi_cmd_SEND_OP_COND}, [5] = {9, sd_spi, "IO_SEND_OP_COND", sd_cmd_optional}, + [6] = {10, sd_spi, "SWITCH_FUNCTION", sd_cmd_SWITCH_FUNCTION}, [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}, @@ -2288,6 +2292,7 @@ static const SDProto sd_proto_sd = { [3] = {0, sd_bcr, "SEND_RELATIVE_ADDR", sd_cmd_SEND_RELATIVE_ADDR}, [4] = {0, sd_bc, "SEND_DSR", sd_cmd_unimplemented}, [5] = {9, sd_bc, "IO_SEND_OP_COND", sd_cmd_optional}, + [6] = {10, sd_adtc, "SWITCH_FUNCTION", sd_cmd_SWITCH_FUNCTION}, [11] = {0, sd_ac, "VOLTAGE_SWITCH", sd_cmd_optional}, [19] = {2, sd_adtc, "SEND_TUNING_BLOCK", sd_cmd_SEND_TUNING_BLOCK}, [20] = {2, sd_ac, "SPEED_CLASS_CONTROL", sd_cmd_optional},