From patchwork Tue Jul 2 09:20:24 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: 809067 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp117343wru; Tue, 2 Jul 2024 02:25:45 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWldg6ZUSIuDdqxhrG4OjPO0VKyr5Pgz6ux0cWFlGrokVnAPw/HH0Gea53Y9ZbbchJQBIYOUxL7bpERvHNXCiva X-Google-Smtp-Source: AGHT+IHLBSiFq2qRKaCL5aKhpVrYjI3By0Dp2QOXp+EyZM4bh3y6rkXLmLwMFzt31NGi5R4Z+S1+ X-Received: by 2002:a05:620a:13f7:b0:79d:6169:7ab9 with SMTP id af79cd13be357-79d7babf63dmr1047240285a.68.1719912345139; Tue, 02 Jul 2024 02:25:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719912345; cv=none; d=google.com; s=arc-20160816; b=py9R1lYSSkt8KvWi/w0ipdqyjiWCJ1n3ZFRD1tgjiy9c95vjwG5WO9afKfVp4PAzo0 yXH6DLTAldteY2q8koTINj7cx9OFY9LtXXF7rQZ9V5YazpGB7rnxB3tIfKXHPv95uKj4 IVTilFwZfRqJnxSYD+U5qy87Is8agp6Wdd6GuoKlaGDrPudRjDF21BOy2ede3Nbcp5qz qWsiHGXnDI5/kuxMSF/577Ng3Mt95+YsufkVW1gn5Yf4McV/pDLGWa0iU9+kNqNpo4dK EEKP6RUjnEzHMyMsHnqe/P4X4Fyv/QgGTbpK2+IHCx3QMkOQuDSItV+qSqzJlfI62dE+ tJeQ== 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=2LarMpzFABrHElvj3cOvSN3U3cpCJlLI7z8esfggSjk=; fh=SWrD6ZzKChsLNd0MI2/W9aN13/YqYpoy69YA//3JWDk=; b=wHtcTHUX0jkXYvOJUWX1rLLkwMH5uMV3K7DYepFMMB+6iC3L+vhjK56C45vEKoaQgf 2+VH9hSpkFbNgP4Hu9/UoGZXD8YFz+TvSR2Wpg1hDpajIGeBp7QrP0bfbtszR4eZmjpx 93t9k7+jMDfK+HvF1kBiSXm//Sra959pfpgsNe0yx76YPm0+zFLBpAalrZB+RVBaUN03 VpKgOgejn3t6+znFSeVlETzEYQefMUFRO9x1qvUVSrNRA4xZ9frbU4ZYHrP6DkVJ3BBh evjFiN9Q/Q6gjj4Mt6i8Gs04PDEIAnxcM5DJxYAzO/XnKtZwZvmGMUIcpSONncZmZAc4 B2rw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OrGmEDNd; 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-79d6930891esi974728885a.419.2024.07.02.02.25.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 02:25:45 -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=OrGmEDNd; 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 1sOZl7-0004X1-2U; Tue, 02 Jul 2024 05:25:09 -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 1sOZky-0004QZ-7h for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:25:02 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sOZkw-0000Dj-Do for qemu-devel@nongnu.org; Tue, 02 Jul 2024 05:24:59 -0400 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-42574064b16so24385845e9.2 for ; Tue, 02 Jul 2024 02:24:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719912297; x=1720517097; 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=2LarMpzFABrHElvj3cOvSN3U3cpCJlLI7z8esfggSjk=; b=OrGmEDNd822MH6A7DGmq8OKRX75lhOREqiRvseth7JjbMsaN6dXhEhcJKqEnxUPHPt HLURdfR1fFdmPSVVcgYgLdGXmljuJcRcQD3Emi+WGooCDBMrl0LSKANG3+ZWMbl7PxFA COksc+ly9ZswI5zNSPBpb015tUxf1EXA+EmCeLPr8n9Dg8IomEUCrKYsrufLwuJ4Aar+ 70R+zr68ym9t+kv1ghf0nJ9/lW/xK1SPBjaRB7bLkSFvaO7nlVQieaekpa35rO7LWGqa /XbvrcL+clCqbbf079NLt9WGogu4gmwj66xgJMQAMQKmm78kY6txpvCGIc9lh61mb+ph p97w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719912297; x=1720517097; 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=2LarMpzFABrHElvj3cOvSN3U3cpCJlLI7z8esfggSjk=; b=nVcsVzqaFudC7Auimu2ZQnYa6Fj5ciMrwcBOUATIFm4zvNGfE4/4ZvtHefIdMesCol ZL4MOn/K6R8FE6r6s5X9P1nHQuLx2Y3SRGWFRoKYmw0X/zmJnGAvCfh3Ea8GiWbo7yzd eZM5IiJEi9L/GAbv0eAsb6YfTeLepXfINS453NAGSoapDsmIeTgWXlX1e8/7HJYzVx59 FqiIZW54hfohxCbPpdQj+ZUWsajeZu9CemgRbRAzRSM1xyH8Ydlr6CzClGfcrzt6e25c gH/kX79qzy7fpFHmVfcWFO6klK43KYn9LbdRz+8xsp0Dxi1Si03KyKRxo654b1BwzzcY +DUw== X-Gm-Message-State: AOJu0YzGX9e4fP9oJ88O/H3HIwM6iglmTRgRH2sNaoQv4YS0xRGWGFE5 QyhJE10WfGekbQKeVXIC0yL3/WQFXbxuDbF2/cvD14YSHhrEQhTygHohOu3depVm4kaFIc9quip g X-Received: by 2002:a05:600c:4814:b0:425:7693:3a38 with SMTP id 5b1f17b1804b1-4257a074b37mr57811185e9.36.1719912296856; Tue, 02 Jul 2024 02:24:56 -0700 (PDT) Received: from m1x-phil.lan ([176.187.209.58]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4256af59732sm190276995e9.11.2024.07.02.02.24.55 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jul 2024 02:24:56 -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?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C=C3=A9?= =?utf-8?q?dric_Le_Goater?= Subject: [PULL 41/67] hw/sd/sdcard: Add sd_cmd_SWITCH_FUNCTION handler (CMD6) Date: Tue, 2 Jul 2024 11:20:24 +0200 Message-ID: <20240702092051.45754-42-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::330; envelope-from=philmd@linaro.org; helo=mail-wm1-x330.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é Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Message-Id: <20240628070216.92609-48-philmd@linaro.org> --- 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 54b9ec72e4..5aa63f732f 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] = { - [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", @@ -1236,6 +1236,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) { @@ -1302,17 +1316,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) { @@ -2268,6 +2271,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}, @@ -2290,6 +2294,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},