From patchwork Tue Jul 9 15:25:38 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: 811443 Delivered-To: patch@linaro.org Received: by 2002:adf:ee12:0:b0:367:895a:4699 with SMTP id y18csp345317wrn; Tue, 9 Jul 2024 08:27:01 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWXnqGQYrWfhe8jrKNeWVfmTAOHWGDWv33wbz8Pp5FaXNrE2vNXlUrZmd3+MRMtBty84x/6ibNr9t4SrrMxKZ8v X-Google-Smtp-Source: AGHT+IHV0B64X3xNhhd5RN6Sp6qeahfokxLvf8TZ+l+mqlAUoHVd9qRfDbb8YkGv8jIeO5x2OuH6 X-Received: by 2002:a05:6102:cca:b0:48f:92de:ddec with SMTP id ada2fe7eead31-490321a40f7mr3191075137.19.1720538821135; Tue, 09 Jul 2024 08:27:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720538821; cv=none; d=google.com; s=arc-20160816; b=C6S/A1WDE/NBKDXoyse+QbGp252bmpBSaUkejr4Gd6u3sft8I6KqXuE8HrtR9asXv0 3LJtoJUCa4HfSGqWsessCy7D5TFmONFGvr/bmRaGUGhTcFTxmQhXno/zw/s5f6HwwIhF +IRCU1ODkwPk4RcvSau+h5iPqPR3o8qNN7BiaE4/q3nto7H4n1Xd0mkg06SMvwaV1glx fs1xm5FbenTPDMzOzvBSlPPTRwPiepkzq4rSzygH0q7N0eHkzje1DRFvfQIiORYqkNdH xyXuel++IN47H3T/DaEFJ7aeAijRubOGc2qXDOTlQRlcPYIspvNzqu8L0qJjoOyju58B Ciow== 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=Qg1OvvbVnYB9NkPyvKNWOuJA/h7PKPgrnxpR3YQLVd8=; fh=MYHLfIjJ6Hvx7rPuopPO2Khw7ypziP9+A2jw2XPCPDM=; b=KopHyaBCb3oDu5vclPHqafZWb8QfX1oJ86gIS6yihbId47o3j5U32VWc97SGvu4Bxq UViNJXCeO34wbAOxcIJiXXwUtqvY8iIQiOBCO9kQK8q3kocV7w7489vUtiprQYpgfUmt URDHYWwQYn4ydieokbORzraclRgfod2Dh5cGx+efCvseMSVtEdZ/Cs394K4tHroDbdHD C47sXN/OJNlRjbIZfmk3WVkk6WY4mSMJ7BCOGSAu8gOx2LAyXQ4B0fcvMWDHRieaqAnw SI97uDw3e0JBREcLPPcVq4JlFn0FKnPbU/dYe5InpmUjcROiOaUIRW+QkRaGg+mpVf0m bXCQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qe79qGCD; 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-490317180dcsi315429137.388.2024.07.09.08.27.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Jul 2024 08:27:01 -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=qe79qGCD; 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 1sRCjQ-00030D-1t; Tue, 09 Jul 2024 11:26:16 -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 1sRCjN-0002sz-Fm for qemu-devel@nongnu.org; Tue, 09 Jul 2024 11:26:13 -0400 Received: from mail-lj1-x233.google.com ([2a00:1450:4864:20::233]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sRCjK-0006Bb-Iy for qemu-devel@nongnu.org; Tue, 09 Jul 2024 11:26:13 -0400 Received: by mail-lj1-x233.google.com with SMTP id 38308e7fff4ca-2eea7e2b0e6so30248081fa.3 for ; Tue, 09 Jul 2024 08:26:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720538768; x=1721143568; 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=Qg1OvvbVnYB9NkPyvKNWOuJA/h7PKPgrnxpR3YQLVd8=; b=qe79qGCD1MrbcMPa5Gab6KXm3Nom68m4Ba/FUfPkxD7HRbaDMnBpmf71NCmQsMPoaj Em3nKRdpmg4bPTlFPRbRj80Z7OfYIHDFpHlxu612pdUb3Sw1LeV2x0KkEu5VuM/Oszim jycivY+2dXA4noodsz11gZrjS4gnMkGuORWQqzc1xORX7c/uf5gDmxiOYyqU3uX7H4Ls 3bGHS+tcrTODHJRjROmtEts6eA+lO/ZJyiGMRn5MkiKp1JFlnNR6OziIn8f9yZmECK2u ELYneF1zN0D1ZqUSlsP7BmwTFGW4UfsQ3Cnhjz5Gb4Av2vDRU6lvn0ZD20OfG3imsJ+R s91g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720538768; x=1721143568; 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=Qg1OvvbVnYB9NkPyvKNWOuJA/h7PKPgrnxpR3YQLVd8=; b=DQqTKTqnqAzI+PEcgi5jS4xnlIp3zSUO4/qLhSEeVvN1FDqXI+j+6FWl/NYDt46nCU ksT68T+t6JKnUeA7bNjMkL4AuZ5wk2dgepKKFvv0I/r4QGDCv+dtcHjnNf1Fzdy7Jslg 7Aueicf+eYeAq1ilnrSzM46zAvIKBD9KrOiwaStGolIor8oKeV9T+rQ+iXB2GWmiNQWq A+z/fNZ1VklQDQsLx1QScyA/RppMpxANTYQ4jwlF3X+X0YAa7vr94UH6UKqgT5i89vTE m/FR99dfw5DMBr15H31gyrEjIksZZEVbSHt2IcvKCrT/Jclxe28lL47y/Ed7fQlql7/H TzDw== X-Gm-Message-State: AOJu0YxcTi5W10mpTR63o4O96fp5ZYIE+TcL4kcRMQhtVivMBkJahPOd Fr/HHd3qXWD2EZntRehhs8tXJYZ6oEKC5jhw3km4it8BQFViZthYe45G+EG04je06h201ramoqk q X-Received: by 2002:a2e:3014:0:b0:2ec:543f:6013 with SMTP id 38308e7fff4ca-2eeb30d9814mr18582841fa.13.1720538766585; Tue, 09 Jul 2024 08:26:06 -0700 (PDT) Received: from m1x-phil.lan (vau06-h02-176-184-43-20.dsl.sta.abo.bbox.fr. [176.184.43.20]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4266f6f5f25sm46032035e9.26.2024.07.09.08.26.04 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 09 Jul 2024 08:26:06 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Peter Maydell , Andrew Jeffery , qemu-block@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= , Bin Meng , Joel Stanley , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , Jamin Lin , Steven Lee , Troy Lee , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v47 01/19] hw/sd/sdcard: Basis for eMMC support Date: Tue, 9 Jul 2024 17:25:38 +0200 Message-ID: <20240709152556.52896-2-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240709152556.52896-1-philmd@linaro.org> References: <20240709152556.52896-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::233; envelope-from=philmd@linaro.org; helo=mail-lj1-x233.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: Philippe Mathieu-Daudé Add basis for supporting eMMC. Since eMMC are soldered on boards, it is not user-creatable. Currently TYPE_EMMC is just a stub, so disabled (marked abstract). RCA register is initialized to 1, per spec v4.3, chapter 8.5 "RCA register": The default value of the RCA register is 0x0001. The value 0x0000 is reserved to set all cards into the Stand-by State with CMD7. Signed-off-by: Philippe Mathieu-Daudé Signed-off-by: Cédric Le Goater Signed-off-by: Philippe Mathieu-Daudé --- include/hw/sd/sd.h | 3 +++ hw/sd/sd.c | 50 +++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 52 insertions(+), 1 deletion(-) 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 d6a07f0ade..91a73aea8d 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -2,6 +2,8 @@ * SD Memory Card emulation as defined in the "SD Memory Card Physical * layer specification, Version 2.00." * + * eMMC emulation defined in "JEDEC Standard No. 84-A43" + * * Copyright (c) 2006 Andrzej Zaborowski * Copyright (c) 2007 CodeSourcery * Copyright (c) 2018 Philippe Mathieu-Daudé @@ -169,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[] = { @@ -697,7 +705,7 @@ static void sd_reset(DeviceState *dev) sd->state = sd_idle_state; /* card registers */ - sd->rca = 0x0000; + sd->rca = sd_is_emmc(sd) ? 0x0001 : 0x0000; sd->size = size; sd_set_ocr(sd); sd_set_scr(sd); @@ -2375,6 +2383,13 @@ static const SDProto sd_proto_sd = { }, }; +static const SDProto sd_proto_emmc = { + /* Only v4.3 is supported */ + .name = "eMMC", + .cmd = { + }, +}; + static void sd_instance_init(Object *obj) { SDState *sd = SDMMC_COMMON(obj); @@ -2446,6 +2461,15 @@ static void sd_realize(DeviceState *dev, Error **errp) } } +static void emmc_realize(DeviceState *dev, Error **errp) +{ + SDState *sd = SDMMC_COMMON(dev); + + sd->spec_version = SD_PHY_SPECv3_01_VERS; /* Actually v4.3 */ + + sd_realize(dev, errp); +} + static Property sdmmc_common_properties[] = { DEFINE_PROP_DRIVE("drive", SDState, blk), DEFINE_PROP_END_OF_LIST() @@ -2457,6 +2481,10 @@ static Property sd_properties[] = { DEFINE_PROP_END_OF_LIST() }; +static Property emmc_properties[] = { + DEFINE_PROP_END_OF_LIST() +}; + static void sdmmc_common_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); @@ -2509,6 +2537,20 @@ static void sd_spi_class_init(ObjectClass *klass, void *data) sc->proto = &sd_proto_spi; } +static void emmc_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(klass); + SDCardClass *sc = SDMMC_COMMON_CLASS(klass); + + dc->desc = "eMMC"; + dc->realize = emmc_realize; + device_class_set_props(dc, emmc_properties); + /* Reason: Soldered on board */ + dc->user_creatable = false; + + sc->proto = &sd_proto_emmc; +} + static const TypeInfo sd_types[] = { { .name = TYPE_SDMMC_COMMON, @@ -2530,6 +2572,12 @@ static const TypeInfo sd_types[] = { .parent = TYPE_SD_CARD, .class_init = sd_spi_class_init, }, + { + .name = TYPE_EMMC, + .parent = TYPE_SDMMC_COMMON, + .class_init = emmc_class_init, + .abstract = true, /* FIXME: Remove once model fully functional */ + }, }; DEFINE_TYPES(sd_types) From patchwork Tue Jul 9 15:25:39 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: 811440 Delivered-To: patch@linaro.org Received: by 2002:adf:ee12:0:b0:367:895a:4699 with SMTP id y18csp345306wrn; Tue, 9 Jul 2024 08:27:00 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUxK7bQCr3HLQqwaISFqcN7orXx1g3xyXmnuacH7QAyiLMq1gjkjA25+ByW6qzJ47PBzot+Hi/hhLqVGk0Hjmcs X-Google-Smtp-Source: AGHT+IFucprsFGtgTbyDOBeLo/9Q5ZnNos86WdKmJ/SvL2O38MWc2CFTQ5dK43z2WpZzqBf80yxj X-Received: by 2002:a81:9113:0:b0:644:2639:8645 with SMTP id 00721157ae682-658ef24b7admr31485087b3.26.1720538819922; Tue, 09 Jul 2024 08:26:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720538819; cv=none; d=google.com; s=arc-20160816; b=sN2KxzmSN10d0tCcp0Xt/oh8NQrtxh+T0EIG8wTh+9NP2bTPzhUWe5NQ/cV7NO/H61 WSiQRDc5ICWKJn/AWYp4ipvOatnE8g9iZP5/I2pZt+zp5gE4imGlxnYMebMzVII3lssl mFQfo/RUbx5aZqTf4MF1urARGVZx2G1fjnZVyFwwd5abRyqUGFygT5/PISMVUN/CJkPn QwtRLxD2W0UGH1jUNuD+RZMgdlpN4lm3SkWZy/13pyE/l/Ga+FsBKqmLUF/DXeTFQgt1 MfjzvdRF2+op0tHoTX5V3dlHnLMwFFbIvO69xsNLGo52GJnydVMq5UpNNFTCZB4RzmJi sSuQ== 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=whoLRb2gVbD8Sem/KoA+COzzbDt33IZ9HQp6/Mjesmw=; fh=zTR2DIZxB+EjUIADI17pmMbbiq3j3O+7JcocDxdvvR4=; b=bGfyCGbttnl8FMCH197ym2/9ju+8mdjyY7mpBNmcRfz1J5LWqGckMaVr0QFuUisopn xdWktM0fNYOO4jnaglddiOXnNnT5HrQgc9Jzsu97AgHEgt/XuXFhnE2bEw5dLaV8FZQ8 rClkmRG4vVD5iB9I8xV+lIV0/WsnEkY5fVoAPelcrl0yGlfEg1hdMryeCDyE4tIJeZg8 vhj1gWs+m9ZXKr49q7zCUer6ZkRK6Qyx9x6pAXK5Yn+gn85JtK61JO55bMnqPK7pvIZb 0jn1ZruRlB6EfVuFl7ul4lXJzP/kjzavRpm22M7FjuGrFpylBVq4uRjeOMLw4kYjbBC/ VtKQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gb9+az7O; 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 a1e0cc1a2514c-8107693a0e9si299946241.73.2024.07.09.08.26.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Jul 2024 08:26:59 -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=gb9+az7O; 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 1sRCjT-0003FO-P5; Tue, 09 Jul 2024 11:26: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 1sRCjS-00039L-9f for qemu-devel@nongnu.org; Tue, 09 Jul 2024 11:26:18 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sRCjQ-0006Cc-Lm for qemu-devel@nongnu.org; Tue, 09 Jul 2024 11:26:18 -0400 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-42671a676c7so7886415e9.3 for ; Tue, 09 Jul 2024 08:26:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720538774; x=1721143574; 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=whoLRb2gVbD8Sem/KoA+COzzbDt33IZ9HQp6/Mjesmw=; b=gb9+az7O6MAMpfAK5CrC0wEO54m7yN5+/H/rixrwkIpzA6bQ0GgOVBVa01zxlI6B2i T8tc6zc7ACuDN+9zVpx1Gxvbuj1+UgndVDRD5byTk/4PQCv32ajjngnPp4wrVFnltAiT 4xDbJnXG3bxSaX5fAun/foTVpNmIX4bQQDKjc/UWn9mIIKfMk71TYDN1gN5Z+XakrmT+ aJlSUBt75EjzKeiARwEaMkfTzDEMXN12XGRpEXllYsOYZCc7AEA31Xol7oq2JHXvKeei pRyRhIgcuNAFXf9JXbKFYPeslYQAMMJ3UZBsnz8TGocG7fLBU2/2l7nhcmCzwG4GfiJ4 9JWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720538774; x=1721143574; 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=whoLRb2gVbD8Sem/KoA+COzzbDt33IZ9HQp6/Mjesmw=; b=JwZSerhlqHHg9JrZkeri8JsPXNeQULQ2CJRL5MsvmoYnnRguXaMzFUjMwWr2THzoUS wlMNW86kjEQVZbtCrgDNbfTrv39oSTN/7J/VUgCHgeqAezr5+GwXkOERF6lfkZQqTTkZ +yx8tonFGazDsMigHtg0aJwkFoFEJy+gryrNYPVJyIbbF/fLk4WzkUQ9j93sfLBzdr/S wi2qFIzbrX3S3IN6LgMleXxEJ7kTmFnCC1son8aPOQpe5j/Gljc7yCGtkqoWnMbqJGme 76eyI+wSSum/Ky5zVQHt5TwnvkpmtS55Ageqo2REJJfCGzmA18G5SJ0NsbpoKN8PdIj6 YWow== X-Gm-Message-State: AOJu0Yyk+YjRey+qFQ4B9Pq6sdME7FqTgtd/zBrvouYhMd+YQsnhcOgQ T/hvTLjOGS1Tl/iv2tITvDo26DSchwi0biv5OqFWYFKhp4MhukgBBCWZZzvSH193MO9wKqjgewG + X-Received: by 2002:a05:600c:6541:b0:426:6364:c2c4 with SMTP id 5b1f17b1804b1-426707cf9c4mr18535505e9.14.1720538774580; Tue, 09 Jul 2024 08:26:14 -0700 (PDT) Received: from m1x-phil.lan (vau06-h02-176-184-43-20.dsl.sta.abo.bbox.fr. [176.184.43.20]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-367cdfa065bsm2855862f8f.72.2024.07.09.08.26.12 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 09 Jul 2024 08:26:14 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Peter Maydell , Andrew Jeffery , qemu-block@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= , Bin Meng , Joel Stanley , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , Jamin Lin , Steven Lee , Troy Lee , =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v47 02/19] hw/sd/sdcard: Register generic command handlers Date: Tue, 9 Jul 2024 17:25:39 +0200 Message-ID: <20240709152556.52896-3-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240709152556.52896-1-philmd@linaro.org> References: <20240709152556.52896-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=philmd@linaro.org; helo=mail-wm1-x334.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 Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20240628070216.92609-84-philmd@linaro.org> --- hw/sd/sd.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 91a73aea8d..eb50862adb 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -2387,6 +2387,29 @@ static const SDProto sd_proto_emmc = { /* Only v4.3 is supported */ .name = "eMMC", .cmd = { + [0] = {0, sd_bc, "GO_IDLE_STATE", sd_cmd_GO_IDLE_STATE}, + [1] = {0, sd_bcr, "SEND_OP_COND", sd_cmd_SEND_OP_COND}, + [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 Tue Jul 9 15:25:40 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: 811444 Delivered-To: patch@linaro.org Received: by 2002:adf:ee12:0:b0:367:895a:4699 with SMTP id y18csp345458wrn; Tue, 9 Jul 2024 08:27:15 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUvEt3bilmUl9hOJGH3U55wNcboRCAvcLwi/NzqkVY3QttGnk/YcuDsdYkjqv/gM/aSmPVEPCNXTnAn9/ncfpI9 X-Google-Smtp-Source: AGHT+IG6cCjJ29r5uZZUX3B55vi/Y7+o3OKeDKtotLkLZ5T+iTxdSxXy0WTJib9HgbUa6v1YJhUc X-Received: by 2002:a05:6102:4b83:b0:48f:b5c1:7269 with SMTP id ada2fe7eead31-49032ff4e42mr1863447137.0.1720538835444; Tue, 09 Jul 2024 08:27:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720538835; cv=none; d=google.com; s=arc-20160816; b=oxMWkLeUf5AOBgcIjQRChBfhTlvLfMyPSr/a/e1uhl6OL2ztqGs2A3GYo/Z3KoWPus QBwx6BC6Ay/dwmRpJVY8rKyDbW+4Tw2EAXXbXvdGEfF73KXX8E/Qrf50fPYIOHZgBRZt zqc7t6SPkO3a0CIEgcuWV7PQW3l/qKzGor/YHOryMzEcDQChzV6lhdM+401H4z4a4TRs qTHauQf0ISB/sKnxCj9H5lkuDdyrMuDSSAnFxvsT3vmR4GDsN8t7a3f7Fl5tQfzaf1S0 X+YPaMhMhPtjL679A9AEwtjKWkG4Je8Ow9AKRzPEy5w5ZHc94fQ2Ps/OxvTQh1ouP5pj E1cw== 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=RJVHkR25AopDRjvaFAHlUdf7mDVai3uQRUgz1HxXftQ=; fh=zTR2DIZxB+EjUIADI17pmMbbiq3j3O+7JcocDxdvvR4=; b=TV0cuAH+L5d00OVluKZ2TeNhRHOOwTM1EFqN98nH5TNL3Jn5zo9/D9QP1HKR+vvTzu aKOM65pc3I8bowazsEHIe8voHJU6uWqdDNe1ySnh/H8WxZ1siD33xU6gRHjQQAAa5xcw gQXi5bFxLs+49n00ilHxYhK6QPg8GRRvA+DvUlIpgMYJ3B19xLUpLRve8U1QFlb90lQ/ 4EqZoWRnzePgdZFEFKgSYPvHR9HsytPgRV989X1Lyw9sTL689/I6/AsZIdcg2pTQW/61 HmWX+et6TSbwGsFrlfzQool2Wtgnd/iEiKD08wFnHA2/hOBxt0jibeit870iTE0In7zs kKIg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gr49xS0I; 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-49031776afdsi357047137.687.2024.07.09.08.27.15 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Jul 2024 08:27:15 -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=gr49xS0I; 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 1sRCjk-0003ll-O3; Tue, 09 Jul 2024 11:26: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 1sRCjZ-0003eH-HR for qemu-devel@nongnu.org; Tue, 09 Jul 2024 11:26:25 -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 1sRCjW-0006DW-I6 for qemu-devel@nongnu.org; Tue, 09 Jul 2024 11:26:25 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-426685732dcso16438035e9.1 for ; Tue, 09 Jul 2024 08:26:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720538780; x=1721143580; 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=RJVHkR25AopDRjvaFAHlUdf7mDVai3uQRUgz1HxXftQ=; b=gr49xS0INqsXUOZsO2U+iBM3QZI8ngbkFFmN1CowDLIv4UXD2j5jvZ4okSLbaX0nM8 UglTSTcGXGoOe65s/r9twpXEew9YKUB+MRDJceq/TfJSCxH4us0Bw9EnvtZQgZLx9w60 rGLOjTN1ofxtcA7Yq3Tei/ar1895NLSyubmuC2ElnEc/f38bu1P3YfURcr99B/SE5knV ZqkA9nCRf32qQY5rLT4W0HR8slFZbimhINWbBiw3er9bBr7ofjwCXomDVOODBDjtNTcf PgHEja097UJLCNuM/ZRPkgvs4khQg/otTrMAAgaD1+jmo6Djkz3enUscxU1+fmviEE3s wqNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720538780; x=1721143580; 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=RJVHkR25AopDRjvaFAHlUdf7mDVai3uQRUgz1HxXftQ=; b=Ocu0PuaMG1z+k+zoBpMaOr+dCmUeNSms9PT6PHJl8syFwo58ahpq3op9r1l4kQ+neT 1HlEEPDTqGmm2uMfJKeTJThgwkFtAQhJdmsZUZWBpL3hKET4FVo7jrY7VpBO1EWm7L9T VcOsdNIWcHYDIx/jOlWaWUpHpBVvWo7KcmMVt9M1H09kXElMsVyXciKLfZjKplCoAZYG B2DRBfMQm7okGbqh1PDNCBAvq/y1wUWWPy4m0X362fHi5RCvYS24iQr30Q/4IOaAGm+A JS84BoeJXQdC4xdNCgCL14GaZiZmZ/hAIqrZihdBfW6LvNpiql+X1HF2BlWNjfsaHO/p PgnA== X-Gm-Message-State: AOJu0YzpZtq04OQgXgiRDor4Ah9nb0dGJLV5cFvtDFuZvoEUBeRCXSS3 BbDnzCvSZQmWu9HKEUKuzDjw6OEhVTEZrfiFct2b3uO/0qdmMIsQczLD8rNrTlYlCVySlH399Kq e X-Received: by 2002:a5d:5f88:0:b0:367:402f:805b with SMTP id ffacd0b85a97d-367cea46b51mr2726113f8f.2.1720538780582; Tue, 09 Jul 2024 08:26:20 -0700 (PDT) Received: from m1x-phil.lan (vau06-h02-176-184-43-20.dsl.sta.abo.bbox.fr. [176.184.43.20]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-367cde846a3sm2870777f8f.30.2024.07.09.08.26.18 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 09 Jul 2024 08:26:20 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Peter Maydell , Andrew Jeffery , qemu-block@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= , Bin Meng , Joel Stanley , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , Jamin Lin , Steven Lee , Troy Lee , =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v47 03/19] hw/sd/sdcard: Register unimplemented command handlers Date: Tue, 9 Jul 2024 17:25:40 +0200 Message-ID: <20240709152556.52896-4-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240709152556.52896-1-philmd@linaro.org> References: <20240709152556.52896-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 Per the spec v4.3 these commands are mandatory, but we don't implement them. Reviewed-by: Cédric Le Goater Tested-by: Cédric Le Goater Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20240628070216.92609-85-philmd@linaro.org> --- hw/sd/sd.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index eb50862adb..097c9cc61f 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -2390,24 +2390,33 @@ static const SDProto sd_proto_emmc = { [0] = {0, sd_bc, "GO_IDLE_STATE", sd_cmd_GO_IDLE_STATE}, [1] = {0, sd_bcr, "SEND_OP_COND", sd_cmd_SEND_OP_COND}, [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}, + [11] = {1, sd_adtc, "READ_DAT_UNTIL_STOP", sd_cmd_unimplemented}, [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}, + [20] = {3, sd_adtc, "WRITE_DAT_UNTIL_STOP", 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}, + [40] = {9, sd_bcr, "GO_IRQ_STATE", 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 Tue Jul 9 15:25: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: 811445 Delivered-To: patch@linaro.org Received: by 2002:adf:ee12:0:b0:367:895a:4699 with SMTP id y18csp345574wrn; Tue, 9 Jul 2024 08:27:33 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXY5ZUhYT8FtmVsfV1o9ZvfWZ6gpm++lP8+cqEEi47NInB64Ymob+sc89hPVomLx3uIx9IUujklAWIxSIUzbBPO X-Google-Smtp-Source: AGHT+IGvJC6cSIkrt/ILJVDFrJn+dDbDfO7IyCnEfKuacl1LKH0cIHpDQsBhUxaCVu9JLZQSOMGF X-Received: by 2002:a05:6214:407:b0:6b5:e9f9:f1b2 with SMTP id 6a1803df08f44-6b61bc83c12mr37268316d6.13.1720538852891; Tue, 09 Jul 2024 08:27:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720538852; cv=none; d=google.com; s=arc-20160816; b=ntcNPNPVk9TRs+kCGyV7CiCAsiAJi/9acyHjEoiiBW18hEgS46KLhHuICdaVuZOkFV j2NZTCRPzPgB/1W6Y2kIPn7gTL3SVCr0XztCDd2D6C8K/6fBb0J6T2b+0Tk/ax7GQjyf 80WbCUqOA55KeyPlXyziGJ1/g3c7+R0uaiAk9QZmuZtmvSba396uYwJU3hrtGdZT/cqo LTLhSBtWG0FhUXAVORb3PVjt1x2F+Zds54os6UH+pqVsR0wukt9V0NqGv7XnxIRMWYOD pmftdp0Mq4qO2VaPGDC3FWQNO7AHtTSNl566u2O50L0nVHnkxhvMQswHBRTQCJQfTPLB WudA== 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=60ugG7sbucLNOSaT9RRMMhTNzSMzLQ61ZmEDNwXQ9Yk=; fh=Txzf7K5YV+qryaChbcvqA4D4sw+KVK3yVi4ERabJCxo=; b=qfvEzerAo9RyuAuq+yHYcDGN2znQzZoz6yCuatTldadgbcRNdU3qScKvJQcbrK8eYg JlMYq0XFYuQcQRfm3AAHUmWmdqPCCVvxrywiCkrNHtoZOop3wWJqfFdb4P7tYBjukOY/ Wb/IGTq6j5J4/ufi/+welj0C8pj4AFacpl+/quy1PL6bnF+Ll9AfEighrE8JghVW9ueb 1QgRBy5aj0B9+5FCNraN6pGuwz0DeFjuvYcIgyd1Zhd+l/7XBZZtYyMx1aFoyXo/kUk+ A7AOcTQY9oyEh9T5haNI/CdFWTG8RuxGVzs823946FB2+IMZCXs+zvrGfCE44zfTM5c8 9L2A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=J9jg8Rg9; 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-6b61baf1d5bsi24691416d6.504.2024.07.09.08.27.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Jul 2024 08:27: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=J9jg8Rg9; 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 1sRCjp-0003yD-DD; Tue, 09 Jul 2024 11:26:42 -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 1sRCje-0003mV-Uc for qemu-devel@nongnu.org; Tue, 09 Jul 2024 11:26:32 -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 1sRCjc-0006Em-FK for qemu-devel@nongnu.org; Tue, 09 Jul 2024 11:26:30 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-4266eda81c5so12836165e9.0 for ; Tue, 09 Jul 2024 08:26:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720538786; x=1721143586; 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=60ugG7sbucLNOSaT9RRMMhTNzSMzLQ61ZmEDNwXQ9Yk=; b=J9jg8Rg9JWoABE0qMwy7A+vzGeCVlheESLswLIhW9km776dchOcDogVPSA65ghbV8y /ElUvgKR89Xb/LOlDmOS4ueACfzZmHY9d14+eBB7kdNKaHwG5UG8HbJiF4l3nohPFZsc EM7YqP/5aVslqGqFWmBOwUi+bDgymJTQeKumiLnkb+Jj9uY5ScFlLbPE7H6H3eB942f2 fsiPVsCd0f4nGu9tWxwn80l5UFGsgF57EqEHctlhrIefdB/s3BLQuQd2RInSCzWg/+73 mQPQGn02dE//YOzbnx7genwmgPYQCsRs9kkS5+24JyNAzoVF/FiCepxow6JNjWL3sDLN T9Jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720538786; x=1721143586; 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=60ugG7sbucLNOSaT9RRMMhTNzSMzLQ61ZmEDNwXQ9Yk=; b=BBfL9FyCG8iCf70Tops2nFrLNuf//J9kzKk+SKsvWhjC0JT7ARoJppHaJJlBrHOHCy lTLjkiPwT+n58CMOl+TNI/+lrKLD/kImmc6llCkJhYP5SRMpHdEmPuwktWbPyC6zXMYz YdKzhR5iFNVUJEepHjYZG2pzm6WfWV07/9fnjAcjmnidnURgidnVe/lKU5rmAxl/qmwM u9jfwSdtISK5FpDRM09/DRjm0Gk32a4C5E7Gcn8Vtkq1R2Q5z4bynBK9s3kmPNNF500k 91xWp014dSz6F3DKA9EPAwBo4de3p80E2uhNnTrXWCgoLIx2rD4n6BUSiFFekYR9/q9e dvyg== X-Gm-Message-State: AOJu0YxUjluX76v1NLbbFVmsitxQBP6TXMnhgz6GprtMvzrAnUKCvtmf kkypEoDfqdsYAHjfgroI/HscnlnQSSuEF6xQPhh70+MthrQZHyrnzYjWgDkeGd9d0Yd3xr1F4ql o X-Received: by 2002:a05:600c:22d4:b0:425:81bd:e5ee with SMTP id 5b1f17b1804b1-426707d07c5mr25276565e9.16.1720538786629; Tue, 09 Jul 2024 08:26:26 -0700 (PDT) Received: from m1x-phil.lan (vau06-h02-176-184-43-20.dsl.sta.abo.bbox.fr. [176.184.43.20]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427270238a6sm12770615e9.20.2024.07.09.08.26.24 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 09 Jul 2024 08:26:26 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Peter Maydell , Andrew Jeffery , qemu-block@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= , Bin Meng , Joel Stanley , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , Jamin Lin , Steven Lee , Troy Lee Subject: [PATCH v47 04/19] hw/sd/sdcard: Implement emmc_set_cid() Date: Tue, 9 Jul 2024 17:25:41 +0200 Message-ID: <20240709152556.52896-5-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240709152556.52896-1-philmd@linaro.org> References: <20240709152556.52896-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 eMMC CID register is slightly different from SD: - One extra PNM (5 -> 6) - MDT is only 1 byte (2 -> 1). Signed-off-by: Philippe Mathieu-Daudé --- hw/sd/sd.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 097c9cc61f..2d737a836f 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -446,6 +446,23 @@ static void sd_set_cid(SDState *sd) sd->cid[15] = (sd_crc7(sd->cid, 15) << 1) | 1; } +static void emmc_set_cid(SDState *sd) +{ + sd->cid[0] = MID; /* Fake card manufacturer ID (MID) */ + sd->cid[1] = 0b01; /* CBX: BGA */ + sd->cid[2] = OID[0]; /* OEM/Application ID (OID) */ + sd->cid[3] = PNM[0]; /* Fake product name (PNM) */ + sd->cid[4] = PNM[1]; + sd->cid[5] = PNM[2]; + sd->cid[6] = PNM[3]; + sd->cid[7] = PNM[4]; + sd->cid[8] = PNM[4]; + sd->cid[9] = PRV; /* Fake product revision (PRV) */ + stl_be_p(&sd->cid[10], 0xdeadbeef); /* Fake serial number (PSN) */ + sd->cid[14] = (MDT_MON << 4) | (MDT_YR - 1997); /* Manufacture date (MDT) */ + sd->cid[15] = (sd_crc7(sd->cid, 15) << 1) | 1; +} + /* Card-Specific Data register */ #define HWBLOCK_SHIFT 9 /* 512 bytes */ @@ -2581,6 +2598,8 @@ static void emmc_class_init(ObjectClass *klass, void *data) dc->user_creatable = false; sc->proto = &sd_proto_emmc; + + sc->set_cid = emmc_set_cid; } static const TypeInfo sd_types[] = { From patchwork Tue Jul 9 15:25: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: 811455 Delivered-To: patch@linaro.org Received: by 2002:adf:ee12:0:b0:367:895a:4699 with SMTP id y18csp346857wrn; Tue, 9 Jul 2024 08:30:24 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV7xMCSDoB/kPFCAcprSqCrvXf1gT0GOyPuRgvIUs2+OEXLtd50AWge11kpn3dkbGHv0PRqhrk0jezM1dZwN/Fz X-Google-Smtp-Source: AGHT+IFPIi+ptUl9l1eNEOVby6q2W55HQOn8b5NtQUzkQr4QxW1acn7qBs/koORjdPUDBiieqb7Q X-Received: by 2002:a05:620a:a58:b0:79f:90:7d50 with SMTP id af79cd13be357-79f19a80203mr287744385a.32.1720539023890; Tue, 09 Jul 2024 08:30:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720539023; cv=none; d=google.com; s=arc-20160816; b=e+fxCPz2dxASy3vkWeeaIILLDTJbc7v3my2K94By770L5FVpjfLi7Vv57afiK68vDj tt4x11BEG/IUb7LXWZDRyAB2NY86F/u/7mH7HcrkGveyC83z5mV4t4jNNG6pYIi93Ajr toSmQ4v/I2cKVcWZsn2wmlOgJO7D21pujcOSHjgYXPEU0wKZ3Mq7KVdcIS7SHqiyZY7Z YmRgnBQJ8HFMfnN9gbnKpaI2UXgPwXlGaP0JK+Nbz9yFsiCakF3RfUz48CgDL6RazJ+T sESQz47Rex3Ii5pKqrXDq7LQ2zFMH4dcEvBsW31mTNoscqwaFbuxk3jt+eF6JdWT4eU0 NZxA== 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=CXlLcchVuZxoQd5Ht8ddmcX5yuPtqrGnU30hdQCRZeA=; fh=Txzf7K5YV+qryaChbcvqA4D4sw+KVK3yVi4ERabJCxo=; b=XLtU6AmQ8LLciHEswgbsvsZeLLyQcp6sTrwXRdEojQvhok6GMU1cJKucYSJwZqi3Ov qm3AO87aJajVVyFTS3zuzQwOsrnD1vV2mVXqKidSjmHhmPFqU9Wa8QvxLS0wVtsAqIBP XPyM6aChLTkRYeFKOcx9kAnlH4IIrfjOPzaO+Uemi8bZs6QpNJTHU+88jEEcl3+ugHRr BNiHqMciY9cdtqg2FQoq/N5/I8rP7jLg4npZDlKy92roP+VdvdcnjGxYvs88khAllARw DrakS/v0iOqRsiXzeENZYLoFJzlgAjaLtHDG66f+ofYpFPdoqNV4hs/EjOnvjPW8IHii /MSA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wLBm1JWJ; 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-79f190a18d6si231428485a.373.2024.07.09.08.30.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Jul 2024 08:30: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=wLBm1JWJ; 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 1sRCjs-0004Ad-2m; Tue, 09 Jul 2024 11:26:44 -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 1sRCjl-0003rX-AR for qemu-devel@nongnu.org; Tue, 09 Jul 2024 11:26:38 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sRCji-0006Fn-BY for qemu-devel@nongnu.org; Tue, 09 Jul 2024 11:26:37 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-4265c2b602aso24560175e9.3 for ; Tue, 09 Jul 2024 08:26:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720538792; x=1721143592; 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=CXlLcchVuZxoQd5Ht8ddmcX5yuPtqrGnU30hdQCRZeA=; b=wLBm1JWJAGCwpEUIz+SWZFY6BqMyJcsMhgoEZ5rmwiUhI1tgCNwQYwRQoFw9/Q/J2J Xci4BGQ7p8WlEclhjjblc1so0b1I1d8gX2n8E5Cp3makkfoeps04Ep1BoYrGRJEtM7ZY Yw3o/iSBjRdSNdigXN4Q00xOvzhrPo6RnVwO4LV5KojEnKBiAMpN8lu6k8WbonIr6XEU Wgs7RISADNilDoIyHFkUUCMzA7Nqzb6gPbn2kmYnHKpGvdaABiFUQOTEt9335jPtB0ek J87mJiMsFnCuzcOxLDSrUo+mIPoYa4Mo65wZBQPqBpStUgk0q+KsKpWFFAsnRwsEmDaP pLyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720538792; x=1721143592; 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=CXlLcchVuZxoQd5Ht8ddmcX5yuPtqrGnU30hdQCRZeA=; b=tB+q3m6jf6Pg9M0CfejAiuVSHcw0GTEEoutlgmCVbOTWsID9tncbPBCfXZFtoXv675 zjBRQh4YMk0X+Mf7ISZInjcucraKsG+Y4bH+sw56Zyr8aPnXOsU4+IBjeKyD5x+C9gdQ BPbFDM/cAl5jxcDO2bvpBjdtf/QyAy1DsHnKrV8Sxr+YzzFxZRJVkKWK+Ic9z7q2L05F hW/YqZBnYSn2SB9S1P4HZawSJ2z5yj+VaEXIiVz60pUF7s2DxX/ucrruU8XsaaD+8NxZ ha6JrcQ/UsjxUogeB37gF62camxhmFYXWuq61dmGYtux8/wYR95aGy6vaZfHK9RhUaal tFIA== X-Gm-Message-State: AOJu0YxQLN7uNIgVe4UFbVN8A8QjfudbBSdM3wDhLRyxHWf4WJnRjWnB NTRreaQmJfSVOt6uCn8RqgT4U2REbgHugShLadtoB6jJLkllFOQqvIQMZf1DGaGMMThb1dANcc/ X X-Received: by 2002:a05:600c:534b:b0:426:6ad8:3e3c with SMTP id 5b1f17b1804b1-426707e2fa2mr19303475e9.17.1720538792517; Tue, 09 Jul 2024 08:26:32 -0700 (PDT) Received: from m1x-phil.lan (vau06-h02-176-184-43-20.dsl.sta.abo.bbox.fr. [176.184.43.20]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42662315363sm125665345e9.26.2024.07.09.08.26.30 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 09 Jul 2024 08:26:32 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Peter Maydell , Andrew Jeffery , qemu-block@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= , Bin Meng , Joel Stanley , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , Jamin Lin , Steven Lee , Troy Lee Subject: [PATCH v47 05/19] hw/sd/sdcard: Implement emmc_set_csd() Date: Tue, 9 Jul 2024 17:25:42 +0200 Message-ID: <20240709152556.52896-6-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240709152556.52896-1-philmd@linaro.org> References: <20240709152556.52896-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=philmd@linaro.org; helo=mail-wm1-x32f.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 eMMC CSD register is very similar to SD one. Most notable change: the version announced is v4.3. Signed-off-by: Philippe Mathieu-Daudé --- TODO: comment magic values? --- hw/sd/sd.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 2d737a836f..f580c6b2ae 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -476,6 +476,44 @@ static const uint8_t sd_csd_rw_mask[16] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xfe, }; +static void emmc_set_csd(SDState *sd, uint64_t size) +{ + int hwblock_shift = HWBLOCK_SHIFT; + uint32_t sectsize = (1 << (SECTOR_SHIFT + 1)) - 1; + uint32_t wpsize = (1 << (WPGROUP_SHIFT + 1)) - 1; + + sd->csd[0] = (2 << 6) | (4 << 2); + sd->csd[1] = 0x07; + 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] = 0xfc | /* Max. write current */ + ((CMULT_SHIFT - 2) >> 1); + sd->csd[10] = 0x40 | /* Erase sector size */ + (((CMULT_SHIFT - 2) << 7) & 0x80) | (sectsize >> 1); + sd->csd[11] = 0x00 | /* Write protect group size */ + ((sectsize << 7) & 0x80) | wpsize; + sd->csd[12] = 0x90 | /* Write speed factor */ + (hwblock_shift >> 2); + sd->csd[13] = 0x20 | /* Max. write data block length */ + ((hwblock_shift << 6) & 0xc0); + sd->csd[14] = 0x00; + sd->csd[15] = (sd_crc7(sd->csd, 15) << 1) | 1; +} + static void sd_set_csd(SDState *sd, uint64_t size) { int hwblock_shift = HWBLOCK_SHIFT; @@ -2600,6 +2638,7 @@ static void emmc_class_init(ObjectClass *klass, void *data) sc->proto = &sd_proto_emmc; sc->set_cid = emmc_set_cid; + sc->set_csd = emmc_set_csd; } static const TypeInfo sd_types[] = { From patchwork Tue Jul 9 15:25: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: 811456 Delivered-To: patch@linaro.org Received: by 2002:adf:ee12:0:b0:367:895a:4699 with SMTP id y18csp346877wrn; Tue, 9 Jul 2024 08:30:26 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU9vyBAzjHMKLaLLRcyjxjHX09tK1RsmOmT+AmcayQ7gxbtvJMesTEvNuoh9XSKezGQF3It+8y6dmdnnd2xa9i6 X-Google-Smtp-Source: AGHT+IEzv/IYoi2sgL0GZKHoX21x7izQNusWO64dQLRsQaLDufYK/5/GTkHfkcstJsrmcow/gSAG X-Received: by 2002:a05:622a:285:b0:447:f41a:aac1 with SMTP id d75a77b69052e-447faac6551mr29378141cf.67.1720539025641; Tue, 09 Jul 2024 08:30:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720539025; cv=none; d=google.com; s=arc-20160816; b=ySBvFWcT1oLW5DxiUk7QOvgXRzhdiY2EuhYOEshie9XHQ3CZjc6AklwuK1GuzDKB4b D5pT2SscF8iA3nHLGg/dyBvkV7fbbhT7DIBl82M1lWBHk2dLi8n0Fs3BU2qI3W02gVSf KcDSnLgSOM6v0DA0Xuxdjo2Qlf+8C9hHyGJfeXHcQLvR7JH448hotcyp/0PdTylg0kS6 XM3azjT38ClYmxy5lQFGi3omunvbJ1lt9OgrI3WhB/DBNHezqw3rg/YmDL0oJ32KSyOo ITRglTxMFOt7vj5eX67mjXHnL8FxIYcKZnIZiRVi2/cCjHg964qB1/jRMfeNppxPh4ln CXbQ== 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=daY+t25+t6fUlvq8XgRmvXSG1rxW6z777bj+RrC4xDs=; fh=Txzf7K5YV+qryaChbcvqA4D4sw+KVK3yVi4ERabJCxo=; b=sztLWJitstIDWy2c4Ew4l1t9D0OVfrqMphdUE9aprcOnV+wb6vi21ZM4s66uv9nZ9d 9jS9Od/QnRm7e23lNODj9aWTe9LrCEjIsP4tstsk5MwQPpfoa6n9l/qKWImGO6O4ygRt 96wTetG9oEgypL+cloE7kOwdeInLHJl5l8RhNiHhjMVOuyFiGcNJ9X66Q8QKB9tbv0SI PBERJQhyNJc2QACxg2d5X5irXls5aRgn4YvWXciPn7XDOf99XPuM8LppPtsQGtfWt7g3 dwd/aNpTc4E985KU+NY6lS2+S8D8CRB/3Pl8kc4cu7c+Mw1z3CCbNyWs+3jqJHHm518U VNhg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FUdkAThu; 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-447f9ba8de6si23997131cf.368.2024.07.09.08.30.25 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Jul 2024 08:30: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=FUdkAThu; 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 1sRCjt-0004Fw-5x; Tue, 09 Jul 2024 11:26: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 1sRCjq-000466-9V for qemu-devel@nongnu.org; Tue, 09 Jul 2024 11:26:43 -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 1sRCjn-0006Gt-W2 for qemu-devel@nongnu.org; Tue, 09 Jul 2024 11:26:42 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-4266fd395eeso8155705e9.3 for ; Tue, 09 Jul 2024 08:26:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720538798; x=1721143598; 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=daY+t25+t6fUlvq8XgRmvXSG1rxW6z777bj+RrC4xDs=; b=FUdkAThuB/oVl2mEKN3PytIRlKxYmI7yeJLXAKUiqwpM3znJpM+m11sH6RTlT01KOE llhMCOfrGBAs9Ta8uOcec6/DCOZw5F7Y47o8rnMI/+5fawcL4U3lsgrZlRbcab4POkLf PpP8CZXjF2CeBDux3odTrQJ19wrmx80qqPjR40CJHG5sxVhZ9D5wJ/HDGPWWX6ST55eP CVH1cmVsVR8ptDKKAyBQLWSNeV4hS4nF80cpJQEIlN3cxg/o0QitMfkuysM9iiXZsme6 dw5WJMuuppHRMLvgnpPX69nIlWBqfatXF1gojPsRG1UmkFiWTggDzuKnwuaH3ZuyThrE JrJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720538798; x=1721143598; 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=daY+t25+t6fUlvq8XgRmvXSG1rxW6z777bj+RrC4xDs=; b=ZyBs/GSMKRMeUHzaGVIluzG+/Iihuqg/hl20htnbKFeFL37ajrKb6qLubuVbtwmwLI ghyS1e+A1pvUqbRzWByhh5ykjwgB8gJEapPl37cV3K+vcwe2CVNvx2GgYvTUpGczbDQh fUQxXKtbnHs58oMD8PCLqhPs+DeFc0lBfaykCWMGRu4ySYgTbGmhvGbNY+m0D+RyzsZ5 ZTSao4JxQQFSWxYit09lv+KNs204hX3u4ldPeox2XkXyvtGygS5kzFLBfP+jSuht2Amb ONHdUwOEJ9vE4bo8IrP0I0Luqc+qiMAVY7jTSz0357AUUCUoByYMyULhzz8pOuQOpDV3 tPmg== X-Gm-Message-State: AOJu0YwfrAm8ogTKtqFcBn35GGkZQjWnjqv1Sm79j1Ow4HFGwXS1ccE0 2E9OWo6EKHA5nu/PxKgn44fQr5iBuwSP5y0u687t7ZmFenXdo/awBV9sgg5xw0ApXkv6gFc6H9Q F X-Received: by 2002:a05:600c:1c10:b0:426:5416:67de with SMTP id 5b1f17b1804b1-426707f7e68mr19359555e9.30.1720538798331; Tue, 09 Jul 2024 08:26:38 -0700 (PDT) Received: from m1x-phil.lan (vau06-h02-176-184-43-20.dsl.sta.abo.bbox.fr. [176.184.43.20]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4266f7362d9sm44351915e9.30.2024.07.09.08.26.36 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 09 Jul 2024 08:26:37 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Peter Maydell , Andrew Jeffery , qemu-block@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= , Bin Meng , Joel Stanley , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , Jamin Lin , Steven Lee , Troy Lee Subject: [PATCH v47 06/19] hw/sd/sdcard: Add emmc_cmd_SET_RELATIVE_ADDR handler (CMD3) Date: Tue, 9 Jul 2024 17:25:43 +0200 Message-ID: <20240709152556.52896-7-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240709152556.52896-1-philmd@linaro.org> References: <20240709152556.52896-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: Cédric Le Goater Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Cédric Le Goater Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20240628070216.92609-86-philmd@linaro.org> --- hw/sd/sd.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index f580c6b2ae..83d45c897f 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1280,6 +1280,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) { @@ -2445,6 +2459,7 @@ static const SDProto sd_proto_emmc = { [0] = {0, sd_bc, "GO_IDLE_STATE", sd_cmd_GO_IDLE_STATE}, [1] = {0, sd_bcr, "SEND_OP_COND", sd_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}, [7] = {0, sd_ac, "(DE)SELECT_CARD", sd_cmd_DE_SELECT_CARD}, [9] = {0, sd_ac, "SEND_CSD", sd_cmd_SEND_CSD}, From patchwork Tue Jul 9 15:25: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: 811442 Delivered-To: patch@linaro.org Received: by 2002:adf:ee12:0:b0:367:895a:4699 with SMTP id y18csp345315wrn; Tue, 9 Jul 2024 08:27:01 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVCA9H2jDAy0dx4s1Ru4YXLXr4BxD4Iv+/os6WUm9f1H6u03GSfoIjTaILEio2TsNJaeIYwb4qzI0NjCYzhTzvP X-Google-Smtp-Source: AGHT+IE46BnfkDu3NqxgfXzIF/+k7CCQhi5VfLmY1BVZtDvaGFWACP5nJb/hDm9beSb6BXneiNfi X-Received: by 2002:a05:6102:2ac5:b0:48f:df86:dba with SMTP id ada2fe7eead31-49032113126mr3394881137.5.1720538821006; Tue, 09 Jul 2024 08:27:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720538820; cv=none; d=google.com; s=arc-20160816; b=rW/YGKOsuLJddxCn/UN8j5ipyIolYarnr5ULPiSaAEQ3kHoo2QM+ucSsAJ94LFlBo3 qxencx78BvMEI5IxjvfdGPFK67iAxUxVU05ocNq8PJixi1S+u+PQaUaGIKXcu9GauyeI mi6QDRb2GY/xnk8rhS9aSJhcLbsvUapX9vT8w4fTgBpz7Oy7tPzDsYhsTUFJIhLnOXr2 9RQqtL5tViHKt2scB8LT8Dm9/Zmr/hD+SpHeuGBDCoigZl7QC+5+6HP5VAsi1L4wBwRZ /Jx1iI+kLqUt2IAcNvtDvZ6QSp144RO4yhNpX53YJcqzZP3wP+oufHbyvkBtc8jPNxij ZKXA== 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=jD29YVy94pKbQqMrPlTZs935rnLUzr1rrw21fvjgKcg=; fh=Txzf7K5YV+qryaChbcvqA4D4sw+KVK3yVi4ERabJCxo=; b=xVUoJ7W8b4YJkAtNBFWDWzeNUFV73M5DCS3EbXA5xfhfAgzBog/CVnu6bziHQxdxuv SlOvkf8buo1vy2QipnDZdOIQ5W/VM5iU/Nf3jmp4EjCIXUDGdY9jyd9Jt15m1lP+KJdh CBR9er86rtx3QPs0JF9cZIYFet+x5HCW9jCRFj77TPZvO6rocjYYPlhmB0t4finOJNKC OQxX9H3wrBW7fMIZWoe/p8+Makhl4cpzWusCw5AwOh6bdoiMqxdbwlGipll+0yUMNqWt n9Uh1lUP42C1kruDKEZlFQTgWC//1sB8ejRtQlw/x+LiJIR82PFvJRa4TAxOiZrYvhPm mFrA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wkUSSrtT; 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-490317645b9si357009137.555.2024.07.09.08.27.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Jul 2024 08:27:00 -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=wkUSSrtT; 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 1sRCjx-0004gT-Qn; Tue, 09 Jul 2024 11:26:49 -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 1sRCjv-0004Ur-Ua for qemu-devel@nongnu.org; Tue, 09 Jul 2024 11:26:47 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sRCju-0006Hr-A9 for qemu-devel@nongnu.org; Tue, 09 Jul 2024 11:26:47 -0400 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-426685732dcso16441365e9.1 for ; Tue, 09 Jul 2024 08:26:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720538804; x=1721143604; 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=jD29YVy94pKbQqMrPlTZs935rnLUzr1rrw21fvjgKcg=; b=wkUSSrtTEMBLbjSD3SUW4Qj57LOYtmzzTYnLyHlMJBftbldSdLZ106aEu2/PfYname Ib4V8B0S8FrDMchZNTD81NEN9IwLpZlEyOZG0cUh9bU0I+3rr4ATFAZGGh+9KdYX14H+ k9UI1GbqIf5RRE3jrTpTxKX91EH6oO2GzqQ75DLQC+163RjhvtcW5KTt9nQBggwg/mQf mzm5J/pLkz+DBm36w32F6L+W1lDEhVQZAvAbssMEc8tL5tIK9yEY4p5p0bArM+wQyJlf Q7rTzdQk+GeY0TUv1ea8cQrMFqswG5Q+eXkJma/MWmFtldleM6UE6ITg270BcXawLTKR FxFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720538804; x=1721143604; 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=jD29YVy94pKbQqMrPlTZs935rnLUzr1rrw21fvjgKcg=; b=p6UW8aJKw2TRrkHHqyD2LPo7i1secr5YRbSuNXQI9TCrpccdqOEFsmQx05eUmB3+zF 0rGst3kC3dMIdLMO0aiZUVELfxTC+N1OtxzqimE7D+Qr+P1Ge0HPOV4WUn0sCJTtLLm2 MR8GvP2wxTdyDkW8sykkDq58bqFLTKR+mzufvdL94QSSFILZWJfzqySO8iY53HSFbgBk 9Y4siDFEyn2g9HtqqTEWVQcLiCIYiLCQptXHLeu1D/xo6wk1pORKYaBNuPNUDTugksHM TyaW2ImBTP4pAJQi14YLMYA3yteQ7iWOEUTe1My0Pg7VMM9IO8viQwPku6hCv1vWlSjo aOnQ== X-Gm-Message-State: AOJu0YzaEO/Jq1iP60MZAOQXt2xglyT9rfkxHPZrqojebL3Alvnzyc3Y G7Cufe6s9U4KMFbxu3HTlk0n3TiR6WNVchNqxnnf4UnmbGPjQOOil0aktD7hiYbKSVQnoKbaXzQ N X-Received: by 2002:a05:600c:6d8:b0:426:6389:94c4 with SMTP id 5b1f17b1804b1-426708f9d84mr19273695e9.37.1720538804219; Tue, 09 Jul 2024 08:26:44 -0700 (PDT) Received: from m1x-phil.lan (vau06-h02-176-184-43-20.dsl.sta.abo.bbox.fr. [176.184.43.20]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-367cdfa070asm2843999f8f.83.2024.07.09.08.26.42 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 09 Jul 2024 08:26:43 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Peter Maydell , Andrew Jeffery , qemu-block@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= , Bin Meng , Joel Stanley , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , Jamin Lin , Steven Lee , Troy Lee Subject: [PATCH v47 07/19] hw/sd/sdcard: Fix SET_BLOCK_COUNT command argument on eMMC (CMD23) Date: Tue, 9 Jul 2024 17:25:44 +0200 Message-ID: <20240709152556.52896-8-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240709152556.52896-1-philmd@linaro.org> References: <20240709152556.52896-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::330; envelope-from=philmd@linaro.org; helo=mail-wm1-x330.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: 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é Message-Id: <20240628070216.92609-88-philmd@linaro.org> --- hw/sd/sd.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 83d45c897f..216d4dfa89 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1533,6 +1533,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 Tue Jul 9 15:25: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: 811448 Delivered-To: patch@linaro.org Received: by 2002:adf:ee12:0:b0:367:895a:4699 with SMTP id y18csp345792wrn; Tue, 9 Jul 2024 08:28:03 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX080kGUqTJCrEDxNHZRPBAlajjiN1FTyG76GKk1q1ejZWOYjFXPWYhyh3olGRFn92DtkJk0OtTPpM8bO8Aooa9 X-Google-Smtp-Source: AGHT+IEkAt5kif0GThTbsb5wg1EMklU/wMX0xjfxJ3AkqOMSvlzWCWrT1gQ2yYAlRnHcwSg4rRq6 X-Received: by 2002:a05:620a:1926:b0:79f:706:b46a with SMTP id af79cd13be357-79f19a1f248mr403945385a.29.1720538883219; Tue, 09 Jul 2024 08:28:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720538883; cv=none; d=google.com; s=arc-20160816; b=zIYwRpiwpc8canvijQMz6mo/uYWj0cNl0cGMH1tvcJkzHrll2JCkPLiPnMHiz6jiHq WLG0kqdJOw4875cBQWzOiZGdm18xl+YMFdBMpu6GT2jBIUYDCFoIP1FjdzRrSBKXKMuE a4ODxOnCC+vdRPn+YsCTWmU2NiaX93yVfhUqPLWpTaC3wQq+bLl+rvm2xKeKMNlhlEKp 2BEt7G1Rwv4wMXsfMJg4Xp069Tvky3dtnyy0vPS6BaHG6fqjL51lM+nfBJYHAQcmqQSV zJF9SuE5lDKd2RjuAQ9tfcPEsvuqhQiUec/+Ulb4ofXSZAbAEOD3w0GU96ON4f3LWuzk mQHQ== 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=achqB7NVcZRX2FNdfvoM8hvaB6H3FSzVjdNn3nYAeTY=; fh=zTR2DIZxB+EjUIADI17pmMbbiq3j3O+7JcocDxdvvR4=; b=linf77vWO8IWAKjgML0DuOn7EiTV/1SeR9iKxxavKVgs0EDL6Yo1lfXsMAhvYnKtGN wIkWAejUs9Acc74MF3JwysDAWubgJcan4+2vNjMcuH2kPDNB8A2z1lIF+eMqpDbpiClS 9g5SLDqcoU+I2o5s6pHoGFW/YtRdImrfwmA0VMn1F4CrNiB/TfDGQClfI57jW+C0Zrej HLk5eHJyoHaEx00hfn4B0LUd3KIZNztbdI34UV8iIex63Mtz8LC6z58zg/Uz/f85fu6R izZerYm9FtTsMgAoYco3nTRO7cEt4FQ57K28Borkpe7cRnxUN/33wIU58p7IUYQczdvf UQ3w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lxCqDIA7; 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-6b61b9f68e8si24369106d6.33.2024.07.09.08.28.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Jul 2024 08:28:03 -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=lxCqDIA7; 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 1sRCk6-0005P3-1d; Tue, 09 Jul 2024 11:26:58 -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 1sRCk4-0005E3-1n for qemu-devel@nongnu.org; Tue, 09 Jul 2024 11:26:56 -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 1sRCk1-0006Ib-Db for qemu-devel@nongnu.org; Tue, 09 Jul 2024 11:26:55 -0400 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-367975543a8so3581553f8f.3 for ; Tue, 09 Jul 2024 08:26:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720538810; x=1721143610; 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=achqB7NVcZRX2FNdfvoM8hvaB6H3FSzVjdNn3nYAeTY=; b=lxCqDIA7QawU7oy+j8DXnkQC9jguJPLeW16eHCIRzOSFPnPfRdMzzG7ROu46tpsBLb YrgRfjrGfbdXObgqyZhxsBpTPwajK0KTS5sizY5SpqicSzX85MbGgAkMsWTwha0DZw63 C4s78J7o2PnpdndD5ZGU90ciM/WAtzAQKMhQNYg5lPMIBTJuwYbZWDIBtu9HPe5NW6Nz g/wkxmvbsONtOdVH3VUH8NrKiUa0I/5To0GsDi5iQQQlZcEkMbfpfGo1F9JJ8km/Gkyj 2ZKPQirvfeA6WfcVVPg+/bgKdj495VhBBy6Xt3b/3+cBO11hp1BYxomaP2+1FeTd2ztA Ef5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720538810; x=1721143610; 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=achqB7NVcZRX2FNdfvoM8hvaB6H3FSzVjdNn3nYAeTY=; b=OSnCj/xEHPcTkOixmjfPa+/lPepge7TDgZ6e6a9Z9Wbi/6jmOuqqUBOtbbXMUiH+6p HD1FNHCFy4V6kJklwYqKDHx3Hf/gJcgOArF486g4q7rpMkkP9lCbhAmWHZTR0D6emI6g YIUP0N5udwKi+L/rc5eeEgrFaSlKwGcu9JXuaMPhj3nrD+nVgfF0gMw/rTG3Gc+E3hoq SK7tJstm/89EGnxEfMXCoypnj/RWVZiQUZf9+iVuiHPmORS8MGDsDgq2f0rv6ZL6jCq1 6/uP9TsYgejhtDMkYiNx2fZ1+dZrkoTFemLgoDRHYMzUQvxgmbV1KIwHpihBU4FRK1UB 2Hdw== X-Gm-Message-State: AOJu0YyIJhvrKG8D2yZoEgJjAa5Rxtjyr4AgBpjZH0vBeJDRJp/B/GFp IbFedvn90Wqm6BcbB5++RuS4harZ8Ut4Jw83bRvcGwwT+R3mqbutGE0stoxFGSxl/9oAKMt889l B X-Received: by 2002:a05:6000:547:b0:362:d875:6dab with SMTP id ffacd0b85a97d-367cea73626mr1964117f8f.25.1720538810415; Tue, 09 Jul 2024 08:26:50 -0700 (PDT) Received: from m1x-phil.lan (vau06-h02-176-184-43-20.dsl.sta.abo.bbox.fr. [176.184.43.20]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-367cdfa06d3sm2835401f8f.75.2024.07.09.08.26.48 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 09 Jul 2024 08:26:49 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Peter Maydell , Andrew Jeffery , qemu-block@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= , Bin Meng , Joel Stanley , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , Jamin Lin , Steven Lee , Troy Lee , =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v47 08/19] hw/sd/sdcard: Add mmc_cmd_PROGRAM_CID handler (CMD26) Date: Tue, 9 Jul 2024 17:25:45 +0200 Message-ID: <20240709152556.52896-9-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240709152556.52896-1-philmd@linaro.org> References: <20240709152556.52896-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, 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é Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Message-Id: <20240628070216.92609-89-philmd@linaro.org> --- 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 216d4dfa89..05c1b85476 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1568,6 +1568,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) { @@ -1917,9 +1923,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; @@ -2478,6 +2481,7 @@ static const SDProto sd_proto_emmc = { [20] = {3, sd_adtc, "WRITE_DAT_UNTIL_STOP", 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 Tue Jul 9 15:25: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: 811447 Delivered-To: patch@linaro.org Received: by 2002:adf:ee12:0:b0:367:895a:4699 with SMTP id y18csp345718wrn; Tue, 9 Jul 2024 08:27:54 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVSOsayOugLcNgVZyzxo2kx0xlEfZ4Pga4Oj6/Qo5VTsTMZPlWUAK9RMxxKeyOlIQ2JCJfaOBIsxmBf07mly/+7 X-Google-Smtp-Source: AGHT+IEnjAUwxmcrzV3gnGaH7XKsB+lJftP2P3LhArefJgNRDOQsRN+we54D8VXMTmj6sCVLGISY X-Received: by 2002:a05:6102:cce:b0:48f:e9df:ec4d with SMTP id ada2fe7eead31-490320f742amr3265221137.2.1720538874456; Tue, 09 Jul 2024 08:27:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720538874; cv=none; d=google.com; s=arc-20160816; b=DWMsl18gT55u0rfGrK9uKupRJ8h0gr7hxqE7JzEfmZLASmEpTqLoX2nRSiCpFVxROy Nt/Thf7cIBsYWMFMDyo4kJ18W+J6HB0ozb4b90cw0NofTX4893QIPPl/E/RdSxrRAGG/ qSgQtRYE40rOIy7XkMEOEfmS3NboJRJ7lCB98v6Ep3yTZff7k/ZW9s4AwFDVFuDPlKK2 7BuxEIwvVeDKusOZfNutpY+9sgK2Lcy5XuiRFm1mJBky64UbZ+epmdjwSX5zqwtPxfwJ +y9Qr8FgDwRq8bcDSKW2ECD66qBIgyJaviSyKv8SUzuWD6e1F0AVsbGeXcRWKCfUyB+k m4WQ== 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=bwlDS3Fem601L5/uj6bQqEPalzfsgOLIBKrXuQLdMJU=; fh=FTbbPrkcFOTABrhnlIgLgb2V+67s1XK5x7UnuAmZO6s=; b=LN6Q9H8wkW7YI0DQY3YVqVcTVGLK5eLjRWx/OWmx2W1c1jvbs9D5Qcah05WCwjb6gZ 8g/OkLyGiEe57tAFRDFAz1kOPUkxyQ//G4s62dna3fpbSFV4VLwjchUWs3+tpnYqQA4b fwTy2obO6AIn/j1nQiI+LS2qV6HRIDUDUvnw9n94nKDFc11nowLZp7MVB5VxS+033Ozl Hftk1QKb/QwyN84J6ie8PbFgso5Ee8/41Lxn0rbME8yU5j2EzMh0Ak4inv1TY/KNy7Js uMIt02VWb+bnut0IVvVG6LybBH/sJzDLJKvIJ/zm274+iIxPGdAMOOqd/qlm08P/rCtj nLKQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FjYgybO3; 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-49031717f6esi329104137.297.2024.07.09.08.27.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Jul 2024 08:27:54 -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=FjYgybO3; 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 1sRCkB-00060E-Mi; Tue, 09 Jul 2024 11:27:03 -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 1sRCkA-0005tX-5T for qemu-devel@nongnu.org; Tue, 09 Jul 2024 11:27:02 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sRCk7-0006JZ-4U for qemu-devel@nongnu.org; Tue, 09 Jul 2024 11:27:01 -0400 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-4266dc7591fso12608765e9.0 for ; Tue, 09 Jul 2024 08:26:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720538816; x=1721143616; 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=bwlDS3Fem601L5/uj6bQqEPalzfsgOLIBKrXuQLdMJU=; b=FjYgybO3Sjth2k4OcmUcrv8Qh0KXzPAJniD0aHyIIrE/b9vUfPpka3LgAEyR8KxPGD +UVBbtt246ubUA5crTU4BhgOKDABGM4RX5LdVBnCPYafeWYjQPK2Vs2C6jq8atBiMlM8 d96NGOFiu3doqTpdrZXiJ5ui5ODs4kfvDx4hGfU8RF9nCI4a7/hq/5Gf0i4Y5McoLL+p ZfiU2WvW1gzCMd88NcrZbcsw5gN8pPg9Ey9u5nvnlC/P74rr7M6XLGMovoV64sj8hPAF TnfV/tuoKfh1AsCaa96Ve3lx9Hui9zHAv8UaBvAcRdkdJkm66G+Qb7htKvl3V11PSFav gyKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720538816; x=1721143616; 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=bwlDS3Fem601L5/uj6bQqEPalzfsgOLIBKrXuQLdMJU=; b=tRidMk2rLuXNTwJU7a5qp6ffkj8325rCxaz4yJGeVz/Ml5muPCmjeBf65PdSOny0Y5 cL/G5lW0cvpg62pbgqqbA8iollbZUR6OinXmkvvaqx39/J68UnKtORvILDLE+8OL+OmH P3n1crUQaEEc5DSGJOt9h31VrZ0JhWcHkzQPHlOGjkiKM4N3EPx0PCHvIRgjyzHugoig nmv9B+TsMu/Y5BEM0ABUP/WrlXCsFW2bNycRO2YdUrGaK97nc7T3TdAAW1ViMp9gB2if BDPeSArUXnbzNqZxwgnhpq4Xu7AnrYjWGN7MuKiStUFiV/WQnJKIhErbOhr//TzuEEk0 reZg== X-Gm-Message-State: AOJu0Yz78bGKJE7xpfsff6qpqZ+eKxCGkh8tqzUqWciFaWXoKpIRsmTM sbiAus/xQG6/iRqi/bLfgQtxwxfBBRUiwmbIYzx0WOZTv0wEglQjmbG5VQWNXZkxX2vNmV4CYNS + X-Received: by 2002:a05:600c:2112:b0:426:6416:aa7a with SMTP id 5b1f17b1804b1-426708f06damr23851025e9.34.1720538816441; Tue, 09 Jul 2024 08:26:56 -0700 (PDT) Received: from m1x-phil.lan (vau06-h02-176-184-43-20.dsl.sta.abo.bbox.fr. [176.184.43.20]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4266857c28esm98167515e9.2.2024.07.09.08.26.54 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 09 Jul 2024 08:26:56 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Peter Maydell , Andrew Jeffery , qemu-block@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= , Bin Meng , Joel Stanley , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , Jamin Lin , Steven Lee , Troy Lee , Luc Michel , Francisco Iglesias , =?utf-8?q?C=C3=A9dric_Le_G?= =?utf-8?q?oater?= Subject: [PATCH v47 09/19] hw/sd/sdcard: Implement eMMC sleep state (CMD5) Date: Tue, 9 Jul 2024 17:25:46 +0200 Message-ID: <20240709152556.52896-10-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240709152556.52896-1-philmd@linaro.org> References: <20240709152556.52896-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=philmd@linaro.org; helo=mail-wm1-x334.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: 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é Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Message-Id: <20240628070216.92609-90-philmd@linaro.org> --- 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 05c1b85476..adba53e822 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1236,8 +1236,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; } @@ -1294,6 +1305,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) { @@ -1696,6 +1731,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) { @@ -2018,6 +2054,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; @@ -2467,6 +2509,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 Tue Jul 9 15:25: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: 811458 Delivered-To: patch@linaro.org Received: by 2002:adf:ee12:0:b0:367:895a:4699 with SMTP id y18csp347008wrn; Tue, 9 Jul 2024 08:30:41 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVLA3res9YgF7yi4lc56sA9AQWoJQ2b6KE0/NFwjwOhoIjDAlf1CkUJxzihtzWLlUu1K+FfKPZy5cQRnZTLPdzf X-Google-Smtp-Source: AGHT+IGpKeX8CcyVF89CrCMOJLg0IDrGtlJLVjCoqm9pFhgKePZ2/AnT1qZO7XZ2np2QOVMjJeOB X-Received: by 2002:a05:620a:5a54:b0:79f:1915:5b3d with SMTP id af79cd13be357-79f19a70e50mr321718685a.18.1720539011464; Tue, 09 Jul 2024 08:30:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720539011; cv=none; d=google.com; s=arc-20160816; b=EeuIqIoA2qv+s7ML2omWs/5RRg3MeZRoN2jN3LRJkKKg5bxtpW2NaAA9+dCtIWo/Ky Mg/Vo5AMN/847kJFuzgOCGyh+Vo8Wlp6L8cyZs+aq1fjiwBjt7qA1lVsU89r7Q2jec7z xnmNr/iopz6gpBEFlvOOtLkSKgEjfFBteDTCarBUmz40ic7wwo9gb0rgGb4h0PxipNNc Yvfk9NZ827c+WSnwa7wW5WB2/ProJpnrcG6g/JXvUkSla0c4UhqM7nn5P0g86R2f23RM IkE75q43UquV90QVAzx+7My8dZjNfWXx3DRdR2CmTxEjcMQFZF6oFgcLm804al9x4uGi in5w== 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=/vVlv/BXkUK0BZMTLjJTuTB4p5N98pUrM0E2su3U72g=; fh=FuYhIR51RzCiT7PmpQ3BfNK1wcoVyrAuVFjuV5b0sBU=; b=hblu5Ead7vX06JTXDzDwE0n5127dTpe4//5uIiMcVdZIHSUu57yZwE/+M5Cg2axISu Zojumx28BDbworGL4k8bn8Gya4BYIbwtbfAZ75ZKPSVXh7oW/hqdeuwQ09cEO4ncsvb9 mTYuKexJMGefJZQbCPvZ8qpcby7E6uhy4POeytpv6aHzwBCBt9+y8BLr79Ft1tcUAvtJ Ixcz8U4aIJhOStUoe+j6t/7inOl6j/YnlPVIEHcka/+3WQFFLxzoe/G1ZeqfO4XYTM3v evXQXRn9Y5GCU5E08hWCZKlKmzseTE0cXOKrRtr3BmdLw0U1l1yzhFPakQqz3Fv3WOAx zK5A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uPoXwasM; 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-79f190a1732si226231285a.356.2024.07.09.08.30.11 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Jul 2024 08:30:11 -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=uPoXwasM; 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 1sRCkG-0006Nc-9y; Tue, 09 Jul 2024 11:27: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 1sRCkE-0006D1-Ic for qemu-devel@nongnu.org; Tue, 09 Jul 2024 11:27:06 -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 1sRCkC-0006MU-Os for qemu-devel@nongnu.org; Tue, 09 Jul 2024 11:27:06 -0400 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-36798ea618bso3445570f8f.0 for ; Tue, 09 Jul 2024 08:27:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720538823; x=1721143623; 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=/vVlv/BXkUK0BZMTLjJTuTB4p5N98pUrM0E2su3U72g=; b=uPoXwasMe0ddcYPlET0kXhhY8dWX9ZAmX/eTktQzX2Yyandp+fcUFTnzmTCy+srJIp M5EDMUab+ZahLj8IRbDo1Udvsqqu+l1aR+TlJYS7gyH7hI+/ndikRw4MPv+ixousN6Jy 64S6eb/coeZ5KO5TQBZFgxiCmo9EolKFu3+qTgCVrXMJfN5eYFCVynI/9tJ6UDillQOC /nhBd/JAOcphFDzBgUag3xURe1rXFw3kWSb18Q0nkAbI8BskhbMa8t1eOnmPJDILMuGV EckJUC1tWGMqLkMAtpYmAvm0sUpemj1hlJ6wqoEnZFR5McQsktnBI4siGKfCQIL40Dux pVpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720538823; x=1721143623; 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=/vVlv/BXkUK0BZMTLjJTuTB4p5N98pUrM0E2su3U72g=; b=W7WlUhxfDRPHgZEmH+ebFBRGLJ3dhEqByXI9EZ+Dd65+C841PTPERND05/itvD4HxY hmUkdNL81AjCB+6V0YppwRsOJqwgjfEjqLMLoWV0g8QsFQjRQm6yk6iw5oZZ2z/Zk+Ib Yx0CvEitx/xREQ/zHZagyXKk4osZnuod5u0B/A4ttKvIEgIWu7OuNxscpATEOaRSFFZe 7p5w/QpW6bjd69bcfJ/+i9ykjaGcSiEn/jp3aCGNleTp/m/JLJhhu73SUEXOxSTzbDwn ykVuCqJUdfosI9FJf+MgJzgMzc866Zbe1x2oW4mRwzvRiAfNqhncUFwME36HE+5lF4Zv cgew== X-Gm-Message-State: AOJu0YwdUb1C3BNfFA845ZeY4VdNGkGuYdzvU5xvIoeBrYCdPjF8Vsur CJqZ/l00GSg7NqKfZC4Gj0rDUYNezC7uNmeeQA+7VvSaGK3Lxk9ftj0wsHdKbzIEzvS0296IvO9 x X-Received: by 2002:a5d:64e1:0:b0:367:9993:dce4 with SMTP id ffacd0b85a97d-367cea4659amr2374389f8f.13.1720538822686; Tue, 09 Jul 2024 08:27:02 -0700 (PDT) Received: from m1x-phil.lan (vau06-h02-176-184-43-20.dsl.sta.abo.bbox.fr. [176.184.43.20]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-367cde890f6sm2850969f8f.53.2024.07.09.08.27.00 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 09 Jul 2024 08:27:02 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Peter Maydell , Andrew Jeffery , qemu-block@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= , Bin Meng , Joel Stanley , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , Jamin Lin , Steven Lee , Troy Lee , Vincent Palatin , Sai Pavan Boddu , "Edgar E . Iglesias" , =?utf-8?q?C=C3=A9dric_Le_?= =?utf-8?q?Goater?= Subject: [PATCH v47 10/19] hw/sd/sdcard: Add emmc_cmd_SEND_EXT_CSD handler (CMD8) Date: Tue, 9 Jul 2024 17:25:47 +0200 Message-ID: <20240709152556.52896-11-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240709152556.52896-1-philmd@linaro.org> References: <20240709152556.52896-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, 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: 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 [PMD: Remove deprecated EXT_CSD_SEC_ERASE_MULT/EXT_CSD_SEC_TRIM_MULT] Signed-off-by: Philippe Mathieu-Daudé --- hw/sd/sd.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index adba53e822..c809961418 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -124,6 +124,7 @@ struct SDState { uint16_t rca; uint32_t card_status; uint8_t sd_status[64]; + uint8_t ext_csd[512]; /* Static properties */ @@ -476,6 +477,50 @@ 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] = 0b1; /* 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_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] = 0x01; /* 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 emmc_set_csd(SDState *sd, uint64_t size) { int hwblock_shift = HWBLOCK_SHIFT; @@ -512,6 +557,7 @@ static void emmc_set_csd(SDState *sd, uint64_t size) ((hwblock_shift << 6) & 0xc0); 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) @@ -1405,6 +1451,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) { @@ -2334,6 +2391,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 */ @@ -2511,6 +2569,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}, [11] = {1, sd_adtc, "READ_DAT_UNTIL_STOP", sd_cmd_unimplemented}, From patchwork Tue Jul 9 15:25: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: 811451 Delivered-To: patch@linaro.org Received: by 2002:adf:ee12:0:b0:367:895a:4699 with SMTP id y18csp346070wrn; Tue, 9 Jul 2024 08:28:40 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWvW/eDXbRgoAyO0849RilhTqUD/rYQ6FuOYhmWHGek6jy6mcO7Xlo9zBM0aZjdDjDLaG4c7qjEOx20obSlK/du X-Google-Smtp-Source: AGHT+IGwTNQsNFLmFzGg6o46ig1ieFtw3WmaOBIV+960jVD5Z8xXLcOcG1NjGcTP6WTlD8hcKPbB X-Received: by 2002:a05:6830:ed5:b0:703:6e22:c8df with SMTP id 46e09a7af769-70375a1751amr3432719a34.13.1720538920091; Tue, 09 Jul 2024 08:28:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720538920; cv=none; d=google.com; s=arc-20160816; b=02YRzzy/Wxa6JARJBYVis++sI78CKMYKgdu8o/9xVNFJpKPS/hgzcsnbOlQKeub8GU QnDCcsxALip3zDKnIiMbCE/pcIvlnqiI94zesa7F7q6/L3rJPq4o+iwxYXq0+DDoeimT gU1rR4lJD90yeHUAy/6JGnYyrS6ChYk1tJNF4uypF+tXAMZti6kLMVIiCz3Vx/nb3uQ1 kiAEIT0Z4vYuoetB/DBl1Qf+6G7ZduCbb71qLSiRjqld4GT78j5HD1EhIpGT7YQ/ZmIF uCwCuvExICldOekUmtjjE1wPEUL0PbemG8xwks6YexlTVst6G31aAt/zZ/5/hwMQelaD hzKQ== 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=LTBSqa3nL1hHOoyNBKxeti60k1BPrqreQUxbpvz+1nE=; fh=Txzf7K5YV+qryaChbcvqA4D4sw+KVK3yVi4ERabJCxo=; b=mA+vYfM8XKCKeuHOyzLTqUtiBaMCaiCKGPVa37Qu9d7kBc4wq55+ZcC0u6XKdMDvVr UhhWTXKH3KZyH/L/EiQ/4SnZp5mzT9XxCyO49V5WfO+ByXG47r6vKF/K1f4q3Z8GLOpw 3d3hKNmNfXT31iAvUrfj/JZfWw0mMTi05KvkXf8thI2PfRcTNYNQMOh2JvhiImRflYyi l7rp8Ry7O1YkrkGblFiIh6p+XFYpSgaTNMHTTYdbzijZjyUvp8ysnzKyv/kKw2KzB6mV pXPHTAJWlAmi9ECOKNUIS+YeGW+Rj/Ka64lrn/4ms8+7aeu+mm12i93SNtEc1e5Xi6JY WpxA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=N8CNDyAF; 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-79f190a1cb2si233485385a.229.2024.07.09.08.28.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Jul 2024 08:28:40 -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=N8CNDyAF; 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 1sRCkM-0006yl-Ez; Tue, 09 Jul 2024 11:27:14 -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 1sRCkK-0006qd-Iv for qemu-devel@nongnu.org; Tue, 09 Jul 2024 11:27:12 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sRCkI-0006NL-46 for qemu-devel@nongnu.org; Tue, 09 Jul 2024 11:27:12 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-4266fd395eeso8159295e9.3 for ; Tue, 09 Jul 2024 08:27:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720538828; x=1721143628; 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=LTBSqa3nL1hHOoyNBKxeti60k1BPrqreQUxbpvz+1nE=; b=N8CNDyAFcgQ45r9+QBj7k2dqvsrN+kuHTqe8+15YCI1z9WR1EYB+BZdvdGaaCqcTGj 2tqQzREcmYEFActSKQU20tN0luQvUS++RU05IQV7LF7xCx9CqJbt1DbT7+0q6VkRPWqs reixfUtWIyd1ywdropRJ+fzCp8Sah3Pp7jvbtm119UP6IvNl6JnLnLQIfG7DAH2z//ll Ptu+RDG2ZalxAjzd3+mAWTR9EsO+uFROxcYHtUVJKXQVrokRND0WHeTgTtxR2Dj1pqAD 0F49zlec3thL9653h8zEjFO5uJGqhch30GFj+v2yZGXFdnu+TXi/41n7y+7qPqoeqDeg C83w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720538828; x=1721143628; 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=LTBSqa3nL1hHOoyNBKxeti60k1BPrqreQUxbpvz+1nE=; b=M2Bj9p/b1Euu91eUZbCnE1zcqsYj6ArZ1rErDBWudSU3NIlknU1Rna7XgTn+G1KagV YRQWnUJzEptkL1Nx59lR2MtHrbq2FTfuTRFjP/lqaIspcfjN8H/vJf6aaBpngvBpgHPM Sd6UgdS7Ic2ZWRsOA83uj2nQ7211yVdpDgo9uqwG71WlNE7vkyN/8vxnzEFZxEeI9YZ4 8vFupZBQA2xR4YuH0KxT9otl5ROqq0gaNpoIZM3QKOzVmsHfmD1G3dLUWEdcDQh5tV91 EXd68TstMkMHMeQaF+YIzrr1tsCeClD7wbrMFdpOhvLTnDz1h/QOOKF8xn3M3jm1O8gq qwYQ== X-Gm-Message-State: AOJu0YyVCf0F50g6zLsSOsi7zUDsaz/YW19YF720AnLiSQzE138PFWAq eSY8U5Gr3bQ9GBQt5xf1x1yFXUClVotmGl6RBWsTqzCpBBWjPM9J6LqDrHfkE6iPzbwagI2B6KH o X-Received: by 2002:a05:6000:c01:b0:366:eb00:9ddd with SMTP id ffacd0b85a97d-367cea47648mr1739600f8f.8.1720538828514; Tue, 09 Jul 2024 08:27:08 -0700 (PDT) Received: from m1x-phil.lan (vau06-h02-176-184-43-20.dsl.sta.abo.bbox.fr. [176.184.43.20]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-367cdfa0666sm2846473f8f.73.2024.07.09.08.27.06 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 09 Jul 2024 08:27:08 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Peter Maydell , Andrew Jeffery , qemu-block@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= , Bin Meng , Joel Stanley , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , Jamin Lin , Steven Lee , Troy Lee Subject: [PATCH v47 11/19] hw/sd/sdcard: Add eMMC 'boot-size' property Date: Tue, 9 Jul 2024 17:25:48 +0200 Message-ID: <20240709152556.52896-12-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240709152556.52896-1-philmd@linaro.org> References: <20240709152556.52896-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=philmd@linaro.org; helo=mail-wm1-x32f.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 Avoid hardcoding 1MiB boot size in EXT_CSD_BOOT_MULT, expose it as QOM property. By default, do not use any size. Board is responsible to set the boot size property. 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 c809961418..df0e2345c0 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -129,6 +129,7 @@ struct SDState { /* Static properties */ uint8_t spec_version; + uint64_t boot_part_size; BlockBackend *blk; const SDProto *proto; @@ -490,7 +491,8 @@ static void mmc_set_ext_csd(SDState *sd, uint64_t size) 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_BOOT_INFO] = 0x7; /* Boot information */ - sd->ext_csd[EXT_CSD_BOOT_MULT] = 0x8; /* Boot partition size. 128KB unit */ + /* Boot partition size. 128KB unit */ + sd->ext_csd[EXT_CSD_BOOT_MULT] = sd->boot_part_size / (128 * KiB); 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] = 0x01; /* HC erase timeout */ @@ -2693,6 +2695,7 @@ static Property sd_properties[] = { }; static Property emmc_properties[] = { + DEFINE_PROP_UINT64("boot-size", SDState, boot_part_size, 0), DEFINE_PROP_END_OF_LIST() }; From patchwork Tue Jul 9 15:25: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: 811446 Delivered-To: patch@linaro.org Received: by 2002:adf:ee12:0:b0:367:895a:4699 with SMTP id y18csp345612wrn; Tue, 9 Jul 2024 08:27:39 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCURyp2xlpztdoXsJexQHL0wAMcYnGd1xCORegsst7L+6o+fKhVOO8m54ECbxx3ZjxQa2lPHKsAUnxCegTqjM/rm X-Google-Smtp-Source: AGHT+IFL5/uUrHWdFYN90yyKKi1mAtO1kGV1sbcaG8enSw5ptxrlnKCDyqGusuo8EVYgIUN/Ie2J X-Received: by 2002:ad4:5d6b:0:b0:6b5:4aa9:9682 with SMTP id 6a1803df08f44-6b61c1c3e86mr35346116d6.41.1720538859614; Tue, 09 Jul 2024 08:27:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720538859; cv=none; d=google.com; s=arc-20160816; b=ht1eelKPyfpJ5To0coO1Y0m58eQRMMRKXn17ymlLwcMxFl9WTZ7XdJnBi7DelKSXp7 FBb09vZRKta6aHR66C3VWiyMNmQuPSD9kr9D/khZLSXZP0j+XeNkxi82u1E7sjqQYvIF 4zL5oVFjvTquZn085q3kRyRNn5CYaLi13VspBs09ni8qdzJ6R91P8o5/5q6K/sPwmtRa fP/sYCD4slZ9PNd6ctN6Qsc9ZBCCj6WlqDBoLO5ZIZJ8tiP6qUTsjTihUZBqGLu3xuEo 0hUVMqNEVNrUC/MEk86FClaOde4r3DZiBVIV69hlZioBRjqi5luV3KX5CUa7JSNlYlFG 1EGw== 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=W7BjhCdKxXxM0Spf2aaSee+AlxJ5nkV7EMWxkmbyq9c=; fh=Txzf7K5YV+qryaChbcvqA4D4sw+KVK3yVi4ERabJCxo=; b=eT04IQ+9b+Bn49Uxm83+pJk8fgG7XUzaLelaMIH/pccKxmhM0E36Xu9FnIQLUSOzHJ G/1eszQflv75yK/lDfhXQGBTQFiX1FC3wCGiumaJrgNEKex6vFFkGXKjOtvlaV7cd5wy ov0ViWGlA8JcKB7HiQvm4UxLQB0h/RGZER2KTMstHTkaZSL5Oe7joaPBLWjas3I+buQG Lh60oHks0DBHgnk6BXgnlNFSdUk11dyLfx2phdbai//fP1tmA76hORtoKTM0SbCGe3sX cJGL2yFh3z25AV/4sD4zfSHLs471C6WRLbfC+xIkBNF7DS59Sh+Ldt3F4sB8WHqZ0zij HgaA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KH5yDK8P; 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-6b61bab028bsi25368086d6.360.2024.07.09.08.27.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Jul 2024 08:27:39 -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=KH5yDK8P; 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 1sRCkS-0007bF-Uu; Tue, 09 Jul 2024 11:27: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 1sRCkR-0007Qr-8E for qemu-devel@nongnu.org; Tue, 09 Jul 2024 11:27:19 -0400 Received: from mail-lf1-x133.google.com ([2a00:1450:4864:20::133]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sRCkO-0006O7-Fv for qemu-devel@nongnu.org; Tue, 09 Jul 2024 11:27:18 -0400 Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-52eafa1717bso2595088e87.2 for ; Tue, 09 Jul 2024 08:27:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720538834; x=1721143634; 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=W7BjhCdKxXxM0Spf2aaSee+AlxJ5nkV7EMWxkmbyq9c=; b=KH5yDK8P4TtEwzPeQg1xdJ15AtIvVWK2QpUHpoKXViQ1qNr4r5TRGGhnCFFR2aC2qU YzbnXbWokvz9AXx9WXnzxNI2TgUm9QLAjvh5HBduMXpONGISVsJKQGsFBcUTGvRtoSUt cmKztsPpMJnKmULfFO8tLxAK9xCRW7JUPkRj/CzPmNtZTQvs8idAs2/IpjJ5jDhZ06CA 5R+V6iJo2gaq4TzOCo02z6ABKt1sPn+5PoFRthjaZKybV3jq0bu1kzqEbDnx3cO9//IL S1MasNQKb9MuYN2OWcTk2kxrCqMSljJBSQXTRbdXHcGfTXb7tii5AeUG0mR/TQLareD0 IpLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720538834; x=1721143634; 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=W7BjhCdKxXxM0Spf2aaSee+AlxJ5nkV7EMWxkmbyq9c=; b=QHPsLgyFJstP6x2NxCQPVs6LrMaYZ5X6JUljVAM/WieXKd18rH+3nYquRdIX3seY1/ hBejY/jkPZXajF+8IzAvOoynk1MBczQT9ZFP6I58OaUUPU0ql22em2wXfvk934c/A7N3 EhulL98T2dL/GA3HNRKvtSuVT3aKOu60sX7p7w2XgDFr4hVMP5Xh9OqnFK2gCe3ddOZ/ C5aL/fdAltJDu549ulL26+93NNUt7N8YaAl00VQ3pUBHePOc/VcaCOK6P/e1FXbtKzGR vhViHQe4Fx9LGuKPvFiE6DmB5+JSlobZkIoO5qGJ8WiJIqx9PnH3rAPFSlRElLqwt1wN dU+A== X-Gm-Message-State: AOJu0Yyg3KC9zr3G6CNzFFV/6MpBdYhBuuilKhM2+xhDmR2+FdOG0fLc IMJPasuhyoiB1yzkESDbv8MLq02b2+4ApCY0LC4ZUrLX3L0nhZeSKvEKPTHkS77rqq2Yix030tU P X-Received: by 2002:a05:651c:198b:b0:2ed:5c34:4082 with SMTP id 38308e7fff4ca-2eeb30ba0abmr27934141fa.8.1720538834345; Tue, 09 Jul 2024 08:27:14 -0700 (PDT) Received: from m1x-phil.lan (vau06-h02-176-184-43-20.dsl.sta.abo.bbox.fr. [176.184.43.20]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4264a2fc9desm215676235e9.45.2024.07.09.08.27.12 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 09 Jul 2024 08:27:13 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Peter Maydell , Andrew Jeffery , qemu-block@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= , Bin Meng , Joel Stanley , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , Jamin Lin , Steven Lee , Troy Lee Subject: [PATCH v47 12/19] hw/sd/sdcard: Simplify EXT_CSD values for spec v4.3 Date: Tue, 9 Jul 2024 17:25:49 +0200 Message-ID: <20240709152556.52896-13-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240709152556.52896-1-philmd@linaro.org> References: <20240709152556.52896-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::133; envelope-from=philmd@linaro.org; helo=mail-lf1-x133.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 - Set some keys to not defined / implemented: . EXT_CSD_HPI_FEATURES . EXT_CSD_BKOPS_SUPPORT . EXT_CSD_SEC_FEATURE_SUPPORT . EXT_CSD_ERASE_TIMEOUT_MULT . EXT_CSD_PART_SWITCH_TIME . EXT_CSD_OUT_OF_INTERRUPT_TIME - Simplify: . EXT_CSD_ACC_SIZE (6 -> 1) 16KB of super_page_size -> 512B (BDRV_SECTOR_SIZE) . EXT_CSD_HC_ERASE_GRP_SIZE (4 -> 1) . EXT_CSD_HC_WP_GRP_SIZE (4 -> 1) . EXT_CSD_S_C_VCC[Q] (8 -> 1) . EXT_CSD_S_A_TIMEOUT (17 -> 1) . EXT_CSD_CARD_TYPE (7 -> 3) Dual data rate -> High-Speed mode - Update: . EXT_CSD_CARD_TYPE (7 -> 3) High-Speed MultiMediaCard @ 26MHz & 52MHz . Performances (0xa -> 0x46) Class B at 3MB/s. -> Class J at 21MB/s . EXT_CSD_REV (5 -> 3) Rev 1.5 (spec v4.41) -> Rev 1.3 (spec v4.3) - Use load/store API to set EXT_CSD_SEC_CNT - Remove R/W keys, normally zeroed at reset . EXT_CSD_BOOT_INFO Signed-off-by: Philippe Mathieu-Daudé --- hw/sd/sd.c | 50 ++++++++++++++++++-------------------------------- 1 file changed, 18 insertions(+), 32 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index df0e2345c0..2a687977d1 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -484,43 +484,29 @@ static void mmc_set_ext_csd(SDState *sd, uint64_t size) memset(sd->ext_csd, 0, sizeof(sd->ext_csd)); + /* Properties segment (RO) */ sd->ext_csd[EXT_CSD_S_CMD_SET] = 0b1; /* 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_BOOT_INFO] = 0x7; /* Boot information */ + sd->ext_csd[EXT_CSD_BOOT_INFO] = 0x0; /* Boot information */ /* Boot partition size. 128KB unit */ sd->ext_csd[EXT_CSD_BOOT_MULT] = sd->boot_part_size / (128 * KiB); - 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_ACC_SIZE] = 0x1; /* Access size */ + sd->ext_csd[EXT_CSD_HC_ERASE_GRP_SIZE] = 0x01; /* HC Erase unit size */ sd->ext_csd[EXT_CSD_ERASE_TIMEOUT_MULT] = 0x01; /* 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; /* ... */ + sd->ext_csd[EXT_CSD_HC_WP_GRP_SIZE] = 0x01; /* HC write protect group size */ + sd->ext_csd[EXT_CSD_S_C_VCC] = 0x01; /* Sleep current VCC */ + sd->ext_csd[EXT_CSD_S_C_VCCQ] = 0x01; /* Sleep current VCCQ */ + sd->ext_csd[EXT_CSD_S_A_TIMEOUT] = 0x01; /* Sleep/Awake timeout */ + stl_le_p(&sd->ext_csd[EXT_CSD_SEC_CNT], sectcount); /* Sector count */ + sd->ext_csd[210] = 0x46; /* Min write perf for 8bit@52Mhz */ + sd->ext_csd[209] = 0x46; /* Min read perf for 8bit@52Mhz */ + sd->ext_csd[208] = 0x46; /* Min write perf for 4bit@52Mhz */ + sd->ext_csd[207] = 0x46; /* Min read perf for 4bit@52Mhz */ + sd->ext_csd[206] = 0x46; /* Min write perf for 4bit@26Mhz */ + sd->ext_csd[205] = 0x46; /* Min read perf for 4bit@26Mhz */ + sd->ext_csd[EXT_CSD_CARD_TYPE] = 0b11; + sd->ext_csd[EXT_CSD_STRUCTURE] = 2; + sd->ext_csd[EXT_CSD_REV] = 3; } static void emmc_set_csd(SDState *sd, uint64_t size) From patchwork Tue Jul 9 15:25: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: 811452 Delivered-To: patch@linaro.org Received: by 2002:adf:ee12:0:b0:367:895a:4699 with SMTP id y18csp346093wrn; Tue, 9 Jul 2024 08:28:43 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVMGEwrkyfe8vYXIGbsZXmGMT7nnK67OPjDmall0RzikgkplhZONnUsmEfUYW2RNqsp1r3iZlvhQaZgAhZGo6xY X-Google-Smtp-Source: AGHT+IFwTRujSwBk0kmP7oknyX1Up7ENu6JB+AmNc7PWqCB4DP6ZdVTsdbd6YIHfzf40ZazK+Tyu X-Received: by 2002:a05:620a:5642:b0:79e:fef3:ba3 with SMTP id af79cd13be357-79f19a3738cmr276671885a.3.1720538923032; Tue, 09 Jul 2024 08:28:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720538923; cv=none; d=google.com; s=arc-20160816; b=xf88Lfcf5LlxGCqM2e4CipzFUzZ4ys0JuS2ILpOhspDjBCZ1oLoEO8YKRoz2xz8ReD a+FdVo2eozGzcC5ZqwMjlWIFJzNe/6E6tESiU1iI8zHi9pU2ACP3MRov1/Rz4iUVCwt6 r8GMpvdgO5Oh+tGxd9pwsctQM9TMGsSSSwQNidzjdItB1NQKLByrcPFYOx9LbzC58EAa rnRO5QRti74cvS5jw8IxWRU3mX8aOVNL3DkTOYxF3EvmEFJAqXzo9+F9cCmuOV2jIdLp cTc3MQANC7pBxiNMfaMcHixye1+kRa5+i/2nXSYGBJGdQYkKN6FwlgODizG9L+Pzifm1 DwlQ== 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=PiXvczI/K3L/YAxv9emlFnk584vxqItosgTLQuNQXtQ=; fh=Txzf7K5YV+qryaChbcvqA4D4sw+KVK3yVi4ERabJCxo=; b=tGDKp1qA9KJ2sIjtd3gy7pV0wlSCm2NKONqqnA26qbsPaz/BtE0Oq0yEHG+dEJOEGh eabWfDIPB+Xugm5YPldA82JHXRCyfkb3BWuxXBB8Bq69cnyE/tz8DiCesAHNVcAR3QO5 kNYLL+IdpOvqk7mAY2uxipviw0KkgpZtf/c/1TUbs/k73+Aw0mErTjjQJDKYuB6cpN+4 n2rRA4DX21DDt+cZwl64G6VUtG9DpQavYmqyL6fA5V+s7gTps/DX+7L+ivFJhYdMTxfY Ct7rd0NGxF9Fo2OikYksPTCH6nhi3DZy11gngVqPEFokbmr+Vp8S8IOeZ0bL5aZkoWQw T3xg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pH3AEk9+; 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-79f1900e973si227732685a.65.2024.07.09.08.28.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Jul 2024 08:28:43 -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=pH3AEk9+; 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 1sRCkX-0008Kv-Mz; Tue, 09 Jul 2024 11:27:25 -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 1sRCkW-00086K-DP for qemu-devel@nongnu.org; Tue, 09 Jul 2024 11:27:24 -0400 Received: from mail-lf1-x129.google.com ([2a00:1450:4864:20::129]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sRCkU-0006P5-Jl for qemu-devel@nongnu.org; Tue, 09 Jul 2024 11:27:24 -0400 Received: by mail-lf1-x129.google.com with SMTP id 2adb3069b0e04-52e9c55febcso6912840e87.2 for ; Tue, 09 Jul 2024 08:27:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720538840; x=1721143640; 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=PiXvczI/K3L/YAxv9emlFnk584vxqItosgTLQuNQXtQ=; b=pH3AEk9+8CnSYWfSBZbiBgmEJcvi5aWFN8nrFWu6D86kbWrDIxBHb9lUGqp88x/aYn 4ZlnIO2v8ZgXil08ppfuXWHcUy56j9rcznUs8JPU22BhQ0iOXZWOcwWqh48uYX3KxxmJ iXU95s9/UXsdIp091jewSPF/tiETWTxS52WC74Sp4xzwzqgPDJgBVjKRLsOX6TmF6Xvx DSW84vErpXK+DA0RfCcwz1WqnW0C4LjXOOW6JLT3Vo9Ck08mWNn8LlKSf59icCQA8Rg2 Y0pvYt0UnEUE4LFRcAVVTtPH1rtM/41vx1RV4ei+GUA2BTWIh6ppbbwWMyfieePDncAr pCwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720538840; x=1721143640; 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=PiXvczI/K3L/YAxv9emlFnk584vxqItosgTLQuNQXtQ=; b=k/41gYokfg1aZu4n8MuRxGC1xBWBKvbnTFJeQ1UYnGJAYAj9BiE1J9N+OTnG/ReMtU 1SDCenijNMyHhSe+As5GrXPZZfIrdUtxsHw8W0KEzPxtx4AKkcG6sjmkfSbVIy+KrQBh eJa+e7oI494RlqJp/CuEV7v4OnnQWlhJeUk3TGiVH9xj/xRtwztAdK9Ry5xrWOTi7juT C/e7Xa2SbeCcj5bp27RSBzsSypGhgwQy3eTxuWyFleRVagk0RVuLznsylfDT/j3b3S9D IXcGMt9VUteuwQ8NK5v//Pu6JnbI86bym8z+SVw0Ok4B/v/r04LNdn1bJvlQrN4RLMMp AllA== X-Gm-Message-State: AOJu0YwTWpXSYup/j5VeHWcwREK2MwZ0KPLGXKy1Y1SePB5dZWQwJ31c CWjiinfWXlMahh3jdUzyzxr2NrA7ruvYOTyMO/5rbe/1mQIj/pVXjRdKN2P6AtNG5KhsspJar4n 2 X-Received: by 2002:a19:f80d:0:b0:52e:97dc:f5c4 with SMTP id 2adb3069b0e04-52eb999b36cmr1551519e87.25.1720538840211; Tue, 09 Jul 2024 08:27:20 -0700 (PDT) Received: from m1x-phil.lan (vau06-h02-176-184-43-20.dsl.sta.abo.bbox.fr. [176.184.43.20]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427270238a6sm12811475e9.20.2024.07.09.08.27.18 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 09 Jul 2024 08:27:19 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Peter Maydell , Andrew Jeffery , qemu-block@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= , Bin Meng , Joel Stanley , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , Jamin Lin , Steven Lee , Troy Lee Subject: [PATCH v47 13/19] hw/sd/sdcard: Migrate ExtCSD 'modes' register Date: Tue, 9 Jul 2024 17:25:50 +0200 Message-ID: <20240709152556.52896-14-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240709152556.52896-1-philmd@linaro.org> References: <20240709152556.52896-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::129; envelope-from=philmd@linaro.org; helo=mail-lf1-x129.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 Spec v4.3, chapter 8.4 "Extended CSD register": The Extended CSD register defines the card properties and selected modes. It is 512 bytes long. The most significant 320 bytes are the Properties segment, which defines the card capabilities and cannot be modified by the host. The lower 192 bytes are the Modes segment, which defines the configuration the card is working in. Only migrate the Modes segment (192 lower bytes). Signed-off-by: Philippe Mathieu-Daudé --- hw/sd/sd.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 2a687977d1..a391f12b2a 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -124,7 +124,13 @@ struct SDState { uint16_t rca; uint32_t card_status; uint8_t sd_status[64]; - uint8_t ext_csd[512]; + union { + uint8_t ext_csd[512]; + struct { + uint8_t ext_csd_rw[192]; /* Modes segment */ + uint8_t ext_csd_ro[320]; /* Properties segment */ + }; + }; /* Static properties */ @@ -881,6 +887,24 @@ static const VMStateDescription sd_ocr_vmstate = { }, }; +static bool vmstate_needed_for_emmc(void *opaque) +{ + SDState *sd = opaque; + + return sd_is_emmc(sd); +} + +static const VMStateDescription emmc_extcsd_vmstate = { + .name = "sd-card/ext_csd_modes-state", + .version_id = 1, + .minimum_version_id = 1, + .needed = vmstate_needed_for_emmc, + .fields = (const VMStateField[]) { + VMSTATE_UINT8_ARRAY(ext_csd_rw, SDState, 192), + VMSTATE_END_OF_LIST() + }, +}; + static int sd_vmstate_pre_load(void *opaque) { SDState *sd = opaque; @@ -928,6 +952,7 @@ static const VMStateDescription sd_vmstate = { }, .subsections = (const VMStateDescription * const []) { &sd_ocr_vmstate, + &emmc_extcsd_vmstate, NULL }, }; From patchwork Tue Jul 9 15:25: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: 811453 Delivered-To: patch@linaro.org Received: by 2002:adf:ee12:0:b0:367:895a:4699 with SMTP id y18csp346332wrn; Tue, 9 Jul 2024 08:29:11 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUSyAS0Con2h+Ah+Nip1CVMaAXLoekefTxaINrQesf0fn4dMEQlK5jN47Lz1YRj4y8iIUQ2oQDpkb40nuZu2PMn X-Google-Smtp-Source: AGHT+IFtiECPapDuaf0h9jPXlhBbr+IaD5Lzq6Nsn54vtlPNkI916mhpMciMOKGb3KrJo7rQIvq2 X-Received: by 2002:ac8:5807:0:b0:447:ea54:8cd with SMTP id d75a77b69052e-447fa8eafb1mr34508791cf.40.1720538950857; Tue, 09 Jul 2024 08:29:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720538950; cv=none; d=google.com; s=arc-20160816; b=b5egK2YbpNDCgPsAsTBnzVgFEoieFTiBYzxNJbdoUkeuAInqo/ZWsBGxBh/z000rKZ +1m6393/OWAGLADWBTY70S0CTWhn5WafFJFnNjqd/J0eswvfOxIRErZQEcJ9ozdJBbc1 ji52Pwdml/2Ik+EUjwYP4szwKaQFIuVKw7jyJqAe3rtwr5+NAZowtfOghVuu3uqbfrTq rvFjzubAdfZXg+WP4pfTObO8yNNKw0MKDl575V3uDPAxVdP4Bcv1z0GDNvcBYH2pDy0f RNTvlhjqTlnGtmIIST+isuQjn3r0Rim6N5C0/nC1i6rJjk5enDktr9ZfNrrX7qiqm4JS FJwA== 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=/wJ5lOyeKuAdtY89+hnEzjIVRBYuAVyLYyRgy5UbxAE=; fh=ObS7FA/lUB5P/4FBqBIiQIwVtwuCTVJOyzPGhPHIzV8=; b=KmiP6kCCytJqWlphkVQwlPJse5ybKdwQNfPdtM/l+UYAv31QFQys2bO1oyLMAaGMo5 5kOOEc01RVXWq811TnYOrqV0xhNGicNTKe3XBdIjksDPSfVomPKU92TxzCRKnbp9P1lH SX6DlincPa7b4RcYWaqVQGuR3nYE7idzHtpzPULSapSxGDawsyIA5KeFnYDn9Efo2J/f XLWobWnqhOzct31uHca3269XHBmGPgXRVO+EUx4+g7RNSPg4uP9JAvoOTMkzYS4smDBb lhSqXANQJdOF0WM4jg+SIFVmWumaziWDxGIljiG7GRDxgc1F30YhV1Trs4+UbUMw/ktA qprw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="hVndUIm/"; 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-447f9c0ebebsi26220731cf.697.2024.07.09.08.29.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Jul 2024 08:29: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="hVndUIm/"; 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 1sRCkf-0000vY-I2; Tue, 09 Jul 2024 11:27: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 1sRCkd-0000jL-FQ for qemu-devel@nongnu.org; Tue, 09 Jul 2024 11:27:31 -0400 Received: from mail-lj1-x231.google.com ([2a00:1450:4864:20::231]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sRCka-0006Pp-D1 for qemu-devel@nongnu.org; Tue, 09 Jul 2024 11:27:31 -0400 Received: by mail-lj1-x231.google.com with SMTP id 38308e7fff4ca-2eeb1ba0468so18543071fa.0 for ; Tue, 09 Jul 2024 08:27:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720538846; x=1721143646; 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=/wJ5lOyeKuAdtY89+hnEzjIVRBYuAVyLYyRgy5UbxAE=; b=hVndUIm/Xg31HQbSY0OG7nh8Zngf6P+sYMVQa11nKs1EiTZWWbsPvLd2+1Eah02Ub2 09T/E1Qql3J1WyoQpKF6As5JfefxyEGSTHkIsJT/J3600XEdE+jMgZVI6KuyOMvpLGdX 8h47GOzVw6nmiyEc5r7b8e55I5KW5ZiZWO0eFjfBdjctatFlbayEbjv5IRFIxLXhu6YZ hdhvpNiE830gMJpo3dT8le0UU/1Nm4z2p9uDH2evx99Rgkwek5ZiLeflsHoYeWfbBSdC hV9Je17jp+nlegTATbwxdScj7MWme8DyE9EYutzAQ1Lve72s7wSQJPPGuVKD+eJzUfWP 4F6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720538846; x=1721143646; 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=/wJ5lOyeKuAdtY89+hnEzjIVRBYuAVyLYyRgy5UbxAE=; b=ESxcr6VcDZ16D3C0JaXsQx28QGuMQD7cESoI0lHbSTFrMsW91qoWwkLHXgKT37aQli nY8xjDr2FLUI1ZWQQaAUgCaJ1VTGZGEQZhqxiJ1ntBksAGeArpuoyWscl3SVjPVhO9Lv 4Adxrx0azztSt0ksGTouksYjOu+9X5loy4ZNxuu0LVJ8OSO5gXbn7g0/FEuYX8XFOwvi F3P6ba/YTyYLsmDkM93qKUf9qR91EzlWYDw8XO76WQ7RXJ48L+NctOhSL3fnYdix7VZC GoGrmyZGgw0gN/9q/pnlZ/UjSaVOi1PeR4QbB6OdXsV7l1MCIPoZDzXalWG4W0w4iRDB h7ng== X-Gm-Message-State: AOJu0Yyv/eR3p3pgPQl9vMG8tFz+igr/sNbHkX2ufGWvLm07gyZ49Zpt ky51gFG4nmH1ku2bVQBSmoFU2d0qXvG3L+P1VL642ZrX3AbS7uHTtcxGW0seVvqzTNlgSPEoFVl Z X-Received: by 2002:a2e:9b86:0:b0:2ec:1708:4daf with SMTP id 38308e7fff4ca-2eeb319887amr18505731fa.47.1720538846212; Tue, 09 Jul 2024 08:27:26 -0700 (PDT) Received: from m1x-phil.lan (vau06-h02-176-184-43-20.dsl.sta.abo.bbox.fr. [176.184.43.20]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427165c69f0sm23171695e9.30.2024.07.09.08.27.24 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 09 Jul 2024 08:27:25 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Peter Maydell , Andrew Jeffery , qemu-block@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= , Bin Meng , Joel Stanley , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , Jamin Lin , Steven Lee , Troy Lee , Sai Pavan Boddu , "Edgar E . Iglesias" Subject: [PATCH v47 14/19] hw/sd/sdcard: Add mmc SWITCH function support (CMD6) Date: Tue, 9 Jul 2024 17:25:51 +0200 Message-ID: <20240709152556.52896-15-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240709152556.52896-1-philmd@linaro.org> References: <20240709152556.52896-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::231; envelope-from=philmd@linaro.org; helo=mail-lj1-x231.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 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 Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Philippe Mathieu-Daudé --- hw/sd/sd.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++ hw/sd/trace-events | 2 ++ 2 files changed, 58 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index a391f12b2a..beb8e2730a 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -642,6 +642,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) @@ -1091,6 +1092,47 @@ static uint32_t sd_wpbits(SDState *sd, uint64_t addr) return ret; } +enum ExtCsdAccessMode { + EXT_CSD_ACCESS_MODE_COMMAND_SET = 0, + EXT_CSD_ACCESS_MODE_SET_BITS = 1, + EXT_CSD_ACCESS_MODE_CLEAR_BITS = 2, + EXT_CSD_ACCESS_MODE_WRITE_BYTE = 3 +}; + +static void mmc_function_switch(SDState *sd, uint32_t arg) +{ + uint8_t access = extract32(arg, 24, 2); + uint8_t index = extract32(arg, 16, 8); + uint8_t value = extract32(arg, 8, 8); + uint8_t b = sd->ext_csd[index]; + + trace_sdcard_switch(access, index, value, extract32(arg, 0, 2)); + + if (index >= 192) { + qemu_log_mask(LOG_GUEST_ERROR, "MMC switching illegal offset\n"); + sd->card_status |= R_CSR_SWITCH_ERROR_MASK; + return; + } + + switch (access) { + case EXT_CSD_ACCESS_MODE_COMMAND_SET: + qemu_log_mask(LOG_UNIMP, "MMC Command set switching not supported\n"); + return; + case EXT_CSD_ACCESS_MODE_SET_BITS: + b |= value; + break; + case EXT_CSD_ACCESS_MODE_CLEAR_BITS: + b &= ~value; + break; + case EXT_CSD_ACCESS_MODE_WRITE_BYTE: + b = value; + break; + } + + trace_sdcard_ext_csd_update(index, sd->ext_csd[index], b); + sd->ext_csd[index] = b; +} + static void sd_function_switch(SDState *sd, uint32_t arg) { int i, mode, new_func; @@ -1402,6 +1444,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) { @@ -2581,6 +2636,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}, diff --git a/hw/sd/trace-events b/hw/sd/trace-events index 5dfe6be7b7..43671dc791 100644 --- a/hw/sd/trace-events +++ b/hw/sd/trace-events @@ -57,6 +57,8 @@ sdcard_write_block(uint64_t addr, uint32_t len) "addr 0x%" PRIx64 " size 0x%x" sdcard_write_data(const char *proto, const char *cmd_desc, uint8_t cmd, uint32_t offset, uint8_t value) "%s %20s/ CMD%02d ofs %"PRIu32" value 0x%02x" sdcard_read_data(const char *proto, const char *cmd_desc, uint8_t cmd, uint32_t offset, uint64_t size, uint32_t blklen) "%s %20s/ CMD%02d ofs %"PRIu32" size %"PRIu64" blklen %" PRIu32 sdcard_set_voltage(uint16_t millivolts) "%u mV" +sdcard_ext_csd_update(unsigned index, uint8_t oval, uint8_t nval) "index %u: 0x%02x -> 0x%02x" +sdcard_switch(unsigned access, unsigned index, unsigned value, unsigned set) "SWITCH acc:%u idx:%u val:%u set:%u" # pxa2xx_mmci.c pxa2xx_mmci_read(uint8_t size, uint32_t addr, uint32_t value) "size %d addr 0x%02x value 0x%08x" From patchwork Tue Jul 9 15:25: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: 811454 Delivered-To: patch@linaro.org Received: by 2002:adf:ee12:0:b0:367:895a:4699 with SMTP id y18csp346414wrn; Tue, 9 Jul 2024 08:29:21 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWqktJsKNNyPcRe5nagn+XreXywciUbXuCUF9M+zXuwMxzYUs/tCI8tY/J3j63M0AK2f9CoMb97IjtC25jQPvq7 X-Google-Smtp-Source: AGHT+IE4PvXkqylJuAWBI3uR7n9S5Z82NUKy0gDluW3uDwDDfToyio7XTCAZ3b37lE01r07cOzWe X-Received: by 2002:ac8:5952:0:b0:446:49f6:8ac6 with SMTP id d75a77b69052e-447fa92ca96mr31766931cf.37.1720538961145; Tue, 09 Jul 2024 08:29:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720538961; cv=none; d=google.com; s=arc-20160816; b=bkR5qqMgL1p/spz8mmtA7Ug8A0oiLAl0WGueGx8G98wwUbTF2Due8XJKcasvpYspoU xkBiNdSMv2wUTOYOj6P96rIFLMaQHzZdWIk9B5E4KSlmtA1Lg/R+I/4XVOkq+ayy/T74 kCVBqdCT6o6HBHkjLLseTL3pDnnDGtXxEExorvo3uG/GSKVLjuEggb7Mh0mMgQ6TplTC kBJtQS3mdruwkBKLe3bRwIRH4ZWMbXGYlJDQ3i2wklEB4hh/dD9YpeQCW3r43ewIWueH 2WGFnm8whNE547UPfJ+Hs1LyW/YzryQ3PjzHK3NkPz5Vx8zLRiAW7GE0YX5tCg+Q9zAD TgmA== 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=h9uxsmCdFdNFYJS/BApUCrJ5ayaONfYjrqqyp7Nd2Kk=; fh=Txzf7K5YV+qryaChbcvqA4D4sw+KVK3yVi4ERabJCxo=; b=rxqVW7dvRSw1Y8ABVU/bVe0hGLs7puE4PzGMX6cOm0CdWNzM8UvMlPZDE5x9dCTN7G QKDVhPux/5EhQys0HUtDJZOsxcY4r0oub/DUwMmiWio52QVb/SEAsy8LaJWu8jljYCM3 H5GZgagNWNvCBe8FG4gC05QaCcY2AgE1oDTgGIP+PV8lMIwHDPGFDGD9Sh1LoSNAnbRf 4WKHQmz71zkP14+eoAmlc+Rngr9PyfDqZw0x+CHxAShMp2kVVk2B909ru0Icu7JzDkZo V0L0EISmrBMGcNiIONwQSg6gHaFwaqD7rZDyA9RIF9dISokg/qvq9lOQTBA5tRsc2mQo bX8Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DrscL89f; 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-447f9af61dcsi26521281cf.30.2024.07.09.08.29.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Jul 2024 08:29: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=DrscL89f; 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 1sRCkl-0001W1-Vs; Tue, 09 Jul 2024 11:27:40 -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 1sRCkj-0001IY-AC for qemu-devel@nongnu.org; Tue, 09 Jul 2024 11:27:37 -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 1sRCkh-0006SF-CM for qemu-devel@nongnu.org; Tue, 09 Jul 2024 11:27:36 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-42561c16ffeso37251885e9.3 for ; Tue, 09 Jul 2024 08:27:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720538852; x=1721143652; 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=h9uxsmCdFdNFYJS/BApUCrJ5ayaONfYjrqqyp7Nd2Kk=; b=DrscL89fF8J5/9XZLjKneAKdukn+47qS33xmqionyZeilCJUhXrVKuYW1+eG69wV8Y zMfcGO5ZhWujkXifkSx+yXxV6jDcD1Ijs83Pjy3+8qHoLNJSshJGbXVrxuUs3e5kYHtz uP+dGkPUe9Lifkg74PPy1eu62f0aiwyJe1n0b623eRiASPe+O1w+9+4z+ko43s8irVBX H9HcGI0z0rHuJegHi/VEuTYYhGYj7DD4u+ibr1OgizuFFG4lbCVr/yXAZtmMvnoMSCcn zSLemHTIbv9Secu31ssVi1wCsHCYIR9fiB1OV5C52kaWWUh+JoED6iZka6sihQNtMqpJ 0JSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720538852; x=1721143652; 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=h9uxsmCdFdNFYJS/BApUCrJ5ayaONfYjrqqyp7Nd2Kk=; b=RCYlZBX7J5NctmDIwxup5vF52Okwy1Gyf9zuvOuPcxSvYQCKFJrf1CvA5FHPFlkP5I zEp8BlpHs7dErX6jLp6EkWbbQqX+85kY2J5bwNGDV4M+peKLg+CfbvYwcyxauIfmX1Rx gLHsYjT8iz7BY3C+gFcOvaS2pqH/W56TMtBgIu/AGLKFRPWQiWyRsyG82czMR+7Evo0R Z9fvSvQeYqEyypoksV/ZO9CJNB6bDQwsMTiIEdaX64aAes01rThqzyy1ODVEMStH2Oxn E5K6MYMBqDox4RfrKvWJMLtMAPOqv77r0Tam0+4vinTDU13KnCgrc8NlypffJiNlUIYl kiFg== X-Gm-Message-State: AOJu0YwYIjoRgps8lHMo8iLfNLdd3jY5K4hxqf8NhD9g5h74rLSOWSmZ Umni26uFUAn7Zeeu55OAUuMr3YX6YUY/2Z7AaAl9rvC/KcihIl0MFgty6RAAZalhL0mjS/QGnQk m X-Received: by 2002:a05:600c:2207:b0:426:5b3b:88b0 with SMTP id 5b1f17b1804b1-426707db78fmr18982815e9.14.1720538852166; Tue, 09 Jul 2024 08:27:32 -0700 (PDT) Received: from m1x-phil.lan (vau06-h02-176-184-43-20.dsl.sta.abo.bbox.fr. [176.184.43.20]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4264a2fca8bsm212580165e9.47.2024.07.09.08.27.30 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 09 Jul 2024 08:27:31 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Peter Maydell , Andrew Jeffery , qemu-block@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= , Bin Meng , Joel Stanley , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , Jamin Lin , Steven Lee , Troy Lee Subject: [PATCH v47 15/19] hw/sd/sdcard: Implement eMMC 'boot-mode' Date: Tue, 9 Jul 2024 17:25:52 +0200 Message-ID: <20240709152556.52896-16-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240709152556.52896-1-philmd@linaro.org> References: <20240709152556.52896-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=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 Spec v4.3 chapter 7.2.2 "Boot operation": If the CMD line is held LOW for 74 clock cycles and more after power-up before the first command is issued, the slave recognizes that boot mode is being initiated and starts preparing boot data internally. Track uptime since last reset, add the sd_uptime_ns() helper. When the first command is received, check at least 74 clocks are elapsed (during the identification phase, at a 10kHz rate) then enable BOOT_MODE in the Ext_CSD register. Signed-off-by: Philippe Mathieu-Daudé --- hw/sd/sd.c | 38 ++++++++++++++++++++++++++++++++++++++ hw/sd/trace-events | 1 + 2 files changed, 39 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index beb8e2730a..c7f8ea11c1 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -163,6 +163,8 @@ struct SDState { */ bool expecting_acmd; uint32_t blk_written; + int64_t reset_time_ns; + uint32_t cmd_count; uint64_t data_start; uint32_t data_offset; @@ -352,6 +354,11 @@ static uint8_t sd_crc7(const void *message, size_t width) return shift_reg; } +static int64_t sd_uptime_ns(SDState *sd) +{ + return qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) - sd->reset_time_ns; +} + /* Operation Conditions register */ #define OCR_POWER_DELAY_NS 500000 /* 0.5ms */ @@ -479,6 +486,10 @@ static void emmc_set_cid(SDState *sd) #define CMULT_SHIFT 9 /* 512 times HWBLOCK_SIZE */ #define WPGROUP_SIZE (1 << (HWBLOCK_SHIFT + SECTOR_SHIFT + WPGROUP_SHIFT)) +#define OD_FREQ_MIN_HZ 10000 +#define OD_FREQ_MAX_HZ 400000 +#define BOOT_MODE_DELAY_CYCLES_MIN 74 + static const uint8_t sd_csd_rw_mask[16] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xfe, @@ -798,6 +809,8 @@ static void sd_reset(DeviceState *dev) sect = sd_addr_to_wpnum(size) + 1; + sd->reset_time_ns = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); + sd->cmd_count = 0; sd->state = sd_idle_state; /* card registers */ @@ -906,6 +919,18 @@ static const VMStateDescription emmc_extcsd_vmstate = { }, }; +static const VMStateDescription sdmmc_uptime_cmdcnt_vmstate = { + .name = "sd-card/uptime-command_count-state", + .version_id = 1, + .minimum_version_id = 1, + .needed = vmstate_needed_for_emmc, + .fields = (const VMStateField[]) { + VMSTATE_INT64(reset_time_ns, SDState), + VMSTATE_UINT32(cmd_count, SDState), + VMSTATE_END_OF_LIST() + }, +}; + static int sd_vmstate_pre_load(void *opaque) { SDState *sd = opaque; @@ -954,6 +979,7 @@ static const VMStateDescription sd_vmstate = { .subsections = (const VMStateDescription * const []) { &sd_ocr_vmstate, &emmc_extcsd_vmstate, + &sdmmc_uptime_cmdcnt_vmstate, NULL }, }; @@ -1980,6 +2006,16 @@ static sd_rsp_type_t sd_cmd_SEND_OP_COND(SDState *sd, SDRequest req) sd->state = sd_ready_state; } + if (sd_is_emmc(sd) && sd->cmd_count == 1) { + int64_t clk_cycles = sd_uptime_ns(sd) / OD_FREQ_MIN_HZ; + + trace_sdcard_ext_csd_bootmode(sd_uptime_ns(sd), clk_cycles, + clk_cycles > BOOT_MODE_DELAY_CYCLES_MIN); + if (clk_cycles > BOOT_MODE_DELAY_CYCLES_MIN) { + sd->ext_csd[EXT_CSD_PART_CONFIG] |= (1 << 3); + } + } + return sd_r3; } @@ -2162,6 +2198,8 @@ int sd_do_command(SDState *sd, SDRequest *req, return 0; } + ++sd->cmd_count; + if (sd->state == sd_inactive_state) { rtype = sd_illegal; goto send_response; diff --git a/hw/sd/trace-events b/hw/sd/trace-events index 43671dc791..5454e55077 100644 --- a/hw/sd/trace-events +++ b/hw/sd/trace-events @@ -57,6 +57,7 @@ sdcard_write_block(uint64_t addr, uint32_t len) "addr 0x%" PRIx64 " size 0x%x" sdcard_write_data(const char *proto, const char *cmd_desc, uint8_t cmd, uint32_t offset, uint8_t value) "%s %20s/ CMD%02d ofs %"PRIu32" value 0x%02x" sdcard_read_data(const char *proto, const char *cmd_desc, uint8_t cmd, uint32_t offset, uint64_t size, uint32_t blklen) "%s %20s/ CMD%02d ofs %"PRIu32" size %"PRIu64" blklen %" PRIu32 sdcard_set_voltage(uint16_t millivolts) "%u mV" +sdcard_ext_csd_bootmode(int64_t uptime_ns, int64_t clk_cycles, unsigned enabled) "%"PRId64" ns, %"PRId64" cycles, boot mode: %u" sdcard_ext_csd_update(unsigned index, uint8_t oval, uint8_t nval) "index %u: 0x%02x -> 0x%02x" sdcard_switch(unsigned access, unsigned index, unsigned value, unsigned set) "SWITCH acc:%u idx:%u val:%u set:%u" From patchwork Tue Jul 9 15:25: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: 811450 Delivered-To: patch@linaro.org Received: by 2002:adf:ee12:0:b0:367:895a:4699 with SMTP id y18csp346019wrn; Tue, 9 Jul 2024 08:28:33 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUs8xJWb271MUkMQOr9e7yBSBM21dQsu9bC8ivqtHy8uMkrH+IdWfe2S8FamDGg+OZRvTXq08cvfx3F9IcTpUPN X-Google-Smtp-Source: AGHT+IGropeJ1qztRrNlZaA9BGNEqEE9pSzpQWh6BEVgM2jnrNlcgYt2tIY8QebWNnVUSEfhjPVp X-Received: by 2002:a05:622a:1496:b0:446:603c:5186 with SMTP id d75a77b69052e-447faad63bbmr32066751cf.60.1720538913121; Tue, 09 Jul 2024 08:28:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720538913; cv=none; d=google.com; s=arc-20160816; b=k3i2dmeO+ASfdFKUYe0CY36o4ovuRhRmSqIpACNa/s0IFl1+b2Fz1dNHKok3+mz0wK p3xaF4kGYUdIz190ZYg133cQetjJONaefaWRWW+LgctY4jrzE3KPEH4/WrPyEO6ZIshr gK0zsqnmXCruO/UGzam0kLoIU22whUom3sv23OtnTgIYreV0hbgkQyaWOi2+LRL/pGnm fzEziVBRH1fC81tOdyq9Qj/X6UE5oTMjhY3PCCaDFWCJBIDH/b5UX9KDXyweScXIJSfr JbHzIkFo/tLh9tWCgbVoFYikNiY/i9hEdYcRxDjpR/bvplcN9dUSIfWsYimikLzHhpvU JGKg== 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=+txOcp3qn5aM6X855Qa2b4pW5/3CYGUDetUe05A68E4=; fh=Txzf7K5YV+qryaChbcvqA4D4sw+KVK3yVi4ERabJCxo=; b=u0BJr/P93XtMRVzbR2LOhD8mGIODUI/c6Sx5+NvvYfxHKDytVw76ONOYl+gOHDUifY CUTaZI3H8JoMZzYdkLvjSclLIiPzX4tgX8LeY03Yx8B5xJxzd12q9WQkav3zPzKrkGdR vopZ4xXjWnOhf/L7XIu/NB7ZOKwST1tjm3X/9vcW0dHzCEwOXiYN30QhZfI2gZXyx/NI OHHTdS5VF5VHVVIPBO5bHB555IQxweZAVNrHgEMDV+KPWcarCiLLPKE2yU16l0M14VM1 4HpfhjPxzIUuNS6rSkdfVhB2vjtLAqOaAsycRAeD3UdChzn/m12t8k5PZ+045Ml/jsK3 5Ipg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kIaWSKI2; 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-447f9b1e259si23293051cf.170.2024.07.09.08.28.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Jul 2024 08:28:33 -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=kIaWSKI2; 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 1sRCkw-0002Pg-Mw; Tue, 09 Jul 2024 11:27:50 -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 1sRCko-0001ln-1V for qemu-devel@nongnu.org; Tue, 09 Jul 2024 11:27:42 -0400 Received: from mail-lf1-x135.google.com ([2a00:1450:4864:20::135]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sRCkm-0006V7-3C for qemu-devel@nongnu.org; Tue, 09 Jul 2024 11:27:41 -0400 Received: by mail-lf1-x135.google.com with SMTP id 2adb3069b0e04-52eafa1717bso2595561e87.2 for ; Tue, 09 Jul 2024 08:27:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720538858; x=1721143658; 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=+txOcp3qn5aM6X855Qa2b4pW5/3CYGUDetUe05A68E4=; b=kIaWSKI27ipfN2ZrRUnpzR1uxBX14Z8BHEVcoaMRaYzrMps/+T1htjYW5e8VNv2Isv 0+j/QsuYxg7b8lypSURktaZNCm8QuPsy6adp3WaZ2FlkdzfafFfse7j2YMcVspcqQeTb InzMvwrSF0pId9D+rQkYIoZrRnyRAGO7Ew9rB7CVCqfaztoeTNna+inpwUSll6zyKeJM hPCsKDbd1szPTSqHHtU0L8kjV7Zf3JB9a2hWIEH/w++dgcjWehusXlhvpULtTCd+xA3D AyKCPNY0YXViYM/Hfeiizmvf8S2eLxKN3J4jzAY2xDGw3C7jPc7seChympz+9taebe0o 89Kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720538858; x=1721143658; 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=+txOcp3qn5aM6X855Qa2b4pW5/3CYGUDetUe05A68E4=; b=SVnxI0Od2jcjsIYfpM1jJiM/WcNUjvZ+qOuMPc5scJzam/tnZopmOCE4YXZqBFLDAZ MLaeWENSOBR8WkmBLu6XRdPLnhSTKRsGJFJtfyIAsvSGSze2klvWObIJf5ETjqU4AiqT Ro+FtUnxPuunnUPXvIZp8ltLy8Nrntlz/1AS9UXTR6xhvvLldVO96yYeNqhjFZn+Xg6A CkkZJtA/o6pYhhfPlgWke9Y9cTGpY89iiT272syfqju9NnOwar7v4psqtQ1fG5f0V/GC 5oSwFoUbKBCju3Kzb63PYpH2wWD2jDLR/S0XDVVqEK/PK4av31rbuvWBR052dUkXxBHb ikyg== X-Gm-Message-State: AOJu0YyhoqzRVzXNwp2BNlprLEE5GyF1nTUK9EyUmf/OkV/yID7UrXGx OlwZxjUJI/VBzRnsUN2/1Hp25t6tJd6cTi6dubvnF38jvIZAhOp9lM9C1/pENjf6hlKPAUQjMP4 F X-Received: by 2002:a2e:9495:0:b0:2ee:7b7d:66df with SMTP id 38308e7fff4ca-2eeb30ba26amr17868591fa.9.1720538857887; Tue, 09 Jul 2024 08:27:37 -0700 (PDT) Received: from m1x-phil.lan (vau06-h02-176-184-43-20.dsl.sta.abo.bbox.fr. [176.184.43.20]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-367cde891a3sm2840837f8f.61.2024.07.09.08.27.36 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 09 Jul 2024 08:27:37 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Peter Maydell , Andrew Jeffery , qemu-block@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= , Bin Meng , Joel Stanley , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , Jamin Lin , Steven Lee , Troy Lee Subject: [Aspeed PATCH v47 16/19] hw/sd/sdcard: Support boot area in emmc image Date: Tue, 9 Jul 2024 17:25:53 +0200 Message-ID: <20240709152556.52896-17-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240709152556.52896-1-philmd@linaro.org> References: <20240709152556.52896-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::135; envelope-from=philmd@linaro.org; helo=mail-lf1-x135.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é --- TODO: Update QEMU command in description --- include/hw/sd/sd.h | 1 + hw/sd/sd.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 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 c7f8ea11c1..5830725629 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -774,6 +774,13 @@ static uint32_t sd_blk_len(SDState *sd) return sd->blk_len; } +static uint32_t sd_bootpart_offset(SDState *sd) +{ + SDCardClass *sc = SDMMC_COMMON_GET_CLASS(sd); + + return sc->bootpart_offset ? sc->bootpart_offset(sd) : 0; +} + static uint64_t sd_req_get_address(SDState *sd, SDRequest req) { uint64_t addr; @@ -1026,9 +1033,33 @@ 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 emmc_bootpart_offset(SDState *sd) +{ + unsigned int access = sd->ext_csd[EXT_CSD_PART_CONFIG] + & EXT_CSD_PART_CONFIG_ACC_MASK; + + switch (access) { + case EXT_CSD_PART_CONFIG_ACC_DEFAULT: + return sd->boot_part_size * 2; + case EXT_CSD_PART_CONFIG_ACC_BOOT0: + return 0; + case EXT_CSD_PART_CONFIG_ACC_BOOT0 + 1: + return sd->boot_part_size * 1; + default: + g_assert_not_reached(); + } +} + 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"); } @@ -1037,6 +1068,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"); } @@ -2871,6 +2903,7 @@ static void emmc_class_init(ObjectClass *klass, void *data) sc->set_cid = emmc_set_cid; sc->set_csd = emmc_set_csd; + sc->bootpart_offset = emmc_bootpart_offset; } static const TypeInfo sd_types[] = { From patchwork Tue Jul 9 15:25: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: 811457 Delivered-To: patch@linaro.org Received: by 2002:adf:ee12:0:b0:367:895a:4699 with SMTP id y18csp346899wrn; Tue, 9 Jul 2024 08:30:28 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVGb8eJ/t/IL9TrInhs35Q6C3Rc5QXM6/KmQ6U370A4sQUIQ4oY5jAxXAg+gxXoK6ynTmEvd1T8UbFp0aB6aW63 X-Google-Smtp-Source: AGHT+IH/VxlQ3nwxabyg8guo/LnVFWXJKGed5mv2kOq5sZEIGwloHJnbC8i2iHxnm/T6K0SBwWZi X-Received: by 2002:a05:620a:4723:b0:79f:e7b:dcaa with SMTP id af79cd13be357-79f19bf15camr375636585a.56.1720539027930; Tue, 09 Jul 2024 08:30:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720539027; cv=none; d=google.com; s=arc-20160816; b=SZaC+QnLS+mRpiUddV1ESQHpnEU4wR7jqOm8aKPRbm+xuzkLErAvrxzZpJxZFsyjJg dq+/6P8NsCKhJqoF1AvzRUecPygBDrQwutm8sKpQ+lqhoP1SUC9UcIrMOgZ9iPQFbk9n P+vkFIpssErlUAmFGJE4vC3lGSzs3GR1IOsE2Hq6+tIt11hrs3ywPlEuVUfEqadcs4m9 rfTcPpwE4EfjCZTVdXB5SfgvV7S5zxf7spBkf+fY4BDLTGlkfkxR2dMR5HuodxfCspWv Vmn886iO325ox3MyYY+JMa44HLh9h7J6YFQGAUqsWRFE9G8YE9yyd18qGsBokoF7qtVO s9VQ== 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=egTnAJY4Ail08o7ydS3nshQ0gmoljQp4B2SNOCZM4Nk=; fh=Txzf7K5YV+qryaChbcvqA4D4sw+KVK3yVi4ERabJCxo=; b=wejPHAuBZAiBfDUUgeNFtt3cf8LzzFvr7ulxMIz8GDae02CVMXtjZF1FK4m/BNh62l m1FjZP+Iaiby8m8NJDR3Jid09ZPsmj3U6jH95bUfTexuf3mVs7OlGXOCnEHGQ7jmmsla 7j9BZEF79sNT8q2T9X92XNBFTJqE/260qTsE6AWyswLbBoYUWl8aYSz2EYaDjL+UF/9a 8nDqcLiPjdJ8m902FVIYeLalNvMX0VbAXErdm0BZGqkcjU+HZenidRDM/ZzDiMQjo5Us PJHFbTzqSZ9eMtDptV5ERVKvOzcnmql5y28t633Aq9XW3Wkdccx3u6zyh/H5vHyQhb6Q 1wnw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OCW5Xo4U; 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-6b61baae92esi24082526d6.392.2024.07.09.08.30.27 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Jul 2024 08:30:27 -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=OCW5Xo4U; 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 1sRClG-00046S-HQ; Tue, 09 Jul 2024 11:28:10 -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 1sRCkw-0002WF-S3 for qemu-devel@nongnu.org; Tue, 09 Jul 2024 11:27:52 -0400 Received: from mail-lf1-x12c.google.com ([2a00:1450:4864:20::12c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sRCkt-0006Wd-Kg for qemu-devel@nongnu.org; Tue, 09 Jul 2024 11:27:50 -0400 Received: by mail-lf1-x12c.google.com with SMTP id 2adb3069b0e04-52eafa1717bso2595699e87.2 for ; Tue, 09 Jul 2024 08:27:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720538864; x=1721143664; 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=egTnAJY4Ail08o7ydS3nshQ0gmoljQp4B2SNOCZM4Nk=; b=OCW5Xo4UcQ5u/BJ4MZXAT1fDkefnYsAR0UV53gtFdVQOc9bbFskBaqgRBcHaOv/TEz ImwmvYdnLBDs8Yno1SkzmQhetSDiu7uVw8KLBhvXr/XVPKrYKbqY1lSXNoiNe4JnnxWX NNXttNrlVfOlV3yuBdyleXnOzcn9ZzNiy2bECUyFOdMxIZ0O80FzJAOsGh2tubfC6Lcm c7IDGtACVso5Ae2nPDC0zwm1eFzhGzOQtTlAKoyLGEevfsKmwXBwQMKrGykOGFSVrwd9 h8o82ToB3+Wpy4D1oqCcJC6xduNLJQFCY5TgAZwXMQp/Eed8qsnbXD1AIRNG4BEtbsZb 8xcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720538864; x=1721143664; 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=egTnAJY4Ail08o7ydS3nshQ0gmoljQp4B2SNOCZM4Nk=; b=nRVy3cy519DBgvT4rkO4dIRyuHcCLW4DIH+/OvU20lVFcxykmHuWgsQvwAbOLcZyJ0 cu+Rz+a4s7azdtb/ZKPkG/KL0JiUVzl2vA2CoZ1q62PIzK9BrjVSIMYU81wGmjpaM8MB POMR+HnDDAR2zSWn5nBNKV38/hxRzbReAhr35+QOKTRn82RHHvIkIGEfLRMaWaQQzcOt pAtrZp33u7y/qen1IYWjJKbjrgjQ2KbWfbLokpoM5bkwt/hum5M8JJS91hV+In2KrWN8 u6SWvew/yUKHqiHcj0vXkRAYKT7O4VdCZqliYyR7yazxOknKxHS0UIjb7iYU7fwNI7xy CE1A== X-Gm-Message-State: AOJu0Yy8wCbNKxIxZLmYC8h5BHbfihpWo0LNaiRKZEalN/BEy0/JJL/M u0vSxtXmcI3OAkiprlZW+t8+MkvVSNqbCUq+UB7d0TA2/P7+8v8tLElPXkg/AaFSnCssM3J2Eas l X-Received: by 2002:a05:6512:2309:b0:52c:8024:1db with SMTP id 2adb3069b0e04-52eb99d4ebamr1935061e87.63.1720538863738; Tue, 09 Jul 2024 08:27:43 -0700 (PDT) Received: from m1x-phil.lan (vau06-h02-176-184-43-20.dsl.sta.abo.bbox.fr. [176.184.43.20]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-367cdfab80asm2863625f8f.109.2024.07.09.08.27.42 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 09 Jul 2024 08:27:43 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Peter Maydell , Andrew Jeffery , qemu-block@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= , Bin Meng , Joel Stanley , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , Jamin Lin , Steven Lee , Troy Lee Subject: [Aspeed PATCH v47 17/19] hw/sd/sdcard: Subtract bootarea size from blk Date: Tue, 9 Jul 2024 17:25:54 +0200 Message-ID: <20240709152556.52896-18-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240709152556.52896-1-philmd@linaro.org> References: <20240709152556.52896-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::12c; envelope-from=philmd@linaro.org; helo=mail-lf1-x12c.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é --- Squash in previous? --- hw/sd/sd.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 5830725629..291497468f 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -814,6 +814,10 @@ static void sd_reset(DeviceState *dev) } size = sect << HWBLOCK_SHIFT; + if (sc->bootpart_offset) { + size -= sd_bootpart_offset(sd); + } + sect = sd_addr_to_wpnum(size) + 1; sd->reset_time_ns = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); From patchwork Tue Jul 9 15:25: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: 811449 Delivered-To: patch@linaro.org Received: by 2002:adf:ee12:0:b0:367:895a:4699 with SMTP id y18csp345956wrn; Tue, 9 Jul 2024 08:28:27 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU3XQu7o63/ty/SSioZ+JZcseYzzfuA1+l8L92h1F8AzqPB+v2UORBqIPSyfJvjp8q4ptcd28EwYSukgvkXndeI X-Google-Smtp-Source: AGHT+IGl9Qxb2aijdwcgmNDw5+zkmlB0sU8SqtuFC4X6ScoP9j/qxvD5FGLPCpsOvLoJ/1NMY9mx X-Received: by 2002:a05:620a:9d5:b0:79e:ff31:5876 with SMTP id af79cd13be357-79f19a78a7amr321646485a.35.1720538907710; Tue, 09 Jul 2024 08:28:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720538907; cv=none; d=google.com; s=arc-20160816; b=qgIXGxiOqKShoJUWYybpgvDaKsWpkzOY188PGx81R9NE/2Yp/3JZs0v4Bhf/xoHvXK PLLSWN7PS4IEA+AyFgCPptguTgeZrFwgj2EzujximDmjKvuR4Vld5Ahin1gXswpkOBgT XkDSptQiY4QY6OWZDbzFVq8QGfhaLquQIsKdyvQRN5QBGnst4PGuaDYcm4iSL0MdUD2u VRVMMOIAsoDyDk9SqIApxFSw/vNfxsn0lC2kwzrEp+rYLe5iOyeYCF8s1+VPwTR1zs67 dB3YTU+Th+g8ZtASrPZCK7gpeJkg7cYt2pRHloKM+UMJtFXZbHPZLRsTRAoACKJorLVY 07tw== 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=QXjiHIW2zvTWYZ1fQhAbimXm28ql9EP4J/4/P4b4vws=; fh=Txzf7K5YV+qryaChbcvqA4D4sw+KVK3yVi4ERabJCxo=; b=QzBixto5phrlr7IoJgdR+3XHZoHq6WeJM7ZyGrEVqpLHe/XgD2zOvqhP8702qBLdhU aeS0auFzZNbGqRI00UGnak030bzTiX5nMuJ2R6m0+Cmb9G9tItaQLrbp3SIQVKjGrWE1 nj4fKB2Wx+4zmHKg10AXaD6KTCJBqNeOf4yrlST0CnbhllLOaeW5dl8X6wMCI0K174mp KUWmSod3n7e5GsFY7WzigqFj0r9JmO2gO8qiVUlWmgE8+wJ+aONmXzxMnL899NDOgewI i/NnITMDXuBHH9QiNSflT0snormNDz+gltEIQ8WVKOdKq+Mh+nFbgJYhkSUjAZl4j3BS x8Kg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PMjZA2Dy; 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-79f190e7919si236596085a.729.2024.07.09.08.28.27 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Jul 2024 08:28:27 -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=PMjZA2Dy; 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 1sRClF-0003v0-FN; Tue, 09 Jul 2024 11:28: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 1sRCl8-0003JQ-6N for qemu-devel@nongnu.org; Tue, 09 Jul 2024 11:28:02 -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 1sRCkx-0006XV-8C for qemu-devel@nongnu.org; Tue, 09 Jul 2024 11:28:01 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-4266edee10cso9947745e9.2 for ; Tue, 09 Jul 2024 08:27:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720538869; x=1721143669; 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=QXjiHIW2zvTWYZ1fQhAbimXm28ql9EP4J/4/P4b4vws=; b=PMjZA2Dy+2ZvgemVNuVYKhGtn2g/XF6fSWTWUY3IbuCvYNFhZdzzHqM/ilkLTX/hA8 FFQMrhQACG9CTxb0S2orNKqd/AUypt/j46OdPESQWlE36wsksa1tuG1Blt9iV7KCuvks Zf2LGGznEpmtVf/hevKaQnbqUDrwUBO2BxWml8cDTY9+thRNUs8wylTs1GKH55PkfOcY dKVqMO5nOKnHoDpfsG94A3vtpyOUaNazXIrpgMm/wII2HSohuacUfn9iD25I7p7CzY3J uwPBkzpfhCPM1zQQwiKkpSdtTJqENQy4Um3g6a7xAgjsuZjOrNvUiW+2/9RfmxRtayrs kMwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720538869; x=1721143669; 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=QXjiHIW2zvTWYZ1fQhAbimXm28ql9EP4J/4/P4b4vws=; b=rSzhkp2AaBaLXfTlEMGlSvRU8YoFYbHFQUAEM/EP2sDVzBD5JHmeNFWKzVe2qQK2Fk YWhYU5ICVpB76VwESF5dZLHIuUTf3ckR3ZUJT7sHwbiCFS4VWAdwIo12BpHgiUD44HBd vvdajdQJCEXnToB/T4thPGMtU/LFtQ9PpFUCqKcbCg0GTSoGqmgXUSx1F2JiWZAub3uh 0wUln2J2PpthxN/5c+xu6u+Mw1PoPjVc0XIgC1nbs9KefzKmaPec9uXLJvvWaCG3Hnaw hPY3/7lHh//Sdcegh/h8lak7daAS8QcPS5Qa4QhS8uCRF7VB5YOwKkCKvE3lNdb6uxPY /Bfw== X-Gm-Message-State: AOJu0YzaEQGqnNCpPmZkv+i/cVph6OZqjguwRCuxqXZ/BUbYpwzfoBk0 EzW8pE42wiPpkh07uKTF11WoOV5WGZm3oBqOvyfOW0PNJKvN0tk7UG7ZBgo8x/JLKC8hNMaNKr3 1 X-Received: by 2002:a05:600c:1592:b0:426:647b:1bfa with SMTP id 5b1f17b1804b1-426707cd9e2mr21459385e9.8.1720538869497; Tue, 09 Jul 2024 08:27:49 -0700 (PDT) Received: from m1x-phil.lan (vau06-h02-176-184-43-20.dsl.sta.abo.bbox.fr. [176.184.43.20]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4265f84cd44sm138532405e9.18.2024.07.09.08.27.47 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 09 Jul 2024 08:27:49 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Peter Maydell , Andrew Jeffery , qemu-block@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= , Bin Meng , Joel Stanley , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , Jamin Lin , Steven Lee , Troy Lee Subject: [Aspeed PATCH v47 18/19] hw/sd/sdcard: Add boot config support Date: Tue, 9 Jul 2024 17:25:55 +0200 Message-ID: <20240709152556.52896-19-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240709152556.52896-1-philmd@linaro.org> References: <20240709152556.52896-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 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é --- Also squash? --- hw/sd/sd.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 291497468f..6aa83251f7 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1047,6 +1047,12 @@ static uint32_t 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; + + if (!enable) { + return 0; + } switch (access) { case EXT_CSD_PART_CONFIG_ACC_DEFAULT: From patchwork Tue Jul 9 15:25: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: 811459 Delivered-To: patch@linaro.org Received: by 2002:adf:ee12:0:b0:367:895a:4699 with SMTP id y18csp347272wrn; Tue, 9 Jul 2024 08:31:06 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVWskOSI9iOS3hTnL7MJr9K6OL20d2xFYW/XzY70YqbZ9IHNHgBl+q5jwNlomiof1q64dPxxH4blmnpEu34ptEs X-Google-Smtp-Source: AGHT+IGBLCzmOVrazLuDAsnMr3l9CbeonGGtjEL0fBdtn53Rpy05dks/8QvhumUzPxRIbvgQW+JH X-Received: by 2002:a05:6808:1811:b0:3d9:3538:8cd0 with SMTP id 5614622812f47-3d93c0a91admr2492783b6e.52.1720539066370; Tue, 09 Jul 2024 08:31:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720539066; cv=none; d=google.com; s=arc-20160816; b=jiINBf/iyF0IWwQuK8E/xdZDtYiaoK03TUGh2ewJ0wUu4zkZqA6HRVY1+fyCK+frRd tz4miD7DdL7bguOO+GRx2sHAwGmw3eYxr91+olWQsUpR6f/aOcPoTjPlhr93TthWqbRN KVD6YM2Fk5xAMQCHGZCea5bqsHxSMp/5dJ+5EMmXkYMfWPt8xJ4DSVy+24ylpuVtBGak 8cI7VLbGXB8Uhks6pgIttA8c2hMThLtTPGMKI2vztlfbiwj81qmPdZ60AfeR7SJhUZYU Wrz7DebzFMXTzEb7rN26UmCxPfHYpazDckWqproYu6wvipbNAcWjBZuHiEovgd6l0bo2 27zw== 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=+IrpdCD+BuSWH4PAnzhWg9dOS6Rs+7FERDF9DQN/buM=; fh=Txzf7K5YV+qryaChbcvqA4D4sw+KVK3yVi4ERabJCxo=; b=QWSRhrd1kMKilyuQ3AA/1oj8FvLRm4yORi+XJdiiTuqSb4fpnDi737SlTUnR5kvLBY jRMSQTUvycyFTbiwn3RLJjoENME/OwKO+NwY6tbgjFTizeDwU0X9jLFXE4HvQzmkgilz mfnSRoBAIktMstiOAHrs6C24KHRqLA46byJPHKTl+725zSwq7nqbgGGSm/jzADN8fKYp XLpvQWPF3kI41jA1UpsIunMTl5oOZZatrJA/nPvAUQXCYUTR37JZNsaQ4+vvCzwUqRJL Dk51vOqzE3CDJJnP3lc/lGEkW1Rs1K2DSxJbvcuxcB2IY65Zm9WvdrsuB9mi6US3/XCL OLtg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TQIzWjlz; 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-447f9bc6fa6si27769031cf.506.2024.07.09.08.31.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Jul 2024 08:31:06 -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=TQIzWjlz; 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 1sRClH-0004JU-KB; Tue, 09 Jul 2024 11:28:11 -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 1sRCl9-0003T9-DA for qemu-devel@nongnu.org; Tue, 09 Jul 2024 11:28:04 -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 1sRCl3-0006Y7-SV for qemu-devel@nongnu.org; Tue, 09 Jul 2024 11:28:03 -0400 Received: by mail-lf1-x12d.google.com with SMTP id 2adb3069b0e04-52ea1a69624so6105525e87.1 for ; Tue, 09 Jul 2024 08:27:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720538875; x=1721143675; 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=+IrpdCD+BuSWH4PAnzhWg9dOS6Rs+7FERDF9DQN/buM=; b=TQIzWjlzP2Vk/R3b23Bu50k2arFb2fFPAA+v5ToFk4KxWqDKMY5A6gtd6a9f0mpctk OGq8Jw7EzNhRqrFrhV0kn3Z0F4Suqd2ziOJabG4NmawKNUtuSWQx3XDZZlmEWmUQ539M pb1paKImHdWxcDDH5rK6h0otyX6aMU4bEkNz00PmdKdBkgfu04cXLLaZkgDRMc1Amfoe pJM1JodVQHMXUQSSV3YbX5zezjLZaemdzZbtBamBjIiYH1RX9jx8GDeqZjunijHRCQDw U9GSkD54z+FTdhJIf9d3IPxQGXRm0dAp0RUiw6nOblzdeZRx/dsXI0orfh1kD6q98Atw nxBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720538875; x=1721143675; 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=+IrpdCD+BuSWH4PAnzhWg9dOS6Rs+7FERDF9DQN/buM=; b=IPl/KlOQdtxmlioyRDMCzQ2Q36enr++P/psKXm8d+V6okb1HwmCuG54rfkMyCF/22J Cbxa+0yhxf7rNl4HhfDGsLPd/21dW839LIluIkHCSSA8mdfUj9Fx90Iyr3Ql5i9FYpzE WdU3+pMgzPUgtWn8lFcZcDYdI6KTGj3iFuPGLaH4UOkzQPLPf1qoQVAeP/7THWJB3SO4 JV79uoNXgJGBERv4AQrHOglmxdlr5S7edwNThHRuqeJVbmSzJN42sda6m6O+iO3IqHJ/ vCf7x+xdXpFsoo9HsJ2+KKQsjhMaeWcoEtY1zhoahQK80oXcEiiRMQQUq5EfxQGYIfCz 8bCQ== X-Gm-Message-State: AOJu0Yz3iwFJsFaZr0Gjbd+xhAIfIZdhhP+WeabgVn8AQT1Ank+noUfE 6gZu47PqoRCm4C+1hxDhzxSIYT4NMnC8wk9f6+Vzzuh7lcqZ3v2O82S7puFLwiNlj6Z7vf3MdfC v X-Received: by 2002:a05:6512:1154:b0:52b:c14d:733c with SMTP id 2adb3069b0e04-52eb99d741bmr1577497e87.68.1720538875240; Tue, 09 Jul 2024 08:27:55 -0700 (PDT) Received: from m1x-phil.lan (vau06-h02-176-184-43-20.dsl.sta.abo.bbox.fr. [176.184.43.20]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4266f7420cesm45316395e9.46.2024.07.09.08.27.53 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 09 Jul 2024 08:27:54 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Peter Maydell , Andrew Jeffery , qemu-block@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= , Bin Meng , Joel Stanley , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , Jamin Lin , Steven Lee , Troy Lee Subject: [PATCH v47 19/19] hw/sd/sdcard: Enable TYPE_EMMC card model Date: Tue, 9 Jul 2024 17:25:56 +0200 Message-ID: <20240709152556.52896-20-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240709152556.52896-1-philmd@linaro.org> References: <20240709152556.52896-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, 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 Now than the implementation is functional, allow to instantiate it. Signed-off-by: Philippe Mathieu-Daudé --- hw/sd/sd.c | 1 - 1 file changed, 1 deletion(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 6aa83251f7..4a6e9cc035 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -2941,7 +2941,6 @@ static const TypeInfo sd_types[] = { .name = TYPE_EMMC, .parent = TYPE_SDMMC_COMMON, .class_init = emmc_class_init, - .abstract = true, /* FIXME: Remove once model fully functional */ }, };