From nobody Mon Nov 25 00:20:58 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1719508337; cv=none; d=zohomail.com; s=zohoarc; b=hmxwVL2b8CLmbTlFwgpksSM++KLo+Fv6ApoOF/PoFpgwnWN0VHkrwGOANoMnFo5FGUbaMcKe5MEDn4P6w5uA0NQ0RoXQDjRLdyqyUCmohYp5cwmqfKlcJ45K5b/0sv7oHTUQHlulKYc9RHFpUREvdYaD1+/GqiKT1NvHMYjDfCg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719508337; h=Content-Type:Content-Transfer-Encoding:Cc:Cc: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; bh=DS5w/rOHX5RjJWkmyFPsFftFPu5c4nwaKlj59xhrXaU=; b=A58S7AGYc1XYiffXTi6wFMA9RzS9KmSuGKot4Qy+mspuza+QrgAJoVckkYG+UdP9gL1IihycmW1ohNCfb0AvzhlVh6lhaZJOYdDfcRqtYKZ2NUJZGCocfheesB8OgcVpD0d5UECMB8HrQYXhga7p3W4bOq+bBLp2Yh+qlrSXl10= 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+importer=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 1719508337287488.1565274758502; Thu, 27 Jun 2024 10:12:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMsen-0007F9-3Q; Thu, 27 Jun 2024 13:11:38 -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 1sMsed-0007Cr-Kg for qemu-devel@nongnu.org; Thu, 27 Jun 2024 13:11:28 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMseY-0001pF-EW for qemu-devel@nongnu.org; Thu, 27 Jun 2024 13:11:26 -0400 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-364ff42999eso6367614f8f.3 for ; Thu, 27 Jun 2024 10:11:22 -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 ffacd0b85a97d-3674357c173sm2534594f8f.18.2024.06.27.10.11.15 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 10:11:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719508280; x=1720113080; 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=DS5w/rOHX5RjJWkmyFPsFftFPu5c4nwaKlj59xhrXaU=; b=OLy6oP86eACS3NFEB6NuEPDLQ+Gbw9jYDuzlhXDEQiJonewp2Dzw/xdPOhxiofcFXb J+ii/xMPs/MjiLGrOoSLQemhrZOImMsVkbCL0C4jcd0ixMqmQf/yLL6qfcJQn9oifyYj 8AarjOwAayfLJhCNQ0Lx/1wqiBRro/kwW9uQU0kZpXs5lLl7cK6uv7nFAD83ZOTYlIM1 8JfppXRICM8Z+EXQHSN0gpayNsauu8vd002G5k9jAbzBpCE+1HwxaGhf0QxAKpisEZOu xJOYOIzZo6RfuY8VI1xGNVBj8s4/N4hzGKUdivUHmgBuFIDiDYytF/EG43DVdMOHOsq2 JXrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719508280; x=1720113080; 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=DS5w/rOHX5RjJWkmyFPsFftFPu5c4nwaKlj59xhrXaU=; b=n2cWRHda+U4ol6Q5063uArNZeQdGaBuwWdId7iQB8l1jUZQQ1Tm9i4EqB1E30FNRHe gZ1zUq8mafk6ZJPxNxNLoCd1zZnmHHgJAtj18kR4d/gRqCYGDiiSNzR9LW14b/Zplwao Yb7z/KVB7oHF4AtOYdSH7S5sstpqaWLbm9m0wwYm0m8kPxyVYqIuZ7z8YVUJm9sYGKpl wJcAIOJ0++Jr7NpcmM5lnrrKilGf3Qcsm66thkJZwy18tm7MCL2RZ3REPInm4WdR27KX WCjE2uY5LUWhuPV7OxIsod8XNbZA828rWOB5AaY/acDc1j7GSyjTdQ6dYoKFnUGJgtVm lcoA== X-Gm-Message-State: AOJu0YwFwGNNkstD2phygh2WP01YrliSJds3sh+HGRDLmrsT9C/QKTMZ 9Nx9+KNoJNhr9wyyTF0KmOiR8K44BJoc5Ge0ve8w8nP5Nm2Wz7d3dQGaElRpPxYxIoG34RU3XjD MvVo= X-Google-Smtp-Source: AGHT+IFbJlRK+CniOeFZTveQBOAZD1UFMtdcrQYiz5wcr+jyqnAgVeH49LHe8r4wTuppPsrXTNqhcw== X-Received: by 2002:a5d:6482:0:b0:366:e986:22ef with SMTP id ffacd0b85a97d-366e9862451mr15683222f8f.4.1719508280679; Thu, 27 Jun 2024 10:11:20 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Joel Stanley , Luc Michel , Francisco Iglesias , qemu-block@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Vincent Palatin , Sai Pavan Boddu , Bin Meng , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH 01/19] hw/sd/sdcard: Introduce set_csd/set_cid handlers Date: Thu, 27 Jun 2024 19:10:41 +0200 Message-ID: <20240627171059.84349-2-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627171059.84349-1-philmd@linaro.org> References: <20240627171059.84349-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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::436; envelope-from=philmd@linaro.org; helo=mail-wr1-x436.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, T_SPF_TEMPERROR=0.01 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1719508337728100001 In preparation of introducing eMMC support which have different CSD/CID structures, introduce a pair of handlers in SDCardClass. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/sd/sd.h | 2 ++ hw/sd/sd.c | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/include/hw/sd/sd.h b/include/hw/sd/sd.h index c1a35ab420..0d6d9e452b 100644 --- a/include/hw/sd/sd.h +++ b/include/hw/sd/sd.h @@ -127,6 +127,8 @@ struct SDCardClass { void (*enable)(SDState *sd, bool enable); bool (*get_inserted)(SDState *sd); bool (*get_readonly)(SDState *sd); + void (*set_cid)(SDState *sd); + void (*set_csd)(SDState *sd, uint64_t size); =20 const struct SDProto *proto; }; diff --git a/hw/sd/sd.c b/hw/sd/sd.c index a0da06e017..b0ef252001 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -671,6 +671,7 @@ static inline uint64_t sd_addr_to_wpnum(uint64_t addr) static void sd_reset(DeviceState *dev) { SDState *sd =3D SD_CARD(dev); + SDCardClass *sc =3D SD_CARD_GET_CLASS(sd); uint64_t size; uint64_t sect; =20 @@ -691,8 +692,8 @@ static void sd_reset(DeviceState *dev) sd->size =3D size; sd_set_ocr(sd); sd_set_scr(sd); - sd_set_cid(sd); - sd_set_csd(sd, size); + sc->set_cid(sd); + sc->set_csd(sd, size); sd_set_cardstatus(sd); sd_set_sdstatus(sd); =20 @@ -2472,6 +2473,8 @@ static void sd_class_init(ObjectClass *klass, void *d= ata) sc->enable =3D sd_enable; sc->get_inserted =3D sd_get_inserted; sc->get_readonly =3D sd_get_readonly; + sc->set_cid =3D sd_set_cid; + sc->set_csd =3D sd_set_csd; sc->proto =3D &sd_proto_sd; } =20 --=20 2.41.0 From nobody Mon Nov 25 00:20:58 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1719508352; cv=none; d=zohomail.com; s=zohoarc; b=I20KEj4c8C7RrQJTMZwasbZade3u3cgr2hC1kojDS58pcy/VT25CveS59zRPeIcxlKbIKBRrOAHMESKC807w72X4TY/A3UM/LAhEUWX/QPAzfmT+s3hvHi620Lbi4UZBd99YcPHTAFHGUvvXbcG0eJx08josr6puSOPaeaKqMZI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719508352; h=Content-Type:Content-Transfer-Encoding:Cc:Cc: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; bh=l5dk8XRtaZNYeklBLa17/11yculQIx4J+IHrxLfyvgU=; b=kcjRsag+HTNMygbhX45u8WV56UkiL+pVFXVdK0Wt+lDcmD+HZKH5Dv35IpWZ+aazx++idYVvMcmoNxtKnmM9niWsHCagvRfps99Jtoi5E8KWsI50XL3Tf5ph98ky2dmCVahNzXjmvwocGLhHAqmWUrXnwxVqL1mqWymlV88jMu4= 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+importer=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 1719508352527601.9057108686854; Thu, 27 Jun 2024 10:12:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMsev-0007LX-79; Thu, 27 Jun 2024 13:11:45 -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 1sMsel-0007HQ-Gs for qemu-devel@nongnu.org; Thu, 27 Jun 2024 13:11:38 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMsej-0001qR-9d for qemu-devel@nongnu.org; Thu, 27 Jun 2024 13:11:35 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-424ad289912so17956945e9.2 for ; Thu, 27 Jun 2024 10:11:32 -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-4256b0c0fbesm435835e9.43.2024.06.27.10.11.27 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 10:11:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719508291; x=1720113091; 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=l5dk8XRtaZNYeklBLa17/11yculQIx4J+IHrxLfyvgU=; b=QrwAPP5d927dS7uwysiG4MPvGT4rp3ZsfRiYi0HZu1MTmnip1y8OxfGE98PTXCuyUy Z6JakFiV/AUbYKs0N7ycGGURdy2nZuHutrMote5GiS7J/XKvdZjBkkyzDhIvmR3oilts h0msTtkGPk90uL5nqxbvhzzyEDiZRnWaDWJylPQ1A8UYIMrgPGsjEbF09HccDT0medKX PD7WZJwy4q9qFUzchZLOk6BEdiSbD7eah3vCZPDZymF84VoiwNtuuBgY0bU+Lx9UQvue 3r1XaeqJWpmqK0j6LnD0VeoEFSnSIHGUqvlsM+SxEcR8cds9dKBO4wrpaEw0XaTDwZnJ d+LA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719508291; x=1720113091; 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=l5dk8XRtaZNYeklBLa17/11yculQIx4J+IHrxLfyvgU=; b=iw3EHIPwTtWsNAEe5UYL7eodL/Yfl2fdDdtw+bD6dK0QUu3Ky1eKjrz8rSUQX6qb6Q cncCvNE6wFCxgwX5spP3ZmsR2IQmJMFwnkSfzbGNVYrpCfiTOa1GltHpsD3KAe1F7kWl 9zGVgGK1AlrnTc0KlhakkdocheGfp6cLiXzgpWREAta/RlQj+N3hJIt+fxspwZzEtsUH ioSxeeD47UHam/sJAFHQdd5/56qQFVB1e2qcl9hi45FRz/Z/vj+pBTrbxFRMEMCU4qAk 7vbB7Jb2jRHi+B2Xo1pYKJ2YGIEAvql1qmWCvm5xJyKEKppFUsR/2rxZGVZ15lMXc4oy jpBg== X-Gm-Message-State: AOJu0YxquggJuz1/5iLLX9l5GdXAE0WuCuisE6+KkR+n5TXLXeQXwyvQ /sUIYbAUeLF5P3KTF+zLr9M4oqeuQ/YCE5VCCVJtBT56M/4x/hX9F4hyryeDM+haWphJSivSK4H LPUo= X-Google-Smtp-Source: AGHT+IHX9Yd05LKTMcVfh3Fq9AkCNaj5LApxDee9M1UmPU7Max3APVhYXUZAEISK4mrW36cMpvZCdg== X-Received: by 2002:a05:600c:888:b0:424:a779:b5c1 with SMTP id 5b1f17b1804b1-424a779b687mr48905595e9.20.1719508291578; Thu, 27 Jun 2024 10:11:31 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Joel Stanley , Luc Michel , Francisco Iglesias , qemu-block@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Vincent Palatin , Sai Pavan Boddu , Bin Meng , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH 02/19] hw/sd/sdcard: Cover more SDCardStates Date: Thu, 27 Jun 2024 19:10:42 +0200 Message-ID: <20240627171059.84349-3-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627171059.84349-1-philmd@linaro.org> References: <20240627171059.84349-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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=philmd@linaro.org; helo=mail-wm1-x32c.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1719508353692100003 So far eMMC will only use sd_sleep_state, but all all states specified for completeness. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sd.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index b0ef252001..92ac57a648 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -76,7 +76,9 @@ enum SDCardModes { }; =20 enum SDCardStates { + sd_waitirq_state =3D -2, /* emmc */ sd_inactive_state =3D -1, + sd_idle_state =3D 0, sd_ready_state =3D 1, sd_identification_state =3D 2, @@ -86,6 +88,9 @@ enum SDCardStates { sd_receivingdata_state =3D 6, sd_programming_state =3D 7, sd_disconnect_state =3D 8, + sd_bus_test_state =3D 9, /* emmc */ + sd_sleep_state =3D 10, /* emmc */ + sd_io_state =3D 15 /* sd */ }; =20 #define SDMMC_CMD_MAX 64 @@ -205,13 +210,19 @@ static const char *sd_state_name(enum SDCardStates st= ate) [sd_standby_state] =3D "standby", [sd_transfer_state] =3D "transfer", [sd_sendingdata_state] =3D "sendingdata", + [sd_bus_test_state] =3D "bus-test", [sd_receivingdata_state] =3D "receivingdata", [sd_programming_state] =3D "programming", [sd_disconnect_state] =3D "disconnect", + [sd_sleep_state] =3D "sleep", + [sd_io_state] =3D "i/o" }; if (state =3D=3D sd_inactive_state) { return "inactive"; } + if (state =3D=3D sd_waitirq_state) { + return "wait-irq"; + } assert(state < ARRAY_SIZE(state_name)); return state_name[state]; } --=20 2.41.0 From nobody Mon Nov 25 00:20:58 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1719508337; cv=none; d=zohomail.com; s=zohoarc; b=kBjvVaaGhFwE4hgwN1dMnPvd4zhiBhDTnZAr22NdeovprAqXDkvw/YEg5YvyC2+bsayXDrbOdUS0Cd+ER6XCHpUBvdW+I4KqnoeRvWKVShYblCnUM/FhfL7JPNy+VS46lGHC3f4AHIxWu0W/77zfdkF3h6UGJufskU/Lm/3mv3g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719508337; h=Content-Type:Content-Transfer-Encoding:Cc:Cc: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; bh=dtkOlWWAl+ZO/rW9NaCd8yU+f3fnPw9yKybdzc1seps=; b=URxdtU2vFHXP/TQmqH72HXkmAgHIOvuFiNgIZ9LKgcdUW73u9kI4LCruyW3dEOps6fJNh+vx1TwY+MifNuSoeEWoiZpJPXgRgCK8/AWpdX0JuIS4TRwpsQx93HTVOX1h8hzsgOR3G16pvtnRil4CjiS4JZcyYLIBmYXl/fodPJ0= 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+importer=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 171950833765611.647392406156428; Thu, 27 Jun 2024 10:12:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMsf2-0007Uj-Ro; Thu, 27 Jun 2024 13:11:52 -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 1sMsez-0007Mu-Hv for qemu-devel@nongnu.org; Thu, 27 Jun 2024 13:11:51 -0400 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMsev-00024s-3z for qemu-devel@nongnu.org; Thu, 27 Jun 2024 13:11:47 -0400 Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-3626c29d3f0so4320061f8f.1 for ; Thu, 27 Jun 2024 10:11:43 -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 ffacd0b85a97d-3674357c0f5sm2518803f8f.4.2024.06.27.10.11.38 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 10:11:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719508302; x=1720113102; 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=dtkOlWWAl+ZO/rW9NaCd8yU+f3fnPw9yKybdzc1seps=; b=LFxi6UZTzQPP+HiVBGfYDtJZFI+eUYLjSUBPcPywkbiRyAgXH5YMWjprRMqnQooZz9 ZY3tjGaCRQAy6TTl6TqVW9ECs1n0waIhMamtnhoBx5FABR/G3xiYZuzFJodDh7y2BLZ8 +ZA/qnJ0HC/Vkq0tlCuMM5idLEisR0WvfF2EQ/BIo8dywg+1GcipN/BSufg7/wHCQbOU lzgZzVqGs0RAK/PCW50XECLBpsdm+DeSz7TAImDr3jG1HhSIEkC8b4FSA8TDUGARmZSb 0JDSU1W5fWMlJl81l+yY4B28EzG3cGrO8O1s1KXx8N5WFMSrDFguYqZYHzYr+iOM3Fsq T45g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719508302; x=1720113102; 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=dtkOlWWAl+ZO/rW9NaCd8yU+f3fnPw9yKybdzc1seps=; b=tEzH1Aan8HTBNpZQE3GM2It90qccgO4joFTu7a+ImOWJDIQl2U83oI+sQJjG1pE1SS iHLXXvfdzF0dwtJsdkvqzeA2LMXaaTqbEz3Rp+fPymCV6j6bVcGZ6/GMBqbt3lSkad5c Gy5WnaOh9FjLIxgqRMAcS+RUdKiPza8vnXJeMVFjkadN3F6MuDBYXuusPB4+QMWRk7Vm sGVURVA4T/BMMLptL4lQtmHWoQqdyxUoI9/M3JLswxjM1qPnZVzhle3/Tl/X90YYEBfg +d0thT4h2L/K2D0a4yk+OWo3TfjV7pFrebfHwfwU/tpZfVCLkivH811WwPsm6s9RA+Kl 2t4g== X-Gm-Message-State: AOJu0Ywp9VweRsqfgJPmYGA4Zo/QdMKZjvVYDjgtHqv2ioUVeSdZXcX4 XX9NWgtiARjrQhPRyNMCYdA2eouTeJNRfmnRMrlYzvvu3JIufnMcCgq52Et1DfP0xRAYcvq5fxf vQyA= X-Google-Smtp-Source: AGHT+IGEbc31zb3KBR06wNiyvJHpxUbo/nPUl8YyefpupXii3Nsr6sUeTOAkp80bbqCW2wJTCE7q5g== X-Received: by 2002:a05:6000:4021:b0:364:d2b6:4520 with SMTP id ffacd0b85a97d-366e937af09mr14977181f8f.0.1719508302067; Thu, 27 Jun 2024 10:11:42 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Joel Stanley , Luc Michel , Francisco Iglesias , qemu-block@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Vincent Palatin , Sai Pavan Boddu , Bin Meng , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH 03/19] hw/sd/sdcard: Basis for eMMC support Date: Thu, 27 Jun 2024 19:10:43 +0200 Message-ID: <20240627171059.84349-4-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627171059.84349-1-philmd@linaro.org> References: <20240627171059.84349-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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::432; envelope-from=philmd@linaro.org; helo=mail-wr1-x432.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1719508339674100011 From: C=C3=A9dric Le Goater Signed-off-by: C=C3=A9dric Le Goater Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/sd/sd.h | 3 +++ hw/sd/sd.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/include/hw/sd/sd.h b/include/hw/sd/sd.h index 0d6d9e452b..d35a839f5e 100644 --- a/include/hw/sd/sd.h +++ b/include/hw/sd/sd.h @@ -96,6 +96,9 @@ OBJECT_DECLARE_TYPE(SDState, SDCardClass, SD_CARD) #define TYPE_SD_CARD_SPI "sd-card-spi" DECLARE_INSTANCE_CHECKER(SDState, SD_CARD_SPI, TYPE_SD_CARD_SPI) =20 +#define TYPE_EMMC "emmc" +DECLARE_INSTANCE_CHECKER(SDState, EMMC, TYPE_EMMC) + struct SDCardClass { /*< private >*/ DeviceClass parent_class; diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 92ac57a648..249fad0468 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -2379,6 +2379,13 @@ static const SDProto sd_proto_sd =3D { }, }; =20 +static const SDProto sd_proto_emmc =3D { + /* Only v4.5 is supported */ + .name =3D "eMMC", + .cmd =3D { + }, +}; + static void sd_instance_init(Object *obj) { SDState *sd =3D SD_CARD(obj); @@ -2504,6 +2511,28 @@ static void sd_spi_class_init(ObjectClass *klass, vo= id *data) sc->proto =3D &sd_proto_spi; } =20 +static void emmc_realize(DeviceState *dev, Error **errp) +{ + SDState *sd =3D SD_CARD(dev); + + if (sd->spec_version =3D=3D SD_PHY_SPECv2_00_VERS) { + error_setg(errp, "eMMC can not use spec v2.00"); + return; + } + + sd_realize(dev, errp); +} + +static void emmc_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + SDCardClass *sc =3D SD_CARD_CLASS(klass); + + dc->desc =3D "eMMC"; + dc->realize =3D emmc_realize; + sc->proto =3D &sd_proto_emmc; +} + static const TypeInfo sd_types[] =3D { { .name =3D TYPE_SD_CARD, @@ -2519,6 +2548,11 @@ static const TypeInfo sd_types[] =3D { .parent =3D TYPE_SD_CARD, .class_init =3D sd_spi_class_init, }, + { + .name =3D TYPE_EMMC, + .parent =3D TYPE_SD_CARD, + .class_init =3D emmc_class_init, + }, }; =20 DEFINE_TYPES(sd_types) --=20 2.41.0 From nobody Mon Nov 25 00:20:58 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1719508342; cv=none; d=zohomail.com; s=zohoarc; b=Vchp8Y+IhtTI45E+8p3GdtSFvWjOiUQUmyT/P4nFET9SLTKgx4s9rXLCxDE/U9g1keqnZMDgeqt9IDgN8+8NrE/bo07LdozfFArAV6kyx5VXLoXp0D6QBiL8avhcJeFd81aQENLzpZU5B1hMta7J7J4sIdo2qyIaLDSd0sZwHp4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719508342; h=Content-Type:Content-Transfer-Encoding:Cc:Cc: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; bh=0++Ogxou44hWy9HUie+kN/Bmub/+XHfRbLoibWWU/Qg=; b=LMSZP2rsKTg798L0KevobwdbegNbJ4p2dKh5haTOTFOoucKzRGmabeb/Rngdtcz4aguNIIJ8zqDrFDoEEBYjjsA23ME2HW1+7CyycKL2zMySIEvwQoqoDEM3BVXiiN1h5vEh4IQy/rdc6If1mkroSvHgG/4mF1MO1/pNzzlvVvc= 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+importer=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 1719508342457376.33781600052146; Thu, 27 Jun 2024 10:12:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMsfT-0007qe-9V; Thu, 27 Jun 2024 13:12: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 1sMsf8-0007YM-Gf for qemu-devel@nongnu.org; Thu, 27 Jun 2024 13:12:05 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMsf6-0002DM-Km for qemu-devel@nongnu.org; Thu, 27 Jun 2024 13:11:57 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-4256aee6d4fso204585e9.3 for ; Thu, 27 Jun 2024 10:11:56 -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-4256af55e61sm893975e9.20.2024.06.27.10.11.49 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 10:11:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719508314; x=1720113114; 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=0++Ogxou44hWy9HUie+kN/Bmub/+XHfRbLoibWWU/Qg=; b=IdOqfydyCFesLcZeKuLplamobxVDKpxSLyWjQTxRv6HTc+XK4TrvfeBPNx9OMZDnUY Vnjsin00hJya379PnnrxshpTbtDvYrvwLyUZqr0UxuLU7H5XeeY7HoLZ4iG4y7PiRdZG OUKarL3Ki6wD2p9sVC3lMQ7tJmP1diga24oJ+S9wynCYtqA98qjJxa2ZTM6R70l33h2b IsVpkmfwK3OGIsfxRxb/g3fb+5n3xXKRRN115gYnSZl0OCfecEtsqy1aykaYjy6FcfZh CsX5Bxp0C0u/Hai1z9mhHsJXRfnG14OzNECcpZjui5QCf43r8A6N8aQQdaJAnXbMqDou UqdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719508314; x=1720113114; 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=0++Ogxou44hWy9HUie+kN/Bmub/+XHfRbLoibWWU/Qg=; b=PnUephiZ2YL2EgUFrL/mPgOkVlydmrHtK6hqpdv9twNanJgMAYECe5cnoQivVucDaj G/V88JUnWN60BDs4piaquXr2E8QHopPY/2eyCh15nX3XJyMWpcn7YZcR8xfZ2L59Y222 yavVAN88+eqdjeay2GycJ93gcQUCGbBAZK/hY1pFXWGBScsZdm5B6hSw0P/nYxs3oZbk RE3r5k2pYK3AW4j11qT0RkW1YlLWddtpGCkXV9XfCNwhfyso7gpiMcMGVbm9hZuK+rcA FLP+BDwHCuvtc+OfhiJUl32YO6t/jWfZJWPGzVY9jiMnMMv93kbY6IumSdiYKDkczdFs UWsA== X-Gm-Message-State: AOJu0YyY4JyBqO/S7NTrRCu6DJ+eT3FzhHssHjtPOxhuGmNNTvl5I9rc i320ayKgVPCG71Cvbu+QkjTUSrf5ZudaUWvgDFywAwp4R3+xKgfH6W16wArmJ9Gd82tmfasZn4R wDxE= X-Google-Smtp-Source: AGHT+IGY+k9n3kTugxO+U2sqWiH7I/kN46agg24tch5AvgN/I63LV8z/sZmnR5dkRrjwkZQj2TAQEA== X-Received: by 2002:a05:600c:5715:b0:421:5609:115d with SMTP id 5b1f17b1804b1-4248cc78a09mr88582175e9.41.1719508313949; Thu, 27 Jun 2024 10:11:53 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Joel Stanley , Luc Michel , Francisco Iglesias , qemu-block@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Vincent Palatin , Sai Pavan Boddu , Bin Meng , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH 04/19] hw/sd/sdcard: Register generic command handlers Date: Thu, 27 Jun 2024 19:10:44 +0200 Message-ID: <20240627171059.84349-5-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627171059.84349-1-philmd@linaro.org> References: <20240627171059.84349-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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=philmd@linaro.org; helo=mail-wm1-x32e.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1719508343648100003 Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sd.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 249fad0468..ebcd8c1e43 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -2383,6 +2383,28 @@ static const SDProto sd_proto_emmc =3D { /* Only v4.5 is supported */ .name =3D "eMMC", .cmd =3D { + [0] =3D {0, sd_bc, "GO_IDLE_STATE", sd_cmd_GO_IDLE_STATE}, + [2] =3D {0, sd_bcr, "ALL_SEND_CID", sd_cmd_ALL_SEND_CID}, + [7] =3D {0, sd_ac, "(DE)SELECT_CARD", sd_cmd_DE_SELECT_CARD}, + [9] =3D {0, sd_ac, "SEND_CSD", sd_cmd_SEND_CSD}, + [10] =3D {0, sd_ac, "SEND_CID", sd_cmd_SEND_CID}, + [12] =3D {0, sd_ac, "STOP_TRANSMISSION", sd_cmd_STOP_TRANSMISSI= ON}, + [13] =3D {0, sd_ac, "SEND_STATUS", sd_cmd_SEND_STATUS}, + [15] =3D {0, sd_ac, "GO_INACTIVE_STATE", sd_cmd_GO_INACTIVE_STA= TE}, + [16] =3D {2, sd_ac, "SET_BLOCKLEN", sd_cmd_SET_BLOCKLEN}, + [17] =3D {2, sd_adtc, "READ_SINGLE_BLOCK", sd_cmd_READ_SINGLE_BLO= CK}, + [23] =3D {2, sd_ac, "SET_BLOCK_COUNT", sd_cmd_SET_BLOCK_COUNT}, + [24] =3D {4, sd_adtc, "WRITE_SINGLE_BLOCK", sd_cmd_WRITE_SINGLE_B= LOCK}, + [27] =3D {4, sd_adtc, "PROGRAM_CSD", sd_cmd_PROGRAM_CSD}, + [28] =3D {6, sd_ac, "SET_WRITE_PROT", sd_cmd_SET_WRITE_PROT}, + [29] =3D {6, sd_ac, "CLR_WRITE_PROT", sd_cmd_CLR_WRITE_PROT}, + [30] =3D {6, sd_adtc, "SEND_WRITE_PROT", sd_cmd_SEND_WRITE_PROT}, + [35] =3D {5, sd_ac, "ERASE_WR_BLK_START", sd_cmd_ERASE_WR_BLK_S= TART}, + [36] =3D {5, sd_ac, "ERASE_WR_BLK_END", sd_cmd_ERASE_WR_BLK_END= }, + [38] =3D {5, sd_ac, "ERASE", sd_cmd_ERASE}, + [42] =3D {7, sd_adtc, "LOCK_UNLOCK", sd_cmd_LOCK_UNLOCK}, + [55] =3D {8, sd_ac, "APP_CMD", sd_cmd_APP_CMD}, + [56] =3D {8, sd_adtc, "GEN_CMD", sd_cmd_GEN_CMD}, }, }; =20 --=20 2.41.0 From nobody Mon Nov 25 00:20:58 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1719508356; cv=none; d=zohomail.com; s=zohoarc; b=P8EsqBohf+UZx9biNp1e/DNFPp14t4KAf5IdpEqPqym19nqcqhQclJt4s+O5o72Xe7vGeK6CkTBHEWkpwGsqDf+JkemHeI1Dtma6YPJC+t8yEtK/HfaRjjAVNU55b3EMuLP3QngnEwarSNIe0vZFrCNOwY6s7wVNUpsn9Xv7/ms= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719508356; h=Content-Type:Content-Transfer-Encoding:Cc:Cc: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; bh=UmLMWLzqSVJb3i4hpxGU8DfPCxonGkzeRg9cK3jhrKk=; b=hq0s1Ubrmo8Ndj1G11/Uc44J7S+mNK88ukxSjFI4dWkE/GUh1zL5jndP8rtm5MY9xZa1WzvcNbKcJDKiXc1jnFbEzVqsIYAT+cd0TujPU8Zxk1NeW8rq/RKn0WTHhfhTJiQ0DzZ+YVU7Yd+MSoDiFka+Sj+fJRMdDStcPPjGURc= 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+importer=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 1719508356465988.6129585373908; Thu, 27 Jun 2024 10: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 1sMsfT-0007pk-5M; Thu, 27 Jun 2024 13:12: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 1sMsfL-0007cV-ER for qemu-devel@nongnu.org; Thu, 27 Jun 2024 13:12:14 -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 1sMsfG-0002Fw-Hl for qemu-devel@nongnu.org; Thu, 27 Jun 2024 13:12:09 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-424adaa6ceeso16913265e9.1 for ; Thu, 27 Jun 2024 10:12:05 -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-4256b09a681sm650995e9.30.2024.06.27.10.12.00 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 10:12:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719508324; x=1720113124; 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=UmLMWLzqSVJb3i4hpxGU8DfPCxonGkzeRg9cK3jhrKk=; b=Y1A6NfH35RWYCWR5yW7NnBmLBTojHHvwFtr2CLm+vn64wxlTaQWThTmfD+omNjBlUk 4gb0lx3GctdZIpZPBgyl78wlV0vlI2u0rBxVk07mzd8YsUfZpXMldI2QceDpXDFtNOww gYadD0uiATnK0uQWSXO8rvx3PRCenMORojDSgClT0W9b6JtvzKAl4b3wZBzQ6E1Qyopi WCDHnuB0wN/lsBnKr87h6YGi12AeiT9ZSZ9+y5L0b65wIDZfCo0At+TN+5Wn/LGvgMY0 bP9X+Jj2i48r/69OEeFuQDj6qm8BFw+7oCW1SIJDehw7bxQztkwyCB7ALqZEmZ0UYhiG pkgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719508324; x=1720113124; 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=UmLMWLzqSVJb3i4hpxGU8DfPCxonGkzeRg9cK3jhrKk=; b=QAEO8rHyN0EdYRaqJdWjoMIO7q3PwEIplfIMf7zta76Lqmd4Flj8lWLhQe42TRl5sA HDbgbPvw5Oa1lAvC+VFWt8JOb/e6A3qS3M+gsOwc9MWpz4lrUY4hMyUXN0MWFXTqUanO Um8w4VtkZyA7XNDJkcGMvZ4z6ZlBaJy8sFFQthvnO45c2+gJRI60/m5dorUwdGJiLFT2 nm0b3oEcjcOdEI/R8TZakYHocva2EoIlIg97Y2+nHdOxy/TUNQ6zhnGjhuKkAOciLFt9 u1ktOzyErW3uaFD8dsLw4PYCihxHJVPh1Mt/SkIZHsEDdkFLD8LiSHXd+2gz30K6jsPB m7Ug== X-Gm-Message-State: AOJu0Yywxhwgo6+lxZCgfs2e3X9COMY9GJg12ijVE/dgF/rzD0h08BfD tMkmcaT6uTo2Rsutr6oDy8wd3qfnSfMuq7S+ZIOubN+W5ENFWppfvN/M+16QuHuoNdXY3wy9G6D 8ktU= X-Google-Smtp-Source: AGHT+IGDCyAn0fUeqPsEP+b662QuYiY3plVCB+tt6PlWVPAmTWWb/ialx1X6Iva0FsqSI7zt1PMnkw== X-Received: by 2002:a05:600c:158a:b0:424:b3cf:d704 with SMTP id 5b1f17b1804b1-424b3cfd940mr38158575e9.37.1719508324562; Thu, 27 Jun 2024 10:12:04 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Joel Stanley , Luc Michel , Francisco Iglesias , qemu-block@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Vincent Palatin , Sai Pavan Boddu , Bin Meng , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH 05/19] hw/sd/sdcard: Register unimplemented command handlers Date: Thu, 27 Jun 2024 19:10:45 +0200 Message-ID: <20240627171059.84349-6-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627171059.84349-1-philmd@linaro.org> References: <20240627171059.84349-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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1719508357679100003 Per the spec v4.5 these commands are mandatory, but we don't implement them. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sd.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index ebcd8c1e43..9a2bfeaab6 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -2385,24 +2385,30 @@ static const SDProto sd_proto_emmc =3D { .cmd =3D { [0] =3D {0, sd_bc, "GO_IDLE_STATE", sd_cmd_GO_IDLE_STATE}, [2] =3D {0, sd_bcr, "ALL_SEND_CID", sd_cmd_ALL_SEND_CID}, + [4] =3D {0, sd_bc, "SEND_DSR", sd_cmd_unimplemented}, [7] =3D {0, sd_ac, "(DE)SELECT_CARD", sd_cmd_DE_SELECT_CARD}, [9] =3D {0, sd_ac, "SEND_CSD", sd_cmd_SEND_CSD}, [10] =3D {0, sd_ac, "SEND_CID", sd_cmd_SEND_CID}, [12] =3D {0, sd_ac, "STOP_TRANSMISSION", sd_cmd_STOP_TRANSMISSI= ON}, [13] =3D {0, sd_ac, "SEND_STATUS", sd_cmd_SEND_STATUS}, + [14] =3D {0, sd_adtc, "BUSTEST_R", sd_cmd_unimplemented}, [15] =3D {0, sd_ac, "GO_INACTIVE_STATE", sd_cmd_GO_INACTIVE_STA= TE}, [16] =3D {2, sd_ac, "SET_BLOCKLEN", sd_cmd_SET_BLOCKLEN}, [17] =3D {2, sd_adtc, "READ_SINGLE_BLOCK", sd_cmd_READ_SINGLE_BLO= CK}, + [19] =3D {0, sd_adtc, "BUSTEST_W", sd_cmd_unimplemented}, [23] =3D {2, sd_ac, "SET_BLOCK_COUNT", sd_cmd_SET_BLOCK_COUNT}, [24] =3D {4, sd_adtc, "WRITE_SINGLE_BLOCK", sd_cmd_WRITE_SINGLE_B= LOCK}, [27] =3D {4, sd_adtc, "PROGRAM_CSD", sd_cmd_PROGRAM_CSD}, [28] =3D {6, sd_ac, "SET_WRITE_PROT", sd_cmd_SET_WRITE_PROT}, [29] =3D {6, sd_ac, "CLR_WRITE_PROT", sd_cmd_CLR_WRITE_PROT}, [30] =3D {6, sd_adtc, "SEND_WRITE_PROT", sd_cmd_SEND_WRITE_PROT}, + [31] =3D {6, sd_adtc, "SEND_WRITE_PROT_TYPE", sd_cmd_unimplemente= d}, [35] =3D {5, sd_ac, "ERASE_WR_BLK_START", sd_cmd_ERASE_WR_BLK_S= TART}, [36] =3D {5, sd_ac, "ERASE_WR_BLK_END", sd_cmd_ERASE_WR_BLK_END= }, [38] =3D {5, sd_ac, "ERASE", sd_cmd_ERASE}, + [39] =3D {9, sd_ac, "FAST_IO", sd_cmd_unimplemented}, [42] =3D {7, sd_adtc, "LOCK_UNLOCK", sd_cmd_LOCK_UNLOCK}, + [49] =3D {0, sd_adtc, "SET_TIME", sd_cmd_unimplemented}, [55] =3D {8, sd_ac, "APP_CMD", sd_cmd_APP_CMD}, [56] =3D {8, sd_adtc, "GEN_CMD", sd_cmd_GEN_CMD}, }, --=20 2.41.0 From nobody Mon Nov 25 00:20:58 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1719508366; cv=none; d=zohomail.com; s=zohoarc; b=EzPzyrGEOBDFyf6DzWbPNBBOC+QJriyDSUaTyxSwOzOfUQe/rKtVVaH91Ii2A0LLaYm5poLiyMIQuPsty6vSsjyZctM7udKu40D7xR14DlU7nGPm/037sBOfLKIuNOJWByLalO524SXCOHwJK5jQtFRSNZKhDUyH7uIrCwLurfY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719508366; h=Content-Type:Content-Transfer-Encoding:Cc:Cc: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; bh=/hWIFWqzHiq8lN1HtcaO+N2xCOE2TizGkz4ySULbbEQ=; b=GODSobe68EidSUg2kyRshIaCLr6tnRicFRXJ79t70lybE7XHD6jQkIh/zey6OWkzPxJ9WGu+uuepYtGoOq4EXgsuBnrEyuSf3TnR2obmVIvmh0Y+bqxu0icAgKYYj64hGgD1lp2EvVhgyP54i3w9FMxBm4daGHx91rtOM34KLok= 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+importer=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 1719508366805249.4870917745278; Thu, 27 Jun 2024 10:12:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMsfX-000842-50; Thu, 27 Jun 2024 13:12:23 -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 1sMsfR-0007nV-Et for qemu-devel@nongnu.org; Thu, 27 Jun 2024 13:12:17 -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 1sMsfP-0002GZ-9F for qemu-devel@nongnu.org; Thu, 27 Jun 2024 13:12:16 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-424a3ccd0c0so27490545e9.1 for ; Thu, 27 Jun 2024 10:12:13 -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-424a2abcfd0sm52986785e9.1.2024.06.27.10.12.10 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 10:12:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719508332; x=1720113132; 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=/hWIFWqzHiq8lN1HtcaO+N2xCOE2TizGkz4ySULbbEQ=; b=xqiLKgDNLMK6hOQE4KzupANglfgoYU9bUs+VSE3bA/SbFMaL2aXVrTkuXPfN2/3tvU KzemlYOleQVLqOXS+PuTNuwig12sUq4rTV0miUTYF8K160RQX3gXIaP1BX0+RZNCuuBS T3AbKpb2dmoi+DRoENalOKHRvHkgsl0xvfDaU0+8zaHs2FdZsOOS+VOXhYAQMDx1wUPl LCiT2Fhsa+Jba+U2egho+iiKrclkWUWCzBeCM7M8XAyWHJzXErzNKvLtM4vuA1xX0J9g kiw19bCkQ8FxCC6gnxAAoltThABEyaV/DXwlH8pxeC5Roq+JRjL5eO+/AUsDd10t39Rj GneA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719508332; x=1720113132; 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=/hWIFWqzHiq8lN1HtcaO+N2xCOE2TizGkz4ySULbbEQ=; b=DnRuqyG6OJRoADnrHpbK+zLCgGgv91yVwAbhe5LfG4RsGOPvDs6a/69+bieEqwpxMk MDQwktek9rsCXEpMKMp2C6HcjXwkKxlrKI9NImleSEDzF5qSbr6a7+zdAzuJ8bq/N8xi qnwqp0FqL8iwiTA/l+h5ZQpa01rYWfKNKBq+HeqnPYGPzJSd8GWBDt46wFN1u7QKgJtR jUYZs5i/ZqDQLkXZqB1D4NRgTv3dhhkA+UK/Z9i2R9PA9RfgpuBmQR+eojelbGoTTGzE HVqfFtJqoxxnqsFN34jv7X+5pztsJ6z8WjBzBbKsZUipjrppk8h0iIlN0BR47nPH+xzy R2Tw== X-Gm-Message-State: AOJu0Yxy+87WAIzROiuvtDaG8irgjtaGYCRWC+Yf6UW/mtL5bO9heI+0 CM0wDtOdCws6nOO+rDyfVUfWbzRIarf5dXioZJR3Ofi4G59AeKaVHGKqfvu6Vfi+mko+WQKftAh Hw1A= X-Google-Smtp-Source: AGHT+IEHCBMDF//TAaUS4JBORPA1qu6e1k7Xy0aG54ZASQ5sAAKOia9qwCyYvW9OHb7jRclv64D2ZA== X-Received: by 2002:a05:600c:3b1f:b0:425:672a:766e with SMTP id 5b1f17b1804b1-425672a7804mr14277585e9.0.1719508332472; Thu, 27 Jun 2024 10:12:12 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Joel Stanley , Luc Michel , Francisco Iglesias , qemu-block@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Vincent Palatin , Sai Pavan Boddu , Bin Meng , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH 06/19] hw/sd/sdcard: Add emmc_cmd_SET_RELATIVE_ADDR() handler Date: Thu, 27 Jun 2024 19:10:46 +0200 Message-ID: <20240627171059.84349-7-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627171059.84349-1-philmd@linaro.org> References: <20240627171059.84349-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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1719508367780100003 From: C=C3=A9dric Le Goater Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: C=C3=A9dric Le Goater Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sd.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 9a2bfeaab6..c6e5c93acb 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1220,6 +1220,20 @@ static sd_rsp_type_t sd_cmd_SEND_RELATIVE_ADDR(SDSta= te *sd, SDRequest req) } } =20 +static sd_rsp_type_t emmc_cmd_SET_RELATIVE_ADDR(SDState *sd, SDRequest req) +{ + switch (sd->state) { + case sd_identification_state: + case sd_standby_state: + sd->state =3D sd_standby_state; + sd_set_rca(sd, req.arg >> 16); + return sd_r1; + + default: + return sd_invalid_state_for_cmd(sd, req); + } +} + /* CMD6 */ static sd_rsp_type_t sd_cmd_SWITCH_FUNCTION(SDState *sd, SDRequest req) { @@ -2385,6 +2399,7 @@ static const SDProto sd_proto_emmc =3D { .cmd =3D { [0] =3D {0, sd_bc, "GO_IDLE_STATE", sd_cmd_GO_IDLE_STATE}, [2] =3D {0, sd_bcr, "ALL_SEND_CID", sd_cmd_ALL_SEND_CID}, + [3] =3D {0, sd_ac, "SET_RELATIVE_ADDR", emmc_cmd_SET_RELATIVE_= ADDR}, [4] =3D {0, sd_bc, "SEND_DSR", sd_cmd_unimplemented}, [7] =3D {0, sd_ac, "(DE)SELECT_CARD", sd_cmd_DE_SELECT_CARD}, [9] =3D {0, sd_ac, "SEND_CSD", sd_cmd_SEND_CSD}, --=20 2.41.0 From nobody Mon Nov 25 00:20:58 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1719508376; cv=none; d=zohomail.com; s=zohoarc; b=Rb/ZPIXu1dDF0bUhFBnHBdcGj2HXCMl0O2/z2YyMOVBoUSzZzFEEHEUTJqqFEIRY52rtpvJXf453QaUClYlGVSV0rSMhK3UcRW9NRtsXwQhPdkWLDpgvAfe7fva09svTUb6onmejxh60A0F2TbvDmVL+KMvD2nIHkHv7boC0qgE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719508376; h=Content-Type:Content-Transfer-Encoding:Cc:Cc: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; bh=z9Lv5oRHhagfJkOeTGJdPKagMg6fgJmQOzE+waR1EWA=; b=LGPxUXEz/vtJdRhWKmoCJhlcu4ohyKI+ldZ7YwDGmwXo7+AB3zLfl7FO/1o8RNBpxUJ+2qG51nz1ffYoazjfyer3LTJk/KBI8ZJQfwA8dP/dblJJe8QsUviwC+Ex8CYnsGLutbiNq1euM02BmxNQzPlKva9AB9euatR6M5TYifw= 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+importer=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 1719508376720927.3851167242971; Thu, 27 Jun 2024 10:12:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMsfd-0008Nj-UV; Thu, 27 Jun 2024 13:12:31 -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 1sMsfY-0008Ab-Bv for qemu-devel@nongnu.org; Thu, 27 Jun 2024 13:12:24 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMsfW-0002Hv-PQ for qemu-devel@nongnu.org; Thu, 27 Jun 2024 13:12:24 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-4255fa23f7bso15163645e9.2 for ; Thu, 27 Jun 2024 10:12:21 -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 ffacd0b85a97d-3674369ed92sm2490144f8f.105.2024.06.27.10.12.16 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 10:12:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719508339; x=1720113139; 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=z9Lv5oRHhagfJkOeTGJdPKagMg6fgJmQOzE+waR1EWA=; b=WFbFROm34UxZorvMkRKKGtpRHQMQaTtofOS/ynldgAz9fG3CNPWLhGdvUoP8O7m9oa b4LbLRFdp2SQwa4xuN2N2S5HmSA7vYq85Mc3CbcZTU3QgMUqRcMai0aiRLDMQr3DvK4y 2AG30CUMUUxLCOqW2zOTNWl5PWBxB8dBe1l7mAgok84GWmIxXDKgGRqTpmM5VgmffKLB fjtloFRfpEa3Wa1seD/9Nedr0UwE75ecrUhycFM1IKbg3gqglprsLyilyEs62DV3QBw7 /7GkyH9IIiZIe1XVpe9SlRzJbZWjnZMAsBf22WsbFKmU4uyLlKDOUmd4rfYoaqdgEmt7 vxuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719508339; x=1720113139; 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=z9Lv5oRHhagfJkOeTGJdPKagMg6fgJmQOzE+waR1EWA=; b=FUWQgs9dzG29vKHoirgEph2JnY/N258+iPfQ2l033W9pXEtubx+pO2zBy1l7OzA9e4 QhV/vBaEmcyJtz1PFymuApGbuzgtDxd3uOq0z0QH5IX2ANlJIaHbXiJK5q85flpKwbeR 35sMnNInEDb+xfIwFSBuKR4cy0tFfL+L/FNErVjPwePMxNIplkDHJU+S/cXTkEOLAh+3 Ers8PZ85TLSQn7pARkpxFT2id+ovr3vc55UHdRsucCp0KhHfadtIyN4CHe0WeJO/ad7m 7RZFNGK6UOJzsADIoN95ip45GUJlnMMaPcEllgOhwJbrdHUlzZopWMh8dj8QH0RaLudX 1qXA== X-Gm-Message-State: AOJu0YzP72t8NYI+C928Hta5uLug+4I97AyGBAYbnmZBkknkrbRhYHG1 bNEY2YuOMWU5ZWcb5VG0RMijUuJuUJ7x5VvRlX1geFowsMW8m2ZF1GX2mqh9PNxreoiO5ssEP+v 8o+c= X-Google-Smtp-Source: AGHT+IE2AdN/IeEA0++g8AMnWzZmbanFjQ5pOfLNrP7Lqhaflitu5gVMnfSYB7RrJWT5yGR1qDGBFg== X-Received: by 2002:a7b:cbd0:0:b0:424:ac14:ddc8 with SMTP id 5b1f17b1804b1-424ac14deddmr42871175e9.17.1719508338799; Thu, 27 Jun 2024 10:12:18 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Joel Stanley , Luc Michel , Francisco Iglesias , qemu-block@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Vincent Palatin , Sai Pavan Boddu , Bin Meng , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Sai Pavan Boddu , "Edgar E . Iglesias" Subject: [PATCH 07/19] hw/sd/sdcard: Add emmc_cmd_SEND_OP_COND handler (CMD1) Date: Thu, 27 Jun 2024 19:10:47 +0200 Message-ID: <20240627171059.84349-8-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627171059.84349-1-philmd@linaro.org> References: <20240627171059.84349-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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=philmd@linaro.org; helo=mail-wm1-x32e.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1719508377811100003 From: Sai Pavan Boddu Add support to Power up the card and send response r3 in case of MMC. Signed-off-by: Sai Pavan Boddu Signed-off-by: Edgar E. Iglesias Signed-off-by: C=C3=A9dric Le Goater Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sd.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index c6e5c93acb..2dc0209482 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1190,6 +1190,12 @@ static sd_rsp_type_t spi_cmd_SEND_OP_COND(SDState *s= d, SDRequest req) return sd_r1; } =20 +static sd_rsp_type_t emmc_cmd_SEND_OP_COND(SDState *sd, SDRequest req) +{ + sd_ocr_powerup(sd); + return sd->state =3D=3D sd_idle_state ? sd_r3 : sd_r0; +} + /* CMD2 */ static sd_rsp_type_t sd_cmd_ALL_SEND_CID(SDState *sd, SDRequest req) { @@ -2398,6 +2404,7 @@ static const SDProto sd_proto_emmc =3D { .name =3D "eMMC", .cmd =3D { [0] =3D {0, sd_bc, "GO_IDLE_STATE", sd_cmd_GO_IDLE_STATE}, + [1] =3D {0, sd_bcr, "SEND_OP_COND", emmc_cmd_SEND_OP_COND}, [2] =3D {0, sd_bcr, "ALL_SEND_CID", sd_cmd_ALL_SEND_CID}, [3] =3D {0, sd_ac, "SET_RELATIVE_ADDR", emmc_cmd_SET_RELATIVE_= ADDR}, [4] =3D {0, sd_bc, "SEND_DSR", sd_cmd_unimplemented}, --=20 2.41.0 From nobody Mon Nov 25 00:20:58 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1719508391; cv=none; d=zohomail.com; s=zohoarc; b=Hp7A20LCzpTpHHZAcGVOdUwrA772fVLUxEHSqrIj/my/8RSYoYznrleJeQKizfq4nWMoZzKshLa+t4pawjPU7aTzRnL+284ETNWZZpEerkM8lqaTSI0NdH/4ZoETV//OIwnuWIlLDgOkc+tQWnLPk1iVwCnb8VdaOkgk68YxlPU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719508391; h=Content-Type:Content-Transfer-Encoding:Cc:Cc: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; bh=tQQUBf2F5gPlbKVK01VAnUB30JlRnWbK2EOrpmfwvjQ=; b=blubV60sMpVzKCFheghVGcqJgvqprin9yVBNcHtK3IRmEF95+A8ToNosjNj3gWRukw/EiIilU/l+HXwPgCs0M7uMxwVfPr4p3tCFkNe27a8wv4X/IPSOP/pD4UgZJmG+Wo8o70WRfUaUgi4VfE5RJ7qf5lBLFAvyatOqdwJ6PPM= 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+importer=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 1719508391358734.5998867701868; Thu, 27 Jun 2024 10:13:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMsfl-0000ra-K4; Thu, 27 Jun 2024 13:12:37 -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 1sMsfj-0000dg-Gi for qemu-devel@nongnu.org; Thu, 27 Jun 2024 13:12:35 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMsfg-0002JQ-OR for qemu-devel@nongnu.org; Thu, 27 Jun 2024 13:12:34 -0400 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-42565697036so5582055e9.1 for ; Thu, 27 Jun 2024 10:12:32 -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-4256b0c1611sm569565e9.42.2024.06.27.10.12.26 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 10:12:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719508350; x=1720113150; 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=tQQUBf2F5gPlbKVK01VAnUB30JlRnWbK2EOrpmfwvjQ=; b=QHAZdY+Y1dpy1YvhvphPnvRajMSu2MqT89vdz7/DLWXxhcTNoaKRZm3STDra/fEqG+ 4jjGwz4kl4dNbqFPzxpD9pAkRvpvySPoSn8/Bbh40x9CcrWX7qC7LJQbWG9luF5EWHw9 bhVp8LqK1t9nLsmj7jF7x8WvKgy89vXXok9QtZTaDiyX5TR8ZKLFCW0WoaBklPTFKWOI INv2eqqkXcondUTkb4fuvPK0A8is6zdMvWQXEHMNkOcKYgke8t7KseudapSFWTGJjybI jEAFJSz4rEzV0fosjEtFkpb1KGDvK1hwAsxi7J/tTUVeFq4i6moFTNrBJ1DIu2zM2iJt Aifw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719508350; x=1720113150; 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=tQQUBf2F5gPlbKVK01VAnUB30JlRnWbK2EOrpmfwvjQ=; b=ikfQevTVr68a9iGfg+q5RhIgJPaG2Wux63ZtZXfV0BHdgEXwbDilF4ArD+cOxtzhS/ v+E9+adslDazbsRkVFfB3GSunlfxFHm2GZmwXwV7nuH47HR6E9iY2B/Ix+s0ZAwv19Gz zjcOBwXaqpulQiYwFF5DTKS3W8lT1uAlnFXnR3JWAxyoJ0U98DzDH3O9No4775d4Ox44 /Dxop7IxmDBKbNUttuSn3WDsS7vpuIXZaOYuRynTiq8IJijhziDsqu5+q0LJpcWLsKok /XXOyGt+pH/3qAUFzqIbl4zyG/EeUyy87OqocoyPRzvoVORb2/85fCZolGM7Oe9aw5SN o8lw== X-Gm-Message-State: AOJu0Yz58la22EhBKyxq16UgBO5dIpkTXVsvnwqF4uJ0wNths2DuCBCW Glxe88c8W5Sjzo2/QZ7Lte5rBJrRgKUqm4v7EesVxMfYdM6AK3k3P05BZdrJEjYBy+rqacFJkWe ZfMs= X-Google-Smtp-Source: AGHT+IE+kD+xYrGBCUUesZSLmjW7bDnhpPn+ya7jIKl+uTZ7L0Er53a28YxcAnAx0K0/WTkZEJ6ZLg== X-Received: by 2002:a05:600c:2e0b:b0:424:895c:b84b with SMTP id 5b1f17b1804b1-425630daf0fmr31725965e9.4.1719508350744; Thu, 27 Jun 2024 10:12:30 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Joel Stanley , Luc Michel , Francisco Iglesias , qemu-block@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Vincent Palatin , Sai Pavan Boddu , Bin Meng , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH 08/19] hw/sd/sdcard: Fix SET_BLOCK_COUNT command argument on eMMC (CMD23) Date: Thu, 27 Jun 2024 19:10:48 +0200 Message-ID: <20240627171059.84349-9-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627171059.84349-1-philmd@linaro.org> References: <20240627171059.84349-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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=philmd@linaro.org; helo=mail-wm1-x332.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1719508391871100001 From: C=C3=A9dric Le Goater The number of blocks is defined in the lower bits [15:0]. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: C=C3=A9dric Le Goater Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sd.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 2dc0209482..7c6f5ccc72 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -171,12 +171,18 @@ struct SDState { static void sd_realize(DeviceState *dev, Error **errp); =20 static const SDProto sd_proto_spi; +static const SDProto sd_proto_emmc; =20 static bool sd_is_spi(SDState *sd) { return sd->proto =3D=3D &sd_proto_spi; } =20 +static bool sd_is_emmc(SDState *sd) +{ + return sd->proto =3D=3D &sd_proto_emmc; +} + static const char *sd_version_str(enum SDPhySpecificationVersion version) { static const char *sdphy_version[] =3D { @@ -1479,6 +1485,9 @@ static sd_rsp_type_t sd_cmd_SET_BLOCK_COUNT(SDState *= sd, SDRequest req) } =20 sd->multi_blk_cnt =3D req.arg; + if (sd_is_emmc(sd)) { + sd->multi_blk_cnt &=3D 0xffff; + } trace_sdcard_set_block_count(sd->multi_blk_cnt); =20 return sd_r1; --=20 2.41.0 From nobody Mon Nov 25 00:20:58 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1719508404; cv=none; d=zohomail.com; s=zohoarc; b=hivXHYX/GspSSohTQZOSK8r2ZiyPeZKqUe6G1wZ9PMHMrOXlFK+hfE6hR/k+XgvFp/FpZ0B/pvgEUNKOJ0XGDBBw/AqUYfyhzyxG0Z09F9ZkH9oFOp0wOy/Wnvkyi7yw1Va3IynDhVVCCkp7TrmOTZSwVvMdW5S6VgtqgONo6VQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719508404; h=Content-Type:Content-Transfer-Encoding:Cc:Cc: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; bh=CppPyHBGnGyh+KeMhLUUfKK62hbBIjgp+PC1jB0KmHY=; b=mnC/ECK9cq2hCv+ZDyIEeL+QDv3e6vlc69du2a6shbeXhfGkZHVrTAMP1endyz0E2dJ/zejgHwFoIF3ujbOsTQwB/SfsC2Ax7FkrU7PZQiW238f7l53l8Cegna4zhIzUJgQisBwjlIZD9Kvu4D1Llj6uc5sySto/4/GDDRlejlk= 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+importer=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 1719508404157236.95182177415427; Thu, 27 Jun 2024 10:13:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMsfu-0001X4-ND; Thu, 27 Jun 2024 13:12:46 -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 1sMsfs-0001Mb-Su for qemu-devel@nongnu.org; Thu, 27 Jun 2024 13:12:44 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMsfr-0002KL-5g for qemu-devel@nongnu.org; Thu, 27 Jun 2024 13:12:44 -0400 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-3636c572257so6588110f8f.0 for ; Thu, 27 Jun 2024 10:12:42 -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 ffacd0b85a97d-3674369ebaesm2489133f8f.91.2024.06.27.10.12.37 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 10:12:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719508361; x=1720113161; 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=CppPyHBGnGyh+KeMhLUUfKK62hbBIjgp+PC1jB0KmHY=; b=Unozw+WbqFhAtxGSCVcjHM2f4ppAu4pQhNXLSiN915fkY4m8t4Zla8HEOWFwUXNScz jjIh84omHzKMeZIXFIxCtlPc4B23Ta/n4uygMVlFD86fvKJcELvJoDVkgVBac0he8Vek gBkFF6rEUuGQ6nvvOynVYP8rv6v46JGCl/BFX5fFF5qKDVACREWkXqv2vH045EyIvXoP DIKCJnU4IWNKTDVUBa3nhbjfrZ5R3wQFeDD0/+YpY4NjSkozlocCzFCuk3LOCNYInMox i0SqLkV9X9ZqZNny3VDXLuMPmCvK6d6QxKxibVIY+xeyDOCSPpHbD8GiN+I3ZQ6hrfW6 i4yA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719508361; x=1720113161; 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=CppPyHBGnGyh+KeMhLUUfKK62hbBIjgp+PC1jB0KmHY=; b=rXfq5QRW50F5BQdUZZbiEuj8YtqD0Z2741uPH0wGKoRcfyfQujBixWbYlqxKCHItrm gvxricdeXj6La/aS+BkGFvDFGFLx23/ZZ1s96BasS/G2x/4PDBkEcSs2ZWhPiKOtxJHy fltUIoHKY//8ppmeRFfoCSc9zn7EkIyoKuP9rogXSj7UqXHVQhP4P2hXRDSapcEVraFh FuI7TWsw1CJRmJJWvn+tmFsBge9i4D1zQ/AaPdK7W4Id8Pbuvkw/U2IIrfq1JkdqFyev GL8hKfwBXTJ8XhXcZRsDNl1xS2dluaEiBz46qSw0tw1YtZInlfjdGu0iytnbZqfkVkWH Xcdw== X-Gm-Message-State: AOJu0YwT1i82JZkRnVknlItcuSSXSQyXjLLjmIzvy64Ejk7SmLOXLx78 IdPF/wZLmqLn+oFRPeaCJ2ozn3Pl4fby8FF/1qLObyhhYgcoO/7V13LTkt01Tp2Go2f41sGNuUF 12hA= X-Google-Smtp-Source: AGHT+IFQedm5omyTJ3NlxjIwSTS0PK3a3Imi4i98PIvZJcL2L9K/BjXrna/LklFVxehY7cJuVO1GcA== X-Received: by 2002:adf:b1d1:0:b0:362:ff67:272f with SMTP id ffacd0b85a97d-366e94db3e5mr11678812f8f.41.1719508361364; Thu, 27 Jun 2024 10:12:41 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Joel Stanley , Luc Michel , Francisco Iglesias , qemu-block@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Vincent Palatin , Sai Pavan Boddu , Bin Meng , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH 09/19] hw/sd/sdcard: Add mmc_cmd_PROGRAM_CID handler (CMD26) Date: Thu, 27 Jun 2024 19:10:49 +0200 Message-ID: <20240627171059.84349-10-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627171059.84349-1-philmd@linaro.org> References: <20240627171059.84349-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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::429; envelope-from=philmd@linaro.org; helo=mail-wr1-x429.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1719508405934100006 Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sd.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 7c6f5ccc72..0f9bab105e 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1520,6 +1520,12 @@ static sd_rsp_type_t sd_cmd_WRITE_SINGLE_BLOCK(SDSta= te *sd, SDRequest req) return sd_cmd_to_receivingdata(sd, req, addr, sd->blk_len); } =20 +/* CMD26 */ +static sd_rsp_type_t mmc_cmd_PROGRAM_CID(SDState *sd, SDRequest req) +{ + return sd_cmd_to_receivingdata(sd, req, 0, sizeof(sd->cid)); +} + /* CMD27 */ static sd_rsp_type_t sd_cmd_PROGRAM_CSD(SDState *sd, SDRequest req) { @@ -1868,9 +1874,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, S= DRequest req) } break; =20 - case 26: /* CMD26: PROGRAM_CID */ - return sd_cmd_to_receivingdata(sd, req, 0, sizeof(sd->cid)); - default: qemu_log_mask(LOG_GUEST_ERROR, "SD: Unknown CMD%i\n", req.cmd); return sd_illegal; @@ -2429,6 +2432,7 @@ static const SDProto sd_proto_emmc =3D { [19] =3D {0, sd_adtc, "BUSTEST_W", sd_cmd_unimplemented}, [23] =3D {2, sd_ac, "SET_BLOCK_COUNT", sd_cmd_SET_BLOCK_COUNT}, [24] =3D {4, sd_adtc, "WRITE_SINGLE_BLOCK", sd_cmd_WRITE_SINGLE_B= LOCK}, + [26] =3D {4, sd_adtc, "PROGRAM_CID", mmc_cmd_PROGRAM_CID}, [27] =3D {4, sd_adtc, "PROGRAM_CSD", sd_cmd_PROGRAM_CSD}, [28] =3D {6, sd_ac, "SET_WRITE_PROT", sd_cmd_SET_WRITE_PROT}, [29] =3D {6, sd_ac, "CLR_WRITE_PROT", sd_cmd_CLR_WRITE_PROT}, --=20 2.41.0 From nobody Mon Nov 25 00:20:59 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1719508382; cv=none; d=zohomail.com; s=zohoarc; b=M8nif/+VLI09393+NEWzNy+gRBEwm1TWJjzA8i7SdLhB9cuRiHW5nqixU+2M9bqASkZxiOI9u5qCsDXDseNlX/OYbDmXr8t0dLlCUOK78LtzluMMvHpuc5zbLaXOZGB5EGjTe6CIDZLyzvJ03W0xQu/PVgjbYODQGVyKt2M4OrE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719508382; h=Content-Type:Content-Transfer-Encoding:Cc:Cc: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; bh=wa9xIcQNODSrwCgxGYM1DSrbhUURwxNAmEEY/4Qlivk=; b=SnbQ20SD3YSNo5oYE3xfow5WeeO10diDW/W1tmAYGv3UcBd59sHRJL6btY1762d87lM6C48Xq9FrI3S+pi0jI4Fs9NrjipJDBBRBbKgBWup4AZ2rqIvd2f+iPJq2qM+/lJycvf3zUXxN27kjDuqw0WPz9K49zWfdpT7lWyezQwI= 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+importer=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 1719508382756400.2767424219054; Thu, 27 Jun 2024 10:13:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMsg7-0002Pe-Kp; Thu, 27 Jun 2024 13:12:59 -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 1sMsg6-0002GE-3I for qemu-devel@nongnu.org; Thu, 27 Jun 2024 13:12:58 -0400 Received: from mail-lf1-x134.google.com ([2a00:1450:4864:20::134]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMsg3-0002LF-PS for qemu-devel@nongnu.org; Thu, 27 Jun 2024 13:12:57 -0400 Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-52cdb0d8107so8315382e87.1 for ; Thu, 27 Jun 2024 10:12:54 -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 ffacd0b85a97d-3674357c14fsm2511586f8f.16.2024.06.27.10.12.47 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 10:12:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719508373; x=1720113173; 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=wa9xIcQNODSrwCgxGYM1DSrbhUURwxNAmEEY/4Qlivk=; b=VoFIIkGqb09cePHXVDdEjQEUN5m1JXroqmEzO1wUtuffieoMVDejUAqAe4hoNTiBH4 /4OREfsY2qNSLUtwTA9U3Eghxzd51THIgKGeyR9XWE4H6a4C2Lg/p7VlfKtuQ6G3wuvw XsrTfxaHdZajucqpUv8j6FRfln+fA28guT4rVhyUhgEDN84dQlg6f+juCP+UIUrzl+QF VEO5DY19T0pfQ07g+Sfygclz058oAjpQJvoSC7NnHvN05hGC2aTF8v6O5XCpyFiqXPVv HvZYTJQhVI2O5ctYDKu2JXRTXJ7irmRVmm46ejN39gjSijdmTaTJ4dxtc1h7OcFFH9uo SpDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719508373; x=1720113173; 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=wa9xIcQNODSrwCgxGYM1DSrbhUURwxNAmEEY/4Qlivk=; b=GWbvi49u+LEnDlxoDoZxLBMQJQBIb+2J60ZsKFjoSxmiLCTIcMmMRh8/mKAOZkRdat LLZux+Pxea8Xp6wG4ZRwFwnsK9yI+YsGo3Afba2QiyG+3cyxh6l2Qz8mKUQTThVYDuSE HqdzKg3t5mLItwq+LrnAQyQivHZO2VykbsmIXgAhhU22G6UWHtK3XmcOh9QXQidzlgRm Rg7i0/SbnZK1mvh4OteqItHJjh76c0zV1egFBuNrdERD5e6CDWKqMVoPt3GyEhj5xovI qIVxCh8Lc0JUMqtPN3zMjYQYOjeyBDPhnsH+DGolF4QVIS9Fr3ud0z/y76Q2tMHBqtHn ybBg== X-Gm-Message-State: AOJu0YzdU63q8weU4FuPmwyCYm7cHOsJrRGvWgJU5MMuVC6sR8+ATK2P V6DFFwa5Aw3qRZtqenVMfPZuO7jyo+FNuatshKSUAPt/2WOvlg7f1+G6r7pNa+ASATQlE9vOCnE Coo0= X-Google-Smtp-Source: AGHT+IGjWfPv5AB6+8vSNJMxy6EaN9nk0J8H2qEgDHr0Qw0CAWDy2PFLDhvrOnE4TCyG/o5jOpM4gw== X-Received: by 2002:ac2:5618:0:b0:52c:dea0:dd55 with SMTP id 2adb3069b0e04-52cdf7f10d2mr9085492e87.24.1719508372617; Thu, 27 Jun 2024 10:12:52 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Joel Stanley , Luc Michel , Francisco Iglesias , qemu-block@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Vincent Palatin , Sai Pavan Boddu , Bin Meng , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH 10/19] hw/sd/sdcard: Implement eMMC sleep state (CMD5) Date: Thu, 27 Jun 2024 19:10:50 +0200 Message-ID: <20240627171059.84349-11-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627171059.84349-1-philmd@linaro.org> References: <20240627171059.84349-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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::134; envelope-from=philmd@linaro.org; helo=mail-lf1-x134.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1719508383872100003 From: Luc Michel The JEDEC standards specifies a sleep state where the eMMC won't answer any command appart from RESET and WAKEUP and go to low power state. Implement this state and the corresponding command number 5. Signed-off-by: Luc Michel Signed-off-by: Francisco Iglesias Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sd.c | 47 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 0f9bab105e..bd77853419 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1182,8 +1182,19 @@ static sd_rsp_type_t sd_cmd_to_sendingdata(SDState *= sd, SDRequest req, /* CMD0 */ static sd_rsp_type_t sd_cmd_GO_IDLE_STATE(SDState *sd, SDRequest req) { - sd->state =3D sd_idle_state; - sd_reset(DEVICE(sd)); + if (sd->state =3D=3D sd_sleep_state) { + switch (req.arg) { + case 0x00000000: + case 0xf0f0f0f0: + break; + default: + return sd_r0; + } + } + if (sd->state !=3D sd_inactive_state) { + sd->state =3D sd_idle_state; + sd_reset(DEVICE(sd)); + } =20 return sd_is_spi(sd) ? sd_r1 : sd_r0; } @@ -1246,6 +1257,30 @@ static sd_rsp_type_t emmc_cmd_SET_RELATIVE_ADDR(SDSt= ate *sd, SDRequest req) } } =20 +/* CMD5 */ +static sd_rsp_type_t emmc_cmd_sleep_awake(SDState *sd, SDRequest req) +{ + bool do_sleep =3D extract32(req.arg, 15, 1); + + switch (sd->state) { + case sd_sleep_state: + if (!do_sleep) { + /* Awake */ + sd->state =3D sd_standby_state; + } + return sd_r1b; + + case sd_standby_state: + if (do_sleep) { + sd->state =3D sd_sleep_state; + } + return sd_r1b; + + default: + return sd_invalid_state_for_cmd(sd, req); + } +} + /* CMD6 */ static sd_rsp_type_t sd_cmd_SWITCH_FUNCTION(SDState *sd, SDRequest req) { @@ -1648,6 +1683,7 @@ static sd_rsp_type_t sd_cmd_APP_CMD(SDState *sd, SDRe= quest req) case sd_ready_state: case sd_identification_state: case sd_inactive_state: + case sd_sleep_state: return sd_invalid_state_for_cmd(sd, req); case sd_idle_state: if (!sd_is_spi(sd) && sd_req_get_rca(sd, req) !=3D 0x0000) { @@ -1969,6 +2005,12 @@ int sd_do_command(SDState *sd, SDRequest *req, req->cmd &=3D 0x3f; } =20 + if (sd->state =3D=3D sd_sleep_state && req->cmd) { + qemu_log_mask(LOG_GUEST_ERROR, "SD: Card is sleeping\n"); + rtype =3D sd_r0; + goto send_response; + } + if (sd->card_status & CARD_IS_LOCKED) { if (!cmd_valid_while_locked(sd, req->cmd)) { sd->card_status |=3D ILLEGAL_COMMAND; @@ -2420,6 +2462,7 @@ static const SDProto sd_proto_emmc =3D { [2] =3D {0, sd_bcr, "ALL_SEND_CID", sd_cmd_ALL_SEND_CID}, [3] =3D {0, sd_ac, "SET_RELATIVE_ADDR", emmc_cmd_SET_RELATIVE_= ADDR}, [4] =3D {0, sd_bc, "SEND_DSR", sd_cmd_unimplemented}, + [5] =3D {0, sd_ac, "SLEEP/AWAKE", emmc_cmd_sleep_awake}, [7] =3D {0, sd_ac, "(DE)SELECT_CARD", sd_cmd_DE_SELECT_CARD}, [9] =3D {0, sd_ac, "SEND_CSD", sd_cmd_SEND_CSD}, [10] =3D {0, sd_ac, "SEND_CID", sd_cmd_SEND_CID}, --=20 2.41.0 From nobody Mon Nov 25 00:20:59 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1719508404; cv=none; d=zohomail.com; s=zohoarc; b=cM4svtkyVyJSQCDcDvY6+tRv9d3LySUxHzeOFg81kW1VeRZyNeRtb7kO5xHkfzaYG7eRNgaijR3TT3C2xwPo/nj5/cfX+u9/1weLFVknnQ/WNbG5ISmdAiKRgr6bao8Nrp8p4aa903lX3EMzbqVcxSOHo8HjlegHZmNoBjl65Qk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719508404; h=Content-Type:Content-Transfer-Encoding:Cc:Cc: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; bh=v3emiqbeR1uOJll/QBrY7vV5cW8ivGXHg4omZJGkoiU=; b=a3GNTvCgo+HqrC/3OFcgh8i1NNHsFotGlyQvQIGfSr+Ww4ZH3IVlYinisd4Dg9Fvzzd29GH+giDe17O4Go0NlBEUTI6g7gZH+Qo+C9N1/E7neUe66sgtBBo791on4OXuppjFoUj8adadtEEY+57MwX46u+em9I1aT4tMe+cf554= 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+importer=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 1719508404199751.5292472172086; Thu, 27 Jun 2024 10:13:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMsgH-0003Rx-3D; Thu, 27 Jun 2024 13:13: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 1sMsgE-0003G5-BN for qemu-devel@nongnu.org; Thu, 27 Jun 2024 13:13:06 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMsgC-0002Na-MY for qemu-devel@nongnu.org; Thu, 27 Jun 2024 13:13:06 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-42562e4b5d1so11170925e9.1 for ; Thu, 27 Jun 2024 10:13:04 -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-4256b0c15f8sm550105e9.47.2024.06.27.10.12.59 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 10:13:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719508383; x=1720113183; 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=v3emiqbeR1uOJll/QBrY7vV5cW8ivGXHg4omZJGkoiU=; b=X3gA2FEqoIiqf/6sogkO646PfmZnu4YhlbFdXDAQFGGI2tRoxRMU/UFWB80F4qp1uS OZIs/YQD/n33kHNilI1gLpvx8Rg11nPWQVUXb8LIPRWvAOaasiEbrnBxjaZcp82bEaKy 7TPf6C7JZmT16XFHj8gPvAAlYsPUNfVwdSu+l11tUz/xxjmIqIcFFJnIItye2eeRrrvV DFGixO8S0bwL+UtrVaX/5i3XaB8AoXI2iwAnyO0f6S3TOqBsRJsdkpd7WqqmFGO1NH26 vPiqj9MYoBE51OS9IivE7OnOXeJok/eiVC7tEGiw0RCw37iePpfFNvPryAGxwZd19GE0 5cVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719508383; x=1720113183; 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=v3emiqbeR1uOJll/QBrY7vV5cW8ivGXHg4omZJGkoiU=; b=guLpbkcOCAU6ZufSxrXq6I39z0NMUd/2SoZL/fGqerCm9cao4jkvDBaIMR+kKv/BT0 67gVnGRQgVXmsKzNLm138ePWXoFobzkjVa1KnVo5k3z4lpfVwdq5tfygoZaumGDtFgMU 4Hx4PI1kMz95v6LTGB5uEmu15f82OcJFh3+T9BK5Z8LHGh4YCh6jCAHn/lMRacF+h3v1 DBOagZ46RD9GynbSe62hNrotuYYRl12VC/6iSvafM20t6zMyI0YGOq/j/GYS01+OUbLV /SArmD3ymmAbuK1Z5D9iqCxjUdQzabTES5d8APqc7xZYQfHydRjwTSom2UiBMZUlFrh3 18bQ== X-Gm-Message-State: AOJu0YyUumpqL6JiT4YRqIWeRHNDHZbZe9kuwZ5jHyBjWm92JkdCkIH4 pUflbH7Ewokpp8S+0wa/zsV+D11PDWepV4jD2Qw7cChOBt+79NuB7mDWiIqMJzsV9ZXkLyDfwc2 Uwu0= X-Google-Smtp-Source: AGHT+IFNU45auTJRyUA+s5bP25FEgBmHPgM8yfwvljy+QAXUT+NyJ7KeDTE3ysMa5uWZKvA9A9eB4Q== X-Received: by 2002:a05:600c:3782:b0:425:64c5:5750 with SMTP id 5b1f17b1804b1-42564c558f6mr15758255e9.7.1719508382842; Thu, 27 Jun 2024 10:13:02 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Joel Stanley , Luc Michel , Francisco Iglesias , qemu-block@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Vincent Palatin , Sai Pavan Boddu , Bin Meng , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [RFC PATCH 11/19] hw/sd/sdcard: Add experimental 'x-aspeed-emmc-kludge' property Date: Thu, 27 Jun 2024 19:10:51 +0200 Message-ID: <20240627171059.84349-12-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627171059.84349-1-philmd@linaro.org> References: <20240627171059.84349-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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=philmd@linaro.org; helo=mail-wm1-x333.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1719508405934100005 When booting U-boot/Linux on Aspeed boards via eMMC, some commands don't behave as expected from the spec. Add the 'x-aspeed-emmc-kludge' property to allow non standard uses until we figure out the reasons. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sd.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index bd77853419..dc692fe1fa 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -127,6 +127,7 @@ struct SDState { =20 uint8_t spec_version; BlockBackend *blk; + bool aspeed_emmc_kludge; =20 const SDProto *proto; =20 @@ -2567,6 +2568,8 @@ static Property sd_properties[] =3D { DEFINE_PROP_UINT8("spec_version", SDState, spec_version, SD_PHY_SPECv3_01_VERS), DEFINE_PROP_DRIVE("drive", SDState, blk), + DEFINE_PROP_BOOL("x-aspeed-emmc-kludge", SDState, + aspeed_emmc_kludge, false), /* We do not model the chip select pin, so allow the board to select * whether card should be in SSI or MMC/SD mode. It is also up to the * board to ensure that ssi transfers only occur when the chip select --=20 2.41.0 From nobody Mon Nov 25 00:20:59 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1719508445; cv=none; d=zohomail.com; s=zohoarc; b=IaQQAiS9h7Rsbp8ZD57hoV0e7w2xLYZ9VMfyH8r0keTP/zEjcdARFDFs+TyAeCpapjQ6mBD7pgp/2RMSQ0K82W7lCgN/ZX+mwDzsxmkkTFogYqMriArZ5U/GXElXTq0BLm/DQK9ChlG+GA1jRIhG7NrFXL5KjXW/qPlDuZOHnYk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719508445; h=Content-Type:Content-Transfer-Encoding:Cc:Cc: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; bh=rhSRW4lnt4/3qEqJkcY7/by3NHero7LaTXmV3ByZHOM=; b=kzWv/+r8Kbf7W8DlNdBkg0CsgZva1/8/27WmniqN5Vr78UuiEVjcbEwoHjHLZ4AND947NsXdRN0ztQimArr0cktH5WcM/H43MicTUxFc2SJSl5bXH4o6ABU0G8MmyV+k/QkBm8y8yQvCpJg5KTowcu5JxJaT0FvhgcslyMOiNRU= 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+importer=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 1719508445093641.8251651656918; Thu, 27 Jun 2024 10:14:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMsgg-0004xQ-Ny; Thu, 27 Jun 2024 13:13:34 -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 1sMsgc-0004Op-53 for qemu-devel@nongnu.org; Thu, 27 Jun 2024 13:13:31 -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 1sMsgP-0002OH-4q for qemu-devel@nongnu.org; Thu, 27 Jun 2024 13:13:29 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-4255fc43f1cso13824875e9.0 for ; Thu, 27 Jun 2024 10:13:15 -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-4256b097c2asm729665e9.38.2024.06.27.10.13.09 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 10:13:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719508394; x=1720113194; 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=rhSRW4lnt4/3qEqJkcY7/by3NHero7LaTXmV3ByZHOM=; b=pcG+9WWweX3UQzJMQrYeEaRDBjuZvThMS2zoZJEjDhVx4NSYmpza1ii0YnsD7ttks7 NRBXhA9aacu4rqcwJ63H3n9IFJbzlhv+zUIRr9o546jShiRaHO4q4f9Ac8MAGl57yfRF 7MkqtdVdbSE3SX681j755eI64f3OLeo1ZbaQt6URyzHIfPMVGBo8WRDzdKDOJlvzX1Un nsc/JUr2etSYZkRehC59+OSAh8JeNlrzFO/0EqrkS7HLyu4jerL2k+ZKBeyeJ3oqh2As r4bCQ8rVF5zM1Y/Z2bX7z824VNP14BPQNgIdYrULtUiqMvnSoB6o2drWzSXqG3qwdA9g rCAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719508394; x=1720113194; 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=rhSRW4lnt4/3qEqJkcY7/by3NHero7LaTXmV3ByZHOM=; b=ET91wTgb+unCGgiCS3Tai7zyUZTaeoYbWDD+oGYvQipeZW6R0cwNXpy2q3YnBDINQ8 Sj1ITbBkSpCOJitva0e5o3BBBAHcZTtsIChqvEEAoi4liAjdSCv1BAjLjvx+QS1iugBZ Q5DITAmhidyXzNSEDH07PZRNnenxOGzUFi9xJFE218dN048FlWM7Phod7E73wOFU8b5Q naA2MOz/ewQkFT3D3mtftjMxlhFoOAedZdpgeGwxh7OqfJNak8CzQMe3Gf71vNlOifS/ K6l2J3q/Id015L3eXGg89YLEYaSH6F4j5AwLgwEcjSWLgiwjbitIi+uFA8K+fPcgttEj BPwg== X-Gm-Message-State: AOJu0Yygg1VB7qvUcUO9+yDIzdoZpfiAU1Eb3Ym0flgx8TrsK3HWXYvJ fpbpH9pp9XAhCMv6E3ohwvFb2dM3VYbZcCScj58UAryLIlMC4z18B1+szJ9x4izqWWSXDUK+FxI JAUM= X-Google-Smtp-Source: AGHT+IHNnGTYj4DHTlMlH+cqK16beN85M2TvK18WkFj3LRNaPiDlf5TtuxVqqRfKBybfblekQxlEtQ== X-Received: by 2002:a05:600c:4f94:b0:424:90fa:6758 with SMTP id 5b1f17b1804b1-42490fa6992mr98172235e9.5.1719508394091; Thu, 27 Jun 2024 10:13:14 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Joel Stanley , Luc Michel , Francisco Iglesias , qemu-block@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Vincent Palatin , Sai Pavan Boddu , Bin Meng , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [RFC PATCH 12/19] hw/sd/sdcard: Adapt sd_cmd_ALL_SEND_CID handler for eMMC (CMD2) Date: Thu, 27 Jun 2024 19:10:52 +0200 Message-ID: <20240627171059.84349-13-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627171059.84349-1-philmd@linaro.org> References: <20240627171059.84349-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+importer=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, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1719508446113100003 From: C=C3=A9dric Le Goater Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: C=C3=A9dric Le Goater [PMD: Use aspeed_emmc_kludge] Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sd.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index dc692fe1fa..f875fcd741 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1218,7 +1218,13 @@ static sd_rsp_type_t emmc_cmd_SEND_OP_COND(SDState *= sd, SDRequest req) static sd_rsp_type_t sd_cmd_ALL_SEND_CID(SDState *sd, SDRequest req) { switch (sd->state) { + case sd_idle_state: + if (!sd->aspeed_emmc_kludge) { + return sd_invalid_state_for_cmd(sd, req); + } + /* fall-through */ case sd_ready_state: + /* Bus always won */ sd->state =3D sd_identification_state; return sd_r2_i; default: --=20 2.41.0 From nobody Mon Nov 25 00:20:59 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1719508418; cv=none; d=zohomail.com; s=zohoarc; b=Rb7LAKBSLkoXDPiOLHbT6DGd2CcENBKrOHKcX4FvozagzlFgz/vwMOBvJ2b6EriIPqzkmOoUK0CdDlAUZXEfoG+AyGl3oEuZSBNNPeAueL9FnOkdNBg67ivp5MJgdr6xPn873ikBbcqwTzh0LfL7EzIBBgq30Z1nmc3jKO786zY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719508418; h=Content-Type:Content-Transfer-Encoding:Cc:Cc: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; bh=ojivM3IaWwWzglQz4g05HwWNW+Y8YVh/DQQ1yO/B8Js=; b=ROUaYzoJSIuvSIp064AadL+/rv/uMeRSTrJjHlXnm4BGS96IaqEWx2ayzud+6uB41ewcCDaocfqj+0cTfgSdev2sh5aqpXa064PoY3fgAyNekKUMd6BM2aS0+y///YtKrqIo423KfEUjl5M4Oaw2dVbPtbDyN1CBcXpyW5OKkKg= 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+importer=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 1719508418378940.3056557068522; Thu, 27 Jun 2024 10:13:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMsgf-0004iu-38; Thu, 27 Jun 2024 13:13:33 -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 1sMsgb-0004Mg-9L for qemu-devel@nongnu.org; Thu, 27 Jun 2024 13:13:30 -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 1sMsgY-0002PB-IK for qemu-devel@nongnu.org; Thu, 27 Jun 2024 13:13:29 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-424f2b73629so23329475e9.2 for ; Thu, 27 Jun 2024 10:13:26 -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 ffacd0b85a97d-3674357fd08sm2510803f8f.27.2024.06.27.10.13.21 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 10:13:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719508405; x=1720113205; 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=ojivM3IaWwWzglQz4g05HwWNW+Y8YVh/DQQ1yO/B8Js=; b=hQD1cNMGVDmbof8gxhndOYSfho6R5rETVw6yhxuIvw5R0RscdR6KLKtZ6g4s5yrPf3 LiSN5uMtCXKKxLxqNrjMdFEQNK4lYh74/ydVMUX8RjKFR3bKV7qbeRGFK6XHbzPgBAZa ruZCn9/JxQncpn3ppeASd2BR3SodzY3Tb4bpL4ikPnAbmscCBU5Z9yuVgFHeobVxKR2w hiJQ0i3nsDzgWAxa3UqXWB6bz+OhcipOeD1KZZAtC+mx2fOlTxOazpzHOP219ojJTq9K TmcQXAqFRQxvOyyvPFm+0K9YSJeOKEjMh2QWOIIpazcoGamzMgzDo2sqglTl97WaZZd+ 1IlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719508405; x=1720113205; 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=ojivM3IaWwWzglQz4g05HwWNW+Y8YVh/DQQ1yO/B8Js=; b=B1ew8PCxw55fwZIkKZCZNpCG848iuN+lVUo9dbTEM2yNT1u4Blo2vDYhQqvkCeUwDE gsjE4jzMd9QIhowVeyIcKcBRBvHgG/zyNSm4g26vVzgW5vPw1+kbjg6nnqm0Muo2cBMw L5oWa+hrVdChM+S6h28wpxaBnmIeBoV5ib6I20UzSWs2cEsHnuAA2Cktgr9Xf15abh3f OvwxSXm0+WU1PcJ03OlKGl1car+9SqD9wIEZElIKE79NyBk4AIuZYXWZe5jsHpyRJ5Zu dFfdsIxfXVYXPBYBU+sreXiB5ZYaOr/GrKTMVNkKLxXtBFZwLM2sJeZx72yI+gqrKKTb ezrw== X-Gm-Message-State: AOJu0YxF/+pNK85gL95a3eBsT3UGxAe9uU6V6zu9MCjFnHW4xyxoHhJ7 TxJMMoLyTuGPV4BtYy1FMl0VYtGNolxLl2RaDk8Ssx8MyMl9AtrddXwcHSLUCs+Y/XDoZgbrixz mTyA= X-Google-Smtp-Source: AGHT+IGMNvfO3BSLG+kEAfN3/+oY+svHa6CvwQH0RZxj9N8q0SIiXQBJIRyB0V8/+bRj9rWbuV+09g== X-Received: by 2002:a05:600c:348c:b0:424:a5ee:a81e with SMTP id 5b1f17b1804b1-4256456c30amr24527945e9.34.1719508404993; Thu, 27 Jun 2024 10:13:24 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Joel Stanley , Luc Michel , Francisco Iglesias , qemu-block@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Vincent Palatin , Sai Pavan Boddu , Bin Meng , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [RFC PATCH 13/19] hw/sd/sdcard: Adapt sd_cmd_APP_CMD handler for eMMC (CMD55) Date: Thu, 27 Jun 2024 19:10:53 +0200 Message-ID: <20240627171059.84349-14-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627171059.84349-1-philmd@linaro.org> References: <20240627171059.84349-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+importer=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=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1719508419989100003 From: C=C3=A9dric Le Goater Signed-off-by: C=C3=A9dric Le Goater [PMD: Use aspeed_emmc_kludge] Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sd.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index f875fcd741..82e0b5838f 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1693,6 +1693,9 @@ static sd_rsp_type_t sd_cmd_APP_CMD(SDState *sd, SDRe= quest req) case sd_sleep_state: return sd_invalid_state_for_cmd(sd, req); case sd_idle_state: + if (sd_is_emmc(sd)) { + return sd_invalid_state_for_cmd(sd, req); + } if (!sd_is_spi(sd) && sd_req_get_rca(sd, req) !=3D 0x0000) { qemu_log_mask(LOG_GUEST_ERROR, "SD: illegal RCA 0x%04x for APP_CMD\n", req.cmd); @@ -1707,7 +1710,7 @@ static sd_rsp_type_t sd_cmd_APP_CMD(SDState *sd, SDRe= quest req) sd->expecting_acmd =3D true; sd->card_status |=3D APP_CMD; =20 - return sd_r1; + return sd->aspeed_emmc_kludge ? sd_r0 : sd_r1; } =20 /* CMD56 */ --=20 2.41.0 From nobody Mon Nov 25 00:20:59 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1719508454; cv=none; d=zohomail.com; s=zohoarc; b=gDaKoxX9d117xnL3qSziOGrirGrUFmunGxJkikgHpvbAL8cxnTAT459WQHVVcnUqZJqomCsSvIu9ldSBdONx83kEb9BquAQ/hTVNcCAbGl20iFTQu6pc8Oe3+afFPJW97xU2+16Ozbsxg9D9aXDnY9sCXVhX+RQsRxKdrf2iMz0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719508454; h=Content-Type:Content-Transfer-Encoding:Cc:Cc: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; bh=O1uKT3cac0wmROcR+mzv/OARkq5bGqfifIlHFoP/L2c=; b=OoSKEonkEIzbteBsKCA3OxldWObpMJMmp2V6hzh/j9V/XaqeLNJJk6o1Hd8dIRRbf3tDLw4dKSVu+NAGnyJmZyd/w77JIzXcZJgOIDIWNQPCtDtv5ozx/Pk+9cN+ktS8dtYB/ZFK21Q9lmUsq8v0Rn+FUg04J0JVkcUvn0k18OM= 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+importer=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 1719508454444373.32717572255626; Thu, 27 Jun 2024 10:14:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMsgz-0005xD-EA; Thu, 27 Jun 2024 13:13:53 -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 1sMsgq-0005SU-Sp for qemu-devel@nongnu.org; Thu, 27 Jun 2024 13:13:48 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMsgo-0002Qz-Ph for qemu-devel@nongnu.org; Thu, 27 Jun 2024 13:13:44 -0400 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-42564316479so8004905e9.2 for ; Thu, 27 Jun 2024 10:13:40 -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-4256af55d0fsm1016565e9.19.2024.06.27.10.13.33 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 10:13:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719508419; x=1720113219; 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=O1uKT3cac0wmROcR+mzv/OARkq5bGqfifIlHFoP/L2c=; b=Xn3XC5qy7Vxn3QQFeENMEAcGDX7GkZYa2FWk9uly7Vn4q+O/JJ7K+tHcYaghMHWMAj 2U+oouZUibid+Pfo5TqM5cZL7Kq45vvz6Bz980d4I47+EwSLD/SJmoAPSvBSYPOrOh8b nRrEUiUpiKBzSemSXkwYH/hBOaudyFAfOVABUcN8+zdKG4VLpw0a9lrq0OpUlslJgQcS XobPf/TIeXP3iQSLdfxq/E2veacFXKeRkoKl1hLw7lf4NqBsWADNEngkSmffTqi5bYNZ SBs8IrdZRnbbeaAMna/jQkNJVnMdqwvQFxwedXJP83gpG30XMso/FzUI6iQhU7n9vrW7 C8IQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719508419; x=1720113219; 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=O1uKT3cac0wmROcR+mzv/OARkq5bGqfifIlHFoP/L2c=; b=N2WAaxcKnt5QUAKe0nRRDahOOoRlcP8B8TVKhrz5Dk8ZxjxtjVRHvbtZoCb2o9LLLh qGJgg4oPqnA9h2KkdagAGXpvLi5QHPS0faF345YoeDRyvEL9Dn+GKa50KLcgVD6ovky7 hjhlSOgo3Z2AywpS7Pp2doifNHvp5koMKWSYgeW79LlDYS2+7jv3wSUMO7r2czNlU4NE SuuOCy1c+ixDHke7lMd4/iYat+3oelEeTEHXTle+JxM5DHJaIa7igCeOMw32+Ih14Dtj tE0ZOqMWrf20kn+24mN5SKx8s6Mb8edglNGyLiXjYzptxlWC/rZxAwF7HACSVVXGwdMK rbXw== X-Gm-Message-State: AOJu0Yx7V/P7s7ueq8/K6qpGZPWl9oP0V9dlPu7X0vG5TgkZ7wjJJLVn s+p3n/44yOvhrWjVl6oUuQrO9fXmiVrqX/kYcppVSTwn4UkTkdMbK3eCyvhepxIZNvHQdOO0gND 9oXM= X-Google-Smtp-Source: AGHT+IGq36AEzflYez2c0YMFH6Y8h+wBmBzgVy6cBDvUdRpjMLwIfFt0l0+W1g3MBWJLkwMsAUqTNA== X-Received: by 2002:a05:600c:993:b0:424:a5d6:6512 with SMTP id 5b1f17b1804b1-424a5d665f9mr52903405e9.20.1719508418077; Thu, 27 Jun 2024 10:13:38 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Joel Stanley , Luc Michel , Francisco Iglesias , qemu-block@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Vincent Palatin , Sai Pavan Boddu , Bin Meng , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Sai Pavan Boddu , "Edgar E . Iglesias" , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [RFC PATCH 14/19] hw/sd/sdcard: Add emmc_cmd_SEND_EXT_CSD handler (CMD8) Date: Thu, 27 Jun 2024 19:10:54 +0200 Message-ID: <20240627171059.84349-15-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627171059.84349-1-philmd@linaro.org> References: <20240627171059.84349-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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=philmd@linaro.org; helo=mail-wm1-x329.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1719508456189100003 From: Vincent Palatin The parameters mimick a real 4GB eMMC, but it can be set to various sizes. Initially from Vincent Palatin eMMC CSD is similar to SD with an option to refer EXT_CSD for larger devices. Signed-off-by: Vincent Palatin Signed-off-by: C=C3=A9dric Le Goater Signed-off-by: Sai Pavan Boddu Signed-off-by: Edgar E. Iglesias Signed-off-by: C=C3=A9dric Le Goater Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- TODO simplify params, see: https://lore.kernel.org/qemu-devel/54bc25fd-acea-44a3-b696-c261e7e9706d@kao= d.org/ --- hw/sd/sd.c | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 82e0b5838f..0561079eff 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -122,6 +122,7 @@ struct SDState { uint16_t rca; uint32_t card_status; uint8_t sd_status[64]; + uint8_t ext_csd[512]; =20 /* Static properties */ =20 @@ -460,6 +461,82 @@ static const uint8_t sd_csd_rw_mask[16] =3D { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xfe, }; =20 +static void mmc_set_ext_csd(SDState *sd, uint64_t size) +{ + uint32_t sectcount =3D size >> HWBLOCK_SHIFT; + + memset(sd->ext_csd, 0, sizeof(sd->ext_csd)); + + sd->ext_csd[EXT_CSD_S_CMD_SET] =3D 0x1; /* supported command sets */ + sd->ext_csd[EXT_CSD_HPI_FEATURES] =3D 0x3; /* HPI features */ + sd->ext_csd[EXT_CSD_BKOPS_SUPPORT] =3D 0x1; /* Background operations */ + sd->ext_csd[241] =3D 0xA; /* 1st initialization time after partitionin= g */ + sd->ext_csd[EXT_CSD_TRIM_MULT] =3D 0x1; /* Trim multiplier */ + sd->ext_csd[EXT_CSD_SEC_FEATURE_SUPPORT] =3D 0x15; /* Secure feature */ + sd->ext_csd[EXT_CSD_SEC_ERASE_MULT] =3D 0x96; /* Secure erase support = */ + sd->ext_csd[EXT_CSD_SEC_TRIM_MULT] =3D 0x96; /* Secure TRIM multiplier= */ + sd->ext_csd[EXT_CSD_BOOT_INFO] =3D 0x7; /* Boot information */ + sd->ext_csd[EXT_CSD_BOOT_MULT] =3D 0x8; /* Boot partition size. 128KB = unit */ + sd->ext_csd[EXT_CSD_ACC_SIZE] =3D 0x6; /* Access size */ + sd->ext_csd[EXT_CSD_HC_ERASE_GRP_SIZE] =3D 0x4; /* HC Erase unit size = */ + sd->ext_csd[EXT_CSD_ERASE_TIMEOUT_MULT] =3D 0x1; /* HC erase timeout */ + sd->ext_csd[EXT_CSD_REL_WR_SEC_C] =3D 0x1; /* Reliable write sector co= unt */ + sd->ext_csd[EXT_CSD_HC_WP_GRP_SIZE] =3D 0x4; /* HC write protect group= size */ + sd->ext_csd[EXT_CSD_S_C_VCC] =3D 0x8; /* Sleep current VCC */ + sd->ext_csd[EXT_CSD_S_C_VCCQ] =3D 0x7; /* Sleep current VCCQ */ + sd->ext_csd[EXT_CSD_S_A_TIMEOUT] =3D 0x11; /* Sleep/Awake timeout */ + sd->ext_csd[215] =3D (sectcount >> 24) & 0xff; /* Sector count */ + sd->ext_csd[214] =3D (sectcount >> 16) & 0xff; /* ... */ + sd->ext_csd[213] =3D (sectcount >> 8) & 0xff; /* ... */ + sd->ext_csd[EXT_CSD_SEC_CNT] =3D (sectcount & 0xff); /* ... */ + sd->ext_csd[210] =3D 0xa; /* Min write perf for 8bit@52Mhz */ + sd->ext_csd[209] =3D 0xa; /* Min read perf for 8bit@52Mhz */ + sd->ext_csd[208] =3D 0xa; /* Min write perf for 4bit@52Mhz */ + sd->ext_csd[207] =3D 0xa; /* Min read perf for 4bit@52Mhz */ + sd->ext_csd[206] =3D 0xa; /* Min write perf for 4bit@26Mhz */ + sd->ext_csd[205] =3D 0xa; /* Min read perf for 4bit@26Mhz */ + sd->ext_csd[EXT_CSD_PART_SWITCH_TIME] =3D 0x1; + sd->ext_csd[EXT_CSD_OUT_OF_INTERRUPT_TIME] =3D 0x1; + sd->ext_csd[EXT_CSD_CARD_TYPE] =3D 0x7; + sd->ext_csd[EXT_CSD_STRUCTURE] =3D 0x2; + sd->ext_csd[EXT_CSD_REV] =3D 0x5; + sd->ext_csd[EXT_CSD_RPMB_MULT] =3D 0x1; /* RPMB size */ + sd->ext_csd[EXT_CSD_PARTITION_SUPPORT] =3D 0x3; + sd->ext_csd[159] =3D 0x00; /* Max enhanced area size */ + sd->ext_csd[158] =3D 0x00; /* ... */ + sd->ext_csd[157] =3D 0xEC; /* ... */ +} + +static void sd_emmc_set_csd(SDState *sd, uint64_t size) +{ + sd->csd[0] =3D 0xd0; + sd->csd[1] =3D 0x0f; + sd->csd[2] =3D 0x00; + sd->csd[3] =3D 0x32; + sd->csd[4] =3D 0x0f; + if (size <=3D 2 * GiB) { + /* use 1k blocks */ + uint32_t csize1k =3D (size >> (CMULT_SHIFT + 10)) - 1; + sd->csd[5] =3D 0x5a; + sd->csd[6] =3D 0x80 | ((csize1k >> 10) & 0xf); + sd->csd[7] =3D (csize1k >> 2) & 0xff; + } else { /* >=3D 2GB : size stored in ext CSD, block addressing */ + sd->csd[5] =3D 0x59; + sd->csd[6] =3D 0x8f; + sd->csd[7] =3D 0xff; + sd->ocr =3D FIELD_DP32(sd->ocr, OCR, CARD_CAPACITY, 1); + } + sd->csd[8] =3D 0xff; + sd->csd[9] =3D 0xff; + sd->csd[10] =3D 0xf7; + sd->csd[11] =3D 0xfe; + sd->csd[12] =3D 0x49; + sd->csd[13] =3D 0x10; + sd->csd[14] =3D 0x00; + sd->csd[15] =3D (sd_crc7(sd->csd, 15) << 1) | 1; + mmc_set_ext_csd(sd, size); +} + static void sd_set_csd(SDState *sd, uint64_t size) { int hwblock_shift =3D HWBLOCK_SHIFT; @@ -1364,6 +1441,17 @@ static sd_rsp_type_t sd_cmd_SEND_IF_COND(SDState *sd= , SDRequest req) return sd_r7; } =20 +/* CMD8 */ +static sd_rsp_type_t emmc_cmd_SEND_EXT_CSD(SDState *sd, SDRequest req) +{ + if (sd->state !=3D sd_transfer_state) { + return sd_invalid_state_for_cmd(sd, req); + } + + return sd_cmd_to_sendingdata(sd, req, sd_req_get_address(sd, req), + sd->ext_csd, sizeof(sd->ext_csd)); +} + /* CMD9 */ static sd_rsp_type_t spi_cmd_SEND_CSD(SDState *sd, SDRequest req) { @@ -2297,6 +2385,7 @@ uint8_t sd_read_byte(SDState *sd) sd->data_offset, sd->data_size, io_len); switch (sd->current_cmd) { case 6: /* CMD6: SWITCH_FUNCTION */ + case 8: /* CMD8: SEND_EXT_CSD */ case 9: /* CMD9: SEND_CSD */ case 10: /* CMD10: SEND_CID */ case 13: /* ACMD13: SD_STATUS */ @@ -2474,6 +2563,7 @@ static const SDProto sd_proto_emmc =3D { [4] =3D {0, sd_bc, "SEND_DSR", sd_cmd_unimplemented}, [5] =3D {0, sd_ac, "SLEEP/AWAKE", emmc_cmd_sleep_awake}, [7] =3D {0, sd_ac, "(DE)SELECT_CARD", sd_cmd_DE_SELECT_CARD}, + [8] =3D {0, sd_adtc, "SEND_EXT_CSD", emmc_cmd_SEND_EXT_CSD}, [9] =3D {0, sd_ac, "SEND_CSD", sd_cmd_SEND_CSD}, [10] =3D {0, sd_ac, "SEND_CID", sd_cmd_SEND_CID}, [12] =3D {0, sd_ac, "STOP_TRANSMISSION", sd_cmd_STOP_TRANSMISSI= ON}, @@ -2649,6 +2739,7 @@ static void emmc_class_init(ObjectClass *klass, void = *data) dc->desc =3D "eMMC"; dc->realize =3D emmc_realize; sc->proto =3D &sd_proto_emmc; + sc->set_csd =3D sd_emmc_set_csd; } =20 static const TypeInfo sd_types[] =3D { --=20 2.41.0 From nobody Mon Nov 25 00:20:59 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1719508473; cv=none; d=zohomail.com; s=zohoarc; b=ZVJL9Tz7IXiWscQWaPRFYdIETfukQmASA0gtOe5uAXTQvA8C0i8h4tykn95p7nZkvMXjc1dMBJJtkVliwR6fWV7Jq5Oz/hLCqP0beTUNMOzPZ6xKCxO94sQ9E201GTr0DCxQaRt41FRcJE8ubX9i400ZbSYv9IVE8Tx03v2AzoQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719508473; h=Content-Type:Content-Transfer-Encoding:Cc:Cc: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; bh=SnL/FPFYEQkll60HqwiRh6fnqmVJNFRbyEObo/B5eRw=; b=QFO0CSo9Fbc6UB3o7uAC130/a42sR8sO/h4xqwZY2A4Zy+guJdy8sq8dcv0CH3hlUCKZdPgo7/pjHlN/DY2djGp9fZodxpX2BUiWIZTZr078R8YJ5jE9bgyGM5U5DzOicsThTm8wZ9pPFJN2kAMswa1rmECcs3m1nx+tMlueGOA= 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+importer=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 1719508473431459.447208574102; Thu, 27 Jun 2024 10:14:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMshN-0006v4-MR; Thu, 27 Jun 2024 13:14:17 -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 1sMsh6-0006XY-Fu for qemu-devel@nongnu.org; Thu, 27 Jun 2024 13:14:03 -0400 Received: from mail-lf1-x134.google.com ([2a00:1450:4864:20::134]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMsgz-0002SG-Mt for qemu-devel@nongnu.org; Thu, 27 Jun 2024 13:14:00 -0400 Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-52cecba8d11so4035352e87.1 for ; Thu, 27 Jun 2024 10:13:53 -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-4256af5b677sm969165e9.18.2024.06.27.10.13.46 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 10:13:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719508432; x=1720113232; 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=SnL/FPFYEQkll60HqwiRh6fnqmVJNFRbyEObo/B5eRw=; b=LqKrV1/8Nt+24RRG8sQRrIidDLpsyzjb6/ULsrAF4N795ceDGcQLV0OQQoWApl9htq Ry+v30QdJMd2OvnH5mIqEwyLBe7nIWYMziB7jlo9MjRImo1k9ZqbXGMDofNj98jT5Vi1 IhtTuZ2XHsLls93IL+VyrawVn/Qayt4eyBOTTphuf7JdSilhXU/QBZwsjsNSzT+cp3cJ xqEImcB4sLJkk3NDeD5oI5AS6Ik9awTZhIM6eqnBrOGCTDYNzOH/yfpZpA5aSJfS5cqi Wdl7pM9CMxfBnqGQVAI5e9sJXwRHncJl6EhTlff0kCFzcXIRAApByqBtI0Z4d2zFrBq4 vtuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719508432; x=1720113232; 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=SnL/FPFYEQkll60HqwiRh6fnqmVJNFRbyEObo/B5eRw=; b=HRJzSQbBM7XtIbvpVzkPUkEO7zaEOTsSPADwydD3sPyneDZic2vl70f39IEL2abE/9 zCZAHRSG+0LxTerK/tSccxTQwVxEMjyhNmOf3JhqwHmjyF81ZYzeMwN9be42HwNdpHat VRdsr+BP3gwbpXZdPf4YpudV0XlYDgaggn+cDg/XN7Hf9XEDBwlDjXyw+w2x5YPiOdKj RWorwdDSF6iJRCssxeJ3BlIuzXCVgG6UDchvw0E5S6HCJ/xLBM0KBObUJ4e7oA1uRIA5 4o45K6/yUoRpiPi3IxKG8NiEEZDzd8lNQCZwyM+E0FfvMD8YkOPtOat65WYnoZu0y7s7 vOZg== X-Gm-Message-State: AOJu0YwQz1sNreAQUCGFTJlYe3j1UjGwKWBrS/Bu/2f0e/3spum02S0N IYTi9ZBj1FGIFxK6SogxJj79px4XmusljdFya1H+e4TcfLWi6TPo/nl2FuGcybSruHFiR/0pBAi UQKY= X-Google-Smtp-Source: AGHT+IGGn9O48kUWlz/aLcfZD5SGHJYXjy6QzYkvT1BPfNkZrQEo5uHaK+qnHboGnHwAWMR/DqhcpQ== X-Received: by 2002:a05:6512:524:b0:52c:7f25:dbac with SMTP id 2adb3069b0e04-52ce1834fe3mr8678776e87.20.1719508431740; Thu, 27 Jun 2024 10:13:51 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Joel Stanley , Luc Michel , Francisco Iglesias , qemu-block@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Vincent Palatin , Sai Pavan Boddu , Bin Meng , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Sai Pavan Boddu , "Edgar E . Iglesias" , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [RFC PATCH 15/19] hw/sd/sdcard: add emmc_cmd_SEND_TUNING_BLOCK handler (CMD21) Date: Thu, 27 Jun 2024 19:10:55 +0200 Message-ID: <20240627171059.84349-16-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627171059.84349-1-philmd@linaro.org> References: <20240627171059.84349-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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::134; envelope-from=philmd@linaro.org; helo=mail-lf1-x134.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1719508474237100003 From: Sai Pavan Boddu MMC cards support different tuning sequence for entering HS200 mode. Signed-off-by: Sai Pavan Boddu Signed-off-by: Edgar E. Iglesias Signed-off-by: C=C3=A9dric Le Goater Signed-off-by: C=C3=A9dric Le Goater Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sdmmc-internal.h | 3 +++ hw/sd/sd.c | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/hw/sd/sdmmc-internal.h b/hw/sd/sdmmc-internal.h index 20d85aea6d..a2769a80aa 100644 --- a/hw/sd/sdmmc-internal.h +++ b/hw/sd/sdmmc-internal.h @@ -108,4 +108,7 @@ #define EXT_CSD_PART_CONFIG_EN_BOOT0 (0x1 << 3) #define EXT_CSD_PART_CONFIG_EN_USER (0x7 << 3) =20 +#define EXT_CSD_BUS_WIDTH_8_MASK 0x4 +#define EXT_CSD_BUS_WIDTH_4_MASK 0x2 + #endif diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 0561079eff..ae5e73175e 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -698,6 +698,25 @@ static const uint8_t sd_tuning_block_pattern4[64] =3D { 0xbb, 0xff, 0xf7, 0xff, 0xf7, 0x7f, 0x7b, 0xde }; =20 +static const uint8_t mmc_tuning_block_pattern8[128] =3D { + 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, + 0xff, 0xff, 0xcc, 0xcc, 0xcc, 0x33, 0xcc, 0xcc, + 0xcc, 0x33, 0x33, 0xcc, 0xcc, 0xcc, 0xff, 0xff, + 0xff, 0xee, 0xff, 0xff, 0xff, 0xee, 0xee, 0xff, + 0xff, 0xff, 0xdd, 0xff, 0xff, 0xff, 0xdd, 0xdd, + 0xff, 0xff, 0xff, 0xbb, 0xff, 0xff, 0xff, 0xbb, + 0xbb, 0xff, 0xff, 0xff, 0x77, 0xff, 0xff, 0xff, + 0x77, 0x77, 0xff, 0x77, 0xbb, 0xdd, 0xee, 0xff, + 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, + 0x00, 0xff, 0xff, 0xcc, 0xcc, 0xcc, 0x33, 0xcc, + 0xcc, 0xcc, 0x33, 0x33, 0xcc, 0xcc, 0xcc, 0xff, + 0xff, 0xff, 0xee, 0xff, 0xff, 0xff, 0xee, 0xee, + 0xff, 0xff, 0xff, 0xdd, 0xff, 0xff, 0xff, 0xdd, + 0xdd, 0xff, 0xff, 0xff, 0xbb, 0xff, 0xff, 0xff, + 0xbb, 0xbb, 0xff, 0xff, 0xff, 0x77, 0xff, 0xff, + 0xff, 0x77, 0x77, 0xff, 0x77, 0xbb, 0xdd, 0xee +}; + static int sd_req_crc_validate(SDRequest *req) { uint8_t buffer[5]; @@ -1603,6 +1622,26 @@ static sd_rsp_type_t sd_cmd_SEND_TUNING_BLOCK(SDStat= e *sd, SDRequest req) sizeof(sd_tuning_block_pattern4)); } =20 +/* CMD21 */ +static sd_rsp_type_t emmc_cmd_SEND_TUNING_BLOCK(SDState *sd, SDRequest req) +{ + const uint8_t *buf; + size_t size; + + if (sd->state !=3D sd_transfer_state) { + sd_invalid_state_for_cmd(sd, req); + } + + if (sd->ext_csd[EXT_CSD_BUS_WIDTH] & EXT_CSD_BUS_WIDTH_8_MASK) { + buf =3D mmc_tuning_block_pattern8; + size =3D sizeof(mmc_tuning_block_pattern8); + } else { + buf =3D sd_tuning_block_pattern4; + size =3D sizeof(sd_tuning_block_pattern4); + } + return sd_cmd_to_sendingdata(sd, req, 0, buf, size); +} + /* CMD23 */ static sd_rsp_type_t sd_cmd_SET_BLOCK_COUNT(SDState *sd, SDRequest req) { @@ -2391,6 +2430,7 @@ uint8_t sd_read_byte(SDState *sd) case 13: /* ACMD13: SD_STATUS */ case 17: /* CMD17: READ_SINGLE_BLOCK */ case 19: /* CMD19: SEND_TUNING_BLOCK (SD) */ + case 21: /* CMD21: SEND_TUNING_BLOCK (MMC) */ case 22: /* ACMD22: SEND_NUM_WR_BLOCKS */ case 30: /* CMD30: SEND_WRITE_PROT */ case 51: /* ACMD51: SEND_SCR */ @@ -2573,6 +2613,7 @@ static const SDProto sd_proto_emmc =3D { [16] =3D {2, sd_ac, "SET_BLOCKLEN", sd_cmd_SET_BLOCKLEN}, [17] =3D {2, sd_adtc, "READ_SINGLE_BLOCK", sd_cmd_READ_SINGLE_BLO= CK}, [19] =3D {0, sd_adtc, "BUSTEST_W", sd_cmd_unimplemented}, + [21] =3D {2, sd_adtc, "SEND_TUNING_BLOCK", emmc_cmd_SEND_TUNING_B= LOCK}, [23] =3D {2, sd_ac, "SET_BLOCK_COUNT", sd_cmd_SET_BLOCK_COUNT}, [24] =3D {4, sd_adtc, "WRITE_SINGLE_BLOCK", sd_cmd_WRITE_SINGLE_B= LOCK}, [26] =3D {4, sd_adtc, "PROGRAM_CID", mmc_cmd_PROGRAM_CID}, --=20 2.41.0 From nobody Mon Nov 25 00:20:59 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1719508465; cv=none; d=zohomail.com; s=zohoarc; b=iMZepszDO+ebBbbqPihcwjEgMR0sPLNKaRKybru+QOIAngErwnuCbz+q/rhVQV8Wi58xFbQaqpIC9mXI7VGXFsPIC5aO4NYsUVkFJyvK6CZk3nqVPXEKAajHMp6Oyzxnysw8Dx4Hw2j7H3zoQU2lUHzyYaJukOmSn5Sl4+LIZ1c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719508465; h=Content-Type:Content-Transfer-Encoding:Cc:Cc: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; bh=L+wEPWvr7kf9AKn0k2ofydQW0/V6lPt4e04Ilr1xeQw=; b=iZaMRSQ4nD5iTr98EXof3cr9qi7YFumQxiZGuvyIXg4bHInIOvwJktkUVYyKpVpgt/lX+sFImbSD4E7lAftnMtkwHoBpH5zx38LLedggIhTmk0F1/xBaFPkYKIpdUcBEx76QrsJFxND+0dqjnOBVSmtq7juehy0r5g0kYa2/4hU= 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+importer=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 1719508465935611.6607721852056; Thu, 27 Jun 2024 10:14:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMshQ-0007YS-8v; Thu, 27 Jun 2024 13:14:20 -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 1sMshN-000750-5D for qemu-devel@nongnu.org; Thu, 27 Jun 2024 13:14:17 -0400 Received: from mail-lf1-x12d.google.com ([2a00:1450:4864:20::12d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMshE-0002jY-RB for qemu-devel@nongnu.org; Thu, 27 Jun 2024 13:14:16 -0400 Received: by mail-lf1-x12d.google.com with SMTP id 2adb3069b0e04-52cdcd26d61so6523716e87.2 for ; Thu, 27 Jun 2024 10:14:05 -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-4256b068d53sm962875e9.22.2024.06.27.10.13.59 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 10:14:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719508444; x=1720113244; 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=L+wEPWvr7kf9AKn0k2ofydQW0/V6lPt4e04Ilr1xeQw=; b=qwuOxiGmSLB2LCy6/0mroM6vcAJyi9fyO9LMHjJElLzDPwzQryQD1B+QZ1bsPta2OU vfGtQjMG61sV80jp164frZ+HXI5iXsUY95Iw/01zrxdgMZjpjluP9p9KYdQpW9LoAq3+ d+r2S9nZiVXpXvUdBOkSpeHQTCMjn7TdUX+0RYQLSU5n5VAe5r0TGpAjfP/SoEjo523B mLj4IehunLhgcveWK6dHTihT7/X5sQitERZ4GBhCWoQCfQifkPGuMpcXSttpR6ZozIxF pdN5gYRQKzInjhCC0/fjKslMY1R9uBKyyGktiQ+Uz3CdPcTYgBsYIL6zVW+6krIBD8gV WxOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719508444; x=1720113244; 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=L+wEPWvr7kf9AKn0k2ofydQW0/V6lPt4e04Ilr1xeQw=; b=qF0w+BfexgS/46NmG35/k26vPaQWhpVCzcoO4y6Lfaf8dJa9PF9M5UDbtC+I22sKzM K7Qu7NI/QkDPCq7JFyKwwoNDcsARnNikufuAszLZuPlM5+k1muDyBo/VvqfGz7NNptde M/jiIjMTqoTs7Ru3GBzkcSbpQ+MQLfrQf//7VP4GnG7Ho7e3OzBGHdwVTW7F0M0iDU4y do6538sXvv4YtgLpSJrcfhDugN3nqOdzOzurPAXDBNG590sYxdoD3OdxnUfEmE5s0SQg lAu0ObsDo2jhX8Y9UzxfHjT2FJwTXzgbJqefELei2pZhaPzHKUakYLO+KCqc1qqPUSpd 0X4g== X-Gm-Message-State: AOJu0YxO9BH3WREkZ7EVLOfUFJ6qLc/dCCHW59FREHwORX8PWYKad2BE gSe2zA3ql6CUuXyaajLEcf0i6CSRaFmyM1hapIXQDAcmSqKNY2GaMjoYwf6hvO6OxTJouz9I55N sLuo= X-Google-Smtp-Source: AGHT+IEUo4kZjjowsGek3Ddkn8CnG2fpc7xcS2MUl3CjnybjD0PPleR4nZkmuxfTvz0gfFCV2cynig== X-Received: by 2002:ac2:5dd4:0:b0:52e:7542:f471 with SMTP id 2adb3069b0e04-52e7542f5b4mr804494e87.29.1719508444158; Thu, 27 Jun 2024 10:14:04 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Joel Stanley , Luc Michel , Francisco Iglesias , qemu-block@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Vincent Palatin , Sai Pavan Boddu , Bin Meng , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Sai Pavan Boddu , "Edgar E . Iglesias" Subject: [RFC PATCH 16/19] hw/sd/sdcard: Add mmc SWITCH function support (CMD6) Date: Thu, 27 Jun 2024 19:10:56 +0200 Message-ID: <20240627171059.84349-17-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627171059.84349-1-philmd@linaro.org> References: <20240627171059.84349-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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::12d; envelope-from=philmd@linaro.org; helo=mail-lf1-x12d.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, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1719508466203100001 From: Sai Pavan Boddu switch operation in mmc cards, updated the ext_csd register to request changes in card operations. Here we implement similar sequence but requests are mostly dummy and make no change. Implement SWITCH_ERROR if the write operation offset goes beyond length of ext_csd. Signed-off-by: Sai Pavan Boddu Signed-off-by: Edgar E. Iglesias Signed-off-by: C=C3=A9dric Le Goater Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sd.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index ae5e73175e..e7d8b9c0fb 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -625,6 +625,7 @@ static bool sd_req_rca_same(SDState *s, SDRequest req) FIELD(CSR, AKE_SEQ_ERROR, 3, 1) FIELD(CSR, APP_CMD, 5, 1) FIELD(CSR, FX_EVENT, 6, 1) +FIELD(CSR, SWITCH_ERROR, 7, 1) FIELD(CSR, READY_FOR_DATA, 8, 1) FIELD(CSR, CURRENT_STATE, 9, 4) FIELD(CSR, ERASE_RESET, 13, 1) @@ -1075,6 +1076,43 @@ static uint32_t sd_wpbits(SDState *sd, uint64_t addr) return ret; } =20 +enum { + MMC_CMD6_ACCESS_COMMAND_SET =3D 0, + MMC_CMD6_ACCESS_SET_BITS, + MMC_CMD6_ACCESS_CLEAR_BITS, + MMC_CMD6_ACCESS_WRITE_BYTE, +}; + +static void mmc_function_switch(SDState *sd, uint32_t arg) +{ + uint32_t access =3D extract32(arg, 24, 2); + uint32_t index =3D extract32(arg, 16, 8); + uint32_t value =3D extract32(arg, 8, 8); + uint8_t b =3D sd->ext_csd[index]; + + switch (access) { + case MMC_CMD6_ACCESS_COMMAND_SET: + qemu_log_mask(LOG_UNIMP, "MMC Command set switching not supported\= n"); + return; + case MMC_CMD6_ACCESS_SET_BITS: + b |=3D value; + break; + case MMC_CMD6_ACCESS_CLEAR_BITS: + b &=3D ~value; + break; + case MMC_CMD6_ACCESS_WRITE_BYTE: + b =3D value; + break; + } + + if (index >=3D 192) { + sd->card_status |=3D R_CSR_SWITCH_ERROR_MASK; + return; + } + + sd->ext_csd[index] =3D b; +} + static void sd_function_switch(SDState *sd, uint32_t arg) { int i, mode, new_func; @@ -1398,6 +1436,19 @@ static sd_rsp_type_t sd_cmd_SWITCH_FUNCTION(SDState = *sd, SDRequest req) return sd_cmd_to_sendingdata(sd, req, 0, NULL, 64); } =20 +static sd_rsp_type_t emmc_cmd_SWITCH(SDState *sd, SDRequest req) +{ + switch (sd->state) { + case sd_transfer_state: + sd->state =3D sd_programming_state; + mmc_function_switch(sd, req.arg); + sd->state =3D sd_transfer_state; + return sd_r1b; + default: + return sd_invalid_state_for_cmd(sd, req); + } +} + /* CMD7 */ static sd_rsp_type_t sd_cmd_DE_SELECT_CARD(SDState *sd, SDRequest req) { @@ -2602,6 +2653,7 @@ static const SDProto sd_proto_emmc =3D { [3] =3D {0, sd_ac, "SET_RELATIVE_ADDR", emmc_cmd_SET_RELATIVE_= ADDR}, [4] =3D {0, sd_bc, "SEND_DSR", sd_cmd_unimplemented}, [5] =3D {0, sd_ac, "SLEEP/AWAKE", emmc_cmd_sleep_awake}, + [6] =3D {10, sd_adtc, "SWITCH", emmc_cmd_SWITCH}, [7] =3D {0, sd_ac, "(DE)SELECT_CARD", sd_cmd_DE_SELECT_CARD}, [8] =3D {0, sd_adtc, "SEND_EXT_CSD", emmc_cmd_SEND_EXT_CSD}, [9] =3D {0, sd_ac, "SEND_CSD", sd_cmd_SEND_CSD}, --=20 2.41.0 From nobody Mon Nov 25 00:20:59 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1719508481; cv=none; d=zohomail.com; s=zohoarc; b=gtZp+3fjReyziDEhxXjrJc6sHhj/qQ0jcES260aaqccAlTXvFM4TfaZR/1p5UUty9Zad7dB0Nuoiy0a2yKXWdBRMHsXEa+5hnXkbeaR6N3RCMedHKMPsSYboog6FOH6tLosk1b/QLDUAuuwd4xSGMkCIDW7F5SDyFINLC4vLvHw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719508481; h=Content-Type:Content-Transfer-Encoding:Cc:Cc: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; bh=cc2phwHICPbHNDUMxZA6a+9UcWAynLl1hqKHKReAlY0=; b=EjZ4mBHSHfC6159bjIXbc03gQrEgiCJph9hpqcW4vXIBTpviE35KHJXDHqdGgZbzHAi/MjpSPBsTvWdUu3NhHrw+4oad4NI+T7EWW6Yrz3TVrLzJT0AUev0fnWi9b5AmMROUh2Xb0qLsWr8EPyjBP5Lkh0R1rxfnu5wcx/LWB/I= 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+importer=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 1719508481592526.4697755045195; Thu, 27 Jun 2024 10:14:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMshS-00083y-Qc; Thu, 27 Jun 2024 13:14:23 -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 1sMshR-0007iy-4E for qemu-devel@nongnu.org; Thu, 27 Jun 2024 13:14:21 -0400 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMshN-0002mX-MX for qemu-devel@nongnu.org; Thu, 27 Jun 2024 13:14:20 -0400 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-362f62ae4c5so1270283f8f.1 for ; Thu, 27 Jun 2024 10:14:17 -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-4256b0c1ab2sm538995e9.47.2024.06.27.10.14.10 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 10:14:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719508456; x=1720113256; 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=cc2phwHICPbHNDUMxZA6a+9UcWAynLl1hqKHKReAlY0=; b=cgOmooimKXeiKlR21K5iyurxBIgV2vY4l/oK1fIpInjlMZwsv+vc2JfI9bEcCskIHJ o/wwdklBfUwhyMBPRq3fLxnHQMJ+cPuJJo3osphY1LEsL9DFKzKq5K5rKmSmvX1iEH3b x1Enrb07d0z0hVERp7MErBCVrAfP931efbcZiT5EKqdf1EMwNnZJcbwsU3qdMsYQZOej TxNwk6uxmPxhsiVz/zEbr/Vp4jOwYfTfkOiZ4/AKIIYJqpeX/xGUU0xBMVfG6oYbpzgj nvoVCx7ik96Fk0aTDD42ECj3085sX/gWbdFqGKoCu72Xr+fvVIa99d3CnDXPl+luaohk zL+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719508456; x=1720113256; 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=cc2phwHICPbHNDUMxZA6a+9UcWAynLl1hqKHKReAlY0=; b=ACTBQWmIxVSWlVWRqr4Qiu8EsGS97YFYEe8Jjt7o6VJBvbpA24iKI+YTh2SJVhP/Io Q5DTY3Br0Ui1NfcCQkEtVOCKXaBIxHIrtnqpTpk4/+YPmyu0OZ4zOzRRP6ygGrOkLkpL jJXiqrYUeb/KTX3a3BQywEcl1azLqcnCE4xZie82R7oRrbQgJMporfhQ8DxNod4bVbJt n5ZJKOxeG0KPGluSfIqNQxajWKzfsk90MVMFbKmh31wn2axC9Sg5hJrB55525TlKKudZ XDlxnHyWSR+HwaZK2jMNBrOJM9T8oLYq+1tLFoGQ/0xqOSYWhC9Dm4z7HZxc2uAk+XKD C2zg== X-Gm-Message-State: AOJu0YxtilqMPPJh0jRCyzFyptODvxEvCyqLEkiRN0Q67lupQloQui5I S/0cT2CFUw1Vis4BjjPrpYq++NHPGhyYg8x2Deoo6rUUhMkmy65vZBXwzml3TJ+JlfuazqHuisq IDwg= X-Google-Smtp-Source: AGHT+IEON9Mfx8bpZHv52+OqFWzTyhKnkksL5/carBrrMOrKME57JHRTsJ+jUlZ9LlDiYkkwC7A6fg== X-Received: by 2002:a05:6000:b8c:b0:361:94d9:1e9f with SMTP id ffacd0b85a97d-3674176d356mr2473353f8f.7.1719508455735; Thu, 27 Jun 2024 10:14:15 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Joel Stanley , Luc Michel , Francisco Iglesias , qemu-block@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Vincent Palatin , Sai Pavan Boddu , Bin Meng , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [RFC PATCH 17/19] hw/sd/sdcard: Support boot area in emmc image Date: Thu, 27 Jun 2024 19:10:57 +0200 Message-ID: <20240627171059.84349-18-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627171059.84349-1-philmd@linaro.org> References: <20240627171059.84349-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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=philmd@linaro.org; helo=mail-wr1-x42a.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1719508482323100001 From: Joel Stanley This assumes a specially constructed image: dd if=3D/dev/zero of=3Dmmc-bootarea.img count=3D2 bs=3D1M dd if=3Du-boot-spl.bin of=3Dmmc-bootarea.img conv=3Dnotrunc dd if=3Du-boot.bin of=3Dmmc-bootarea.img conv=3Dnotrunc count=3D64 bs=3D1K cat mmc-bootarea.img obmc-phosphor-image.wic > mmc.img truncate --size 16GB mmc.img truncate --size 128MB mmc-bootarea.img For now this still requires a mtd image to load the SPL: qemu-system-arm -M tacoma-bmc -nographic \ -global driver=3Dsd-card,property=3Demmc,value=3Dtrue \ -drive file=3Dmmc.img,if=3Dsd,index=3D2 \ -drive file=3Dmmc-bootarea.img,if=3Dmtd,format=3Draw Signed-off-by: Joel Stanley Signed-off-by: C=C3=A9dric Le Goater Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/sd/sd.h | 1 + hw/sd/sd.c | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/include/hw/sd/sd.h b/include/hw/sd/sd.h index d35a839f5e..07435d2e17 100644 --- a/include/hw/sd/sd.h +++ b/include/hw/sd/sd.h @@ -132,6 +132,7 @@ struct SDCardClass { bool (*get_readonly)(SDState *sd); void (*set_cid)(SDState *sd); void (*set_csd)(SDState *sd, uint64_t size); + uint32_t (*bootpart_offset)(SDState *sd); =20 const struct SDProto *proto; }; diff --git a/hw/sd/sd.c b/hw/sd/sd.c index e7d8b9c0fb..2d49be61f6 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -783,6 +783,12 @@ static inline uint64_t sd_addr_to_wpnum(uint64_t addr) return addr >> (HWBLOCK_SHIFT + SECTOR_SHIFT + WPGROUP_SHIFT); } =20 + +static unsigned sd_boot_capacity_bytes(SDState *sd) +{ + return sd->ext_csd[EXT_CSD_BOOT_MULT] << 17; +} + static void sd_reset(DeviceState *dev) { SDState *sd =3D SD_CARD(dev); @@ -984,9 +990,40 @@ void sd_set_cb(SDState *sd, qemu_irq readonly, qemu_ir= q insert) qemu_set_irq(insert, sd->blk ? blk_is_inserted(sd->blk) : 0); } =20 +/* + * This requires a disk image that has two boot partitions inserted at the + * beginning of it. The size of the boot partitions are configured in the + * ext_csd structure, which is hardcoded in qemu. They are currently set to + * 1MB each. + */ +static uint32_t sd_emmc_bootpart_offset(SDState *sd) +{ + unsigned int access =3D sd->ext_csd[EXT_CSD_PART_CONFIG] & + EXT_CSD_PART_CONFIG_ACC_MASK; + unsigned int boot_capacity =3D sd_boot_capacity_bytes(sd); + + switch (access) { + case EXT_CSD_PART_CONFIG_ACC_DEFAULT: + return boot_capacity * 2; + case EXT_CSD_PART_CONFIG_ACC_BOOT0: + return 0; + case EXT_CSD_PART_CONFIG_ACC_BOOT0 + 1: + return boot_capacity * 1; + default: + g_assert_not_reached(); + } +} + +static uint32_t sd_bootpart_offset(SDState *sd) +{ + SDCardClass *sc =3D SD_CARD_GET_CLASS(sd); + return sc->bootpart_offset ? sc->bootpart_offset(sd) : 0; +} + static void sd_blk_read(SDState *sd, uint64_t addr, uint32_t len) { trace_sdcard_read_block(addr, len); + addr +=3D sd_bootpart_offset(sd); if (!sd->blk || blk_pread(sd->blk, addr, len, sd->data, 0) < 0) { fprintf(stderr, "sd_blk_read: read error on host side\n"); } @@ -995,6 +1032,7 @@ static void sd_blk_read(SDState *sd, uint64_t addr, ui= nt32_t len) static void sd_blk_write(SDState *sd, uint64_t addr, uint32_t len) { trace_sdcard_write_block(addr, len); + addr +=3D sd_bootpart_offset(sd); if (!sd->blk || blk_pwrite(sd->blk, addr, len, sd->data, 0) < 0) { fprintf(stderr, "sd_blk_write: write error on host side\n"); } @@ -2833,6 +2871,7 @@ static void emmc_class_init(ObjectClass *klass, void = *data) dc->realize =3D emmc_realize; sc->proto =3D &sd_proto_emmc; sc->set_csd =3D sd_emmc_set_csd; + sc->bootpart_offset =3D sd_emmc_bootpart_offset; } =20 static const TypeInfo sd_types[] =3D { --=20 2.41.0 From nobody Mon Nov 25 00:20:59 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1719508474; cv=none; d=zohomail.com; s=zohoarc; b=bNdHfbztmWN+3TFZGz2U1NFiU1t3tn3VopZcnwg5kh0s+TgHCvoxks6JpzdY2EFjGlp/oXMRyQHGO7qydqWMqYE06gmogWqqgpFJAyyLkhob3vQ+9Ar/stDBGfidbvISxKZ1pS7cE6J4k+1O8Acim+5I7BspRoYRcoRbSTcKRxU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719508474; h=Content-Type:Content-Transfer-Encoding:Cc:Cc: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; bh=avuRrMAF6rH/sTJFTAsB7oMGZ0jZuIMfuK+mEn/O+u4=; b=ENh4/P8y78phqmEWgLMG/kyIhJJfjBhNaQ8XVP77qOeSebbuuSRI4wJm4Eu8wQ7K/E1OLuuebuzRv+0zhnoPQ5AOG5P0ySopD/6DmZ0dTZuQXGyCIU3UCJjn59+Et4tODwPQljD76l+kKtg4/8wU8prcvL5FgZwSlbZECdmiyFs= 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+importer=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 1719508474940193.11577950711387; Thu, 27 Jun 2024 10:14:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMshc-0000yM-F3; Thu, 27 Jun 2024 13:14:32 -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 1sMsha-0000o1-QV for qemu-devel@nongnu.org; Thu, 27 Jun 2024 13:14:30 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMshY-0002nx-Sh for qemu-devel@nongnu.org; Thu, 27 Jun 2024 13:14:30 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-4247f36f689so58416715e9.1 for ; Thu, 27 Jun 2024 10:14:28 -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-4256b098426sm770925e9.32.2024.06.27.10.14.22 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 10:14:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719508467; x=1720113267; 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=avuRrMAF6rH/sTJFTAsB7oMGZ0jZuIMfuK+mEn/O+u4=; b=plA0Tm00Sj5yPaM0/wcvzBXoFhqjuOK6f/MjBUFMSdZdFrOhMJ3Quy/5QErr9pLLi5 lpkw38riTZvrqi6rjbpYDzTLNKGZ8K4TrsXuTpP9G0qg3TfPXQ2hzRC0+/489enMY3Bz fQ6NXrKNaaq2S5xHqDQE4jCKK+ZdQBkL2G2OWc7LTDhiYcwtVziRurhcaovA9mzLALNh MBWUDhT9Ai74Lf5t4pdUZtjAm5vKd0wem/kQdrwbgZ0eUuCMShFMXnXRsVYR8+JRRIR+ xAe+ZFYfEHK7OVOcILfopCu4HFqt8bTOlQO1L+PpiQAuPES44VnEE1Dczswc1GwB/PAN t62Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719508467; x=1720113267; 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=avuRrMAF6rH/sTJFTAsB7oMGZ0jZuIMfuK+mEn/O+u4=; b=fccAoFBtJSeOmRPv4ryIhR2tU+usnXTMrtsnzGDfdW0R706gxE9o3S/LeitrjbBCj4 wytVRMIJwi+Ry5fkmqMXwPvKEsfVMukVLW3BUGduN1nr26K8plgzPYaGRse6iHEOLdhi JhMH/LhsvLnS3N8R5lSILvY+EniLgwVh3kbtn9QgcD5ylpO85XEb+Vig5Js85ScGKW15 9o79QBSNs2WnlGcHKyq2E7QZc9ASMKrXJlex8d7H8TpM07FinmV9AEuncrWLU3XndC0a odcB9Fq2K+aJYbbZSkMuBp8prfSVb+8dRo0ubW1vqjdGFbuYxEHAsnodeu/OLcij/tz3 67Lg== X-Gm-Message-State: AOJu0YwFmftX+k0jKiHfR6F8VNkm+/OQRRa1IUzW+9kqFSyquY7AD9pt hyks9ZHTQF7Is1MXufAcm1hYHGxGHf9uQgWq5GxVovn7S35dMc4WJo4zT+Ayzm6IYRD7M9x1By2 za6Y= X-Google-Smtp-Source: AGHT+IFukD632jAS5C/FWo1BJTpZTyOyS5eDSMoz6WDOmt6b03ZazV4LWYdBdKmB6FrQYfuZ2hkj0g== X-Received: by 2002:a05:600c:5d5:b0:424:a779:b5bf with SMTP id 5b1f17b1804b1-424a779b679mr50628845e9.20.1719508467093; Thu, 27 Jun 2024 10:14:27 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Joel Stanley , Luc Michel , Francisco Iglesias , qemu-block@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Vincent Palatin , Sai Pavan Boddu , Bin Meng , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [RFC PATCH 18/19] hw/sd/sdcard: Subtract bootarea size from blk Date: Thu, 27 Jun 2024 19:10:58 +0200 Message-ID: <20240627171059.84349-19-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627171059.84349-1-philmd@linaro.org> References: <20240627171059.84349-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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=philmd@linaro.org; helo=mail-wm1-x335.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1719508476326100007 From: Joel Stanley The userdata size is derived from the file the user passes on the command line, but we must take into account the boot areas. Signed-off-by: Joel Stanley Signed-off-by: C=C3=A9dric Le Goater Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sd.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 2d49be61f6..bbf054ea1e 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -804,6 +804,10 @@ static void sd_reset(DeviceState *dev) } size =3D sect << HWBLOCK_SHIFT; =20 + if (sc->bootpart_offset) { + size -=3D sd_boot_capacity_bytes(sd) * 2; + } + sect =3D sd_addr_to_wpnum(size) + 1; =20 sd->state =3D sd_idle_state; --=20 2.41.0 From nobody Mon Nov 25 00:20:59 2024 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1719508518; cv=none; d=zohomail.com; s=zohoarc; b=bOzYO1jusTCEcE7mSMDT8/9zY42Vxwhr/li1GPpTxTpuRQjX2bCn+TRPm3v5Ampuc5d4h8+xtcOed6GgT5S4FuZGWXrGbc4LelBmdenwBJVtEb6nD6jDI9qUlvDD9c9S3zQLwtnvttM5NPVmlOCd6oQlCjV2BbAKqxUi+z7QAnE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719508518; h=Content-Type:Content-Transfer-Encoding:Cc:Cc: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; bh=wfOV4Z9kH5/WWEkygPAPJDC+UN3xtUZojvL70U9kebo=; b=gVWieZiU8nJCV2KsRRgQDO/RdPwAxBOVuWGjEeo0JAwcvckLz9fV+s1ktS+ugRdQJOYZjD74kk2qdxWN+SX2RwP5VqM6ClE9ZZdM2rZUIre1YC/IJCIut5I1Dc9C2gcRCYpY1f1GD6M80gs+KowB0BbKIHTR6qNqSRw82JU6/Po= 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+importer=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 1719508518202111.75029054498646; Thu, 27 Jun 2024 10:15:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMsiB-0001rd-PT; Thu, 27 Jun 2024 13:15:08 -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 1sMshm-0001au-Uc for qemu-devel@nongnu.org; Thu, 27 Jun 2024 13:14:45 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMshl-0002oj-7a for qemu-devel@nongnu.org; Thu, 27 Jun 2024 13:14:42 -0400 Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-36701e6c6e8so1814457f8f.1 for ; Thu, 27 Jun 2024 10:14:40 -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 ffacd0b85a97d-3674357fd08sm2514150f8f.27.2024.06.27.10.14.35 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 10:14:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719508479; x=1720113279; 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=wfOV4Z9kH5/WWEkygPAPJDC+UN3xtUZojvL70U9kebo=; b=wxYUtCb2LKDm0pv3eRppVMyfv3yNHgZJoxvKALbw3Kha7ZwjX8qulUYzwHfd/GETc1 fJJiawfM6vj0s3lO1L+6IELvh8wjbdl7bVFddmujg5WIH8gZQFsqWI4/q8wHJnbasthI MwYiohoLgDFVLOM6c3pYJ2O3fjVsH28BroGa1ERcGNvfOp5qHch5YCWgKexgl4Qyd66G xX+om+SeH+tLhRxg9dFcP4EO8wTy4zhoJyV+oMENWloHmKD56IM439mPPPKJiFqM8jbz MdmKZ5rwyno2Kx+/++WTVhcDvzgAp/XJlCU4gUU+JR5GYiC3JCOMRHkz1RZXP7gLS7oz 8NtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719508479; x=1720113279; 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=wfOV4Z9kH5/WWEkygPAPJDC+UN3xtUZojvL70U9kebo=; b=LwcjtpmsCT3JGBtAU/uKOpAis4a6PzEtddAwwSbMx+t0dp5Pb/VwtgP/HfxilG/xX5 WG296fFTYER1Arz4I8+6SfLdr1KwqLg3eheAKuIb7MBIcRzr+CcBZFfN9mnvmjkM2iFl TmlR+DEiWLYXp3SwaZkWH7A7IPJo9zckBgOWGDHJWi3deR2KEsgEGN/GgsEbGE346Cjv Wg/wRzbFqq6YlbXEzdRwaqWMDxbFhufUQW7AnnUELgZn/zEknRBtAdZgPgp5UjuqUFhl X1AeGhewTowa4jR7Sjwd89KSxZwQseummC8EdwnLwTk2wDFGHgHGrj/Cdlb9CaJZC1ai b+EQ== X-Gm-Message-State: AOJu0YysxOeZVZI5wPt6dz6/bbPr1t3hXBjatNt0YEoaerhARBGc1Wdj X9wFBhi7azbemA8cJs+ok9KWbKCZJuXM0yq1env0GvBFaWqKCV+vNM4Zxi529+B5DcmoVLJSyoj 1G4g= X-Google-Smtp-Source: AGHT+IGmgLLjOxCbmIOh7IHTnXcb5jlPJ0AMY8vhPwh32Uu0Va8H4ERz/2juGFhU+aAkZYKTzo26BQ== X-Received: by 2002:adf:e34e:0:b0:35d:ca63:4e74 with SMTP id ffacd0b85a97d-366e7a64642mr10429990f8f.70.1719508479316; Thu, 27 Jun 2024 10:14:39 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Joel Stanley , Luc Michel , Francisco Iglesias , qemu-block@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Vincent Palatin , Sai Pavan Boddu , Bin Meng , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [RFC PATCH 19/19] hw/sd/sdcard: Add boot config support Date: Thu, 27 Jun 2024 19:10:59 +0200 Message-ID: <20240627171059.84349-20-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627171059.84349-1-philmd@linaro.org> References: <20240627171059.84349-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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::431; envelope-from=philmd@linaro.org; helo=mail-wr1-x431.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1719508518450100001 From: Joel Stanley Introduced "boot-config" property to set CSD 179, the boot config register. With this correctly set we can use the enable bit to detect if partition support is enabled. Signed-off-by: Joel Stanley Signed-off-by: C=C3=A9dric Le Goater Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sd.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index bbf054ea1e..b598974bbf 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -129,6 +129,7 @@ struct SDState { uint8_t spec_version; BlockBackend *blk; bool aspeed_emmc_kludge; + uint8_t boot_config; =20 const SDProto *proto; =20 @@ -505,6 +506,8 @@ static void mmc_set_ext_csd(SDState *sd, uint64_t size) sd->ext_csd[159] =3D 0x00; /* Max enhanced area size */ sd->ext_csd[158] =3D 0x00; /* ... */ sd->ext_csd[157] =3D 0xEC; /* ... */ + + sd->ext_csd[EXT_CSD_PART_CONFIG] =3D sd->boot_config; } =20 static void sd_emmc_set_csd(SDState *sd, uint64_t size) @@ -1004,8 +1007,14 @@ static uint32_t sd_emmc_bootpart_offset(SDState *sd) { unsigned int access =3D sd->ext_csd[EXT_CSD_PART_CONFIG] & EXT_CSD_PART_CONFIG_ACC_MASK; + unsigned int enable =3D sd->ext_csd[EXT_CSD_PART_CONFIG] & + EXT_CSD_PART_CONFIG_EN_MASK; unsigned int boot_capacity =3D sd_boot_capacity_bytes(sd); =20 + if (!enable) { + return 0; + } + switch (access) { case EXT_CSD_PART_CONFIG_ACC_DEFAULT: return boot_capacity * 2; @@ -2808,6 +2817,7 @@ static Property sd_properties[] =3D { * whether card should be in SSI or MMC/SD mode. It is also up to the * board to ensure that ssi transfers only occur when the chip select * is asserted. */ + DEFINE_PROP_UINT8("boot-config", SDState, boot_config, 0x0), DEFINE_PROP_END_OF_LIST() }; =20 --=20 2.41.0