From nobody Sun Dec 29 01:23:55 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1719558756; cv=none; d=zohomail.com; s=zohoarc; b=MstAIk7zrurAOvS0wuNSCeDSyujqZsBCwFfX5tGF0Yie+JUKmVJL8mpyDsE59To37PgicgnTVksECL5O67vP4XMnPQ3kKUYpM0rmtemQ4N7TsR4gjhfBhPUsLPYqNXhXcSOCucGG2xaxLf5BzotFGGpunurf/wlZHa1tCT/Qr04= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719558756; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=bHvyGuDRbuJRmw1vnphLPFr0BQjrkrSSL7KeWPzCQwM=; b=Q5WVkgVbaEf0OEGvJikR09ka/yGZmFYIVVURWIssrvEBFawYc5sJwG0JTaNrkJb2FoZVh2zyeqR5C5l3g4jZ+sacq1CKtwvfRz3uw2wAJjn1Qh4S0s/AyVtD64CXjvrDuhTp9Y9KT/u1Sbw0fDw3JVuiHH1iqAL3QnkPg3alwr0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1719558756740764.9419171076883; Fri, 28 Jun 2024 00:12:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sN5gH-0000Qo-7h; Fri, 28 Jun 2024 03:06:01 -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 1sN5gF-0000AX-Nk for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:05:59 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN5gD-0003DQ-AN for qemu-devel@nongnu.org; Fri, 28 Jun 2024 03:05:59 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-4248ff53f04so2334915e9.0 for ; Fri, 28 Jun 2024 00:05:56 -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-4256b0c18cfsm21369195e9.45.2024.06.28.00.05.54 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 28 Jun 2024 00:05:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719558355; x=1720163155; 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=bHvyGuDRbuJRmw1vnphLPFr0BQjrkrSSL7KeWPzCQwM=; b=hkQrUBLomPLqznOG6RnPnRuXFYEfb00ulmd7fw49TpFaOy2Mmm4npfqJu92TcITui7 +5WV10c18QlXekQ79c6UcqZEIcUdSBRXKC8kJnvNruO+nWxqQg6E559Ztk6C1i9nqNTY gmiOrGyO7H9KXe38swl5QmxAwyDsF31Y99P9IfP+wMCeVy+JmXKOQKYFUxRx7GJr16Ia pkruTyrv1sQN7fiXXcjw1J7CfpuHv92ihaupYz1Vuji8/GLjBnmP0uWRbMF5Fi3w5Wrz R8YNwsJQPJu/QpxRH56xUmuRcr6TTG7JqInk1i9nAjg3C/p0kuMjti2yYsdLuISXAESN 2HLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719558355; x=1720163155; 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=bHvyGuDRbuJRmw1vnphLPFr0BQjrkrSSL7KeWPzCQwM=; b=UJKQazjExV6ohWKH2eV678E09SyxcsY9OWCaU98GP0MjTS/WuP0kzbYLRJFMBt+Kz6 7+TRiYiGDfE1QQdtjuviPiF/6fxP/x/1NFvVeDoTFLl2S2mdgItx5HmRHfoB4guaUwdh mkSGx1bq3XzFUFwSbUmKNXDLeCvVfgzpmKMv+GS8semt1JStqp23v5hQ4jdMGXEfciUy /mXZv6XoTpwM0gGFoS+VVM4Peyga+1frIx9pIlIYxAZybRdyCGs58DlyYQIbvS821qQ8 nwj38iEL2IIU4x3jx9E8qLGPL4YfXj9mU0mubIU+wpbk35j4FRyRZnzW7ix39x5Qtxbj C9FQ== X-Gm-Message-State: AOJu0YyaBTouHFH0JgpQy9fGfLMcvAYMLp6G8aVwX7Iy4HBSEJ9clBNP /dwOaPzJqCZp7wBoyJubYiCOIURojSzeHZ0GmMeG8pVO2808MaxJpsB2at12WTBexaFP3a6HNjU Qdyw= X-Google-Smtp-Source: AGHT+IF/PY/I6z2pflqpmNY7jTVACHCw6tN9mKWcariEjyNxZoMrN38feX9csfgZacGsRtVF5GBhFg== X-Received: by 2002:a05:600c:3b1d:b0:425:6dce:8c54 with SMTP id 5b1f17b1804b1-4256dce8cd3mr4395505e9.33.1719558355577; Fri, 28 Jun 2024 00:05:55 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH v42 36/98] hw/sd/sdcard: Move sd_[a]cmd_name() methods to sd.c Date: Fri, 28 Jun 2024 09:01:12 +0200 Message-ID: <20240628070216.92609-37-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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=philmd@linaro.org; helo=mail-wm1-x32d.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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1719558759156100024 Merge sdmmc-internal.c into sd.c by moving sd_cmd_name() and sd_acmd_name() and updating meson.build. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: C=C3=A9dric Le Goater --- hw/sd/sdmmc-internal.h | 26 --------------- hw/sd/sd.c | 62 ++++++++++++++++++++++++++++++++++++ hw/sd/sdmmc-internal.c | 72 ------------------------------------------ hw/sd/meson.build | 2 +- 4 files changed, 63 insertions(+), 99 deletions(-) delete mode 100644 hw/sd/sdmmc-internal.c diff --git a/hw/sd/sdmmc-internal.h b/hw/sd/sdmmc-internal.h index 306ffa7f53..20d85aea6d 100644 --- a/hw/sd/sdmmc-internal.h +++ b/hw/sd/sdmmc-internal.h @@ -108,30 +108,4 @@ #define EXT_CSD_PART_CONFIG_EN_BOOT0 (0x1 << 3) #define EXT_CSD_PART_CONFIG_EN_USER (0x7 << 3) =20 -#define SDMMC_CMD_MAX 64 - -/** - * sd_cmd_name: - * @cmd: A SD "normal" command, up to SDMMC_CMD_MAX. - * - * Returns a human-readable name describing the command. - * The return value is always a static string which does not need - * to be freed after use. - * - * Returns: The command name of @cmd or "UNKNOWN_CMD". - */ -const char *sd_cmd_name(uint8_t cmd); - -/** - * sd_acmd_name: - * @cmd: A SD "Application-Specific" command, up to SDMMC_CMD_MAX. - * - * Returns a human-readable name describing the application command. - * The return value is always a static string which does not need - * to be freed after use. - * - * Returns: The application command name of @cmd or "UNKNOWN_ACMD". - */ -const char *sd_acmd_name(uint8_t cmd); - #endif diff --git a/hw/sd/sd.c b/hw/sd/sd.c index f9708064d0..93a4a4e1b4 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -88,6 +88,8 @@ enum SDCardStates { sd_disconnect_state =3D 8, }; =20 +#define SDMMC_CMD_MAX 64 + typedef sd_rsp_type_t (*sd_cmd_handler)(SDState *sd, SDRequest req); =20 typedef struct SDProto { @@ -231,6 +233,66 @@ static const char *sd_response_name(sd_rsp_type_t rsp) return response_name[rsp]; } =20 +static const char *sd_cmd_name(uint8_t cmd) +{ + static const char *cmd_abbrev[SDMMC_CMD_MAX] =3D { + [0] =3D "GO_IDLE_STATE", [1] =3D "SEND_OP_COND", + [2] =3D "ALL_SEND_CID", [3] =3D "SEND_RELATIVE_A= DDR", + [4] =3D "SET_DSR", [5] =3D "IO_SEND_OP_COND= ", + [6] =3D "SWITCH_FUNC", [7] =3D "SELECT/DESELECT= _CARD", + [8] =3D "SEND_IF_COND", [9] =3D "SEND_CSD", + [10] =3D "SEND_CID", [11] =3D "VOLTAGE_SWITCH", + [12] =3D "STOP_TRANSMISSION", [13] =3D "SEND_STATUS", + [15] =3D "GO_INACTIVE_STATE= ", + [16] =3D "SET_BLOCKLEN", [17] =3D "READ_SINGLE_BLO= CK", + [18] =3D "READ_MULTIPLE_BLOCK", [19] =3D "SEND_TUNING_BLO= CK", + [20] =3D "SPEED_CLASS_CONTROL", [21] =3D "DPS_spec", + [23] =3D "SET_BLOCK_COUNT", + [24] =3D "WRITE_BLOCK", [25] =3D "WRITE_MULTIPLE_= BLOCK", + [26] =3D "MANUF_RSVD", [27] =3D "PROGRAM_CSD", + [28] =3D "SET_WRITE_PROT", [29] =3D "CLR_WRITE_PROT", + [30] =3D "SEND_WRITE_PROT", + [32] =3D "ERASE_WR_BLK_START", [33] =3D "ERASE_WR_BLK_EN= D", + [34] =3D "SW_FUNC_RSVD", [35] =3D "SW_FUNC_RSVD", + [36] =3D "SW_FUNC_RSVD", [37] =3D "SW_FUNC_RSVD", + [38] =3D "ERASE", + [40] =3D "DPS_spec", + [42] =3D "LOCK_UNLOCK", [43] =3D "Q_MANAGEMENT", + [44] =3D "Q_TASK_INFO_A", [45] =3D "Q_TASK_INFO_B", + [46] =3D "Q_RD_TASK", [47] =3D "Q_WR_TASK", + [48] =3D "READ_EXTR_SINGLE", [49] =3D "WRITE_EXTR_SING= LE", + [50] =3D "SW_FUNC_RSVD", + [52] =3D "IO_RW_DIRECT", [53] =3D "IO_RW_EXTENDED", + [54] =3D "SDIO_RSVD", [55] =3D "APP_CMD", + [56] =3D "GEN_CMD", [57] =3D "SW_FUNC_RSVD", + [58] =3D "READ_EXTR_MULTI", [59] =3D "WRITE_EXTR_MULT= I", + [60] =3D "MANUF_RSVD", [61] =3D "MANUF_RSVD", + [62] =3D "MANUF_RSVD", [63] =3D "MANUF_RSVD", + }; + return cmd_abbrev[cmd] ? cmd_abbrev[cmd] : "UNKNOWN_CMD"; +} + +static const char *sd_acmd_name(uint8_t cmd) +{ + static const char *acmd_abbrev[SDMMC_CMD_MAX] =3D { + [6] =3D "SET_BUS_WIDTH", + [13] =3D "SD_STATUS", + [14] =3D "DPS_spec", [15] =3D "DPS_spec", + [16] =3D "DPS_spec", + [18] =3D "SECU_spec", + [22] =3D "SEND_NUM_WR_BLOCKS", [23] =3D "SET_WR_BLK_ERASE_C= OUNT", + [41] =3D "SD_SEND_OP_COND", + [42] =3D "SET_CLR_CARD_DETECT", + [51] =3D "SEND_SCR", + [52] =3D "SECU_spec", [53] =3D "SECU_spec", + [54] =3D "SECU_spec", + [56] =3D "SECU_spec", [57] =3D "SECU_spec", + [58] =3D "SECU_spec", [59] =3D "SECU_spec", + }; + + return acmd_abbrev[cmd] ? acmd_abbrev[cmd] : "UNKNOWN_ACMD"; +} + static uint8_t sd_get_dat_lines(SDState *sd) { return sd->enable ? sd->dat_lines : 0; diff --git a/hw/sd/sdmmc-internal.c b/hw/sd/sdmmc-internal.c deleted file mode 100644 index c1d5508ae6..0000000000 --- a/hw/sd/sdmmc-internal.c +++ /dev/null @@ -1,72 +0,0 @@ -/* - * SD/MMC cards common helpers - * - * Copyright (c) 2018 Philippe Mathieu-Daud=C3=A9 - * - * This work is licensed under the terms of the GNU GPL, version 2 or late= r. - * See the COPYING file in the top-level directory. - * SPDX-License-Identifier: GPL-2.0-or-later - */ - -#include "qemu/osdep.h" -#include "sdmmc-internal.h" - -const char *sd_cmd_name(uint8_t cmd) -{ - static const char *cmd_abbrev[SDMMC_CMD_MAX] =3D { - [0] =3D "GO_IDLE_STATE", [1] =3D "SEND_OP_COND", - [2] =3D "ALL_SEND_CID", [3] =3D "SEND_RELATIVE_A= DDR", - [4] =3D "SET_DSR", [5] =3D "IO_SEND_OP_COND= ", - [6] =3D "SWITCH_FUNC", [7] =3D "SELECT/DESELECT= _CARD", - [8] =3D "SEND_IF_COND", [9] =3D "SEND_CSD", - [10] =3D "SEND_CID", [11] =3D "VOLTAGE_SWITCH", - [12] =3D "STOP_TRANSMISSION", [13] =3D "SEND_STATUS", - [15] =3D "GO_INACTIVE_STATE= ", - [16] =3D "SET_BLOCKLEN", [17] =3D "READ_SINGLE_BLO= CK", - [18] =3D "READ_MULTIPLE_BLOCK", [19] =3D "SEND_TUNING_BLO= CK", - [20] =3D "SPEED_CLASS_CONTROL", [21] =3D "DPS_spec", - [23] =3D "SET_BLOCK_COUNT", - [24] =3D "WRITE_BLOCK", [25] =3D "WRITE_MULTIPLE_= BLOCK", - [26] =3D "MANUF_RSVD", [27] =3D "PROGRAM_CSD", - [28] =3D "SET_WRITE_PROT", [29] =3D "CLR_WRITE_PROT", - [30] =3D "SEND_WRITE_PROT", - [32] =3D "ERASE_WR_BLK_START", [33] =3D "ERASE_WR_BLK_EN= D", - [34] =3D "SW_FUNC_RSVD", [35] =3D "SW_FUNC_RSVD", - [36] =3D "SW_FUNC_RSVD", [37] =3D "SW_FUNC_RSVD", - [38] =3D "ERASE", - [40] =3D "DPS_spec", - [42] =3D "LOCK_UNLOCK", [43] =3D "Q_MANAGEMENT", - [44] =3D "Q_TASK_INFO_A", [45] =3D "Q_TASK_INFO_B", - [46] =3D "Q_RD_TASK", [47] =3D "Q_WR_TASK", - [48] =3D "READ_EXTR_SINGLE", [49] =3D "WRITE_EXTR_SING= LE", - [50] =3D "SW_FUNC_RSVD", - [52] =3D "IO_RW_DIRECT", [53] =3D "IO_RW_EXTENDED", - [54] =3D "SDIO_RSVD", [55] =3D "APP_CMD", - [56] =3D "GEN_CMD", [57] =3D "SW_FUNC_RSVD", - [58] =3D "READ_EXTR_MULTI", [59] =3D "WRITE_EXTR_MULT= I", - [60] =3D "MANUF_RSVD", [61] =3D "MANUF_RSVD", - [62] =3D "MANUF_RSVD", [63] =3D "MANUF_RSVD", - }; - return cmd_abbrev[cmd] ? cmd_abbrev[cmd] : "UNKNOWN_CMD"; -} - -const char *sd_acmd_name(uint8_t cmd) -{ - static const char *acmd_abbrev[SDMMC_CMD_MAX] =3D { - [6] =3D "SET_BUS_WIDTH", - [13] =3D "SD_STATUS", - [14] =3D "DPS_spec", [15] =3D "DPS_spec", - [16] =3D "DPS_spec", - [18] =3D "SECU_spec", - [22] =3D "SEND_NUM_WR_BLOCKS", [23] =3D "SET_WR_BLK_ERASE_C= OUNT", - [41] =3D "SD_SEND_OP_COND", - [42] =3D "SET_CLR_CARD_DETECT", - [51] =3D "SEND_SCR", - [52] =3D "SECU_spec", [53] =3D "SECU_spec", - [54] =3D "SECU_spec", - [56] =3D "SECU_spec", [57] =3D "SECU_spec", - [58] =3D "SECU_spec", [59] =3D "SECU_spec", - }; - - return acmd_abbrev[cmd] ? acmd_abbrev[cmd] : "UNKNOWN_ACMD"; -} diff --git a/hw/sd/meson.build b/hw/sd/meson.build index abfac9e461..bbb75af0c9 100644 --- a/hw/sd/meson.build +++ b/hw/sd/meson.build @@ -1,5 +1,5 @@ system_ss.add(when: 'CONFIG_PL181', if_true: files('pl181.c')) -system_ss.add(when: 'CONFIG_SD', if_true: files('sd.c', 'core.c', 'sdmmc-i= nternal.c')) +system_ss.add(when: 'CONFIG_SD', if_true: files('sd.c', 'core.c')) system_ss.add(when: 'CONFIG_SDHCI', if_true: files('sdhci.c')) system_ss.add(when: 'CONFIG_SDHCI_PCI', if_true: files('sdhci-pci.c')) system_ss.add(when: 'CONFIG_SSI_SD', if_true: files('ssi-sd.c')) --=20 2.41.0