From patchwork Thu Jun 27 17:10:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 807882 Delivered-To: patch@linaro.org Received: by 2002:adf:e842:0:b0:362:4979:7f74 with SMTP id d2csp913113wrn; Thu, 27 Jun 2024 10:12:17 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU/abe+REO5UCHIjFR0C28Qbekt5IiqFg34CKV0TmXvkRlGZ6R24AZpPOOSEOU/3ueP65nX+fi9L+FLQhd5dj+p X-Google-Smtp-Source: AGHT+IHEkloYXPiq279yd+mFyFtrI8kW/0trt5XNG/8zayllCgs0ClXJQtl2LaCByu0M9SY/o0Wv X-Received: by 2002:a05:620a:4110:b0:79b:b571:4c09 with SMTP id af79cd13be357-79be47e06ffmr1677818585a.63.1719508336956; Thu, 27 Jun 2024 10:12:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719508336; cv=none; d=google.com; s=arc-20160816; b=AZ/tUe+ijsIrUlrur4W2pm+4hCebmjjlIzYuGD27Qolxi3mU+1YPfSK1rZpeL9f40r nvnA8EfquVyatF1+z1+RY1ba27w/jayizZQEyxZ4RPDLjPLBWvQ2yEmwwT3H9B/b41qw pCHDZ9VK4SkSSleEltJeaM4pfjZCWDuNPf2gTB9oNsCSF0IWEleceBT+RbH/a0O4cIXy P45stl4baZOgo0uwz/XDMAyeWIH8rkz3GCKAckf9yzjruUT0RhdB/mO7EpMa2IcPGaj2 fNM9ruBQiCoyNw1BMgKGe+eo8fmaPKy32hCfWLiF5vkwqPXECFlygAH2isMYiNK6lzlx p8eQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=DS5w/rOHX5RjJWkmyFPsFftFPu5c4nwaKlj59xhrXaU=; fh=WUqfD5CNolTLXU3odpyK/irI96uSRBSbw3kHmNv9290=; b=y1LzTx1NS8VEB6dnID7IenaWJ6YniOQGJMFN4LmIv5QQixcXWuS5XPV9ylcGtJYQWE kV0CYx9QPnmXDMah4mO4ITFXw0lnfUX3kbUbqfFawoRIG8l2EkqEjWchFcbLQ6jdaXTT 1DPrI1F1YzLjWsWgLyRWUEefE186ElC5SZm7X3snLuSxEhGxzVjeAbPXHxl1yI/38zSN XaTj4NYXSpYfxfRbiNAqk2lggV4VoraAbG4XA9vgh4e5payvf45jV6F4b7Z+Y3qMkU5g 52S2Y2G8JnRz3bYO6pQd9noxYh4HfJFn5N1vzQ1MPUX9vrGzXVgc/c0sP8p0ODJKKNfa z9lQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OLy6oP86; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-79d5c8ecc72si192136685a.691.2024.06.27.10.12.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 27 Jun 2024 10:12:16 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OLy6oP86; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Joel Stanley , Luc Michel , Francisco Iglesias , qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Vincent Palatin , Sai Pavan Boddu , Bin Meng , =?utf-8?q?C=C3=A9dric_Le_Goater?= 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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é --- 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); 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 = SD_CARD(dev); + SDCardClass *sc = SD_CARD_GET_CLASS(sd); uint64_t size; uint64_t sect; @@ -691,8 +692,8 @@ static void sd_reset(DeviceState *dev) sd->size = 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); @@ -2472,6 +2473,8 @@ static void sd_class_init(ObjectClass *klass, void *data) sc->enable = sd_enable; sc->get_inserted = sd_get_inserted; sc->get_readonly = sd_get_readonly; + sc->set_cid = sd_set_cid; + sc->set_csd = sd_set_csd; sc->proto = &sd_proto_sd; } From patchwork Thu Jun 27 17:10:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 807885 Delivered-To: patch@linaro.org Received: by 2002:adf:e842:0:b0:362:4979:7f74 with SMTP id d2csp913274wrn; Thu, 27 Jun 2024 10:12:33 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUztOVVqEs3UDUWrwtCjgGrmacfj68hFfFP0xgya3uS92yZZGCbJo63PomWeNvYK5gSGGnZa8kgnKgiF6cT6XqT X-Google-Smtp-Source: AGHT+IH3KqYzA1hdpOOtsqRjlMrhRh2Og0LWgfwBd5N+Ppb+huUDJMFUNeBEagaQOtAqU2jtzNWC X-Received: by 2002:a05:6122:4a1b:b0:4ec:f018:ee1e with SMTP id 71dfb90a1353d-4ef6a7394ebmr11801571e0c.12.1719508352954; Thu, 27 Jun 2024 10:12:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719508352; cv=none; d=google.com; s=arc-20160816; b=OaetgTOmi0lDleV+STdMlSzvSCOH6BhR4bhqv7DaS9hDIm2C0anQ1qErxhtvsneKXI ZXMDdGVr7M4GuvfXraEQiHcKypU2zbyjPgGWFH6e9fSD4GNp6s8RaCGeLjbnFB+F4X/b 7acYKewy21mEHcJqmekoY7Om6i8LmjqJ+gGMjtiPOindVsrhH2jex1pXzX0NFPtc9Raz ZrutE5BoP4WpfAsrhPwpxt7RZZv36IjV3nyHvj8p2ZIn8ZIs7lgM8o4vVcrA0NxUKTLL tYpdPC6Ipph52Uhm8FrAB0lXNLQgdvTRIsJhBqQwvAQAeTN+4Z+Ow/irJnQl+vJ/Y1tz AHfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=l5dk8XRtaZNYeklBLa17/11yculQIx4J+IHrxLfyvgU=; fh=WUqfD5CNolTLXU3odpyK/irI96uSRBSbw3kHmNv9290=; b=IWDcMATi1YHMqU5qHqhmuiirDiiNw3U85C2dLJJ7pumAy0bq7JBOK9Ul/+hxvlVo0u pqH/LeeMkF5KK/UiaMoDRn7d3o5Edr1pqHFzkpKGt3VT51cC++RwVjAZMdBpto83zIXV udsvGX+X0yS7EMC4c9P+5EgzyYUpD0MjvTLETt5JfqYr9dY/9l0wiiyzhxUXkmWopPC7 Dl8ntG1ocw7VSWTu4oJog7ooIVgNMZvJQ9xvOFauRkPpwZJ5wnVn4MGYbu9lATbvld11 FC+zjOVY25WBf4aN+VhmfXv0sA39VUX/ZQo0uH48NEy3sF4F+NezNaTocpL5CsLMQNQ6 NGGA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QrwAPP5d; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 71dfb90a1353d-4f2922874cesi22558e0c.295.2024.06.27.10.12.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 27 Jun 2024 10:12:32 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QrwAPP5d; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Joel Stanley , Luc Michel , Francisco Iglesias , qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Vincent Palatin , Sai Pavan Boddu , Bin Meng , =?utf-8?q?C=C3=A9dric_Le_Goater?= 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org So far eMMC will only use sd_sleep_state, but all all states specified for completeness. Signed-off-by: Philippe Mathieu-Daudé --- 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 { }; enum SDCardStates { + sd_waitirq_state = -2, /* emmc */ sd_inactive_state = -1, + sd_idle_state = 0, sd_ready_state = 1, sd_identification_state = 2, @@ -86,6 +88,9 @@ enum SDCardStates { sd_receivingdata_state = 6, sd_programming_state = 7, sd_disconnect_state = 8, + sd_bus_test_state = 9, /* emmc */ + sd_sleep_state = 10, /* emmc */ + sd_io_state = 15 /* sd */ }; #define SDMMC_CMD_MAX 64 @@ -205,13 +210,19 @@ static const char *sd_state_name(enum SDCardStates state) [sd_standby_state] = "standby", [sd_transfer_state] = "transfer", [sd_sendingdata_state] = "sendingdata", + [sd_bus_test_state] = "bus-test", [sd_receivingdata_state] = "receivingdata", [sd_programming_state] = "programming", [sd_disconnect_state] = "disconnect", + [sd_sleep_state] = "sleep", + [sd_io_state] = "i/o" }; if (state == sd_inactive_state) { return "inactive"; } + if (state == sd_waitirq_state) { + return "wait-irq"; + } assert(state < ARRAY_SIZE(state_name)); return state_name[state]; } From patchwork Thu Jun 27 17:10:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 807881 Delivered-To: patch@linaro.org Received: by 2002:adf:e842:0:b0:362:4979:7f74 with SMTP id d2csp913103wrn; Thu, 27 Jun 2024 10:12:16 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUfvhrTRVRwZCN2lGHkxAVGL1uidmqKi+OTSB3LTdGs1gcf/tDAx5G/8dcejRni8CAUw5bpo1W66P0dmMXy3AZP X-Google-Smtp-Source: AGHT+IETUfItRRJJVqgDMt0pL+FW/lWI4LVg1nzkFsVVXuDDeuYNrSNFwdH0PpFklKGi6kxELCR8 X-Received: by 2002:a05:620a:4049:b0:79d:59a1:fb16 with SMTP id af79cd13be357-79d59a202a3mr433440985a.39.1719508336435; Thu, 27 Jun 2024 10:12:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719508336; cv=none; d=google.com; s=arc-20160816; b=0kI40ALK0Vr8yN9tdrPPdzcdOats4y1YqGhiJUKC4hWjvgICcQ7UZSmNbQDRVpdZF+ 4OYHw3TvaIRg6SFUgh5+cunRN75DsnCMkm64EjeIqI3PiX5B5zDpYWejxErzrMaFsY34 TAc0+qD+ijEU6vR24BIvAM0XLSzNfC9hX5UDeQ82krvBv7WV5MGLVCIZ67Hft/zkhwNH wreHxYWEgS3OYZDQJmqYIUEG+dLTTwBi5d5gutkbEEoAnpYqBLMCDcoQ3skJKq8+0lVi e+drC4tKKngtQT0wq15Njhim/FgvP5UYk7hn8wpOlVvFnpHlXMDBAN4bhU9fScDDUu9t iGLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=dtkOlWWAl+ZO/rW9NaCd8yU+f3fnPw9yKybdzc1seps=; fh=WUqfD5CNolTLXU3odpyK/irI96uSRBSbw3kHmNv9290=; b=PYMxz+gv67bPyDqndgtAMRooFHY9r6HQ+QCJu9ju5QHflOvP567DxHGWqFvAKbIvob Od4JUzsnP6W5/ZQjrTIQSqxomEdaG+96752AJuYNhBNunQ6BExQhdiwR6Tk7Tf9gSPq5 ygcehUQYTizq/rgM5TciJaTiq8YlKKOyVRvqb3rcQkP4wOuiRUE8fvEfWohhHepMarS1 TWGYv/EvG35xdW+Y4juKJqA2c+E4AroZui36QK38Y3lunUyz/W2E/I58ATK8U0lkZsc3 dJx20eckOkdZTFYoy6i6FrhwN7qUxBeneg8vh2mfWoqWwBCCvTatlgvNdt1RoasE31e9 G+qA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LFxi6UZT; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-79d5c8c45besi166078085a.564.2024.06.27.10.12.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 27 Jun 2024 10:12:16 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LFxi6UZT; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Joel Stanley , Luc Michel , Francisco Iglesias , qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Vincent Palatin , Sai Pavan Boddu , Bin Meng , =?utf-8?q?C=C3=A9dric_Le_Goater?= 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Cédric Le Goater Signed-off-by: Cédric Le Goater Signed-off-by: Philippe Mathieu-Daudé --- 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) +#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 = { }, }; +static const SDProto sd_proto_emmc = { + /* Only v4.5 is supported */ + .name = "eMMC", + .cmd = { + }, +}; + static void sd_instance_init(Object *obj) { SDState *sd = SD_CARD(obj); @@ -2504,6 +2511,28 @@ static void sd_spi_class_init(ObjectClass *klass, void *data) sc->proto = &sd_proto_spi; } +static void emmc_realize(DeviceState *dev, Error **errp) +{ + SDState *sd = SD_CARD(dev); + + if (sd->spec_version == 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 = DEVICE_CLASS(klass); + SDCardClass *sc = SD_CARD_CLASS(klass); + + dc->desc = "eMMC"; + dc->realize = emmc_realize; + sc->proto = &sd_proto_emmc; +} + static const TypeInfo sd_types[] = { { .name = TYPE_SD_CARD, @@ -2519,6 +2548,11 @@ static const TypeInfo sd_types[] = { .parent = TYPE_SD_CARD, .class_init = sd_spi_class_init, }, + { + .name = TYPE_EMMC, + .parent = TYPE_SD_CARD, + .class_init = emmc_class_init, + }, }; DEFINE_TYPES(sd_types) From patchwork Thu Jun 27 17:10:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 807884 Delivered-To: patch@linaro.org Received: by 2002:adf:e842:0:b0:362:4979:7f74 with SMTP id d2csp913175wrn; Thu, 27 Jun 2024 10:12:22 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWYeVQWVNog6EIxtTj9y+ecgNEhc8WWoldFXwljVL+mubNr/J6O4U5OY1y7hhEVWNNAe+YVyVC/ZP6qHC4lE4Io X-Google-Smtp-Source: AGHT+IH5X1NVIRnV+zCVX2+vAVT+tKkEbni2YgMfjUBtvaWdN3K6jKj5933VkwzqeZnZ+XjeFaaS X-Received: by 2002:a05:6122:469f:b0:4ef:4b35:896f with SMTP id 71dfb90a1353d-4ef6d82ffb5mr13939981e0c.7.1719508341826; Thu, 27 Jun 2024 10:12:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719508341; cv=none; d=google.com; s=arc-20160816; b=kHTeJTc9RckY/s00g3Q75bJrUTX7UKkpHvkI67/XXrwMMBfqvpV1KjJKxeXsDJjTUX CVzUN0lIKhY4K2HG52hUZlF7UJ4sBBCouWbPO4//zRQNTl3gGS+xLXt7iBa3UnXtUXT1 8bKKgOtS2p0iLSpI6bH7n9VSuZ550eKl/NOCE40zrw0lew34at78WlYfMvd9ybuYp619 dP9CyIM0b2z+Rk47hmFItKZduGrcdhBZLQUsenm9RG2y9E2cOUw7qGc+bXrI5kteF4iL Enstf3OOl+2eF2M60OI/H+pbsAbxsJFRNTZOXCbNzgh5irGa+P8r+bv2wefr3TAPIFyp Eajw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=0++Ogxou44hWy9HUie+kN/Bmub/+XHfRbLoibWWU/Qg=; fh=WUqfD5CNolTLXU3odpyK/irI96uSRBSbw3kHmNv9290=; b=fuMgyniGDCqLcu48Meg9U/0pcHXm3NB+61Ix2Gq9y5pjzSCVykpP5d+PCNtCqxNT3j iXLX10x6xAxplYYCRktwFphkZ9ZSDZAaVuP4RWCbapmTTduOIcMxhl8J9zMjzQnAfZs/ pbvXMc5nw7rrDUJ04TJTvhNBe99g6WEgLTKbPTUqXl6ySNmvIxTaasu1ezALLo301SHq yFqj+dznQkcoUX7vPyy5R9VbCblAXcyR8gdntWowSsDUYDi1uDrNeDVqrSAzqStK7FSa 2Syf76V2/on+ubwwQnE90dEEftD+LokjNjwnir9xjNfetg6OCnIwB1n9JbOBf7xrNAYd UhuA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IdOqfydy; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 71dfb90a1353d-4f2922986b8si22289e0c.318.2024.06.27.10.12.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 27 Jun 2024 10:12:21 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IdOqfydy; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Joel Stanley , Luc Michel , Francisco Iglesias , qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Vincent Palatin , Sai Pavan Boddu , Bin Meng , =?utf-8?q?C=C3=A9dric_Le_Goater?= 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Philippe Mathieu-Daudé --- 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 = { /* Only v4.5 is supported */ .name = "eMMC", .cmd = { + [0] = {0, sd_bc, "GO_IDLE_STATE", sd_cmd_GO_IDLE_STATE}, + [2] = {0, sd_bcr, "ALL_SEND_CID", sd_cmd_ALL_SEND_CID}, + [7] = {0, sd_ac, "(DE)SELECT_CARD", sd_cmd_DE_SELECT_CARD}, + [9] = {0, sd_ac, "SEND_CSD", sd_cmd_SEND_CSD}, + [10] = {0, sd_ac, "SEND_CID", sd_cmd_SEND_CID}, + [12] = {0, sd_ac, "STOP_TRANSMISSION", sd_cmd_STOP_TRANSMISSION}, + [13] = {0, sd_ac, "SEND_STATUS", sd_cmd_SEND_STATUS}, + [15] = {0, sd_ac, "GO_INACTIVE_STATE", sd_cmd_GO_INACTIVE_STATE}, + [16] = {2, sd_ac, "SET_BLOCKLEN", sd_cmd_SET_BLOCKLEN}, + [17] = {2, sd_adtc, "READ_SINGLE_BLOCK", sd_cmd_READ_SINGLE_BLOCK}, + [23] = {2, sd_ac, "SET_BLOCK_COUNT", sd_cmd_SET_BLOCK_COUNT}, + [24] = {4, sd_adtc, "WRITE_SINGLE_BLOCK", sd_cmd_WRITE_SINGLE_BLOCK}, + [27] = {4, sd_adtc, "PROGRAM_CSD", sd_cmd_PROGRAM_CSD}, + [28] = {6, sd_ac, "SET_WRITE_PROT", sd_cmd_SET_WRITE_PROT}, + [29] = {6, sd_ac, "CLR_WRITE_PROT", sd_cmd_CLR_WRITE_PROT}, + [30] = {6, sd_adtc, "SEND_WRITE_PROT", sd_cmd_SEND_WRITE_PROT}, + [35] = {5, sd_ac, "ERASE_WR_BLK_START", sd_cmd_ERASE_WR_BLK_START}, + [36] = {5, sd_ac, "ERASE_WR_BLK_END", sd_cmd_ERASE_WR_BLK_END}, + [38] = {5, sd_ac, "ERASE", sd_cmd_ERASE}, + [42] = {7, sd_adtc, "LOCK_UNLOCK", sd_cmd_LOCK_UNLOCK}, + [55] = {8, sd_ac, "APP_CMD", sd_cmd_APP_CMD}, + [56] = {8, sd_adtc, "GEN_CMD", sd_cmd_GEN_CMD}, }, }; From patchwork Thu Jun 27 17:10:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 807886 Delivered-To: patch@linaro.org Received: by 2002:adf:e842:0:b0:362:4979:7f74 with SMTP id d2csp913295wrn; Thu, 27 Jun 2024 10:12:36 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWzcDJkwJQqlbPcS4m1jiSu4Y8Lqn2hJfqx0oqSajpLML7WVt2Ch/86ih8BwZ2SI5CYLjcVhAtyFPg9IgRgLJl+ X-Google-Smtp-Source: AGHT+IEatrUcS6ZD5wr9MIPGXJAL7d1n189Q9VRktnNG0Opu8aUMdoka+k5LjZQV6BpBT2oW981k X-Received: by 2002:a05:622a:143:b0:440:6139:f9c8 with SMTP id d75a77b69052e-444d93874ddmr183087501cf.54.1719508355918; Thu, 27 Jun 2024 10:12:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719508355; cv=none; d=google.com; s=arc-20160816; b=e+ZkZX2xwqb7v2c1nK4uzW7MTOyhsmEVRBxWn+1PRKRV1/q7q2cKhYdjrfQsVTZlTG fsUi/MiYpwH7I6v8TM+d8wWYqD7JOmIY4g7rzK9BPGNWQrTJ/kAVy+fbLsqApnhU+wwD jZ5CIgeZpauqO65n6sAQCHB5H9SMpiEGLJCh581ZzpOgB+yKApQXI1IQb+V9AuaNell+ 4OtzGwz2kye+UBGZkimmu8e3GGZcVZt9iZJDhRh6lOH610nto6Eadv+IjBW6VD+lPcnH ZLKHN+HRegNlU0svLcxjCJEnYkeHIBZYtZWYFyvHHugxwoAubSTfs4ASI04lYwXll3dW Maxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=UmLMWLzqSVJb3i4hpxGU8DfPCxonGkzeRg9cK3jhrKk=; fh=WUqfD5CNolTLXU3odpyK/irI96uSRBSbw3kHmNv9290=; b=EOaVvt9ZLCXbU3R8D5vxUwJUlKh9Snh0x7Ajf9ILP3W2PUDlf0fluEnmjCQsknsoku G0mQJE2kYhWSL1057vEdVT4WzvHVMOx0TKRGcqwfWxNxq1B/WRCI5kMigEQX13Zprk4Q r1AGtkzHMrod3x/fDbubtoezIt4ZU1kUtOnnAKw2m/buJs4KYlSnhZEHem/g44GWqQDK +VsSYxmyfFUJG9I6Xr2nL0JikOEGyWtaqa9QxFoTZ6QEJ1pnDt7Mf7Njfbj20tbbwjNz k/yd3NTYrdVoijPKYBmaJO7L1HBXBzLb9t+HyhMJqI69DGPJgXhHIhMz44pTou5J/3Ei rA7Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Y1A6NfH3; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-446514e3fe9si191951cf.720.2024.06.27.10.12.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 27 Jun 2024 10:12:35 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Y1A6NfH3; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Joel Stanley , Luc Michel , Francisco Iglesias , qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Vincent Palatin , Sai Pavan Boddu , Bin Meng , =?utf-8?q?C=C3=A9dric_Le_Goater?= 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Per the spec v4.5 these commands are mandatory, but we don't implement them. Signed-off-by: Philippe Mathieu-Daudé --- 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 = { .cmd = { [0] = {0, sd_bc, "GO_IDLE_STATE", sd_cmd_GO_IDLE_STATE}, [2] = {0, sd_bcr, "ALL_SEND_CID", sd_cmd_ALL_SEND_CID}, + [4] = {0, sd_bc, "SEND_DSR", sd_cmd_unimplemented}, [7] = {0, sd_ac, "(DE)SELECT_CARD", sd_cmd_DE_SELECT_CARD}, [9] = {0, sd_ac, "SEND_CSD", sd_cmd_SEND_CSD}, [10] = {0, sd_ac, "SEND_CID", sd_cmd_SEND_CID}, [12] = {0, sd_ac, "STOP_TRANSMISSION", sd_cmd_STOP_TRANSMISSION}, [13] = {0, sd_ac, "SEND_STATUS", sd_cmd_SEND_STATUS}, + [14] = {0, sd_adtc, "BUSTEST_R", sd_cmd_unimplemented}, [15] = {0, sd_ac, "GO_INACTIVE_STATE", sd_cmd_GO_INACTIVE_STATE}, [16] = {2, sd_ac, "SET_BLOCKLEN", sd_cmd_SET_BLOCKLEN}, [17] = {2, sd_adtc, "READ_SINGLE_BLOCK", sd_cmd_READ_SINGLE_BLOCK}, + [19] = {0, sd_adtc, "BUSTEST_W", sd_cmd_unimplemented}, [23] = {2, sd_ac, "SET_BLOCK_COUNT", sd_cmd_SET_BLOCK_COUNT}, [24] = {4, sd_adtc, "WRITE_SINGLE_BLOCK", sd_cmd_WRITE_SINGLE_BLOCK}, [27] = {4, sd_adtc, "PROGRAM_CSD", sd_cmd_PROGRAM_CSD}, [28] = {6, sd_ac, "SET_WRITE_PROT", sd_cmd_SET_WRITE_PROT}, [29] = {6, sd_ac, "CLR_WRITE_PROT", sd_cmd_CLR_WRITE_PROT}, [30] = {6, sd_adtc, "SEND_WRITE_PROT", sd_cmd_SEND_WRITE_PROT}, + [31] = {6, sd_adtc, "SEND_WRITE_PROT_TYPE", sd_cmd_unimplemented}, [35] = {5, sd_ac, "ERASE_WR_BLK_START", sd_cmd_ERASE_WR_BLK_START}, [36] = {5, sd_ac, "ERASE_WR_BLK_END", sd_cmd_ERASE_WR_BLK_END}, [38] = {5, sd_ac, "ERASE", sd_cmd_ERASE}, + [39] = {9, sd_ac, "FAST_IO", sd_cmd_unimplemented}, [42] = {7, sd_adtc, "LOCK_UNLOCK", sd_cmd_LOCK_UNLOCK}, + [49] = {0, sd_adtc, "SET_TIME", sd_cmd_unimplemented}, [55] = {8, sd_ac, "APP_CMD", sd_cmd_APP_CMD}, [56] = {8, sd_adtc, "GEN_CMD", sd_cmd_GEN_CMD}, }, From patchwork Thu Jun 27 17:10:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 807887 Delivered-To: patch@linaro.org Received: by 2002:adf:e842:0:b0:362:4979:7f74 with SMTP id d2csp913404wrn; Thu, 27 Jun 2024 10:12:46 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUdfO/ygaVwf4Qhhw+ke5TZtuP5fizBvi3Eqkf8+n2Pvr4wejzhYoueINGjktCRebEHt5vNldSx2UtSf/jQX8ac X-Google-Smtp-Source: AGHT+IEePOTs2ef3EZLdNsRou34/jBuT70DzSreNitjU6Ldrkdq2AjTHieRr5d/3ViigGmESmOg3 X-Received: by 2002:a0c:f051:0:b0:6b0:8789:ae2e with SMTP id 6a1803df08f44-6b5409ca388mr149855686d6.23.1719508366616; Thu, 27 Jun 2024 10:12:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719508366; cv=none; d=google.com; s=arc-20160816; b=ncG0KvuutXpHnmNjszNesR3wzUS8/zekzDzgR0jZPlV6bXFzy5BkB/cc2vs+X/4tdI fEBwD+UvZNOCCjHvSunQYt8+VnTjMJQqfIzVO/wneWUBFdzVHf2Oydhkdkaq963t2hnU FaJjiJSuyr3ZVuO8oWbqUvOQ0Pmab5Rt4FRFJejeQi/2vowNnK0bCy5mDdoQU70Pikfo YQ2ISaQd/Qrc+/6Virp1U4T8miEgV5ydz3bC40EUUXCG3Wx4ivWKqaepj0iqWWgXPpL/ eS3Q0amFduqif8vGjK3Rpx1S0shRNxeCsfDghKVG0IG2eyedfzdi4OGgXpDgSHwdfnW0 NNhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=/hWIFWqzHiq8lN1HtcaO+N2xCOE2TizGkz4ySULbbEQ=; fh=WUqfD5CNolTLXU3odpyK/irI96uSRBSbw3kHmNv9290=; b=gXo4aMzS2ZtN7Ay3M6GTBWVp08sbObpu656vmSGypMJEus9a6pw2s/AglESnKyDJkp ymjYuTPD1RaoJJmMZ+yB7wUJuRIMBxeXI8VQC0G3xQ4mFf5eR5RS0VaPsjhBd/mUWz+f 9gWOm/Z4AuZlLt9vSbB8+OEyRBeDfDz/kScljFTpkuu+oUfRq7K+4wJvgyCAx9AzXesX rNCZqBpjx1+AJ4AdkNozCLVeCfpHUB1hgM3h37hMO/8tBK9mIkz50V9hk4JQtn8mjsPf 3usXGcmb8TDe9f79w4c1EwwqSb6Y6ZDFjAeuTrhZFNL6gzaHKMIpqhm9EIN47VcSrwqr me2g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xqiLKgDN; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6b59e607529si688536d6.455.2024.06.27.10.12.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 27 Jun 2024 10:12:46 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xqiLKgDN; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Joel Stanley , Luc Michel , Francisco Iglesias , qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Vincent Palatin , Sai Pavan Boddu , Bin Meng , =?utf-8?q?C=C3=A9dric_Le_Goater?= 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Cédric Le Goater Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Cédric Le Goater Signed-off-by: Philippe Mathieu-Daudé --- 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(SDState *sd, SDRequest req) } } +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 = 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 = { .cmd = { [0] = {0, sd_bc, "GO_IDLE_STATE", sd_cmd_GO_IDLE_STATE}, [2] = {0, sd_bcr, "ALL_SEND_CID", sd_cmd_ALL_SEND_CID}, + [3] = {0, sd_ac, "SET_RELATIVE_ADDR", emmc_cmd_SET_RELATIVE_ADDR}, [4] = {0, sd_bc, "SEND_DSR", sd_cmd_unimplemented}, [7] = {0, sd_ac, "(DE)SELECT_CARD", sd_cmd_DE_SELECT_CARD}, [9] = {0, sd_ac, "SEND_CSD", sd_cmd_SEND_CSD}, From patchwork Thu Jun 27 17:10:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 807888 Delivered-To: patch@linaro.org Received: by 2002:adf:e842:0:b0:362:4979:7f74 with SMTP id d2csp913480wrn; Thu, 27 Jun 2024 10:12:56 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXonDvLPWMk8NC1qATMcQiY6v2SjeB0EVuZ95OF39tJBSKqwm9puRoZADAYi3+FpP9/knpVcQRdmc1Jziua5oKX X-Google-Smtp-Source: AGHT+IGZ8GhpHNjkovbqK+FbMId1q3+ZSRWbPpsOwHC932FRkIJ6rrHywWHXtNZlmN/sWiXwy79O X-Received: by 2002:a05:6820:283:b0:5c2:2a3d:a671 with SMTP id 006d021491bc7-5c22a3da789mr5093497eaf.8.1719508376130; Thu, 27 Jun 2024 10:12:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719508376; cv=none; d=google.com; s=arc-20160816; b=fSc/u03sib1sLMMNzOLO9aSbfUvXA1YGahN4PTeS+8xZwayHf0WFjFeTVVtzEYSPy5 qYVwyHA2rcXpWepQcrZr0YsPrPqH/XC6MZHOHRg6+OfoNGAC7Gljw8qNqu/5ojdSwXmP lg+xdcCiWCIg3wnla5vyFIvMXdUJ5IY87JWwDKUtN9fS/HW4aRxMcnA0DqGfSisB8xsp eoclXtHUn02JFNmOG/javlTx0ZcQJgBAoYzqKdFTuec94wWZykd/h+3Gw4Q7CdSdqaXJ 6gFsg0zooKVqP+8SSPrEuLk5rcifTggZXhMDWICkqioWnA8iwTjZDXErnZYj+yw1LZRW 8dNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=z9Lv5oRHhagfJkOeTGJdPKagMg6fgJmQOzE+waR1EWA=; fh=hi+Z1uczzb3Vo1qwBJMClbqKaoMhkHGylvMWIc31pRE=; b=zdiVxRUJI6V+3tyPzbfvJbvdaxfqNhmSUlYEBEHmRFxcw/rvVu7tBPBqjKZhpZ2Rc4 72gZzCprtjSqqCPirWj1wS/0C0Z3W2gqaNsHeyYm9awwgc0DWn5DoLmsk2SFvOXI3uoh epR3Z+kZbwJPPBIaXotNHwloxcfcsAsECTZ4ZLhM+JRubqklBj+p4x9VifuLJr1qgf1l NN8bre1YQnmnq6eHDPOOUrJVFuTo1irCP0p0ptNsL1QKwvGC+CBUR5cawJKgg0LejQ4+ Ll+M2Gz5FJ7A1TpDfW4ZJW3q71hruduPEsgyw3F6ePdF2b+jPmUo4pG/qzUx3+c9I4H9 n8IA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WFbFROm3; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6b59e6169a8si677606d6.562.2024.06.27.10.12.55 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 27 Jun 2024 10:12:56 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WFbFROm3; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Joel Stanley , Luc Michel , Francisco Iglesias , qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Vincent Palatin , Sai Pavan Boddu , Bin Meng , =?utf-8?q?C=C3=A9dric_Le_Goater?= , 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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édric Le Goater Signed-off-by: Philippe Mathieu-Daudé --- 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 *sd, SDRequest req) return sd_r1; } +static sd_rsp_type_t emmc_cmd_SEND_OP_COND(SDState *sd, SDRequest req) +{ + sd_ocr_powerup(sd); + return sd->state == 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 = { .name = "eMMC", .cmd = { [0] = {0, sd_bc, "GO_IDLE_STATE", sd_cmd_GO_IDLE_STATE}, + [1] = {0, sd_bcr, "SEND_OP_COND", emmc_cmd_SEND_OP_COND}, [2] = {0, sd_bcr, "ALL_SEND_CID", sd_cmd_ALL_SEND_CID}, [3] = {0, sd_ac, "SET_RELATIVE_ADDR", emmc_cmd_SET_RELATIVE_ADDR}, [4] = {0, sd_bc, "SEND_DSR", sd_cmd_unimplemented}, From patchwork Thu Jun 27 17:10:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 807890 Delivered-To: patch@linaro.org Received: by 2002:adf:e842:0:b0:362:4979:7f74 with SMTP id d2csp913619wrn; Thu, 27 Jun 2024 10:13:11 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUDC9rAd4U87X28CNoM6+8hNb2An0hMKpSiCvILU/mERsp5HzA1MUl40iZ4TzelHYf0scbRUOsSoBHfJjo6Yauf X-Google-Smtp-Source: AGHT+IGLMLrHFpgT37fhezfQWgw0c8nBcMrVtclwVQWHXSBG0sd4/0BJZxck6A12F7KTX9pHoa/W X-Received: by 2002:a05:620a:1711:b0:79d:77d:9738 with SMTP id af79cd13be357-79d077da414mr600425485a.19.1719508390886; Thu, 27 Jun 2024 10:13:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719508390; cv=none; d=google.com; s=arc-20160816; b=ZbyXGFrzzbwnzrXzaRT4du/Ze7jkw0v2IugAN6SCHUzTNl0v48WU1n3se4oTIOl+2l iM7qShmP6g+wgh3T7FUQGCfpeyHW4zmi1T8b5MNagUjTq6xyESyb/UZIj6dJHWLINvZR 7cqqnpdBWZfV2ixUnEM9KCDcqG5OXwwEWlmjK6snSpvzhSmgQ8KB7Fn/v7jPgpaMWVeF EOvrXPwgbefahwhA5uBaP4Y7kKStFu+DDsthzXzt+kTQmrvjDwTtMUM0rXjYVnAnME/T 2V/qqV9ZIE2elMfL9YAXEhOlcUYU5fYLWMLsgQQOzdlH4C63LKmnIE1l+cSbvPG8bu1T hXpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=tQQUBf2F5gPlbKVK01VAnUB30JlRnWbK2EOrpmfwvjQ=; fh=WUqfD5CNolTLXU3odpyK/irI96uSRBSbw3kHmNv9290=; b=BnC5Bmy85nbYUdJg+DDAnXE3+vFtgGptNnfh5n99fBKBKH3idaD+6iCMFCMJ4Xgcrl U6/Gld33j5dSr0xsKlVMvX4MK5S+Wouxt2AeEofSJ2AK1SkFAkF/hmzdvjq9/nWNyiGR V1AdWThNymIQ7rUMb8AXRvGWbQrrXfswR/1BDH7hE16sMTIOTOspTJozDJrrKRLJn6Cd scR+VbFhlCCe+vUYn1zzsef9u6s9q2IExFOQDXhHoOVUjBFoQnj8skzAPEuOZAy6RF7Q gfXINRatUaU52aBvzGlcVkXvb8oD9LONH0dGvBWmyCq1KDdi7H0yJWec8CHAwbiKSjIY gmDg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QHAZdY+Y; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-79d5c78a87bsi188940285a.76.2024.06.27.10.13.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 27 Jun 2024 10:13:10 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QHAZdY+Y; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMsfl-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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Joel Stanley , Luc Michel , Francisco Iglesias , qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Vincent Palatin , Sai Pavan Boddu , Bin Meng , =?utf-8?q?C=C3=A9dric_Le_Goater?= 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Cédric Le Goater The number of blocks is defined in the lower bits [15:0]. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Cédric Le Goater Signed-off-by: Philippe Mathieu-Daudé --- 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); static const SDProto sd_proto_spi; +static const SDProto sd_proto_emmc; static bool sd_is_spi(SDState *sd) { return sd->proto == &sd_proto_spi; } +static bool sd_is_emmc(SDState *sd) +{ + return sd->proto == &sd_proto_emmc; +} + static const char *sd_version_str(enum SDPhySpecificationVersion version) { static const char *sdphy_version[] = { @@ -1479,6 +1485,9 @@ static sd_rsp_type_t sd_cmd_SET_BLOCK_COUNT(SDState *sd, SDRequest req) } sd->multi_blk_cnt = req.arg; + if (sd_is_emmc(sd)) { + sd->multi_blk_cnt &= 0xffff; + } trace_sdcard_set_block_count(sd->multi_blk_cnt); return sd_r1; From patchwork Thu Jun 27 17:10:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 807891 Delivered-To: patch@linaro.org Received: by 2002:adf:e842:0:b0:362:4979:7f74 with SMTP id d2csp913753wrn; Thu, 27 Jun 2024 10:13:23 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUfrDZ8rctnJybLhzgQqBfFYnaGYlAR1JA+WyID42PhZLe/4KmsbmxWad2NcdQwuBNM+UDvA4OhEF1XJnVePLia X-Google-Smtp-Source: AGHT+IEsS/HU4dsnR59FM89pwGn6iNDhYtwn9YAW8wiGb+5XwOOsCHvhkn14cppi1XW0XDyIhDjr X-Received: by 2002:a05:6122:168a:b0:4ef:5744:483 with SMTP id 71dfb90a1353d-4ef6a5fe3e8mr14511622e0c.6.1719508403524; Thu, 27 Jun 2024 10:13:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719508403; cv=none; d=google.com; s=arc-20160816; b=Y6fhQBLgfBN0cGsBGGQ6IXaqq7J22NyjjUUjP9zk0oc+SVjBxMEJImfRpcciYcY4IM MngWnIeCFjfGnUtpqK5cLOeRNlPXrmnutoAdMYQhQyvX9aXC1/CDCE43fWiEk+qLH2JY QrLjzO/8Qs4Lk1zHOeJ1bQwuRAzjJM214n3A+XEbHugzMto7QArCndzzqjKRFyG1O5B3 4PXbNWhj/VtyjMWKCoaWLX7rNTQIyS0RoyH5Q9z7vWLjqJREBNK6RkWwkhwGF4zsgyzk 4CpMDsbbtaq+y19sHlELmxE23Wv/SKsBJvUGqe+67zi5YasJAJMORK4dPFAPuguGOSvg 72Jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=CppPyHBGnGyh+KeMhLUUfKK62hbBIjgp+PC1jB0KmHY=; fh=WUqfD5CNolTLXU3odpyK/irI96uSRBSbw3kHmNv9290=; b=yo6ISwYKR2zh1nWOv7gkk6fzFXb949ZN9O5sBC/Kn7654yfzoKihxvbYwAN8lSDsv7 wM3lJZ2GIUAE8Un0FDNNgJawgqfo3UTbp5tLyiPWdjKJsx3yf3PhNQIKE08Dt12NFjw/ s2sK3/1AibPt1/+thN7BYrZpUL39GCYZU9RpeonZs1sLwzpFeV8GNymfPSOT/Qhwcs9J R7mrKbQos5lpqfkmE54EhRlBJv2Yqmy+Vrh3DkEeEPcnZgvUZR2DrjO1ATgxCdWrm1Ci SegfkdoccRdjZhsNXNz2VNNO/hA/SpAlrpNsq02OSESPsEfp8u1LMglYD171WiQqwmQl 9zkg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Unozw+Wb; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 71dfb90a1353d-4f292265f91si26273e0c.237.2024.06.27.10.13.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 27 Jun 2024 10:13:23 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Unozw+Wb; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Joel Stanley , Luc Michel , Francisco Iglesias , qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Vincent Palatin , Sai Pavan Boddu , Bin Meng , =?utf-8?q?C=C3=A9dric_Le_Goater?= 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Philippe Mathieu-Daudé --- 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(SDState *sd, SDRequest req) return sd_cmd_to_receivingdata(sd, req, addr, sd->blk_len); } +/* 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, SDRequest req) } break; - 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 = { [19] = {0, sd_adtc, "BUSTEST_W", sd_cmd_unimplemented}, [23] = {2, sd_ac, "SET_BLOCK_COUNT", sd_cmd_SET_BLOCK_COUNT}, [24] = {4, sd_adtc, "WRITE_SINGLE_BLOCK", sd_cmd_WRITE_SINGLE_BLOCK}, + [26] = {4, sd_adtc, "PROGRAM_CID", mmc_cmd_PROGRAM_CID}, [27] = {4, sd_adtc, "PROGRAM_CSD", sd_cmd_PROGRAM_CSD}, [28] = {6, sd_ac, "SET_WRITE_PROT", sd_cmd_SET_WRITE_PROT}, [29] = {6, sd_ac, "CLR_WRITE_PROT", sd_cmd_CLR_WRITE_PROT}, From patchwork Thu Jun 27 17:10:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 807889 Delivered-To: patch@linaro.org Received: by 2002:adf:e842:0:b0:362:4979:7f74 with SMTP id d2csp913537wrn; Thu, 27 Jun 2024 10:13:02 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUq0+vDxKIxc/x7yscxp58mWM7NYgdWWBVb9QYhpRaOMPQT5smCgAtUomThzQ8MKQyHcoZYi8KQ1nQEYm7A7nXp X-Google-Smtp-Source: AGHT+IHn/Bv8Yq6MDW3zXHXfJLw2cCjR6wCreDYcbg8RmWoi5wJ/5yYFenlXVPzsuUF9kx5x2hcG X-Received: by 2002:ad4:5de8:0:b0:6b5:45bb:6b2b with SMTP id 6a1803df08f44-6b545bb6d7fmr160716526d6.51.1719508382174; Thu, 27 Jun 2024 10:13:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719508382; cv=none; d=google.com; s=arc-20160816; b=J1s/0Q2cSilC0MvLFH0Ey5f+YCrOMovF/17ye1DyNt9Aee/bJxK0IUVePjbJX3pHYx hyUIA17bITW1Z7sEK2UNQwEqF0Qbh7LEi+ReNudYRnYuhMQDzceWwDVtJL6wC16sYX5p 64DqWqxyqt9lFwnu4Y6e432lMzdcP6Ayz8OxZ4twP0qHtvROA8I41Fr85VhfeQxizzUA ufFyfVPwYt8lLBZd0ro/qiVerZbeYOnphShk77U3YT/JvRaf094HOy/33OXocndvPPlP DobuxLOZ9UWWArp8wOj7VR4oCJNIMEYmwnwgwZe7GSIpSSpAWC3Q5hILJs1RZnOIN0+l dZxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=wa9xIcQNODSrwCgxGYM1DSrbhUURwxNAmEEY/4Qlivk=; fh=WUqfD5CNolTLXU3odpyK/irI96uSRBSbw3kHmNv9290=; b=wGOJz5ILreReZ0vx+HzrLsLsOJVXafCO1vczqJ5cbNyMfi/FFUUe/jwju3anriE9qn zLDFNjjPTi4RFrVwvQa+zF+jI5TY4oIAc1jgHkqIp2VCdeJST57y1ckLedJ8kdBB8ps1 YpfXMJ9ZKWIfBvdaXR45Apk4F19YBmf6mRjUmtUCn1XqzcVIE/VKfYCyzbf3jar/r/va RJ1HZljL+0sPM5m1l1auYgWkmdk+4s3FauMUtOjZCpVJe6D87jd+KlR3rnWUYZqdOn1E abpQAtLQNTIbF1VdDMNAlUAptRmK2qNaBEf9o6qzJjvRvP6NwEPjzAgbrjZpJ5o9pfJQ Rg8Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VoFIIkGq; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6b59e5eb435si681296d6.351.2024.06.27.10.13.01 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 27 Jun 2024 10:13:02 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VoFIIkGq; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Joel Stanley , Luc Michel , Francisco Iglesias , qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Vincent Palatin , Sai Pavan Boddu , Bin Meng , =?utf-8?q?C=C3=A9dric_Le_Goater?= 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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é --- 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 = sd_idle_state; - sd_reset(DEVICE(sd)); + if (sd->state == sd_sleep_state) { + switch (req.arg) { + case 0x00000000: + case 0xf0f0f0f0: + break; + default: + return sd_r0; + } + } + if (sd->state != sd_inactive_state) { + sd->state = sd_idle_state; + sd_reset(DEVICE(sd)); + } return sd_is_spi(sd) ? sd_r1 : sd_r0; } @@ -1246,6 +1257,30 @@ static sd_rsp_type_t emmc_cmd_SET_RELATIVE_ADDR(SDState *sd, SDRequest req) } } +/* CMD5 */ +static sd_rsp_type_t emmc_cmd_sleep_awake(SDState *sd, SDRequest req) +{ + bool do_sleep = extract32(req.arg, 15, 1); + + switch (sd->state) { + case sd_sleep_state: + if (!do_sleep) { + /* Awake */ + sd->state = sd_standby_state; + } + return sd_r1b; + + case sd_standby_state: + if (do_sleep) { + sd->state = 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, SDRequest 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) != 0x0000) { @@ -1969,6 +2005,12 @@ int sd_do_command(SDState *sd, SDRequest *req, req->cmd &= 0x3f; } + if (sd->state == sd_sleep_state && req->cmd) { + qemu_log_mask(LOG_GUEST_ERROR, "SD: Card is sleeping\n"); + rtype = sd_r0; + goto send_response; + } + if (sd->card_status & CARD_IS_LOCKED) { if (!cmd_valid_while_locked(sd, req->cmd)) { sd->card_status |= ILLEGAL_COMMAND; @@ -2420,6 +2462,7 @@ static const SDProto sd_proto_emmc = { [2] = {0, sd_bcr, "ALL_SEND_CID", sd_cmd_ALL_SEND_CID}, [3] = {0, sd_ac, "SET_RELATIVE_ADDR", emmc_cmd_SET_RELATIVE_ADDR}, [4] = {0, sd_bc, "SEND_DSR", sd_cmd_unimplemented}, + [5] = {0, sd_ac, "SLEEP/AWAKE", emmc_cmd_sleep_awake}, [7] = {0, sd_ac, "(DE)SELECT_CARD", sd_cmd_DE_SELECT_CARD}, [9] = {0, sd_ac, "SEND_CSD", sd_cmd_SEND_CSD}, [10] = {0, sd_ac, "SEND_CID", sd_cmd_SEND_CID}, From patchwork Thu Jun 27 17:10:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 807892 Delivered-To: patch@linaro.org Received: by 2002:adf:e842:0:b0:362:4979:7f74 with SMTP id d2csp913750wrn; Thu, 27 Jun 2024 10:13:23 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWUJVYJ2V5Wo1Hi30HjeQI7HYNSYznfLPi+/Hn5hCcFtZj3fkfj5XKNnvExTCvoPfnzu5ZxsRTTYcJrNHZpnLUe X-Google-Smtp-Source: AGHT+IGKXgnMYefSfEoHxDBQvCVuekbP6q6QniiFw35oQhoPe7mTbE2PrEpqZc0QxdoW0HcojD+k X-Received: by 2002:a05:6122:4f97:b0:4ef:58d4:7106 with SMTP id 71dfb90a1353d-4ef6635fea5mr14160053e0c.5.1719508403415; Thu, 27 Jun 2024 10:13:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719508403; cv=none; d=google.com; s=arc-20160816; b=syJrGefzFgkEgO6Q5KUSosrcQdGM3iOHfr4Mc0KB9cPX2wLXydVDjCSEQZeKunBGuy ueMP//FmwcEBlEBMKQUSy0fhfLAWmZtaPu4R2mloJ8YjPK4rylfBfIkepsvkuKVuSNDA nA2CxmGgruiYoW1uFI4AM+V2bBQ5I/Y2S24PpQQcNo8NzFlgUlNycyf9Tcz5bP/7Mfgy ikhpF/DJODydi9Sw3xcvStrdoch/So7kFA20mOAl53IPAxEjUcFKjrE03bVQMlt8Ugcu yVWr82bjX5g++qjsZeVZ8rfLJq8m/9hYLF/te/NOWD66+1x9sKJVmVQgbFNdbrAEZCsT k8Bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=v3emiqbeR1uOJll/QBrY7vV5cW8ivGXHg4omZJGkoiU=; fh=WUqfD5CNolTLXU3odpyK/irI96uSRBSbw3kHmNv9290=; b=jFJ12BcnB/qkOKW4154Z6mEzTpu6PCy/0/TjYwOZA8tOfoykv51JkTfvLw+J5fzAPO iHivZGofAsO1pIN8jck86ipMA4vYkhU7xzwhlB/MElYYUw78ClaOaT3SNO3SMmQnYg7S fxRmJMOHl/en3X2PfwvjGWwBWr/0EmqxjmwTSZFCbBTiLngSQnIuQdaOwgjkO8Wavs83 p4EIkNZdXJic6dxGMmIgchg4+Vpc3gXBURG3w/8ueU0xHkASYacBa8JylslLLPsD0AWy haNxkSvaWlc/ZjDIVqGY5f2nPDmP3jz89f5Qbr565esC6EwPA6oofm/qUZtKNUVf5nqv Movg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=X3gA2FEq; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 71dfb90a1353d-4f29224e10esi31644e0c.182.2024.06.27.10.13.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 27 Jun 2024 10:13:23 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=X3gA2FEq; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Joel Stanley , Luc Michel , Francisco Iglesias , qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Vincent Palatin , Sai Pavan Boddu , Bin Meng , =?utf-8?q?C=C3=A9dric_Le_Goater?= 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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é --- 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 { uint8_t spec_version; BlockBackend *blk; + bool aspeed_emmc_kludge; const SDProto *proto; @@ -2567,6 +2568,8 @@ static Property sd_properties[] = { 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 From patchwork Thu Jun 27 17:10:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 807894 Delivered-To: patch@linaro.org Received: by 2002:adf:e842:0:b0:362:4979:7f74 with SMTP id d2csp914134wrn; Thu, 27 Jun 2024 10:14:05 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWud9AIrYZIuJigKCrZGI8y3Kiw5a6K3s2rBNq6Gq7mRnm4lsv+Q5fK51r0+a/568jbc90EJyooWCmrTemMpm39 X-Google-Smtp-Source: AGHT+IGLmHOiB+Gbu45HdNDQ5mgOWBzm9QH2rrJBhSihBb0JWrjXyLvwZrhac1UAUm96bftUb5KP X-Received: by 2002:a67:eb18:0:b0:48f:4bba:778c with SMTP id ada2fe7eead31-48f529a9ebfmr13813270137.8.1719508445610; Thu, 27 Jun 2024 10:14:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719508445; cv=none; d=google.com; s=arc-20160816; b=CgZDkc06tnN8fHkdJVILQVTFGDj8KDUJqQK73uxYtPYO0TMUpsf5/Tc530W8ZG90+t EFI/jWg5XeYKxd4+kLWkJGm4MOnFJg5a3DFsFdkKb2WY+fakMvfpnfLw+uEZ8HxABuoj YvtslsTUme4qGkeol0pqJNVnL5hsQQ/n3V4DEvuLSfBhyLIULwj20toTMd/YGA8TP1ke spEsW4otgH9S1+c3BKan4hY7zD7oabYIIlv+uk5qPBTRExaCUHdf3LDbCAfqk0h4qV5i sG9VNwl/EuPwJfqTFXsjWrvfUHFlTlBDQULZB2o9pe9rb6vBw8bf0NOY377JtVFItI5g TD2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=rhSRW4lnt4/3qEqJkcY7/by3NHero7LaTXmV3ByZHOM=; fh=WUqfD5CNolTLXU3odpyK/irI96uSRBSbw3kHmNv9290=; b=NeUYOwwfwQeUYdl4NU+qquN+2FVVMPMLS0+Tc+keuVcWQOmvhnJvfRAJsn5y/gf0sF bZPA+VjqxmuwoR9TeeMV18enc9is8rLQ6VJpg5Pyyp35w07i7iaRRk4QuKx1HReM4iqa 0iAIoKgFU77kZCtF3SLb05l5yFU6dX28gyR5oD7a2VED2E7qCS9VUDH4O01yUVuDwo06 oKcMue9VL3ikx6OS2P3o7+bBu5Ln0n4TqSZ/PfH7qEmalQJ16y3yAa9MmJ78oW4uQlex 9L93AdJ5zgpNUNC3UknhB4HUxxAOeDrISFKYNGHmt6xTxs2ZXmQO8AJyOgpjJrJ5m68w GhHQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pcG+9WWw; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ada2fe7eead31-48f95ba565dsi300344137.561.2024.06.27.10.14.04 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 27 Jun 2024 10:14:04 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pcG+9WWw; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Joel Stanley , Luc Michel , Francisco Iglesias , qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Vincent Palatin , Sai Pavan Boddu , Bin Meng , =?utf-8?q?C=C3=A9dric_Le_Goater?= 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Cédric Le Goater Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Cédric Le Goater [PMD: Use aspeed_emmc_kludge] Signed-off-by: Philippe Mathieu-Daudé --- 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 = sd_identification_state; return sd_r2_i; default: From patchwork Thu Jun 27 17:10:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 807893 Delivered-To: patch@linaro.org Received: by 2002:adf:e842:0:b0:362:4979:7f74 with SMTP id d2csp913886wrn; Thu, 27 Jun 2024 10:13:38 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXMjcJBkp7ABgqk/9wiR4TfdZJiVXk/pzZu6ls2EN93yjFp1AX+kDlvQoJ8835ufHcIdB2FHfu67wLvrzqPgedc X-Google-Smtp-Source: AGHT+IEiccNEUpNzKdD30Ex3igTP57P3PY1tw4jZIRWE1x+Wr6+EQJR+UxuFUWvSIYlUt4+xQyMY X-Received: by 2002:a67:fd66:0:b0:48f:19af:d2be with SMTP id ada2fe7eead31-48f4c064bd6mr15254438137.2.1719508417917; Thu, 27 Jun 2024 10:13:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719508417; cv=none; d=google.com; s=arc-20160816; b=cta2TgQm+TZ2vUud9k+XZqcOoLNnZTVrH5/gzp618McFTaeizs/ovQSijRH563pcYq LAi/0xdKetl0Sgj1Z6YE7V1j7gRbnC5smM4cy7qsJFtxDgwq9qXEf7Tqh1Dg/q22Sdef 5gpAh0JDTyn0WU6NAb7wwVxTlyaJjsydb6g7c7cGx+wStZ+vbfEuu90rpSN6tUfKR+QL m5s6nmmhK7sKkiii5WgEDbIirCsg3VK1HgVKan4djxsENZMSllhvGBvyHfDqpiLKZEa/ gjAAtqZtF0izoitFMAdLP0dln4f50PUMG73dpTboZ5aPR1/yhETqXM4dxQCU+YPT/B1D T2UA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ojivM3IaWwWzglQz4g05HwWNW+Y8YVh/DQQ1yO/B8Js=; fh=WUqfD5CNolTLXU3odpyK/irI96uSRBSbw3kHmNv9290=; b=OBy2r9jX6mHVR15xErGkZ7/UNFnujMMK20djRvrTtSjhMxSCAJLqSU0MmomVGTxU5m STTyV9AurHj9bY+SPp0E4Wa4Z2DWRPfSzm7OfASTURe6AmTbGDz74usIO2urEbq8fkbC TJkKEjADYt513pqa2rcZGXKVliaBS38o3e3+5IMe8jbQ4vtFs6Ptsg3tPHIOVjsyx5tv 7DN5fg1eBKVMSV0AuVNf82OvtDottFqDWnD+q/wY2zgGYL9a+dR7UjM5Ft4xkWAu/0yO cKBwfLHJAPg9g7txY1oUW3+agnEESLFDI7RMw6+oMK5gC/E0WpGTFSGErbhSreuZxToE 7TYw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hQD1cNMG; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ada2fe7eead31-48f8e5bd550si301602137.745.2024.06.27.10.13.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 27 Jun 2024 10:13:37 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hQD1cNMG; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Joel Stanley , Luc Michel , Francisco Iglesias , qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Vincent Palatin , Sai Pavan Boddu , Bin Meng , =?utf-8?q?C=C3=A9dric_Le_Goater?= 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Cédric Le Goater Signed-off-by: Cédric Le Goater [PMD: Use aspeed_emmc_kludge] Signed-off-by: Philippe Mathieu-Daudé --- 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, SDRequest 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) != 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, SDRequest req) sd->expecting_acmd = true; sd->card_status |= APP_CMD; - return sd_r1; + return sd->aspeed_emmc_kludge ? sd_r0 : sd_r1; } /* CMD56 */ From patchwork Thu Jun 27 17:10:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 807895 Delivered-To: patch@linaro.org Received: by 2002:adf:e842:0:b0:362:4979:7f74 with SMTP id d2csp914221wrn; Thu, 27 Jun 2024 10:14:14 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVN3pIf12zF+6xMVqas84PzOn2soOzQJNh1N3qPq7bWMuK0jSmAOKTq9vO7M7jXcyHO7KVGEBHxTBCVn90FawzI X-Google-Smtp-Source: AGHT+IEo3dl1ELJPQiJcf6D55YsEgNwwyBAX//OmE5CiczJ3NlO7vIu9+WcIB63oiFDhR+EX8JI3 X-Received: by 2002:a05:6830:120f:b0:700:cc10:56ff with SMTP id 46e09a7af769-700cc105a03mr8248284a34.34.1719508454217; Thu, 27 Jun 2024 10:14:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719508454; cv=none; d=google.com; s=arc-20160816; b=oA0HRPWNNfg+CawjzGMDfSivz76L5EtrH7/G8IfyWpsHAcwwYODYioJC3m00lNkCpf Z4CnWXaWi+kqDsHMieDdzHlp9wLQNxhW02Kuh0t/IYFpXrjFit7F5UNChCkEK1kzAxzl 6+U6gfHG3hIRYsvbJYvS4hTH2eBniZHpLMQpzaMYLMtcMPQOwH2C/7Q0yIbRQ7u0/Z0G 3wonXaXtX++Gb6ivezgku1GxlGHtG0dEIfPlWsILXcXGWVTaP43bxU3gWQiWw4ePmhYA 1R6Nsy7lyO5LUwFYNJ8J93TMpNIF/EMcZdpcspMCEcdEJBA0RzLhEoaXRmos+czC1Zcm qVhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=O1uKT3cac0wmROcR+mzv/OARkq5bGqfifIlHFoP/L2c=; fh=IOPU27vAwBVBPt2zaW+XO8o7l0J+dJ6yLR322iTOwug=; b=TceVy1tMdJh3FpmCMiWSozOg5YeHrMF6Ih2fGgMJ7ICaiLCCTOnxPn2vaMkRr3/CUR GrEKkhwzpKc6idslt5GKUZ7vPqoL9NdO4jRO1FEbluc0f2kRxgZ4Hl7YD7WcezXeyPb9 AcXRklD8Pb4Pt4hXPcjSA1U/IjTQkQA0txbA5R4LbHSGzgWS99mnwWqutUQYsik/sza/ 2BZiFmngSZxYevi6Zt0A2SSGuPRfDLY/uZ640aX3wDhnv62gDBv8pXdTQxe7bCjOvxwu TWeUDNPkj2e5zDKeGIfiOpym4W7NB3Uxm++yHnqCdDjgffD87twTmJNjyaKbAa1JK+bE mwkQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Xn3XC5qy; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ada2fe7eead31-48f92c9321dsi280073137.48.2024.06.27.10.14.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 27 Jun 2024 10:14:14 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Xn3XC5qy; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Joel Stanley , Luc Michel , Francisco Iglesias , qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Vincent Palatin , Sai Pavan Boddu , Bin Meng , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Sai Pavan Boddu , "Edgar E . Iglesias" , =?utf-8?q?C=C3=A9dric_Le_?= =?utf-8?q?Goater?= 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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édric Le Goater Signed-off-by: Sai Pavan Boddu Signed-off-by: Edgar E. Iglesias Signed-off-by: Cédric Le Goater Signed-off-by: Philippe Mathieu-Daudé --- TODO simplify params, see: https://lore.kernel.org/qemu-devel/54bc25fd-acea-44a3-b696-c261e7e9706d@kaod.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]; /* Static properties */ @@ -460,6 +461,82 @@ static const uint8_t sd_csd_rw_mask[16] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xfe, }; +static void mmc_set_ext_csd(SDState *sd, uint64_t size) +{ + uint32_t sectcount = size >> HWBLOCK_SHIFT; + + memset(sd->ext_csd, 0, sizeof(sd->ext_csd)); + + sd->ext_csd[EXT_CSD_S_CMD_SET] = 0x1; /* supported command sets */ + sd->ext_csd[EXT_CSD_HPI_FEATURES] = 0x3; /* HPI features */ + sd->ext_csd[EXT_CSD_BKOPS_SUPPORT] = 0x1; /* Background operations */ + sd->ext_csd[241] = 0xA; /* 1st initialization time after partitioning */ + sd->ext_csd[EXT_CSD_TRIM_MULT] = 0x1; /* Trim multiplier */ + sd->ext_csd[EXT_CSD_SEC_FEATURE_SUPPORT] = 0x15; /* Secure feature */ + sd->ext_csd[EXT_CSD_SEC_ERASE_MULT] = 0x96; /* Secure erase support */ + sd->ext_csd[EXT_CSD_SEC_TRIM_MULT] = 0x96; /* Secure TRIM multiplier */ + sd->ext_csd[EXT_CSD_BOOT_INFO] = 0x7; /* Boot information */ + sd->ext_csd[EXT_CSD_BOOT_MULT] = 0x8; /* Boot partition size. 128KB unit */ + sd->ext_csd[EXT_CSD_ACC_SIZE] = 0x6; /* Access size */ + sd->ext_csd[EXT_CSD_HC_ERASE_GRP_SIZE] = 0x4; /* HC Erase unit size */ + sd->ext_csd[EXT_CSD_ERASE_TIMEOUT_MULT] = 0x1; /* HC erase timeout */ + sd->ext_csd[EXT_CSD_REL_WR_SEC_C] = 0x1; /* Reliable write sector count */ + sd->ext_csd[EXT_CSD_HC_WP_GRP_SIZE] = 0x4; /* HC write protect group size */ + sd->ext_csd[EXT_CSD_S_C_VCC] = 0x8; /* Sleep current VCC */ + sd->ext_csd[EXT_CSD_S_C_VCCQ] = 0x7; /* Sleep current VCCQ */ + sd->ext_csd[EXT_CSD_S_A_TIMEOUT] = 0x11; /* Sleep/Awake timeout */ + sd->ext_csd[215] = (sectcount >> 24) & 0xff; /* Sector count */ + sd->ext_csd[214] = (sectcount >> 16) & 0xff; /* ... */ + sd->ext_csd[213] = (sectcount >> 8) & 0xff; /* ... */ + sd->ext_csd[EXT_CSD_SEC_CNT] = (sectcount & 0xff); /* ... */ + sd->ext_csd[210] = 0xa; /* Min write perf for 8bit@52Mhz */ + sd->ext_csd[209] = 0xa; /* Min read perf for 8bit@52Mhz */ + sd->ext_csd[208] = 0xa; /* Min write perf for 4bit@52Mhz */ + sd->ext_csd[207] = 0xa; /* Min read perf for 4bit@52Mhz */ + sd->ext_csd[206] = 0xa; /* Min write perf for 4bit@26Mhz */ + sd->ext_csd[205] = 0xa; /* Min read perf for 4bit@26Mhz */ + sd->ext_csd[EXT_CSD_PART_SWITCH_TIME] = 0x1; + sd->ext_csd[EXT_CSD_OUT_OF_INTERRUPT_TIME] = 0x1; + sd->ext_csd[EXT_CSD_CARD_TYPE] = 0x7; + sd->ext_csd[EXT_CSD_STRUCTURE] = 0x2; + sd->ext_csd[EXT_CSD_REV] = 0x5; + sd->ext_csd[EXT_CSD_RPMB_MULT] = 0x1; /* RPMB size */ + sd->ext_csd[EXT_CSD_PARTITION_SUPPORT] = 0x3; + sd->ext_csd[159] = 0x00; /* Max enhanced area size */ + sd->ext_csd[158] = 0x00; /* ... */ + sd->ext_csd[157] = 0xEC; /* ... */ +} + +static void sd_emmc_set_csd(SDState *sd, uint64_t size) +{ + sd->csd[0] = 0xd0; + sd->csd[1] = 0x0f; + sd->csd[2] = 0x00; + sd->csd[3] = 0x32; + sd->csd[4] = 0x0f; + if (size <= 2 * GiB) { + /* use 1k blocks */ + uint32_t csize1k = (size >> (CMULT_SHIFT + 10)) - 1; + sd->csd[5] = 0x5a; + sd->csd[6] = 0x80 | ((csize1k >> 10) & 0xf); + sd->csd[7] = (csize1k >> 2) & 0xff; + } else { /* >= 2GB : size stored in ext CSD, block addressing */ + sd->csd[5] = 0x59; + sd->csd[6] = 0x8f; + sd->csd[7] = 0xff; + sd->ocr = FIELD_DP32(sd->ocr, OCR, CARD_CAPACITY, 1); + } + sd->csd[8] = 0xff; + sd->csd[9] = 0xff; + sd->csd[10] = 0xf7; + sd->csd[11] = 0xfe; + sd->csd[12] = 0x49; + sd->csd[13] = 0x10; + sd->csd[14] = 0x00; + sd->csd[15] = (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 = HWBLOCK_SHIFT; @@ -1364,6 +1441,17 @@ static sd_rsp_type_t sd_cmd_SEND_IF_COND(SDState *sd, SDRequest req) return sd_r7; } +/* CMD8 */ +static sd_rsp_type_t emmc_cmd_SEND_EXT_CSD(SDState *sd, SDRequest req) +{ + if (sd->state != 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 = { [4] = {0, sd_bc, "SEND_DSR", sd_cmd_unimplemented}, [5] = {0, sd_ac, "SLEEP/AWAKE", emmc_cmd_sleep_awake}, [7] = {0, sd_ac, "(DE)SELECT_CARD", sd_cmd_DE_SELECT_CARD}, + [8] = {0, sd_adtc, "SEND_EXT_CSD", emmc_cmd_SEND_EXT_CSD}, [9] = {0, sd_ac, "SEND_CSD", sd_cmd_SEND_CSD}, [10] = {0, sd_ac, "SEND_CID", sd_cmd_SEND_CID}, [12] = {0, sd_ac, "STOP_TRANSMISSION", sd_cmd_STOP_TRANSMISSION}, @@ -2649,6 +2739,7 @@ static void emmc_class_init(ObjectClass *klass, void *data) dc->desc = "eMMC"; dc->realize = emmc_realize; sc->proto = &sd_proto_emmc; + sc->set_csd = sd_emmc_set_csd; } static const TypeInfo sd_types[] = { From patchwork Thu Jun 27 17:10:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 807897 Delivered-To: patch@linaro.org Received: by 2002:adf:e842:0:b0:362:4979:7f74 with SMTP id d2csp914392wrn; Thu, 27 Jun 2024 10:14:32 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUPZyj+SOVSFTZqeqW+5EMehoGJAFGp8oXlFeVbjR6BENGflsnj992OH+woy/fQkNN4T8D3XCjqhHFH9JCQYf7w X-Google-Smtp-Source: AGHT+IE3e2pYg60LK/ZCZSUblabh0z1fu0zMXfEvrzxwwycEq5PMlvvEJh65J5wRjYIiomySAQgw X-Received: by 2002:a05:622a:315:b0:444:d4b9:85c1 with SMTP id d75a77b69052e-4464279cc91mr39727041cf.14.1719508472638; Thu, 27 Jun 2024 10:14:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719508472; cv=none; d=google.com; s=arc-20160816; b=R8qxBUAnivAHw/eEwAo0QgHMG66HoxQ247/rtkcabCOzLCOjHQqCgu7tU99/QB3x+H BPMQyluRLR8dsCe9to3YWEqlz5EGY06NugYIZIBtJutOacePWJkCwp3yF69rZ+abtPz1 W6RSpuf6Zf04TDsEQAynIr2osPXeUBTCQhRFKyEYT3Xq17NYXQ8l51I+YPthr8yO6sHS v/pZZSDZ2U5Z3VXGzijiDo7pk9vKNYO/u3pdeWLUNcG63HELjClR6NdwwXsjh3y/xkzE eO1REp44czzp+1caldrtqMOOnh/yqZuX4EO3e3M7kVmS32wGLjQl6jGHKaMgU9TKf8IL el4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=SnL/FPFYEQkll60HqwiRh6fnqmVJNFRbyEObo/B5eRw=; fh=IOPU27vAwBVBPt2zaW+XO8o7l0J+dJ6yLR322iTOwug=; b=I1qGhaRSFCUtQCqBy8CKcgO+x0NG2hyiiJt0P3CudYt3COAlRS0rlWASYlJUDEydwj ATHqmS6XguxoOSuA0d/XCPKIGtFvOfjK85fUwuATgP9i+pb6S6mjxW4ImY/upGuRo9BJ dd6Cmu5g8lZSm4P1FaeoCkq9XOQ6jIeiXW4xK9ifIi2OsXt00Pya2hbXxZdZlhhhGGM6 w5tiRARyZoClSxaCyJUMsaKGeYAbmXpIj6G1OQJ9N+BodwOlFB47wkGL9LWanihW6A+A QefWUJuG6nq13SL/AlN6uabnyV8t97TQkVjHIvYAe22zhwzRQJc2CntmktwAH1LaH4Pk 96vQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="LqKrV1/8"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-4465148592fsi330011cf.313.2024.06.27.10.14.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 27 Jun 2024 10:14:32 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="LqKrV1/8"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Joel Stanley , Luc Michel , Francisco Iglesias , qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Vincent Palatin , Sai Pavan Boddu , Bin Meng , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Sai Pavan Boddu , "Edgar E . Iglesias" , =?utf-8?q?C=C3=A9dric_Le_?= =?utf-8?q?Goater?= 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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édric Le Goater Signed-off-by: Cédric Le Goater Signed-off-by: Philippe Mathieu-Daudé --- 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) +#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] = { 0xbb, 0xff, 0xf7, 0xff, 0xf7, 0x7f, 0x7b, 0xde }; +static const uint8_t mmc_tuning_block_pattern8[128] = { + 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(SDState *sd, SDRequest req) sizeof(sd_tuning_block_pattern4)); } +/* 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 != 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 = mmc_tuning_block_pattern8; + size = sizeof(mmc_tuning_block_pattern8); + } else { + buf = sd_tuning_block_pattern4; + size = 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 = { [16] = {2, sd_ac, "SET_BLOCKLEN", sd_cmd_SET_BLOCKLEN}, [17] = {2, sd_adtc, "READ_SINGLE_BLOCK", sd_cmd_READ_SINGLE_BLOCK}, [19] = {0, sd_adtc, "BUSTEST_W", sd_cmd_unimplemented}, + [21] = {2, sd_adtc, "SEND_TUNING_BLOCK", emmc_cmd_SEND_TUNING_BLOCK}, [23] = {2, sd_ac, "SET_BLOCK_COUNT", sd_cmd_SET_BLOCK_COUNT}, [24] = {4, sd_adtc, "WRITE_SINGLE_BLOCK", sd_cmd_WRITE_SINGLE_BLOCK}, [26] = {4, sd_adtc, "PROGRAM_CID", mmc_cmd_PROGRAM_CID}, From patchwork Thu Jun 27 17:10:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 807896 Delivered-To: patch@linaro.org Received: by 2002:adf:e842:0:b0:362:4979:7f74 with SMTP id d2csp914323wrn; Thu, 27 Jun 2024 10:14:25 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUpq5cnUCpD3g9cnKrG5Mh/bY1SmJ+Wv6gbcisXJ7GK3CQlwWT5Tp37XAu8r3WOqjQbx6LigdZRqvVHwpynoaiW X-Google-Smtp-Source: AGHT+IHmkjy3xXuX1Js29kgr+B4aZl0C4ILIiZ1is5vb1i8/EYDe6/moRs8cwSU/bQeIwVHzNhZA X-Received: by 2002:a05:6102:188b:b0:48f:2404:ea7d with SMTP id ada2fe7eead31-48f529e3c92mr11637009137.13.1719508465593; Thu, 27 Jun 2024 10:14:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719508465; cv=none; d=google.com; s=arc-20160816; b=H3nR4Xyf7O6ldM6w/w7Zad2isouiBrqkzCJAINv4FhoqT58vVe57MDu9/yvvbG35DC 6rJGnTTMoP5DNygSrdTG89ND9aEhFgrOpq5Oq86uhPwwr5atgEqPKz/1CUd144dr0xos 3AoGWI8+0buGr6aUFpeM8eRLWtsd43tZoVXf9jEXCuyx7LbzFQp67tKwS7JQQq/bOqbZ F0dZBprbQ6hz3oYdJM3cxoQgegFnrx3gMu4aj9kjZ+AdYRhT5kCJwCPnSxTFV+BMTTcK UA9g9jiXsBLSt37C79b6Rd0ApxBtXmzFtNqtAfVNT6KGrq8s21Q3SkJrDD3Cj0od6ZbA Hb8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=L+wEPWvr7kf9AKn0k2ofydQW0/V6lPt4e04Ilr1xeQw=; fh=hi+Z1uczzb3Vo1qwBJMClbqKaoMhkHGylvMWIc31pRE=; b=WxFXmPWQt+wBZHNGnlDr+IHgAAqmCLBv9V1agmrCz7Vz4nJAC80lpe2+lR+mBU2eBC ARM639sC1KXesojgaGRcJdgW1aZxbGugDGZ4cRlgd6WpHlwAvcVdU1+4rVfA815wp6+/ 8hSNC47/AwmdhyERryLBUkEDZ66OkvxctAsA0TgBj9b022zfoDzoCzqw8BmPVdGi6bpe YcAP24Q42tJxJjTUQmexIuYlEph7i8iShRKmCAqKKN9gpMJ7c3ZAaIAijbURMMzQLRxc UhkYJyIsdUpsN7LM7WvGKU/Ns0SwwEqGu3c2UZazdz5aKTgwYdgL7UUCDdTAprrCV4qZ gVIg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qwuOxiGm; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ada2fe7eead31-48f8e5be6dbsi271706137.780.2024.06.27.10.14.25 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 27 Jun 2024 10:14:25 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qwuOxiGm; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Joel Stanley , Luc Michel , Francisco Iglesias , qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Vincent Palatin , Sai Pavan Boddu , Bin Meng , =?utf-8?q?C=C3=A9dric_Le_Goater?= , 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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édric Le Goater Signed-off-by: Philippe Mathieu-Daudé --- 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; } +enum { + MMC_CMD6_ACCESS_COMMAND_SET = 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 = extract32(arg, 24, 2); + uint32_t index = extract32(arg, 16, 8); + uint32_t value = extract32(arg, 8, 8); + uint8_t b = 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 |= value; + break; + case MMC_CMD6_ACCESS_CLEAR_BITS: + b &= ~value; + break; + case MMC_CMD6_ACCESS_WRITE_BYTE: + b = value; + break; + } + + if (index >= 192) { + sd->card_status |= R_CSR_SWITCH_ERROR_MASK; + return; + } + + sd->ext_csd[index] = 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); } +static sd_rsp_type_t emmc_cmd_SWITCH(SDState *sd, SDRequest req) +{ + switch (sd->state) { + case sd_transfer_state: + sd->state = sd_programming_state; + mmc_function_switch(sd, req.arg); + sd->state = 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 = { [3] = {0, sd_ac, "SET_RELATIVE_ADDR", emmc_cmd_SET_RELATIVE_ADDR}, [4] = {0, sd_bc, "SEND_DSR", sd_cmd_unimplemented}, [5] = {0, sd_ac, "SLEEP/AWAKE", emmc_cmd_sleep_awake}, + [6] = {10, sd_adtc, "SWITCH", emmc_cmd_SWITCH}, [7] = {0, sd_ac, "(DE)SELECT_CARD", sd_cmd_DE_SELECT_CARD}, [8] = {0, sd_adtc, "SEND_EXT_CSD", emmc_cmd_SEND_EXT_CSD}, [9] = {0, sd_ac, "SEND_CSD", sd_cmd_SEND_CSD}, From patchwork Thu Jun 27 17:10:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 807899 Delivered-To: patch@linaro.org Received: by 2002:adf:e842:0:b0:362:4979:7f74 with SMTP id d2csp914467wrn; Thu, 27 Jun 2024 10:14:41 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUdp+vtzxonS1us2iw7R/W8RKozJ1Tt0wEJcVO/MC2qtQd95/JNfuom6+mVWC2TYjbM5M5KrpIpVk08OPzxRpO8 X-Google-Smtp-Source: AGHT+IHQoK95cQJal13zp6yXlw2cNkPHEAUkKoCSpryzDyJKGyHDhl3W1em5Xb0oiEpBcOYEul5S X-Received: by 2002:ac8:594a:0:b0:444:a454:8922 with SMTP id d75a77b69052e-444d91a467emr147528121cf.27.1719508481170; Thu, 27 Jun 2024 10:14:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719508481; cv=none; d=google.com; s=arc-20160816; b=cXXr/qMB6nEVRjHnEZ2Hvt7WrMyiqQb1vyLid5IL58bOoClP3Ii95B9iDt6qwUAjK/ TyML6UCMpSaOvP/qZhSn1HcVXWpK03k0yRgi54jKMDOfP/ryqd+KZ5l0eq9zTBZwpcgC h0H7SVBxJSDPg5ME1gVCyIjtpshx4QsJ9lixQQlbIScAWrra2zWD6hvjXo6QIQ1oeunv ILVRSUe7rTkuuviVUzRlLj5BLaMI68s9t5rqmOdjI67nZ56N8U09DEbTpd/plmCobKLL sp2xd3B00z5qltlL0JNsMhsQOnRJsb4oupJ7YNnWhF45UPy9QYrYe+pf53mnxewwT+3S z+CA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=cc2phwHICPbHNDUMxZA6a+9UcWAynLl1hqKHKReAlY0=; fh=WUqfD5CNolTLXU3odpyK/irI96uSRBSbw3kHmNv9290=; b=qYRSw+/cFwhr0dfyOwNGL7xh6E1DI38ZL4x0KTyiDuS6/6/QRtapVRfCe0K3tX0+Jc 1sAkOpWySZDQ/ejFJArxGOLflpdS7DsXswXp1+qjheEizr08XILpkoHjxUO1M7viiath ZSVmPassagnRn4lfQmNNzCMdVfXNL9cMsEX/8ngZYMxFvAgT+y4NR4iU1sZsV/oA1FLY HuQM6Rdsut35c6vIAsoV5cgJdb4yW2xmIKvYiqBcT6u4G70bjPsEWQ32y0lLEnEJJHnD s4jmWAw7ksuoKNX3O5xmdNPn5+ts96m3GGpKfc1VlTuS5VnHYRwfWtQKhAkblHNVr9O4 h6aw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cgOmooim; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-446513df7bfsi423711cf.194.2024.06.27.10.14.40 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 27 Jun 2024 10:14:41 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cgOmooim; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Joel Stanley , Luc Michel , Francisco Iglesias , qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Vincent Palatin , Sai Pavan Boddu , Bin Meng , =?utf-8?q?C=C3=A9dric_Le_Goater?= 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Joel Stanley This assumes a specially constructed image: dd if=/dev/zero of=mmc-bootarea.img count=2 bs=1M dd if=u-boot-spl.bin of=mmc-bootarea.img conv=notrunc dd if=u-boot.bin of=mmc-bootarea.img conv=notrunc count=64 bs=1K 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=sd-card,property=emmc,value=true \ -drive file=mmc.img,if=sd,index=2 \ -drive file=mmc-bootarea.img,if=mtd,format=raw Signed-off-by: Joel Stanley Signed-off-by: Cédric Le Goater Signed-off-by: Philippe Mathieu-Daudé --- 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); 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); } + +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 = SD_CARD(dev); @@ -984,9 +990,40 @@ void sd_set_cb(SDState *sd, qemu_irq readonly, qemu_irq insert) qemu_set_irq(insert, sd->blk ? blk_is_inserted(sd->blk) : 0); } +/* + * 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 = sd->ext_csd[EXT_CSD_PART_CONFIG] & + EXT_CSD_PART_CONFIG_ACC_MASK; + unsigned int boot_capacity = 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 = 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 += 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, uint32_t len) static void sd_blk_write(SDState *sd, uint64_t addr, uint32_t len) { trace_sdcard_write_block(addr, len); + addr += 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 = emmc_realize; sc->proto = &sd_proto_emmc; sc->set_csd = sd_emmc_set_csd; + sc->bootpart_offset = sd_emmc_bootpart_offset; } static const TypeInfo sd_types[] = { From patchwork Thu Jun 27 17:10:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 807898 Delivered-To: patch@linaro.org Received: by 2002:adf:e842:0:b0:362:4979:7f74 with SMTP id d2csp914411wrn; Thu, 27 Jun 2024 10:14:34 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVX8gNfYGFCrJyHjVR4CJQy182xXvNGMSt5WZNTOamR6SqFKjAXkBeo4anOetUKa0VfJMavFdJrJBGXiKM2VUzZ X-Google-Smtp-Source: AGHT+IGhjENaJD4E/275XcI9A6Y0Sy/OYgLeDbAdeOlapwUZPh6ZD7ZUQpcZl5vbTY7Ng1Kjrjks X-Received: by 2002:a0c:c241:0:b0:6b5:5485:dec9 with SMTP id 6a1803df08f44-6b55485e022mr117971396d6.62.1719508474367; Thu, 27 Jun 2024 10:14:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719508474; cv=none; d=google.com; s=arc-20160816; b=owmjWwlM76JvDOj0icgjbOImBuDDLikR13a1lmKHT2ICv+meX9fXhGTmqOrft8Mpb+ 8xNJs7DSrBGunczfbYUtDexssf2U4OUy+0n6/x6L7Hs4O1BUsB8fMssYqqQi5/lpB1Wn tIhTnQqD8Kq8AaV5IlNq2tZJX52GyOFW4/KhGh2U9gMZWpc0+Uf9uDG7lySZMZ/UkBMt AUOx144g1jvXNcE827evHomBlunD+BjyckEQGh7nyYjKJN+KXFiSzCYPgXzUfWG9weez gcxACtZ5ptLIwR/I/4REWpm8tqwKjEa3VmeDhDFanEjaRNWa+tKTaIzZ+Ap/OyHaXbBu ZlfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=avuRrMAF6rH/sTJFTAsB7oMGZ0jZuIMfuK+mEn/O+u4=; fh=WUqfD5CNolTLXU3odpyK/irI96uSRBSbw3kHmNv9290=; b=CPYSW+7FS3MpOSYAXTOrTHXtvhANSvCIsspDUGWQq2PVHfzmVWlHZtG8oZTifJAbvs 9dPK0to2V8iiZhLCuWeFEKYdEM6WPyGlAFKVbEWr2kzWbdc+zBM2D2QQT7MeR3W2W0L/ +acwoUpq/vIZpw9z48Aqt0SLLNL4DGe9+tIyL9vF3xSQiLVIyzbUUGjiW4GJi9uCu6rI Wz1wnjXBhRUo3jArRcjTiRLXd9icJWHQxTLAGf78m86OZv+BtDdGtXLK9eE1iDyEeFjd 6BidTZfbgLQErlHEJDs3UwnpHdP84Biq5E7XwCPsCLiXY5lSrAYnJeZmnaqii5u1NyK8 Rfdw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=plA0Tm00; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6b59e5ad55dsi764666d6.207.2024.06.27.10.14.34 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 27 Jun 2024 10:14:34 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=plA0Tm00; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Joel Stanley , Luc Michel , Francisco Iglesias , qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Vincent Palatin , Sai Pavan Boddu , Bin Meng , =?utf-8?q?C=C3=A9dric_Le_Goater?= 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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édric Le Goater Signed-off-by: Philippe Mathieu-Daudé --- 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 = sect << HWBLOCK_SHIFT; + if (sc->bootpart_offset) { + size -= sd_boot_capacity_bytes(sd) * 2; + } + sect = sd_addr_to_wpnum(size) + 1; sd->state = sd_idle_state; From patchwork Thu Jun 27 17:10:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 807900 Delivered-To: patch@linaro.org Received: by 2002:adf:e842:0:b0:362:4979:7f74 with SMTP id d2csp914760wrn; Thu, 27 Jun 2024 10:15:17 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUNknuw7/80t4BkG8raeT4ECa3y57OVU/n0XeK++NvGnIT14JN8SRWVYibzhOAd01cEVmyzQJjB78siQDBZRMCl X-Google-Smtp-Source: AGHT+IFRZWvK/9xWzDoKio6ZQ96hb8ozFwVulryHO+QP336NWgdmdFo0I8Ua2OWm3EnNl3rMnByX X-Received: by 2002:a05:6122:1790:b0:4ed:145:348f with SMTP id 71dfb90a1353d-4ef6d8ad6cfmr14419522e0c.12.1719508517078; Thu, 27 Jun 2024 10:15:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719508517; cv=none; d=google.com; s=arc-20160816; b=jj+5nrLjZuSnFic0HlD4RljHr3EnVU4WuUuCyzh6RQBBKWxhcPpY9iYei91Pdt7HNO rjMkYL1tOoKd02m14h1fV5m0xrqhZtgoPWEx2b7ijMCxpiOpC4HlrahgoWE74F3ecspP QU/+JseKl9pPYEA9po7YAfFvnH5bJJ0VO2h0smpQLZtGY3Z3CeY/I5KR1MqfhJ4z7SRq yntqntPnDbcKJIjZ8mIPX6Yz6InP9tMV3qqv9/kxJWMIN2qjGGJ2uk5w3+KtzeK039Zt VK7Ajo8AM5+apyp5z2HJ+i5et7rD4x4FXvJ3Dfy8h/74cAqjROpPeBqq9HY3hLOQT5q6 VSsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=wfOV4Z9kH5/WWEkygPAPJDC+UN3xtUZojvL70U9kebo=; fh=WUqfD5CNolTLXU3odpyK/irI96uSRBSbw3kHmNv9290=; b=RHB6yKrl+/eoajOhqx8WJqDBs8wPUq6Y358Vzpm9odVPZewJhkGILWwMseuZ/yAwiz Cu/CuN7+yLzIpULkSzwnFrfG9CPHoGyGgCmyAdYtAi1+6F/1UY9bfGAovYCZKm6Qe09P 7mNuAkmW7qkSgmR78Y4jQRFXosYeKT32BEE+6GcAmzQ7Yu/qw9HP872Lj4ClLS31iQb+ pKW7hvUvafUWJSGhvw/N0UIAmnD5f5arYF2oXF+dHUZGmXViA2CUqvhxw2q1hM7oBCK5 o/SDkuAsVxB22bTk/hzao1JtVNY1cwjVI+cR8jLtaglGXTB4kPex+Fon6Nb/uUjOkt/w 6BWA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wxYUtCb2; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 71dfb90a1353d-4f291cf91e5si32999e0c.53.2024.06.27.10.15.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 27 Jun 2024 10:15:17 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wxYUtCb2; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Joel Stanley , Luc Michel , Francisco Iglesias , qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Vincent Palatin , Sai Pavan Boddu , Bin Meng , =?utf-8?q?C=C3=A9dric_Le_Goater?= 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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édric Le Goater Signed-off-by: Philippe Mathieu-Daudé --- 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; const SDProto *proto; @@ -505,6 +506,8 @@ static void mmc_set_ext_csd(SDState *sd, uint64_t size) sd->ext_csd[159] = 0x00; /* Max enhanced area size */ sd->ext_csd[158] = 0x00; /* ... */ sd->ext_csd[157] = 0xEC; /* ... */ + + sd->ext_csd[EXT_CSD_PART_CONFIG] = sd->boot_config; } 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 = sd->ext_csd[EXT_CSD_PART_CONFIG] & EXT_CSD_PART_CONFIG_ACC_MASK; + unsigned int enable = sd->ext_csd[EXT_CSD_PART_CONFIG] & + EXT_CSD_PART_CONFIG_EN_MASK; unsigned int boot_capacity = sd_boot_capacity_bytes(sd); + 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[] = { * 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() };