From patchwork Fri Jul 12 16:27:09 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: 812326 Delivered-To: patch@linaro.org Received: by 2002:adf:fac3:0:b0:367:895a:4699 with SMTP id a3csp776356wrs; Fri, 12 Jul 2024 09:28:36 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVZVo18ooM7m0DIDA20ARYlbCF5e4Mu991hxzZU15i4kWDuDmvRN8tZ5L86/CT3ICJaLXGkzkF5aznJ92ILyJ3W X-Google-Smtp-Source: AGHT+IGADHaFe88AJ86nEEGIm+HnKEJ1YG7B7bsZLbTeNvq9IZqw1ie1BLJAy4SWllAJUiXPiBzC X-Received: by 2002:a05:622a:44e:b0:440:5c2c:4cdb with SMTP id d75a77b69052e-447fa8ada02mr134426741cf.2.1720801716221; Fri, 12 Jul 2024 09:28:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720801716; cv=none; d=google.com; s=arc-20160816; b=dGRVuJ+6l+Xky4x+yQC/gkzZ2R/DqV/GK7WBERVTcNlBKJAUa2nQWMWyVKVTaETSTs qqKv5e+WqmGWpGIpMMO5WWCjlPtuFqD/eWxiJSvRtc1j77oiGQDGroCcXIla3iyxm5NF OrawvWSAbuPKC14XWCMAn4DRwah2+BHBjjwL7QyQ7R3KCuucrJtWUciPOS8/EJZu3P7n nfeF5C4xIOCVp62SZu+C03qNnyHMNmkDxHfuIt0vKfAubqQD3At85vfMZ4uNkzl29u/X VvXQL6PLWiA+Qh/k+qpasSwqNvs2ajUIgNUxUp102d4UgwOEGINy5zehHn4PRqta1GnK zqTA== 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=028ItQlbMTMgJ1FRirGXJn1fWZM/NJLzC/E7/yKCK2M=; fh=0lh1+S5AkurUmwugNk9f2JvBhFbiqisXOXBMxcJJ8zQ=; b=B5fcp3c4dPKjLssjmBaY5nioCMg8yNLVqYaVw/vpW5kRuM7eTMjkSvOY+DlEY0vJvy vxSN4M9hKlVwCAK2BoUgGnL21qpZaZcush3k/CZcZxS/59aK8H7ZGdLL8TKvDzDYcl8D 1pdkOqXUGkYdW265gsvoPg3je1xFWy0G5AZLLsIAkh9sZlMvYuJlFyypBoqQOccGOekF cs5oRUvSqg8eW4Q3qsLvX2h6oPUej7JEOlmt9/y4kXhkBJlea5QLYmi1UNIngV8CQr// unOvtj0ofOeq3yDhp5145wYbuZ7sxUgRkOD2X0qMF5cN5vBwd+uSPpd4ysqztI9qoJju Hq9Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BBwyHqP1; 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-447f9bc37e6si95710011cf.434.2024.07.12.09.28.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 12 Jul 2024 09:28:36 -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=BBwyHqP1; 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 1sSJ7P-0004ZD-K5; Fri, 12 Jul 2024 12:27:35 -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 1sSJ7N-0004S3-Gs for qemu-devel@nongnu.org; Fri, 12 Jul 2024 12:27:33 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sSJ7L-0001wD-C6 for qemu-devel@nongnu.org; Fri, 12 Jul 2024 12:27:33 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-4277a5ed48bso16036955e9.2 for ; Fri, 12 Jul 2024 09:27:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720801648; x=1721406448; 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=028ItQlbMTMgJ1FRirGXJn1fWZM/NJLzC/E7/yKCK2M=; b=BBwyHqP18d0ORlJM3UX35X0FPfexfW42uAt2mnIplVe3zSFT9UGD3Md1muEB6v0vFb q8stCUyklJKBTYvJDFo4VGvURuWn8TUUhMJ7PLI6jCLYlacLqhGLaxoUtyx3F8AGUJMc dYmlXYhIA3ZlCSxEFVywBaGrkjKdwGvBy3B4b6VXEHhO4cXSj9mKDTlsfYzGkZ6wyTAQ KTdmsjCXGuTVR8k5nWERE1790FrUQ4ZNstla9BOjpTSYDV0M0iqtCqmGY0YVUUeK7p/O hIKpALwSVMIKS40xVbT9pjJSKwITdRmxRJ0/NjewPACtFDc9UoQoUa5iGlQQ7X/BkPMD uylw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720801648; x=1721406448; 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=028ItQlbMTMgJ1FRirGXJn1fWZM/NJLzC/E7/yKCK2M=; b=u3VTInTLxjdtk8KKtoqNJj5692iY9XGJfqmQRWhCwl9NfiXhgDD9yhpeGYAQasyowr wXjpp4lbUDNGrj+rGEcHE3eIZdG1wZbG5A83bSN0mUh6rMTvkf6KZIKjMgm1BblhVA/E A84y7hoJ6K1wmANjICaGFygQqWN4U+bgfk3j+h83LzrgksTG8L18ib4aYekkXz6GBKqq WN40Xoirj+gApCPI89U7L8Z7da4US8efI0i52Vga352+8R9g0mxRwaS08yXzE1FiWhi5 KYJqPa+vc/T6I6G3nr+GFzjNBPq89qIedkfu/7PmpPJbxFf5eU4Lks5o4t6Z8CgfF2M0 5c+w== X-Gm-Message-State: AOJu0Yzo3NMeg4d4r69BsiGU0oLKyan2PC4GbFP0XGVxbA7NINP6vA1r VFLZPcmtGVhy43AVCMs9TQqpjipdBIMM/QvhbP+HlhGVNPbLhFZO+yiFMhpJDnoaZyWQPCq5pCk N X-Received: by 2002:a05:600c:252:b0:426:5b21:97f9 with SMTP id 5b1f17b1804b1-426708f02c6mr83562715e9.32.1720801648620; Fri, 12 Jul 2024 09:27:28 -0700 (PDT) Received: from localhost.localdomain (nsg93-h02-176-184-54-152.dsl.sta.abo.bbox.fr. [176.184.54.152]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4279f264875sm28271505e9.11.2024.07.12.09.27.27 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 12 Jul 2024 09:27:28 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , =?utf-8?q?Philippe_Mat?= =?utf-8?q?hieu-Daud=C3=A9?= , =?utf-8?q?Philippe_Mathieu-D?= =?utf-8?q?aud=C3=A9?= , =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH v49 01/11] hw/sd/sdcard: Basis for eMMC support Date: Fri, 12 Jul 2024 18:27:09 +0200 Message-ID: <20240712162719.88165-2-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240712162719.88165-1-philmd@linaro.org> References: <20240712162719.88165-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=philmd@linaro.org; helo=mail-wm1-x331.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Philippe Mathieu-Daudé Since eMMC are soldered on boards, it is not user-creatable. RCA register is initialized to 0x0001, 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. The CSD register is very similar to SD one, except the version announced is v4.3. 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é Signed-off-by: Cédric Le Goater Signed-off-by: Philippe Mathieu-Daudé Tested-by: Cédric Le Goater --- include/hw/sd/sd.h | 3 ++ hw/sd/sd.c | 107 ++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 109 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..ea01bf6e28 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[] = { @@ -438,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: soldered 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 */ @@ -451,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] = (3 << 6) | (4 << 2); /* Spec v4.3 with EXT_CSD */ + sd->csd[1] = (1 << 3) | 6; /* Asynchronous data access time: 1ms */ + sd->csd[2] = 0x00; + sd->csd[3] = (1 << 3) | 3;; /* Maximum bus clock frequency: 100MHz */ + 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; @@ -697,7 +760,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 +2438,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 +2516,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 +2536,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 +2592,23 @@ 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; + + sc->set_cid = emmc_set_cid; + sc->set_csd = emmc_set_csd; +} + static const TypeInfo sd_types[] = { { .name = TYPE_SDMMC_COMMON, @@ -2530,6 +2630,11 @@ 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, + }, }; DEFINE_TYPES(sd_types) From patchwork Fri Jul 12 16:27:10 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: 812325 Delivered-To: patch@linaro.org Received: by 2002:adf:fac3:0:b0:367:895a:4699 with SMTP id a3csp776357wrs; Fri, 12 Jul 2024 09:28:36 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWJDUakOGvjSgHudg2g9cmwtOMn+cnqvFpsnlXmLaw5i0R7mAR7/AMUBF4/zYysy1AJJhFVLqUFc6ZlWXgY3jap X-Google-Smtp-Source: AGHT+IENOPaCflmIZOzkzS7CmPP3WRI5SWSgm0ZqXTJCa6N8T/zGxnOBJSx4vhlqc69/st35q1NT X-Received: by 2002:a05:620a:987:b0:79f:1869:11fe with SMTP id af79cd13be357-79f19be7542mr1312459085a.52.1720801716205; Fri, 12 Jul 2024 09:28:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720801716; cv=none; d=google.com; s=arc-20160816; b=qS1nzqFlTi1VWVxSaBYxLKUhXeLq9eMZzUCJLLdr7t6GJ8ar3EUa10QwSlWc9/rt8v Ga/YfB9wQBpJfQIcGbtWyKjqCyqUIwvqnJ3FKv1c1S4vS2tzC5kFQy5o3qph9V9qYQvP C+3uVUmn7+Zee0aZCqcEzeYk1bC5aF4if1yNEpLlaozNNYfsTRBqWujJtKg+fSSDx+n4 PxYvxGJ/7DO0DnwCQy9nlLzo0VCm82//j8uO5N9kzLjfkFWVUN/BBymQl+NLMFKN3rnX nMGZGgNGOiqVFlSV5NDOKpYgHFZGBCG/MjGl9MF3C0ixS3BpYSEoGFUJarnZaWSMi4z2 LSBg== 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=c7/Od3GnXnJNmfNQc7GYavEDu253S3N7cdGFHtSU0M4=; fh=TW6+ULwo1p4b9zwtgcIpKT4kG3RJoiJN3Pv7qtK92ok=; b=IRHiwzYSke0nBRr/vdAJtogjb8+ZzKA17+FVaZC5brIIrrWxJo6mAvMTfmSNINkY9G X8Syf8OxKt+RXqUNh3cobefextvBvZ0gqPDCQgUgxTxX3eEpD9HXCAq2T7qkbr6g5KAh Ev+C9uf1s9gyuyw3iu6SZZfKJ4drTbc4cy+zmA4gkV9Wllm86C7HltERy1HIy6nY9VkZ ftTP/k39BywZ6evWChjlt86wwNAPf+vP1kPHQpsUW8b45sw2A+J8nvDeLppafSXDWbdc PQBo0RDB4kLgRiFT7RgDR5/IDW00Or5H6XMEsPuhWv2MEm/HxeR95qwm1/86HRSFHouG J2pA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zGFrfDW5; 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-79f19029c82si993509685a.183.2024.07.12.09.28.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 12 Jul 2024 09:28:36 -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=zGFrfDW5; 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 1sSJ7U-0004n4-8i; Fri, 12 Jul 2024 12: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 1sSJ7S-0004jy-2X for qemu-devel@nongnu.org; Fri, 12 Jul 2024 12:27:38 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sSJ7Q-0001x7-BN for qemu-devel@nongnu.org; Fri, 12 Jul 2024 12:27:37 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-4279f48bd94so6160615e9.1 for ; Fri, 12 Jul 2024 09:27:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720801654; x=1721406454; 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=c7/Od3GnXnJNmfNQc7GYavEDu253S3N7cdGFHtSU0M4=; b=zGFrfDW56y0r2P7qCCFQt5OTAeLe2Xa+hPcGWqkdTICwXwvNJbPpybYnwahMUMOoqm tqcpth7mnc/VZoLyZZ54adn9mf3sMQx719MAP/3nm7FGVceV2zkFqoKpActRKW8GADLE mvHyHlIRHGQg/5MZyN+keZGjt3d+UKRGyn3lFe6yXNrRF5nu+NIAoX4/1KmOUBrdGw5b GSH6xP9Rp1fGKbEwdTTNB2z70xBCcsi9ZGPthzLj1VFn9UkFMdfX4hjtfXtU5lxM+IKz vRKzuOOCUeEDGL/5jlt/YZ50eqaio7vW3jnUHD++wmFPTnGPFL15rBTTMUqpRmZpxs91 QjTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720801654; x=1721406454; 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=c7/Od3GnXnJNmfNQc7GYavEDu253S3N7cdGFHtSU0M4=; b=Mqeb4HL8Tp/bUdGDWlIxjOjx4BBsPg+oVBLiQMY8kLSK1d0fgjdhJFcRRAFrB5Ss/p 8ZYyAMDmkPNO69eeorQuFvwBL3PNKvyy7tiSTy6Y5IJgpAzqmTVqm7qd+h5xBGzy4ZCM G9zYszFOS96Oo1XfqqS0DpclERqdy/UAjtQ0ItSPKPuESMIL58BUdRhSDckxLGHnQDde 3ZtOh+xeK4ggi5Be+Hq3jwk7xqc6S53q2TJcTmZJEd9oNcOdMDsy4dLbQsA5WxIF/Ku/ rbX4dhG6782OI/y3DyH2V2RQU0jTK7s5UBhD1dUqVascV+RKNmlGjlZHLDizp7vALj+a 3hZQ== X-Gm-Message-State: AOJu0Yz4ndOu+w33hM0qYgeSQmmpf9fs9y5+LkHQKOhnWpKJBspGDMel 3IH0UZGjtW70KZNhLPEItBloUYghWXlv3mCGRqUSBZpseMtBnX5QZpGOAaDVRu+aMu8+BUrcjxO o X-Received: by 2002:a05:600c:17c7:b0:426:654e:16d0 with SMTP id 5b1f17b1804b1-4267018b105mr98273645e9.0.1720801654547; Fri, 12 Jul 2024 09:27:34 -0700 (PDT) Received: from localhost.localdomain (nsg93-h02-176-184-54-152.dsl.sta.abo.bbox.fr. [176.184.54.152]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4279f2b97dbsm28067025e9.31.2024.07.12.09.27.33 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 12 Jul 2024 09:27:34 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , =?utf-8?q?Philippe_Mat?= =?utf-8?q?hieu-Daud=C3=A9?= , =?utf-8?q?C=C3=A9dric_Le_G?= =?utf-8?q?oater?= , Andrew Jeffery Subject: [PATCH v49 02/11] hw/sd/sdcard: Register generic command handlers Date: Fri, 12 Jul 2024 18:27:10 +0200 Message-ID: <20240712162719.88165-3-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240712162719.88165-1-philmd@linaro.org> References: <20240712162719.88165-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=philmd@linaro.org; helo=mail-wm1-x336.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 Tested-by: Andrew Jeffery Signed-off-by: Philippe Mathieu-Daudé Tested-by: Cédric Le Goater --- hw/sd/sd.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index ea01bf6e28..0093bbab3e 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -2442,6 +2442,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 Fri Jul 12 16:27:11 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: 812328 Delivered-To: patch@linaro.org Received: by 2002:adf:fac3:0:b0:367:895a:4699 with SMTP id a3csp776382wrs; Fri, 12 Jul 2024 09:28:41 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXvHOrG7Tq5i2rJu125+vjCP18GGF5Y5BKTJzqNmfep94mhUm/7jOHYpX7aLFTcTJbxb4VBwZUnyFnxOsqDNJvY X-Google-Smtp-Source: AGHT+IGD/NH8uz9i1+jgXmdxtC3PtAhrRwpCUFMb049No2fRnT4wURHefc3F1WSTzHZKRJrOSxpE X-Received: by 2002:a9d:7497:0:b0:703:5fb2:34b7 with SMTP id 46e09a7af769-70375b5595bmr13743092a34.32.1720801721597; Fri, 12 Jul 2024 09:28:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720801721; cv=none; d=google.com; s=arc-20160816; b=ZjycdaOo+wtRBGjekQ1rgYETB1J0y8YDoILBVSYriNQbckxx7NpmSdToL9XrZ+lZgj Bd3Uz/o/GcAXjk4MQr5DIIH5TaX4QDp+BY7STaYaGllqdlQCG7ag0ipjwroDP+VOUQNG +GRDVC4jHJTLtglnepG/kRWwokHohhy1VqlCZQg+sX0CU7u2uK0y2btk82+zB0MmvK3U m5OdDYzpohW6QkT/IV9AWXkxNU+/ohF6m31P6mQ1oKp+pgixPmdHsXbZ4Z6GKtcAp7rH LE+5ZpZBB4Iq9NA7tmHpvyewMqKRv4YbPUWHXYgUle92on6OXwszLzhJ2R82wBdnAl/Q XNqQ== 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=ebPss3HetnUGp7ZOFtBIyU5z7Qqo1tTAoW4e3fLcmFs=; fh=TW6+ULwo1p4b9zwtgcIpKT4kG3RJoiJN3Pv7qtK92ok=; b=SXbRJv3Vn5K1ZMIf7p+5hQXtOWaqWztmZmqBUvJZ7GE3iOTkLNH8WnzMssTI6gEqBn ftiddxQmwZDq2812IYM3/8NzMEvQRJY0dN6sBqBWZknLFwK3kcIs9Q376/mVJx93yMaG dolRe+Y7T6sM7/b1bM21BfYw4z3EX+ZFIA/LG4m6TWxzRdsS23vLuwmfJ4D1iaXhn+Wh Tn+7CGG6JP73YZbEwq48zaJ6V+2s4uM7kJvR2fWBxkQDPx8GPK/dLWpKRZPnwYeN0lnF /qkTjx/rI7Vw4Rg1/qdby1USNrua+CPMgCsXhgjN6mFMM+++YQjhLOVjtXmlHfDVaKdN LORw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SbWBirSB; 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-6b61bac9956si105133496d6.459.2024.07.12.09.28.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 12 Jul 2024 09:28:41 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SbWBirSB; 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 1sSJ7g-00053W-Bi; Fri, 12 Jul 2024 12:27:54 -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 1sSJ7Y-0004xv-GS for qemu-devel@nongnu.org; Fri, 12 Jul 2024 12:27:44 -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 1sSJ7W-0001z2-6v for qemu-devel@nongnu.org; Fri, 12 Jul 2024 12:27:43 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-42797289c8bso16155055e9.0 for ; Fri, 12 Jul 2024 09:27:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720801660; x=1721406460; 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=ebPss3HetnUGp7ZOFtBIyU5z7Qqo1tTAoW4e3fLcmFs=; b=SbWBirSBRc9yYNMMjiL6pcpgu/b5UN48oB1XLhPveUj4O51Fdghdo8rTuhQ1VKxJZ0 y9QkDLSs3dBejiew4mREkhM5ILuWEErx57NldKFFm1yJTELdBpfGKzPWtu3yt6EUmhRe 6PxEO3xKCPuTwa/uA5ZqyBcI14HAkPqde1qC04WyL5gYWFrRxzsDML7imx1hgUDpX113 F5GW07QblpE935XE6e2pZM7HWE3aO1zcK17FRSdSEANqfpyWuje9xpY5rLcsAw3dtkA3 ma7dZAj0HPYSJFYOYkXsVcQVf+1FOdZSNpq7Y8FoVfaN++57IgShJMFW4676LxOmMD9I Zg2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720801660; x=1721406460; 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=ebPss3HetnUGp7ZOFtBIyU5z7Qqo1tTAoW4e3fLcmFs=; b=I+94VhU00SCzWoQ4PrZMS3RMAtAcVdH2yPI53Q3+xmCj9sZZ+cwal5MsdkZPge04eq xufJAul64TZ/SPA0msj1QH0IMAl6L0DTFzI6057HbyRTsNCd4bHLZl41ubLub0Oi+I7Y TcE1O3KKXdb1ecWRyKEr5rk7UnHjhiJrnKQIdUOjDS9TvRezT4YI8hYLKQQr2BM0WsaH qEbqTxBpESmC2NL9+vYFKsSJeWN43gkrKwzsPNydw0tTmdpnpHUhUz7jB0EljtKrrHuJ 38bsRG7KO9GkDtnOcOGgF7zpTW8a90iqLe1vwNoqtRErDA3FXiZEIusiBsDXg7b3oq6T jcTA== X-Gm-Message-State: AOJu0Yxn3gy7EJxVPcvH1CsXYC8UYNr84MZb18BDldv4FWy+PjC4ZkjE SpU6JLtz3LizeXu8rftepQXjFF6OLsuWamYjbvFdOu154SverNkbgCBhg2pOtTXfln4o2WXYt5z D X-Received: by 2002:a05:600c:21a:b0:426:59fe:ac2e with SMTP id 5b1f17b1804b1-426707f812dmr83658065e9.29.1720801660296; Fri, 12 Jul 2024 09:27:40 -0700 (PDT) Received: from localhost.localdomain (nsg93-h02-176-184-54-152.dsl.sta.abo.bbox.fr. [176.184.54.152]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-367cdfb2327sm10573226f8f.116.2024.07.12.09.27.39 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 12 Jul 2024 09:27:39 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , =?utf-8?q?Philippe_Mat?= =?utf-8?q?hieu-Daud=C3=A9?= , =?utf-8?q?C=C3=A9dric_Le_G?= =?utf-8?q?oater?= , Andrew Jeffery Subject: [PATCH v49 03/11] hw/sd/sdcard: Register unimplemented command handlers Date: Fri, 12 Jul 2024 18:27:11 +0200 Message-ID: <20240712162719.88165-4-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240712162719.88165-1-philmd@linaro.org> References: <20240712162719.88165-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=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Per the spec v4.3 these commands are mandatory, but we don't implement them. Reviewed-by: Cédric Le Goater Tested-by: Cédric Le Goater Tested-by: Andrew Jeffery Signed-off-by: Philippe Mathieu-Daudé Tested-by: Cédric Le Goater --- hw/sd/sd.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 0093bbab3e..8a23e9eb23 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -2445,24 +2445,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 Fri Jul 12 16:27:12 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: 812333 Delivered-To: patch@linaro.org Received: by 2002:adf:fac3:0:b0:367:895a:4699 with SMTP id a3csp776684wrs; Fri, 12 Jul 2024 09:29:21 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWJNDj6ej4EpTCzuEhmgAp55r61jkxKg1KwxmKJWBQcErOKxyt2JmHwHzQ+PdagD1uavD2geTAXdDoPtt36dAZN X-Google-Smtp-Source: AGHT+IHwgwP88r5dOC4cenTUXau/HoxTd5lMcXbpatBLiSVmVtg7Ljd68A7mWyHb7Lgr74VLGinm X-Received: by 2002:a05:620a:4550:b0:79e:ff18:b4f7 with SMTP id af79cd13be357-79f19bf229amr1761427785a.50.1720801761219; Fri, 12 Jul 2024 09:29:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720801761; cv=none; d=google.com; s=arc-20160816; b=bZy2Gq94KmDhuxXO64eQ5bZtp5w00lSI9kuVpHrAdPZdXq6mZ+M8ZRhy5IUb8/jw3E p3XjaSTa9buP2clxmeGUkr8s6Ejf3uUAE8D65GbX/YPWpzfJoolbmNuNzwLkYy2ycoir Eu4ycqvZGYJki2V1lFK9wKAe9IMD4vZF7o9E59lsU8lrQYYRvNWG2Y1HM5Mlryr5AFZp MRiQTLbA5jPnQowT36SkqiG72/Fc4H/8IJOEpV0eY08GCm074F/hPL5ugQ7kNthGx4lh /sbT40/vUFyZz8SFub4+WaicRksKIyheoDRzKO+8jqYLMB0T3hNZmPV3sKMN+CVyPim4 G+Bg== 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=MXx6w/D78X+t+qnSkczpOs9wEizLZ3KClTSUA0/rCmI=; fh=PL8ckMkyAhAkso3TNNQ58kdISuodHNUfk6+te16KrPk=; b=fUB1BV13PR7NYzoGjYDCx9yALyHQOu2lBtn3IlNGGsSarz2OQxizczcMEOHT8Qjegx 0jFjyRS8RBQEZuNS6c9pSu6I9LZV4HzRcbRV71c6zFO8zKziBiIOYTCLSs1HaaJNMTKb GrC1NibXmrcZ2sMQ01yR2U7tmPgqefnQFTFUfhBtz7+ddlHI2nrcDOmFJXFvhUe77P3f uFXBaoqs673XodZ6Y+MUvZ3Po7zY4AjrGodmqUM6q7Gw7HbtLfCoUc+5yklmbHwkPWQu zHrqnXahGLcmAgKdpxweo9jjPGeFXG6Nf/yEyhrFLlhL8ZH5mqviJ0c7bT2C4DKk59sW lioQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YprpmLTW; 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-79f190d728esi954431185a.567.2024.07.12.09.29.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 12 Jul 2024 09: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=YprpmLTW; 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 1sSJ7o-0005Fa-05; Fri, 12 Jul 2024 12:28:00 -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 1sSJ7g-00055t-JR for qemu-devel@nongnu.org; Fri, 12 Jul 2024 12:27:54 -0400 Received: from mail-lf1-x136.google.com ([2a00:1450:4864:20::136]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sSJ7e-0001zZ-J6 for qemu-devel@nongnu.org; Fri, 12 Jul 2024 12:27:52 -0400 Received: by mail-lf1-x136.google.com with SMTP id 2adb3069b0e04-52e99060b0dso2395189e87.1 for ; Fri, 12 Jul 2024 09:27:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720801666; x=1721406466; 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=MXx6w/D78X+t+qnSkczpOs9wEizLZ3KClTSUA0/rCmI=; b=YprpmLTWiOL6z1AMt0810rSZhXbHHLKx/L1BiqNEWzaq86x/5p52J6L6VSWXd36WlE mHpPiUknIDqLdBWlv1KtHAq+lFgVp+R2sYfsTmY06iVa8ZZe/JDr12/Aewz6gAqJRb7C HxgIcH5SP4wGdAcl+i/t/XVP35QlUwHC8f8kHxe1mYtbJfKDKbO/zu2dsxW/NPmPgxLu MnoviDFY4pMUeNxkoldtL71yfcC+PIUlq0gdxJqNIPcX6emAZ+zny+kXDHJK6RMZNDDH GRjj4wqoC/2HBNflpenAY5qASRJdh/5BWsLyl4NsetlIg699S9TgwgiQRM2FhXCAlVrs 24BQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720801666; x=1721406466; 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=MXx6w/D78X+t+qnSkczpOs9wEizLZ3KClTSUA0/rCmI=; b=sdt0YgUvwit+d9jt9K4//BY+2QLmp19Xfwhf83mnIxOPVmGDBItrDKrCaO8IBV5k7h 9SDysR7WTD2xBeUbnxti4G/XIftVkz2YYjBBvuFG5oRzOfWP8ubRH/ggDC4M0f/ZVt0u zA+g9JSKshYhrSdmorPT1DYbW+KYk2N68KGRAiSYaMUEG0KrSEQZzGpMqWuX1rAUPlnu YnrQ/0h7LRcfQS6pkbCGDDv29wAJvBsV9F+oroEEVzSxL8lY/TYCoND4oMMokB/D5QjJ 5Gk7ZwudqEEySJA4PIygLYc+2+6psXFcqo6Xm9I6YZf/Y2WyJkmcQJpB5a+2UpdBZB9W UfHg== X-Gm-Message-State: AOJu0Yx1t6/ZZBTIe6fhgScyXzVpPxF0Tui4F7cAMkriUtpFps6l4NJi sty45xYAyLftvivEQo6K15AveUilpqy36d/0QTQBvDVsawkdopYQieMKLNd7qax3XIv3AXNay9+ n X-Received: by 2002:ac2:5b01:0:b0:52c:dc6f:75a3 with SMTP id 2adb3069b0e04-52eb99a310bmr6993970e87.40.1720801665937; Fri, 12 Jul 2024 09:27:45 -0700 (PDT) Received: from localhost.localdomain (nsg93-h02-176-184-54-152.dsl.sta.abo.bbox.fr. [176.184.54.152]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4279f2679b1sm27598995e9.15.2024.07.12.09.27.44 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 12 Jul 2024 09:27:45 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , =?utf-8?q?Philippe_Mat?= =?utf-8?q?hieu-Daud=C3=A9?= , Andrew Jeffery , =?utf-8?q?C=C3=A9dric_Le_Goat?= =?utf-8?q?er?= Subject: [PATCH v49 04/11] hw/sd/sdcard: Add emmc_cmd_SET_RELATIVE_ADDR handler (CMD3) Date: Fri, 12 Jul 2024 18:27:12 +0200 Message-ID: <20240712162719.88165-5-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240712162719.88165-1-philmd@linaro.org> References: <20240712162719.88165-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::136; envelope-from=philmd@linaro.org; helo=mail-lf1-x136.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 Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Cédric Le Goater Tested-by: Andrew Jeffery Signed-off-by: Philippe Mathieu-Daudé Tested-by: Cédric Le Goater --- hw/sd/sd.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 8a23e9eb23..ab502d19b8 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 Fri Jul 12 16:27:13 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: 812334 Delivered-To: patch@linaro.org Received: by 2002:adf:fac3:0:b0:367:895a:4699 with SMTP id a3csp776686wrs; Fri, 12 Jul 2024 09:29:21 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUK6/A3f++LlJd6KFM3olLGPBOz3EIs+7RNhwpe6vUYMO0neg/N4SUcxhIP2v1MpS9nzZY1khuUkjXXnam0VoGD X-Google-Smtp-Source: AGHT+IEccMSWYR0XrO7ZnZBzSS9BqFmnr+QoLOwZ2KZrIUb0u17OhE7KDpIBA44bQG7ESIdkbpSO X-Received: by 2002:a05:6808:189b:b0:3d9:2b15:65d4 with SMTP id 5614622812f47-3d93c01937bmr13695172b6e.21.1720801761426; Fri, 12 Jul 2024 09:29:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720801761; cv=none; d=google.com; s=arc-20160816; b=Dpl0hJ4T/xZd3ITDpCR3GoeHCLHBLRcBsKKKUszV9oAammomFCJU4nU66rVWm2FqPr t85ASVvsKE/k28knK+NROfjUIkSsIPcpJONHr4YyxJWjley6YomM5NGOSTq5XQe9Wr3U 3ljQ0uNckbo86kB0Tzr6Src36GbW/OiuDvbEL83SHo6dYYiMGSgHhoRgZYT5qrSK9pYZ CLEHXnM9AvHG22bhRO3KCS7rsTKKHBG98CW7Ov4e7lCPVp8V+qTchmYeUJjXzoaYSKSY b5jFGkxymChe2Rm8aq11oNNijuT7O2LGIIOBbm/eHLPUh06AYpF1JOMN/2eqjDJjO4zR YoxQ== 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=haoIBckcRPKFI1igV/tcFjqM0juY8TSEYfggrZriKRI=; fh=PL8ckMkyAhAkso3TNNQ58kdISuodHNUfk6+te16KrPk=; b=rSCLuQBea8jzkSNlSLHbCQ0WJgPjZPW9VA0+3rCseTack5nJhx2lJPgnfSd59C/Eqm K4/ckwNBCB5dhiERch1m2V95pHPlq/ptEXo+Bez2nPnsKXFSU7KmC+sLzu7/Emfk1zIk S/rKmSCXFwshsyWVw8vP9TdqmDSoElXc7uHi3Ee3Iwlc99wjL6kfFBvNVw2XulwxnUdp zqdetIjb3A+WkEQHPfzbOOXvvkadD6tG1Yba17ycFtrw5/LfbjzL8SwibBvypmT/xrGd Y1AePQAzjVJW/rhtP+FTQaX1OHCb3VGZOAuKtn8t/D1hDlNGvJyN4yYB4+PE4FsU7zLM 2s9g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=k0XS1zph; 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-79f1901160csi963263185a.96.2024.07.12.09.29.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 12 Jul 2024 09: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=k0XS1zph; 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 1sSJ7o-0005JF-WD; Fri, 12 Jul 2024 12:28:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sSJ7j-000583-Fm for qemu-devel@nongnu.org; Fri, 12 Jul 2024 12:27:56 -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 1sSJ7h-00020G-Qg for qemu-devel@nongnu.org; Fri, 12 Jul 2024 12:27:55 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-4277a5ed48bso16039885e9.2 for ; Fri, 12 Jul 2024 09:27:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720801671; x=1721406471; 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=haoIBckcRPKFI1igV/tcFjqM0juY8TSEYfggrZriKRI=; b=k0XS1zphO2XQB86m/ufL94bWvNCNJSP3OX8vg5cXWj9Um7mICioFQUMXi/Tqu9ilfM 55XpN6X2Z2nAHETr18USd4hZ8XkFVx3Kedye5ND1X0alH+NgkOsd7NO3/uR6SE4Q+ilk V2EKahkOBshXkcV+Q7mgB2LnlxllyiewQtWf97SlO1CAzO/89whkGPDxPcmemBoaRV1I 5W42XoLdqlsoeglANWOcHDzbUJoduclr2XrzYr8l0iOgCgscbUFklthBZthjxwjUq1no 88Ff4XfwZwzWuLPdKyCO020iPDEGg8U5aEX1kjAdKCJSxPj6lrYl4nTGQuh/vB2mzq4X 197g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720801671; x=1721406471; 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=haoIBckcRPKFI1igV/tcFjqM0juY8TSEYfggrZriKRI=; b=vaBYVTWqMNFO0PxWxVm0Df3gTw72HARZC+/8muJRZ3VXUTxLGtRfxvbGjCHZIm9fPW mRYBx0cMQ8n28YRONzayM6gS6eiLqGz9wTCV0jKuTnbTo2yMTPFweUu+zVUz1kTDxeUP as7S5dtCHjhCJwcamy9vEcvPObY02le4oi8aBJEfNf1fsTzwdOErJZL95mIGDwgrj3vc 2RoHXHOTXZT2SpcnpyCsLpxN1Brrzfcg2k+0OP+Wlmo3MkFnCko4yJMPPQUdXKSPC7NY FdlRicjFWjNXflY9JXpnltrRX97RgNoJBD7qSX7CtLm4SLxn5xJWIf9PBP/mI7seZeao NUGA== X-Gm-Message-State: AOJu0YwkZ1auXIpN+AWsPoOVDu1YTSL7P3l+IBV3BbTocW272E7O+vb2 ZBs+PcbPRcO/+dH/h/lKCMqF5IPIpAGqRsQMLzipxMNdPiKpj1gBihcMJPlibunuXBcDOmhnWp1 n X-Received: by 2002:a5d:408d:0:b0:362:41a4:974a with SMTP id ffacd0b85a97d-367cead83eemr7223482f8f.66.1720801671703; Fri, 12 Jul 2024 09:27:51 -0700 (PDT) Received: from localhost.localdomain (nsg93-h02-176-184-54-152.dsl.sta.abo.bbox.fr. [176.184.54.152]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-367cde890f6sm10542001f8f.53.2024.07.12.09.27.50 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 12 Jul 2024 09:27:51 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , =?utf-8?q?Philippe_Mat?= =?utf-8?q?hieu-Daud=C3=A9?= , Andrew Jeffery , =?utf-8?q?C=C3=A9dric_Le_Goat?= =?utf-8?q?er?= Subject: [PATCH v49 05/11] hw/sd/sdcard: Fix SET_BLOCK_COUNT command argument on eMMC (CMD23) Date: Fri, 12 Jul 2024 18:27:13 +0200 Message-ID: <20240712162719.88165-6-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240712162719.88165-1-philmd@linaro.org> References: <20240712162719.88165-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=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 Tested-by: Andrew Jeffery Signed-off-by: Philippe Mathieu-Daudé Tested-by: Cédric Le Goater --- hw/sd/sd.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index ab502d19b8..09077f0154 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 Fri Jul 12 16:27:14 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: 812335 Delivered-To: patch@linaro.org Received: by 2002:adf:fac3:0:b0:367:895a:4699 with SMTP id a3csp776734wrs; Fri, 12 Jul 2024 09:29:27 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWsdrd/1agGShfa1n3Y5yPQUZrXMd0LYFfuTGNurPZhoUBBr5b0e5/dvtJzFQuOUutXXyEovJOyNAebARblID1n X-Google-Smtp-Source: AGHT+IH+VFpBkddqjh8hN8HdryjqdSVsE1IihHagA8WNpL8VwejW+piYC+Bw7obN1NLkwn5/pPbn X-Received: by 2002:a05:6214:ac9:b0:6b5:ea99:bdcb with SMTP id 6a1803df08f44-6b61c1c4107mr160465636d6.42.1720801767740; Fri, 12 Jul 2024 09:29:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720801767; cv=none; d=google.com; s=arc-20160816; b=Tm5LHAl682KAa1O3eXUs9OYuTOJTrN6s6bql0tiB3j2SQ4KZjThemZPOXgk9rRR1XA j1A5/x7XU9taYfL2GHM1RETVZn3daaB4G0QEPON9xUrjZWb4vLbR6aVz/DuuvAy4Z1/U zAtZOZRyK39VpNsyEMOQtlFXuv2Dc11w4y9J43M44Viu9CQqm7QhJtk8Ea13xq2wj/E9 eVJC9YxUCZgq+Q5DMgmi5eoNMTUSFDxDYP5NoVnAESUtPYh/w8k8enw1SwMvzwiI9dKx tsvKROJOAGiJ7+TsoibfVnB7k9wQfWVOh/M2KCkEHMaaIBC4F8iXxVt4FDED4PRUFrEG HvOA== 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=5v0lhbhFJNzaNnnpGempJ4TqJKsskD8Q6hiPRfCwH2w=; fh=TW6+ULwo1p4b9zwtgcIpKT4kG3RJoiJN3Pv7qtK92ok=; b=c91r1J1HEMUwhVs5bBumtWxBcsTSrV3eQoyFz0cTP5pXRt9r9hYU3NCXcoW0BAe0AP JBrAWSE2TzBt0ix2Uxc0AwJZXbwklHmU0+0sfeZk50OUvIqaHwFHhAFpIz1jbkqhqJT7 mj8S7Y+8uWgM/TTptsEOrM/6kd83K4sMB2CctTd9zgtCon1d/MdbdPONV3/5qeVWrF/A XmC6qD5p986AAnrJFbiNnPLZbOmNfIy2J26/yfqasMRNvepc/PzI8Y0CYzwYewd0sz/C CmVvwOo14A2AHyUdBSNV+sz1ZcbBW4tCGzH4+HAFvvlKzyh3Lp5Q6FwDSo1i9bCbxkul Va6w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FoUvpwCg; 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-6b61bac9764si99866056d6.447.2024.07.12.09.29.27 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 12 Jul 2024 09:29: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=FoUvpwCg; 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 1sSJ7x-0005dn-Cg; Fri, 12 Jul 2024 12: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 1sSJ7s-0005VP-6G for qemu-devel@nongnu.org; Fri, 12 Jul 2024 12:28:04 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sSJ7q-00020g-Fq for qemu-devel@nongnu.org; Fri, 12 Jul 2024 12:28:03 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-4266fcb311cso14943725e9.1 for ; Fri, 12 Jul 2024 09:28:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720801677; x=1721406477; 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=5v0lhbhFJNzaNnnpGempJ4TqJKsskD8Q6hiPRfCwH2w=; b=FoUvpwCgymd4jAGYwOFijW4fwywDFil/AvJIhW048fZWmuK2ZIuqPZ/6NFWbL2kd7M iVMukrjmvzeC3qGTjoQu+umPT1TwtndM2eCym1OfDJprwYM1yLdwaGrFiWH3VQAOl3QF mNG9QoSKwh3xikgkFSnbJZ2I0AstlXyItOpZajJ8Js2mHXeOmpKmWTylAIJqRCBKlz9m sQ/rGtf2HMHhKmDc2ZN0HPMspUW7quOvCxXXVqNM0XoPDcLcB07Zrwz2Cawx3P5uux2n JdFa+xN1/FT9+74EGilX24wudXxhuxm1jCKVMYuScmBLKhZGL9+mpwj6m8omYVH0ocdJ MwsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720801677; x=1721406477; 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=5v0lhbhFJNzaNnnpGempJ4TqJKsskD8Q6hiPRfCwH2w=; b=EFey2NFapnSOzhNms+h8SsMMm3eOwiR+EJuqduf/DLW9lkh9yqsCA76O1rnz4xFmO6 nIwAt//lCtueHSY/k8W562+TBbWEmYreN1S1u1WSz0tDPpvImr2pSYSzm4lm87A7pP5o D8FSGOd6ZF5sbUS6tCOCVHTu4r84coZAFCnxNhkz8gJx9eMPLBSvLO/Xa+dIf148uPwY uthNWcni2PJpGZfHp8hO0YRpai5O8qC++Vxnd/YX/w0reNd+p5aZWX5zq93qdqBKEFN/ 7QRvBpa9WWJC3FqJLIFw2AtINc/n/bfuTDyJeTV94XDBpOJN2+sOySNGnm3L9T34VmFS heuQ== X-Gm-Message-State: AOJu0Yx2e7fX908JQH/uRUq5RsOcTqGH80OnKez1JEenUzCGbAIr7HyE v4Pw1soasDcFjeL97wyyyl/eSxl+GIlAty8O7Mt1dYfR9Ybpn9Lz0n2Kvm9AO1I/bmSep/DHYVj 2 X-Received: by 2002:a05:6000:ec4:b0:365:f52f:cd44 with SMTP id ffacd0b85a97d-367cead8fa4mr7617932f8f.57.1720801677685; Fri, 12 Jul 2024 09:27:57 -0700 (PDT) Received: from localhost.localdomain (nsg93-h02-176-184-54-152.dsl.sta.abo.bbox.fr. [176.184.54.152]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-367cdfa06desm10619430f8f.76.2024.07.12.09.27.56 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 12 Jul 2024 09:27:57 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , =?utf-8?q?Philippe_Mat?= =?utf-8?q?hieu-Daud=C3=A9?= , =?utf-8?q?C=C3=A9dric_Le_G?= =?utf-8?q?oater?= , Andrew Jeffery Subject: [PATCH v49 06/11] hw/sd/sdcard: Add emmc_cmd_PROGRAM_CID handler (CMD26) Date: Fri, 12 Jul 2024 18:27:14 +0200 Message-ID: <20240712162719.88165-7-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240712162719.88165-1-philmd@linaro.org> References: <20240712162719.88165-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=philmd@linaro.org; helo=mail-wm1-x32b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Philippe Mathieu-Daudé Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Tested-by: Andrew Jeffery --- 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 09077f0154..a90612af58 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 emmc_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", emmc_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 Fri Jul 12 16:27:15 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: 812329 Delivered-To: patch@linaro.org Received: by 2002:adf:fac3:0:b0:367:895a:4699 with SMTP id a3csp776461wrs; Fri, 12 Jul 2024 09:28:53 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW+M5hPJgsnUo6a5NPQAonYaZwdYn7OSLfe9mXPYReQq9uhffZ/J+MVkzjhAUeGG8oSrjWibn07+gt/gmIyPdkE X-Google-Smtp-Source: AGHT+IHbxItrdN/+ncDaRC3L+/TcT0nAug8pgMMryZUlGCKTo3u3YTDF9SXU5oB+E/SEb7Rvovlm X-Received: by 2002:a05:620a:4693:b0:79f:d80:592b with SMTP id af79cd13be357-79f19be6383mr1537876485a.53.1720801733129; Fri, 12 Jul 2024 09:28:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720801733; cv=none; d=google.com; s=arc-20160816; b=RnAL/cZnTdXKiCkY6hhz6ycg1xCATr6HzMbSa5DiSmJJp19lQL/q9FTqrYuaiIzSYn +oE3YILk1KUmK1s0E09AxfWTAS+TcTCqD8b/bOWEqGwUdCByXmAnw46tKeVFMlMN0Y1X A0EydqXz6Pq1aJTVXlgAKNdBldqSagPKE52nfbNjPrRWRujE6cCzi6GuAtP41e/1P7a+ mMTdxp6uy92U/JRk5ZYoMyre/S4lEZ9iCd/4lg9cjkmFueijgWQfu7nSyQim+H6cyB/t nzIRlt9Yn+Mj5CKjeb5Z/vnEq1FqODLTP9Y3RjjKlz6W7kpdSNp91ZUl/9O/KcXpC6w+ 1djA== 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=vnSk+HyM9RUPBHofeptNbf+IDVj02UnUmKWQ+zhFPvw=; fh=Dh9Cnb9TfVHRl4NNm0HJn6CoQZvCRErd1Z+sbgjvh0M=; b=CC0f7W2CtYEDvT59KCJw3jnRAbO42BsxBSERblEQpKwxhgWSqDmIgrKLdPZbl0nIho fB4xGXuW2HVx09C77pPnP+S3w3VD5TrxPxf7HdsudO3qPTMb2ZKSx2SEeRrJHWp26QrL fVKhPJ/HhgT865zFkNgOQ+yvomFsaX98gbH82YNjECHORGP4QiCd2xftK0h/y4u0O/jl nUuHVhsY9hukfz+lgczo9u5FD9mv51uTw3ICEaTa9OdI00TJx10HpnL8pcK27+d5YIHp xtOmTqTlE0gjj9bhwaHHLTSi40k1V/enTVsbEYcUY3Xn5wIka4mbj7pVWsLdVd+ra+mU BbYg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=M7L7A7EQ; 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-79f190a1732si951530785a.356.2024.07.12.09.28.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 12 Jul 2024 09:28:53 -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=M7L7A7EQ; 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 1sSJ84-0005ka-84; Fri, 12 Jul 2024 12:28:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sSJ7z-0005fL-8s for qemu-devel@nongnu.org; Fri, 12 Jul 2024 12:28:12 -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 1sSJ7u-00021I-6o for qemu-devel@nongnu.org; Fri, 12 Jul 2024 12:28:10 -0400 Received: by mail-lf1-x12c.google.com with SMTP id 2adb3069b0e04-52ea3e499b1so2559469e87.3 for ; Fri, 12 Jul 2024 09:28:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720801684; x=1721406484; 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=vnSk+HyM9RUPBHofeptNbf+IDVj02UnUmKWQ+zhFPvw=; b=M7L7A7EQlv9F85mRqKDvDyTene5T73OEByfQLR/XLdHfnW05Z/v/dHmtdktoKV5F40 YUPK7syn6P7FBtMF0V/daP9KnxtpMJvzaqqy1eg/lDACK9awZ/QsA5Hud3vN7y9oEHpi AA6y8qWbmmr9nb7CftyheW/JqlkugdXM2r6vRESubyFRuGljktSGXBh0WjcUnEn3QRev TOWMEGHZCwcvdJrIxKPq5txeXHPhpnj/9FgNFjQt32Uzi+2pbHW+RgG9oKsjg5kQMhUD RxWRRmvCZohtiIyw9+6v/IVtAs7bN6APxEApC8WYMePBs0P/2NmHxqOQSgeyGehcFQi+ 17DA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720801684; x=1721406484; 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=vnSk+HyM9RUPBHofeptNbf+IDVj02UnUmKWQ+zhFPvw=; b=Z4h2NTz6841j21OVgaOCZtj5wdJpVVz144niKqz8r5FXkABTn64JcS8msBVoPQno1q fRe16NiI4ijW0L29LhPmk4kzY8PO1hK2eia5QiIe6zclTngssFDWjc1W/L5U8AUi9xCT RWnlTSxbpZ7kPbH5mG+xMrWjgq7KF7ji5GFdv3zZxQLN0nLQMSowiROj65/uxGsc7Oln X0ZnIULYFQQJtPiPKFLFVF7TmUkopuBEq2+gIXIGoP/UxpN5VS+BAfczutdxFg16GS9W BiqVYtT7ZB9+uyNnZFMUR9O5PQzt/gJP96lWNtFDrhDi0OsYw7EtFQpAOW+7uUrfAMV+ cPmA== X-Gm-Message-State: AOJu0Yx02P23znMBt8ntuuKU40uB6WDp4Nq64uZolCop5c21kOJqDJnL E+MffV8l7bTh/5UguWWDBgZ7HJxi3ttUjQbP0VPAChwlClVqkpAlTuVMWsT4asCdAjFs1qA6DKF z X-Received: by 2002:a05:6512:3f18:b0:52c:e312:2082 with SMTP id 2adb3069b0e04-52eb99d2087mr8928511e87.54.1720801683753; Fri, 12 Jul 2024 09:28:03 -0700 (PDT) Received: from localhost.localdomain (nsg93-h02-176-184-54-152.dsl.sta.abo.bbox.fr. [176.184.54.152]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4279f2cc286sm28591425e9.33.2024.07.12.09.28.02 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 12 Jul 2024 09:28:03 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , Luc Michel , Francisco Iglesias , =?utf-8?q?Philippe_Mathieu?= =?utf-8?q?-Daud=C3=A9?= , =?utf-8?q?C=C3=A9dric_Le_Goate?= =?utf-8?q?r?= Subject: [PATCH v49 07/11] hw/sd/sdcard: Implement eMMC sleep state (CMD5) Date: Fri, 12 Jul 2024 18:27:15 +0200 Message-ID: <20240712162719.88165-8-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240712162719.88165-1-philmd@linaro.org> References: <20240712162719.88165-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, T_SPF_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Luc Michel The JEDEC standards specifies a sleep state where the eMMC won't answer any command appart from RESET and WAKEUP and go to low power state. Implement this state and the corresponding command number 5. Signed-off-by: Luc Michel Signed-off-by: Francisco Iglesias Signed-off-by: Philippe Mathieu-Daudé Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater --- 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 a90612af58..d98952a12f 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 Fri Jul 12 16:27:16 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: 812331 Delivered-To: patch@linaro.org Received: by 2002:adf:fac3:0:b0:367:895a:4699 with SMTP id a3csp776481wrs; Fri, 12 Jul 2024 09:28:55 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUuADQLqNW6xV8NsIDMipp9Y1JpGdHdLTxd/3lAOP2xLX/P1/TvqlrfQRTzaSL6p1gJJOsb86a0s1jte9EVXqli X-Google-Smtp-Source: AGHT+IHGpMUIxcGBNeEH2TpP7RZ9fOBcBwzrIZ9wLM4sHd7Kgg47PaOY7w4tXe8z5MHW3w/D8KIR X-Received: by 2002:a05:620a:91a:b0:79f:afc:12e with SMTP id af79cd13be357-79f19a428b1mr1190590285a.31.1720801735676; Fri, 12 Jul 2024 09:28:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720801735; cv=none; d=google.com; s=arc-20160816; b=NKdUnZlJEtnvDQANpZnUTGDqIpO6CYcZCLEbfAGZg7XsYcVhpTC1n+OLpeusDIt38C B9E9Hu/waou1XE4zJZirnFagszBxb3eYPXET35Ryd+gp6hK8DPCM+CBsUChpHgYJ/Y9w FO0VtREaaTVgayd756w6WNuUEOjDksNhmR/PEE/I/D0oV12HtABV7soRgnjcpAbEDTgQ 8f9rtLXjeEDq/GAn7U6R6nYRk22pUr0U6UkTghuZHpy+AiXLFQx5eSbdMPCSVe9o6w0M I92omF4CjSyiX8jxiB56UO6xRGCYt7cdinvPfmYLivHZQYiZm+6TZiK8BvpdGR4mr89m Song== 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=//Nd/sODDGIVrsfvCE9k+Hv/ZNYbSdV3BUNQY8d0myE=; fh=NG3CfSrYc5uxyTqBbESFjaUue0nWy32lz7gWe8Y7gzs=; b=MUb5WUuGN8zg+D+PtaUMEvl1mBF7Cw3kz4cEFdiw9lMjreb2y2+zSA+TA3NH2fmHKJ yOd2T2Dtqe/QzxRcl0YxQNgG+tvN9KSp+0AHbdJZu/hnhhDZm/q+YQbrxg9uA39sxXwD XuRXgn+X7tJZHlY3XOvNEwRtMjqPh22m3GEEskNlM2+3ofWfl+P6wGJ08DwImJvvid3U hMBjMjzvZRwiNSY2vn/3HVlNWNxA1lYZ2MCAid1IB+KvLWS1ZQFAu2roLrEG1rjUqBG/ pwVTOBiZdkoJyXlrfiHyDewXsNSP5VWRbxVcc9PXbGc9OHxxf9WgZn+B/uvgue8zr4O6 yeOA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JvdXhdjR; 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-79f190bb6dcsi968920385a.529.2024.07.12.09.28.55 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 12 Jul 2024 09:28:55 -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=JvdXhdjR; 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 1sSJ8A-0005r6-0c; Fri, 12 Jul 2024 12:28:26 -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 1sSJ82-0005it-4f for qemu-devel@nongnu.org; Fri, 12 Jul 2024 12:28:14 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sSJ7z-00021v-23 for qemu-devel@nongnu.org; Fri, 12 Jul 2024 12:28:13 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-4266eda81c5so17583355e9.0 for ; Fri, 12 Jul 2024 09:28:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720801689; x=1721406489; 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=//Nd/sODDGIVrsfvCE9k+Hv/ZNYbSdV3BUNQY8d0myE=; b=JvdXhdjRYt9WfYOYi4bIjOqRw4oPF/9g/QZNAGHX4AFQNegTKO0Cn5HnCtYgj2sWsu 8J75kHx1k+bzBXgsl+HbeBu1Zt6+Ue7LfABnPO4L7SxsX1POUzv2M1XUnqAxBqyv9/UV IRfC/+rM2XzFSzRSDrn/InS4PvPzkj0uLvy2VfHBhvhltSWv198HlxWXlmASBr8w2CBS RLXL8gXg/YAu8jYncGCeshIszU+SQhnDrDe23xc1aZec7G/jj9aNZyj1WRGoxPIe3L9O dywXzgUNWI9SIzNV32uMEMyOA07MzFnHtD1Fr/v+2Mz8LnIBpNA4AY+EfVbIDDVf4Iaz RBGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720801689; x=1721406489; 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=//Nd/sODDGIVrsfvCE9k+Hv/ZNYbSdV3BUNQY8d0myE=; b=qIwDsfZnZ1VvrHbU4XDmkPvYXt8fWWkGDMaZaqx2F7sQSgDlxaOZZP5mQGGs90pIiU lRl8poC0o/dAsH3CtRXhIzjYx4z6GzF8Zwmf5S7apxy/TqsWQiny8u1pGIXqQ+R0fRbx 95Gm7KOh9U8zkhlosAhwOyxG1cUuZLWdBPrTDvg+4Vnq/jETjEhyhZmuzG5xuAHSML3q 6RCrdSb5YIGEzsB1/wuGNscnMOtvpGl4PcINJ8fBEX5A3XXrs6nLvXR9H6UVgKVpotZm leWnTy17ljAkGDpMUTdqri3EZ2P9T/vJS/NqDsTs5wca10meFMfg87Jvnm0H5Rujb0WJ RbAA== X-Gm-Message-State: AOJu0YzAz/tDKtMnQVCPL++Ym1mPEPnz98UuAo1dAuQfWWiSO1gj4QcO ynB2oNfToeFwBVtcghFm0hcWHjYjMTbN42CR8+DU2cXeoHpXsMmHc7PgSAb2LkZ/mdA5oHNSFCW M X-Received: by 2002:adf:e04d:0:b0:367:8607:daa9 with SMTP id ffacd0b85a97d-367cea67d16mr9712747f8f.15.1720801689458; Fri, 12 Jul 2024 09:28:09 -0700 (PDT) Received: from localhost.localdomain (nsg93-h02-176-184-54-152.dsl.sta.abo.bbox.fr. [176.184.54.152]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-367cde847b1sm10501176f8f.42.2024.07.12.09.28.08 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 12 Jul 2024 09:28:09 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , Vincent Palatin , Sai Pavan Boddu , "Edgar E . Iglesias" , =?utf-8?q?C=C3=A9dric_Le_?= =?utf-8?q?Goater?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v49 08/11] hw/sd/sdcard: Add emmc_cmd_SEND_EXT_CSD handler (CMD8) Date: Fri, 12 Jul 2024 18:27:16 +0200 Message-ID: <20240712162719.88165-9-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240712162719.88165-1-philmd@linaro.org> References: <20240712162719.88165-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=philmd@linaro.org; helo=mail-wm1-x32b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Vincent Palatin The parameters mimick a real 4GB eMMC, but it can be set to various sizes. 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 EXT_CSD values from Vincent's patch simplivied for Spec v4.3: - Remove deprecated keys: . EXT_CSD_SEC_ERASE_MULT . EXT_CSD_SEC_TRIM_MULT - 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 Migrate the Modes segment (192 lower bytes) but not the full EXT_CSD register, see 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. These modes can be changed by the host by means of the SWITCH command. Signed-off-by: Philippe Mathieu-Daudé Tested-by: Cédric Le Goater --- hw/sd/sd.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index d98952a12f..2246213b31 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -124,6 +124,13 @@ struct SDState { uint16_t rca; uint32_t card_status; uint8_t sd_status[64]; + 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 */ @@ -476,6 +483,36 @@ static const uint8_t sd_csd_rw_mask[16] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xfe, }; +static void emmc_set_ext_csd(SDState *sd, uint64_t size) +{ + uint32_t sectcount = size >> HWBLOCK_SHIFT; + + memset(sd->ext_csd, 0, sizeof(sd->ext_csd)); /* FIXME only RW at reset */ + + /* Properties segment (RO) */ + sd->ext_csd[EXT_CSD_S_CMD_SET] = 0b1; /* supported command sets */ + sd->ext_csd[EXT_CSD_BOOT_INFO] = 0x0; /* Boot information */ + sd->ext_csd[EXT_CSD_BOOT_MULT] = 0x8; /* Boot partition size. 128KB unit */ + 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] = 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) { int hwblock_shift = HWBLOCK_SHIFT; @@ -512,6 +549,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; + emmc_set_ext_csd(sd, size); } static void sd_set_csd(SDState *sd, uint64_t size) @@ -847,6 +885,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; @@ -894,6 +950,7 @@ static const VMStateDescription sd_vmstate = { }, .subsections = (const VMStateDescription * const []) { &sd_ocr_vmstate, + &emmc_extcsd_vmstate, NULL }, }; @@ -1405,6 +1462,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 +2402,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 +2580,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 Fri Jul 12 16:27:17 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: 812336 Delivered-To: patch@linaro.org Received: by 2002:adf:fac3:0:b0:367:895a:4699 with SMTP id a3csp776849wrs; Fri, 12 Jul 2024 09:29:44 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWbpZTbpLorlbvfdolZLu1dP4Ka+c4LFIDx3uRy8L7sdg2ZUPinXu5ARiOSh/gN9M4DDP5z1/jJIL4KU1yjH2zz X-Google-Smtp-Source: AGHT+IH6EBMS0MFGeKT0WtvlmdasFqtaRnUEmJBoqiBq9FNcAAWKPAV29mAkd+L9wdxvc6a6/kFR X-Received: by 2002:ad4:5fcb:0:b0:6af:6799:912c with SMTP id 6a1803df08f44-6b61c1e51famr139747276d6.54.1720801783990; Fri, 12 Jul 2024 09:29:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720801783; cv=none; d=google.com; s=arc-20160816; b=MKRdeDq+yVX1rfOSqeOEGQqrGrQREuwU41TbmKwbu/Vimm9HcQPu26bzH3Relsmwk7 +bNBQh8LE0xyCkhCigt+C2qVy2avRpqOrCKTQe9nc32Ckgv2veNmxkhS76VhtbuOW15l 3mBrbtImZlgmhXdXSWpZXjBxzX7V4F7zC3MgQdOQqbtMw9xZiRzHocHPySIX+IKUgk/q XxceKrVHu44fLIzsL2miNTP1LoOxGxDtDEb+OkItSX3h4Im5Y2gYOurm6kt2WpGlEfE7 yLPdUMecLhXU6yIELcd47h9X4/oabFEE5gxmOIR7Ee6UPyzVYHMwFQfon/pdssKG6IQz TBGQ== 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=cD8b7Rs4S7P6621jHOvHnCt1DVRmUFEAq/B8zAgtE4Y=; fh=jXN/sTi4nZax05DmiOdx9tUuq7OEqj8iNEsZQLBlpag=; b=ev5ygXVp0aLXyGJkwvGfZ7srbDCzfSQpmae5C618CzVPd7ol1Wkg7e6nIgMlMGFK0J DACLxN4J8wQCSX0bA0ihstlgz2ZsI2BOgcA+oKQ+5g3KtATJMCtF722WV19P7/bKDkhn EB3KYlbIgnh9sMnob1JEcNlBntkQcN4RXR50v+woChQ+TwwMgOeN+j1pUEC9n69Tl8m5 xSyQMGeLZleDKO0OwyjN43IaIpSVkE8LFhRmfeBsy6dhd+G0HRGd0r21yOq++47ocCIc xd5tt1C+SoRJwmc3ixzf7lNCvdcrIU7xjPCoZIULZuzDGefcH7zCzdcEX5qIzgHtnXr9 pW/g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iuCmszTn; 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-6b61ba193bcsi100737006d6.150.2024.07.12.09.29.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 12 Jul 2024 09:29: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=iuCmszTn; 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 1sSJ8H-0006BI-QA; Fri, 12 Jul 2024 12:28:29 -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 1sSJ88-0005t3-Iz for qemu-devel@nongnu.org; Fri, 12 Jul 2024 12:28:21 -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 1sSJ87-00022O-1R for qemu-devel@nongnu.org; Fri, 12 Jul 2024 12:28:20 -0400 Received: by mail-lf1-x135.google.com with SMTP id 2adb3069b0e04-52e9f788e7bso2616100e87.0 for ; Fri, 12 Jul 2024 09:28:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720801695; x=1721406495; 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=cD8b7Rs4S7P6621jHOvHnCt1DVRmUFEAq/B8zAgtE4Y=; b=iuCmszTnUWX9ZPAK7OWbGuoY4+BdR7t9ZTHlQI4K4KTli0ge7Rp/RexXypKa3AFDMB 68H8z0cfgX5afZa4BwVJGACxzxtVE1Ynco0eyIXGlQhM/z9ToXw2jUjZR3rgVG4ncCZN +ITlftvi/wTXF4IPW6WhJN4FWnF0lWbA60ns8VJlfXph+bFvAPJ8L2SjKNfyd4UaMyIG Eaj8tWJ/pvDbuAE6nFTkLiPVkhMjdZiE1yfnvDmvVM41e9sY2z1CMXdKDL+VgT2rGvX3 uSDV+ybGzMrczrp0rEFMjVZ9JPsjej4/gEvjrG9EsK2KinfI5mp5kT9JvI17wSmaG1dY ed8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720801695; x=1721406495; 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=cD8b7Rs4S7P6621jHOvHnCt1DVRmUFEAq/B8zAgtE4Y=; b=M3tMXyy2uG6Kt5GcSi7oyK+7pTjcRQUvvzl98lq2mhszbdani+HjmfPYIBG4xsVk8M S7ntZ6/BEjWBASGdwA3v08z84/aihsphohlBokev5uj3GchQn+cVHhXytRP9YxUNZZ85 k+1XD1FD8WHYn4RyJR4lGuU5JkCljopjh9C9B6RAlH7Y8bzOsCsEPuddwJdAY+gDqO5W SEJSa8BtcUHaeBgX1qsOXYOZOpXCC3CP0Q1sQGF4K0enWSdTKUy0aTX3ovVw1jq32LMt vWgZbCuVN+mi/i/73JUM/voEw5fRC7QLnbDKj5sr5XtaA5YPObQl9/PxK4hdWQTruOKB 4LyA== X-Gm-Message-State: AOJu0YzACWRzwBiRNuMwXcEXQM6Od7zfAjvVeWhbksQZPXyusuwBjZZV 0CbiwaY6q3iUO58HHDLum9ostWAbYIChnkzO0uydGMAaXRumKcOCR42jiqQiHWxEfCYIZ3rv19M c X-Received: by 2002:a05:6512:3e09:b0:52e:9a4f:204c with SMTP id 2adb3069b0e04-52eb998e696mr9477913e87.10.1720801695086; Fri, 12 Jul 2024 09:28:15 -0700 (PDT) Received: from localhost.localdomain (nsg93-h02-176-184-54-152.dsl.sta.abo.bbox.fr. [176.184.54.152]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4279f09d1d8sm27750285e9.0.2024.07.12.09.28.13 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 12 Jul 2024 09:28:14 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , =?utf-8?q?Philippe_Mat?= =?utf-8?q?hieu-Daud=C3=A9?= , =?utf-8?q?C=C3=A9dric_Le_G?= =?utf-8?q?oater?= Subject: [PATCH v49 09/11] hw/sd/sdcard: Add eMMC 'boot-partition-size' property Date: Fri, 12 Jul 2024 18:27:17 +0200 Message-ID: <20240712162719.88165-10-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240712162719.88165-1-philmd@linaro.org> References: <20240712162719.88165-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 Avoid hardcoding 1MiB boot size in EXT_CSD_BOOT_MULT, expose it as 'boot-partition-size' QOM property. By default, do not use any size. The board is responsible to set the boot partition size property. Signed-off-by: Philippe Mathieu-Daudé Tested-by: Cédric Le Goater --- 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 2246213b31..d49b144214 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -135,6 +135,7 @@ struct SDState { /* Static properties */ uint8_t spec_version; + uint64_t boot_part_size; BlockBackend *blk; const SDProto *proto; @@ -492,7 +493,8 @@ static void emmc_set_ext_csd(SDState *sd, uint64_t size) /* Properties segment (RO) */ sd->ext_csd[EXT_CSD_S_CMD_SET] = 0b1; /* supported command sets */ sd->ext_csd[EXT_CSD_BOOT_INFO] = 0x0; /* 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] = 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 */ @@ -2704,6 +2706,7 @@ static Property sd_properties[] = { }; static Property emmc_properties[] = { + DEFINE_PROP_UINT64("boot-partition-size", SDState, boot_part_size, 0), DEFINE_PROP_END_OF_LIST() }; From patchwork Fri Jul 12 16:27:18 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: 812330 Delivered-To: patch@linaro.org Received: by 2002:adf:fac3:0:b0:367:895a:4699 with SMTP id a3csp776480wrs; Fri, 12 Jul 2024 09:28:55 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWwJwTJ88b7+7Kuw6NLNH0D+DGdZOcDn7aGAZ+Ct6nJP0VfmqxvcL8o8PefPNQoLZpLqmmtJldnGfo3ZsV+tMwL X-Google-Smtp-Source: AGHT+IE6o3h9nEt0De7g+UVdREqmzMsPlCjhA6+uwJQIWxyyD+roeyUEcAHcXWVxLwaGlvErNXgA X-Received: by 2002:a05:6808:1928:b0:3d5:6775:1288 with SMTP id 5614622812f47-3d93befbab7mr13198511b6e.14.1720801735627; Fri, 12 Jul 2024 09:28:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720801735; cv=none; d=google.com; s=arc-20160816; b=pBjPOB3ZZLznVDVJ0pfNmpqT5ICGpwjHl+amey0Hck5+unh+Ex4+uLTyYtPEctVHaR 2benLJv6J7AkEsw5YflK40wJCPOoJMPLy3dH9j8576wbqhkxxD1idssEwZcYqH0ePEr3 ygTfelRsBRHISnxA82kfYDVrgvAFNMrxeazxTm2VMTyAxwRN3Ru/f6+ijIoJXCPpkv2R 8zdLepnHMkTAkWOBYzok6TuleiJjR9ikL6aFAsxSbbMqFYCUqvQGnkjfTAjXmDCP4ExF o5piF22R+92ZUpAi0Y0sidvaEPOLEqCEEHI50CZUdyCsLrGTcVl+v0ERk6iYCdjCl8ex nmew== 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=aiTXpNJrGohCUYgTTYi7sWQdFZInskq2DBWZYnrxIv0=; fh=U/qe6sgcXGnfs6+boLKvTbZL9Mlalxd+UxLKX5IdRQE=; b=JfYmjDECqBcDbxAsVxlyfZG4IIT9PqwtasUcRHzib9Qepn1DzDYYi6/QwqRnnDlVs9 SaGv33X1vlkc6UnnMDhMRGxrI+woIsXcDuZZMc+7xo4aDEL1Iycbd0QIBuLCCN9vDFux WWUzXaYsFUIBsowOLMwvN6c0zvHuk/VH3QcMooleByk793QCwWZDZ1LEbyTnCPveG1YO JAGzRnYMHeFPzHN3v1NNtCyIOC3YW52jPz0IixJ3YzDiQDNhpD4ne86kTFF92w2VdzNL lNFuF4HlDvxHFNEgn/8nL8Lhh2sijCddfZbDgLPvUCjfOZcnQu5bK+k3YDXOo5dNTwCn 4Fvw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qIwJy+hF; 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-79f190e7409si971705985a.711.2024.07.12.09.28.55 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 12 Jul 2024 09:28:55 -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=qIwJy+hF; 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 1sSJ8J-0006V1-OD; Fri, 12 Jul 2024 12:28:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sSJ8E-00064c-Gq for qemu-devel@nongnu.org; Fri, 12 Jul 2024 12:28:27 -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 1sSJ8A-00022m-EP for qemu-devel@nongnu.org; Fri, 12 Jul 2024 12:28:26 -0400 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-4257d5fc9b7so17437665e9.2 for ; Fri, 12 Jul 2024 09:28:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720801701; x=1721406501; 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=aiTXpNJrGohCUYgTTYi7sWQdFZInskq2DBWZYnrxIv0=; b=qIwJy+hFIb0L//fdlP20m7+B51DYHJzxIeeo0I/C0bJsED2FoCpL2Y8a/x66/i217A aWrzdjGpp04qIRei/EUc4rBxzZdO/xTBO9vV+7a0/RVW0/54jvTW4N2L9daaWL/AwZqT LCrZI0nXvC/fdPSCi0e4BIwCVe11D8F1PgKaZvzCIFCe9iL89CLKcmjrQcT+ot7wQgOV lxcaTzl0hM8tJD89C+1YhIMtEoHuig0X2o+NA730LU6cleYLpAUSpg67nmf/j6DoMItt R7vxoRr2RsEpFwdv4OGT7zDYvspNPW2dWOff2KG792Kj0xnDUjVohVSMjF6/0Rlj0ywR bePg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720801701; x=1721406501; 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=aiTXpNJrGohCUYgTTYi7sWQdFZInskq2DBWZYnrxIv0=; b=HVFZ6iHO4m8gfqRQtSP2IPPpumvvcYaHJ7uoZ+GVOnVuenc9BNGWrNcOQat3Lptl4y TyZpIQAmL2ylSvi89a4eonHDduChJHIG4lj3M4xGfTW9s08czT+EThtyeV4hoYv4/NaR Aim4PwSqDrxjiWxmOpXabLYR3Wp+dYbxqXcHzEb3zwJ9cMTXEF0hI3yT8xOMNRN+8Wg+ S8xyvateZSt8xzAQ8DZDJeCPLACdlh7ohTo+6CYhXQOaKimy1N2qwLueDHhW+Anu6HwN TlvUcj48IyXiS/DnaI3DHhPj1swvurDDMg6GGxJyxk+vfhJBK4sicp3TCT/siW/34K3A Q6Dg== X-Gm-Message-State: AOJu0YwFdnJmfukldHtMUnoX31zsZwl4G/DinKaDfpgd5z+pnCg8/pfV z6Bjmf+sQpCDPGhGS+JSbmzyjSwrIjPfSEVf96X74qEu2E89GpWwE8WoNFSC+XMRIPggAGq//kR u X-Received: by 2002:a7b:cb92:0:b0:426:61fc:fc1a with SMTP id 5b1f17b1804b1-426706c6399mr89446745e9.3.1720801700798; Fri, 12 Jul 2024 09:28:20 -0700 (PDT) Received: from localhost.localdomain (nsg93-h02-176-184-54-152.dsl.sta.abo.bbox.fr. [176.184.54.152]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4279f288c3fsm27622175e9.29.2024.07.12.09.28.19 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 12 Jul 2024 09:28:20 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , Sai Pavan Boddu , "Edgar E . Iglesias" , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Andrew Jeffery , =?utf-8?q?C=C3=A9dric_Le_Goat?= =?utf-8?q?er?= Subject: [PATCH v49 10/11] hw/sd/sdcard: Add mmc SWITCH function support (CMD6) Date: Fri, 12 Jul 2024 18:27:18 +0200 Message-ID: <20240712162719.88165-11-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240712162719.88165-1-philmd@linaro.org> References: <20240712162719.88165-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: 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é [PMD: Convert to SDProto handlers, add trace events] Signed-off-by: Philippe Mathieu-Daudé Tested-by: Andrew Jeffery Tested-by: Cédric Le Goater --- 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 d49b144214..1f16c16fd1 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 emmc_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; + emmc_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 Fri Jul 12 16:27:19 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: 812332 Delivered-To: patch@linaro.org Received: by 2002:adf:fac3:0:b0:367:895a:4699 with SMTP id a3csp776600wrs; Fri, 12 Jul 2024 09:29:09 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVRMzx3ZqkF8TOKea7TYDhD3JELvFWGXqJTimGLKhw6Vgn0FPs3oFTCN2JJHBAT7AY0N76H1+9dU5xsre281DvT X-Google-Smtp-Source: AGHT+IF5U0wN7P/d5fTBCUwFvhx/sWF10L25953yUc5rXzOu0exYuSiB3bXmJ4rbgguniIAHEwHF X-Received: by 2002:ac8:5d06:0:b0:444:a454:8922 with SMTP id d75a77b69052e-447fa8a3a5emr154357241cf.27.1720801748680; Fri, 12 Jul 2024 09:29:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720801748; cv=none; d=google.com; s=arc-20160816; b=FUVi1sWtd7dRGC6JZjuj5jssp/PjMCfVr0/k9fLi9uHIfo1jZSLoy7djfssmoIs8iW lkqZXK98pFHLWs5KhCqRkc/6boeYDZI/Ellsa7CBbB4olF64Dd3G3rYFxNskKIxBZfNO NTNNYdE/yRhfl5XhC2oL0c9EsfQseVd9YtwZTjqcYYLek0IfDyvtMPrw53C0DPKo3c7y +YAngORGP2B+EDcV/p7sqSJuxArhoK5vwiE5J/HTJinG6hm24bn7uuAbEqh7z5nmHVcF SYbWYjvbEh+azIx4UjDjiBUxrDQrUsPxSXl13U+NmBSx0itJU2RVJ9Ds9qVcP8pU7rN2 7VYA== 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=glf0Dg5n4+P+FxR4zbHuZCiafWvUhX2krPIpxd4tsFI=; fh=QxApz0DWK1UNdSyPusNib3hDChnPHIrtvSgK+3jBiRs=; b=sq4REeriNSGJFxSFRYpYQB3npVQgFsY5vTVNrFsGovac9uvtFik+qg2JPpgmfRO2Az 7kZmHEEXFhOordfJ5YtMjLPAITvVz/QPO6ZlYnGqFQanTd0gAhK6iYLG5x5b5dMUnQrQ Os9kqeWC6KPr/SwIT/5Ls9rW5wpVADBVeAkr8xoisWkKTWZY6GVEx59fjHWFH4MYSduL x56DgTmAHJhEL4HqV/0ulzH/l1Z+WD9iCZdsob+mvsgdrnBp1pn9J307godetgc1sMlm Bg2V21btxaNxBjsjSCfrMCgxFkF5K3/0iwTZUiW1IFJd7h52bMuPtFQ+eB/avFgqMK5S T7Uw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gx8HRFj4; 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-447f9aee622si95815551cf.95.2024.07.12.09.29.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 12 Jul 2024 09:29:08 -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=gx8HRFj4; 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 1sSJ8L-0006ge-3b; Fri, 12 Jul 2024 12:28: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 1sSJ8I-0006N1-Pf for qemu-devel@nongnu.org; Fri, 12 Jul 2024 12:28:30 -0400 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sSJ8F-00023Z-TI for qemu-devel@nongnu.org; Fri, 12 Jul 2024 12:28:30 -0400 Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-36796bbf687so1184398f8f.0 for ; Fri, 12 Jul 2024 09:28:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720801706; x=1721406506; 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=glf0Dg5n4+P+FxR4zbHuZCiafWvUhX2krPIpxd4tsFI=; b=gx8HRFj4AKvCh3bX8Lywn0cV1Ve5HR4D/fyH9ekckM60ZaUYZBqDfHSpfLJSwWucqA llegillcgVh9kpBT/XStGUD8GZ+cO1f12LaUF9nKwYU3gUccWxTfYurOdQHioOoX85e8 Cwgw6C/aWE9c8T90z0FdAr/B4uDDqJyhYXJlyvuoQyL6aAfXLOfW7bINLfWpJrcOS347 ZSljksdTAqqAeEfs6S4DUKM06S7lYoFwXmzHgmj9wxcINPRIS3pEwQpEP8AvhYBvfeqM 4LvPbSB0OAVMp0zgFJcllaSK7FBtImZFN1hR848hp6nO9fD50H5XceTuyNQu3Q67i3io HItw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720801706; x=1721406506; 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=glf0Dg5n4+P+FxR4zbHuZCiafWvUhX2krPIpxd4tsFI=; b=vaSfs2cUQZ1A4jvDfs49UyredMgfYGXc7sbaYpKMPScybW2NxIA+4w4Kj1VstTI2tt QjVJO9FqAct9GkfDk7ydZpkrI7cFTpdkmI8+C+tRl2onzYMhKO5vS5ftq7HMuId8Xfsi c+1f7aqvJgdORB/sTtR3AFF3zfGTckMaHEE8vxp8293ZLMmzLQQRakLJXy8Q275PMHns M2X7QPh68uQakZ4EVhhTuFMtt/5wPeQ+qVrS5EdnzZWDnFQgftyOyMFiq8/CR5mku+Qj B5X/SfhPlFqHfhZ70OywnLsd3KaU4SoP0mq/feNjZfIQXXcqKmwuJZjWzfH7C3mr3fPx eqOQ== X-Gm-Message-State: AOJu0YwkDE7fd5V1kgpSy7L5CROt0yJFjpK0+r5aY1PS3S7Qc8GXnNBf maFm0ThcasLGzUT2DZb8XQoemTY9+Y1wUZ/JjNtxUCQwSCf5jg1xxeu41Ajabi2yef4fPUELviA N X-Received: by 2002:a05:6000:ac9:b0:367:8a6f:8c0e with SMTP id ffacd0b85a97d-367cea67f4dmr8065002f8f.21.1720801706106; Fri, 12 Jul 2024 09:28:26 -0700 (PDT) Received: from localhost.localdomain (nsg93-h02-176-184-54-152.dsl.sta.abo.bbox.fr. [176.184.54.152]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-367cde89113sm10473168f8f.56.2024.07.12.09.28.25 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 12 Jul 2024 09:28:25 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , Joel Stanley , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v49 11/11] hw/sd/sdcard: Support boot area in emmc image Date: Fri, 12 Jul 2024 18:27:19 +0200 Message-ID: <20240712162719.88165-12-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240712162719.88165-1-philmd@linaro.org> References: <20240712162719.88165-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::432; envelope-from=philmd@linaro.org; helo=mail-wr1-x432.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: 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 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,format=raw Signed-off-by: Joel Stanley Signed-off-by: Cédric Le Goater Signed-off-by: Philippe Mathieu-Daudé --- hw/sd/sd.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 1f16c16fd1..07cb97d88c 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -137,6 +137,7 @@ struct SDState { uint8_t spec_version; uint64_t boot_part_size; BlockBackend *blk; + uint8_t boot_config; const SDProto *proto; @@ -513,6 +514,9 @@ static void emmc_set_ext_csd(SDState *sd, uint64_t size) sd->ext_csd[EXT_CSD_CARD_TYPE] = 0b11; sd->ext_csd[EXT_CSD_STRUCTURE] = 2; sd->ext_csd[EXT_CSD_REV] = 3; + + /* Mode segment (RW) */ + sd->ext_csd[EXT_CSD_PART_CONFIG] = sd->boot_config; } static void emmc_set_csd(SDState *sd, uint64_t size) @@ -763,6 +767,40 @@ static uint32_t sd_blk_len(SDState *sd) return sd->blk_len; } +/* + * This requires a disk image that has two boot partitions inserted at the + * beginning of it. The size of the boot partitions is the "boot-size" + * property. + */ +static uint32_t sd_bootpart_offset(SDState *sd) +{ + bool partitions_enabled; + unsigned partition_access; + + if (!sd->boot_part_size || !sd_is_emmc(sd)) { + return 0; + } + + partitions_enabled = sd->ext_csd[EXT_CSD_PART_CONFIG] + & EXT_CSD_PART_CONFIG_EN_MASK; + if (!partitions_enabled) { + return 0; + } + + partition_access = sd->ext_csd[EXT_CSD_PART_CONFIG] + & EXT_CSD_PART_CONFIG_ACC_MASK; + switch (partition_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 uint64_t sd_req_get_address(SDState *sd, SDRequest req) { uint64_t addr; @@ -795,6 +833,7 @@ static void sd_reset(DeviceState *dev) sect = 0; } size = sect << HWBLOCK_SHIFT; + size -= sd_bootpart_offset(sd); sect = sd_addr_to_wpnum(size) + 1; @@ -1003,6 +1042,7 @@ void sd_set_cb(SDState *sd, qemu_irq readonly, qemu_irq insert) 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"); } @@ -1011,6 +1051,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"); } @@ -2763,6 +2804,7 @@ static Property sd_properties[] = { static Property emmc_properties[] = { DEFINE_PROP_UINT64("boot-partition-size", SDState, boot_part_size, 0), + DEFINE_PROP_UINT8("boot-config", SDState, boot_config, 0x0), DEFINE_PROP_END_OF_LIST() };