From patchwork Tue Jul 16 18:41:34 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: 812789 Delivered-To: patch@linaro.org Received: by 2002:a5d:42c4:0:b0:367:895a:4699 with SMTP id t4csp446866wrr; Tue, 16 Jul 2024 11:42:20 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXWoQTJ5wZTl9q0rR3MuvDIdXC2OoFnHAPduoafCL1lfCWhDz8IgMGaRDMge6yZ7L6jtPMvyaCys0NDGpMWUSVC X-Google-Smtp-Source: AGHT+IG07uZDM7O+HB4gguvE2q+xgPapc+NLglSk1uuo0Mqh/ANmaKnWND6NGRM/B9B/h63L4AXJ X-Received: by 2002:ac8:7d96:0:b0:445:e9:e67b with SMTP id d75a77b69052e-44f7ca7185fmr43659851cf.23.1721155339797; Tue, 16 Jul 2024 11:42:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721155339; cv=none; d=google.com; s=arc-20160816; b=nRPbxDHjjnXMATvv6jMYwxD59xZD5z5F4zZmjcvAdpXl0GDtUxygvYyywG/O4y9AFA Q/e7MqaQdoLpo0XDOLrxQU7oAH2l+GGAYg+fnIovQg25vX3E/hbI3njf7Xr9C5tKu5XK jRwNUflcxVII3qiDbsrAK9zZx3jHCZm51bMgXlWDri7pHC5BxJbe+KQ3LmofvickRlxg KYcjOW382JtQWtui51rgQsO2lX3FCINeTVlmYpS76Qjiqb8FHk+1PAvHi0poM30TbIz0 nBDZ9BcMcG4TkXsnKNMAR25iGZ/MDVwGTXlyLYHf3qR5a3utoJf6+OOS9BlG6rKJh/4c iBfA== 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=/8XMgdEVyY0VdVNyuXlmmK4WZkWYiNYAeoLhbkAo0l4=; fh=p1L4j7P4jKEmvfR3EDNhW50kJO4RQ6f+q+y/XbIVqvY=; b=feSIT39Y8KqxIwTi+Yo6MRtnbY6QPNmQy09EX5wtPXpW5FCQYz0mcMuRwI5C9j04Q8 x4H5yjYZv3lybQbRttXC/K8RbXofKxMkxnYkWiWHbXPIvKx96/2GquNA3ut3bTcTtW1B qxQEkVysx5fTThCvMAn1MPp2G+b6dygMZg3NmkRrD/CRpp8nHTTWl8H77bZi4uchUSI7 l2ce2GaHXK1jMVCazntvvy11SbbbohmwmVXNsAcDmiD/N7zQzvYaqWklhI0AxY3hfDmX FCwwTX8wRrf25f/xhkGkUS58JYAEHjC3w9VDQROsYYvn7F3dvYFNibdAsBCs5gHS2pL4 J6Ag==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=P0k7JBNp; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-44f5b7f67dbsi83987301cf.237.2024.07.16.11.42.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Jul 2024 11:42:19 -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=P0k7JBNp; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sTn7h-0008Kl-Ti; Tue, 16 Jul 2024 14:42:02 -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 1sTn7f-0008Cf-RV for qemu-devel@nongnu.org; Tue, 16 Jul 2024 14:41:59 -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 1sTn7d-0007Kk-Sl for qemu-devel@nongnu.org; Tue, 16 Jul 2024 14:41:59 -0400 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-427b8571820so11170715e9.0 for ; Tue, 16 Jul 2024 11:41:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721155314; x=1721760114; 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=/8XMgdEVyY0VdVNyuXlmmK4WZkWYiNYAeoLhbkAo0l4=; b=P0k7JBNpYkWnNausNQK2KN7bjl7IxmxT379rdA0qm6l2w4VQmAhqOHUM3vFJDCck/L USUpZA0IArN/5sA8xNHq9oDPDG6EQRBIvFDM5/8hIQwQI1/iP6jT/xVawOUplGjml7Qh MrXLbY5M5+xKqa+tLhQ8hmCjURRZJMo4IvYiwIg5xojHCBhQGEDy7cRfZFCprvjmULc6 c9Vr+l4ArikOpfd6Zi2mrbdd8h+qWxt/jK6mWqH30ASnR12I70gVthjwtth5mGYmBJ+6 i+j4WC7n/iMJDdNPs9XdCPEPEwJpUxu4e3h0Ub63/kV7i6GhxBlMb8OzxkOeYZDgONOc SbdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721155314; x=1721760114; 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=/8XMgdEVyY0VdVNyuXlmmK4WZkWYiNYAeoLhbkAo0l4=; b=eeW+QPnAHqrynt6D9A7XbSdf6ZI5TjFX/O21tc5ZhSBh6TIuUoplHtk4qQjZj0BTZB A3d2ogDCsIMb5X+LxfBod+WyU5cOKtKsXzVfAt+829JsITYSDHP1SeOVC70mktaLVxAt 2hSWnVY9bNUblPqOWbgvQ3EF5KSxJQrnfIfJLbfKvYVDQqRBjOqSVYRYkGgSCp1nKIiD etNVH+6xc2W4bGBLGzb6csYweG/VcTOHH+cKeTmj3+bnzS9MaJoBuEisO9yV8+IlzK6V RP2J2GN5blUSAm48wHxrNfMpIRA8ZFiWBwOSO1hMPabSHXlTzVc+jlfaVN1NPG9wbubG mnlQ== X-Gm-Message-State: AOJu0YzL3yyEInS77CbTWhd6YJ2XZ9qezoKJGBPyWAooNJzmh7GGELV3 65zBBrUX/MzmCKTUQ1OrqsCDCpC3Ef52/qnf4cGpyAov5fQXd9C5X8emtzJshRYX1n6vUba5C0n I3qVpcA== X-Received: by 2002:a5d:6482:0:b0:364:d2b6:4520 with SMTP id ffacd0b85a97d-36825d0a478mr2791775f8f.0.1721155313667; Tue, 16 Jul 2024 11:41:53 -0700 (PDT) Received: from localhost.localdomain ([176.187.209.82]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3680daccc55sm9769218f8f.50.2024.07.16.11.41.52 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 16 Jul 2024 11:41:53 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= , =?utf-8?q?Philippe_Mathieu?= =?utf-8?q?-Daud=C3=A9?= , =?utf-8?q?C=C3=A9dric_Le_Goate?= =?utf-8?q?r?= Subject: [PULL 01/11] hw/sd/sdcard: Basis for eMMC support Date: Tue, 16 Jul 2024 20:41:34 +0200 Message-ID: <20240716184144.42463-2-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240716184144.42463-1-philmd@linaro.org> References: <20240716184144.42463-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: 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 Message-Id: <20240712162719.88165-2-philmd@linaro.org> --- 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 Tue Jul 16 18:41:35 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: 812795 Delivered-To: patch@linaro.org Received: by 2002:a5d:42c4:0:b0:367:895a:4699 with SMTP id t4csp447302wrr; Tue, 16 Jul 2024 11:43:44 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXxJIx6yHGkPygIILnZoXDN8RcNNCL1OcPvLcBHxF/+uKrZSl+qllHzhdy0KO5mbJv7HD7NXeEPndU1mIu+zSqB X-Google-Smtp-Source: AGHT+IEEZxwil68/YVqXW1ET/NDNwNi/5fe1t7XnrLdnr+rYrxl+Uuz8EkGwTY6dYjoRDdyZmbzw X-Received: by 2002:a05:6902:1107:b0:e03:5897:770e with SMTP id 3f1490d57ef6-e05d56d705dmr4824739276.27.1721155424334; Tue, 16 Jul 2024 11:43:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721155424; cv=none; d=google.com; s=arc-20160816; b=UZ6Qk/RJsrp2QT+ezofPI8FfJ76r4JfQpIhuBBqXOPNf2fa3P2w6daLCI2U5kTHS72 rT4hi1wdyrr8qoDm49G4zfG3ORosOLhuSPCC6rHZVC+wT6tC71q0Y7RYgnCBKOzW3sb4 qmjzCYT7ACqrdovBeA063wD8cl+18Y5kyqleAm82N3cKNyaQCAvGrwgB50HErtwIb2po pDDi11AFSzj/51jC6sHFEk9DPcSsN9GCHmdokQxOugRi+AHs1M0GVnOctZCKzMufdAPy u+gH8WTwI6D2UiISnryvAUZT6SzcSDpxEzob/gFdpc5Kw3yZcXd1CrcMDYjS0FveRcwl 2z+g== 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=25d8r/+FljDN61432gFDtIj9k/AKYUKw9R2OfNlM2/Y=; fh=8ly4dktE5qX7scQRc1qmWVsO0MVOdxfDtQTaDzdLLVc=; b=ea7u4IqsfbupNl/Q3aRkNrZgUvCOswFeEOiNaNC0FqQT47IfxSJylfvKPyQoF0OE5l JB+pFiL7DAItX7iqfk4jOK4PnvL862eCbe1JGSqFbNMJRA7FBbizZwbWK55YhCLGVr1C ScOeXw6lMUzBJ4FTlqZohYrOY3RMQGv3KSE6KLM+xSNsUy9N56nysUrYjXLyquSOGhQA 62Q2FsjUOPxEsVAg8O4OL/TG+ypLN8DfENVWJdMi9KCwqmB3axSngemE2Mk1nwef/JDj 9SprEcxq8tgk0+rSxpGPbbcp6lf+gqO2T5pUFEA0z89relNOBrkGhbiLRZ1qAc6CT3sy Djtg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lkUt3VNW; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6b780eeadf5si19788866d6.434.2024.07.16.11.43.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Jul 2024 11:43:44 -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=lkUt3VNW; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sTn7o-0000JZ-HS; Tue, 16 Jul 2024 14:42:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sTn7k-0008UX-9Y for qemu-devel@nongnu.org; Tue, 16 Jul 2024 14:42:04 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sTn7i-0007L8-PO for qemu-devel@nongnu.org; Tue, 16 Jul 2024 14:42:04 -0400 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-4266fd39527so43704785e9.1 for ; Tue, 16 Jul 2024 11:42:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721155320; x=1721760120; 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=25d8r/+FljDN61432gFDtIj9k/AKYUKw9R2OfNlM2/Y=; b=lkUt3VNWtIVDPyy9lW8YeeFGFswrLc66ezotrtvNxvJsqbxjsd9jcW87Vg5ThyKbz9 ft+2usm6W5aBbXjTTZD9iTZ89DqZln1X8Deo3CSecnE42iPk/iX/2cwka0BATfbGs9fq S+7sa8i8C0ztiXwkebq4Yv6zwt8JoQLiZ/PvOSKptKNzzXqWu1srYkNe86t8ruPLY/94 lTXOQj+xCoaG2QJD13VAHt9WjBvgJjuv2fFNLRKlNJeXEygWAxvMG2odxAg0Txs78RX/ bwA5KuEwPMDzpx/6DEroPxt7UqCNkqDm5/KvnqXG4OoBvBhUSk0b8NHNSk8qps9g7rqz dJCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721155320; x=1721760120; 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=25d8r/+FljDN61432gFDtIj9k/AKYUKw9R2OfNlM2/Y=; b=Bu6I+e/7U8oB8mFFMjsMKBq6OnaQga9ojwW5M+FuFTECyayOItVqYxF7uCtPXtZYdA i3bTR6VSyV2EH5q8ybXD2NP5Z4evDF3MqUw0EMrQ2K9XT2LuiAKU3+lGWXVPGPX2EwkV prbgylDkjEZOI69FhelFDqTFLs6JRiwfAkjCyl+g+eZxhlfs5BJK3mVpxsWsYd0K1OR4 RKgUFYOrFsEteIiNe0ONkxkBSRD8YvhGC11+0advCq/DKDERxGFibaozg71Fh6DmCpTJ 8Gh+hEtRo4PypQfYHm4n34ZofcTGbQrI02CgBdlEKzWXbQoG78gbvmAhuGlMUkhrBKKg IEHw== X-Gm-Message-State: AOJu0YxAtz78Fvw7ry7f3BuSXTerk4KJW/Y5xlMUc4wysxSBNWnz9PRf 4++dSj8+U4yv3N+4LplWljty3BASJUWoW1Zjp+SJMxDeg+qn3Cd23CT49TRCgacT5s5nsP8xQXd AN67kLw== X-Received: by 2002:a05:600c:4fd5:b0:426:5546:71a with SMTP id 5b1f17b1804b1-427ba656518mr19501355e9.2.1721155319826; Tue, 16 Jul 2024 11:41:59 -0700 (PDT) Received: from localhost.localdomain ([176.187.209.82]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427a14d32e8sm165818145e9.17.2024.07.16.11.41.58 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 16 Jul 2024 11:41:59 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= , Andrew Jeffery Subject: [PULL 02/11] hw/sd/sdcard: Register generic command handlers Date: Tue, 16 Jul 2024 20:41:35 +0200 Message-ID: <20240716184144.42463-3-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240716184144.42463-1-philmd@linaro.org> References: <20240716184144.42463-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=philmd@linaro.org; helo=mail-wm1-x332.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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 Message-Id: <20240712162719.88165-3-philmd@linaro.org> --- hw/sd/sd.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 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 Tue Jul 16 18:41:36 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: 812790 Delivered-To: patch@linaro.org Received: by 2002:a5d:42c4:0:b0:367:895a:4699 with SMTP id t4csp446966wrr; Tue, 16 Jul 2024 11:42:39 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV4EM1qk/b/9yu+zOEQjLNw7xApaiIbGFIo3h5P7ssBSsLc4nNc7TN4Knora85n7gUy3A+dfF2NlMy/xRpknZgK X-Google-Smtp-Source: AGHT+IHrlkSkjUFXgelTgpEuBFM8a1cbFcE+syGzaZwpImSCUvCn+ec+OeejmizRjdm2S/GjcM57 X-Received: by 2002:a05:6808:2381:b0:3d5:4256:26d4 with SMTP id 5614622812f47-3dac7b6102emr4265726b6e.7.1721155359179; Tue, 16 Jul 2024 11:42:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721155359; cv=none; d=google.com; s=arc-20160816; b=vZ3aDhO8SJHu7SpEtx3qo2ttPP670jwQ7jZ/HqvvISPbu6X/Sec+Qufoh4nXMPyFHa Ufs3H4h+Amh2ZV2ftcJpyjK/W6wdgNamHpOjK5M0lncelr3oF6lBCXnA3oC7Klo91Ox/ x03Tk64xRNuWPpAVmZxMxB7zyy8kSYNvHMQlZ60tlYwQrMN42Wn4b/yXPfUpVudMr5Zf gzDsW6Ft0Rp3Jk09/PI4G3YZr2lBg1edsgl25pxjW0n0MWq60eg1IiFsMlc7qMBTcb1y 7YuHD3u4GJr3WFABJ3oLEcufoZjuTz8ljYjjszic0RHTw0ZY/TkviUt5Tq94qnKP+y2h +jjA== 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=JznOvy06gTAUHJS2akh7+jNgw+O2s3K30hb0qRzqsUU=; fh=8ly4dktE5qX7scQRc1qmWVsO0MVOdxfDtQTaDzdLLVc=; b=KXLHAavOVvYiDnrkre+V9qf6S5JDuPtiQdMY1j4r9k4xTctGGKT5LKEaTEF/hnSQzA EfW/IjzjgvbkozQ2ks2kOk4arRJDJWfCfkpTfofnVFQA/SvoOGuINVIhAEGmlIH9BbJx EmpCjaf2PbsBs3v3RQA5+2cYPAId59gRP/xPvhLi/Klnj3V8H29mpdPPvpZzcJW5Rlt3 Gp+PPd7IZmP0FBfFO0nr16lSbWG0F+iS2gWU95aN16xUm6ECooiKW8196WEC6KDqnnTg RKdiP7a7C+ZfNJZkquxHwlIDMYg3tMk/gI95cEi0vtczQ8YZ7fvx35/lWbZuDve/2/qO KFPw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jMm0WnBq; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7a160c51582si793726185a.360.2024.07.16.11.42.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Jul 2024 11:42:39 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jMm0WnBq; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sTn7s-0000e7-Jz; Tue, 16 Jul 2024 14:42:12 -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 1sTn7q-0000XJ-R3 for qemu-devel@nongnu.org; Tue, 16 Jul 2024 14:42:10 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sTn7n-0007LY-PW for qemu-devel@nongnu.org; Tue, 16 Jul 2024 14:42:10 -0400 Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-367940c57ddso3579748f8f.3 for ; Tue, 16 Jul 2024 11:42:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721155326; x=1721760126; 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=JznOvy06gTAUHJS2akh7+jNgw+O2s3K30hb0qRzqsUU=; b=jMm0WnBqz15Bof6QhsShZouoGjeWGO/R8vfIEpezeETdGW0omrqtxqYwn41pIlvRS3 zxY7mXvZuq4OV4UxJqbnbYnutk3RH9jP59W1xdLEAQc2s73rQNp5qmOueICJ7JSva04/ Oi8RkX7zjermyw6zjtyg5qGN93W/l1mmOB6LJkpI6mecVoIIIQUY3vCIjy5E+NhAtbbN XCz7zp/6ft9AdUDQrvHTF5RIZsmK2kX8QkVppsvwIb/RuPvfxkXtIx0cZ1vfjSk2nGbs XrMl4D7O291S32cVl0+SnBC2gUtQd3E4j4COp2nqo4SJi8Z04b+JIyYpumnsUFRM1mx6 lYwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721155326; x=1721760126; 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=JznOvy06gTAUHJS2akh7+jNgw+O2s3K30hb0qRzqsUU=; b=BB7Zz8W8J9yOlurTxP048ZKV3DuZNnoh9NqYKORP7Xvq7wDM3MoFd6Z6JKtGE5LN5M lhPriftiZ86lRCfYqst3csVHKObpqodIdL35gufRUNKm5yMZLEb0h3G60xJrxMtAwyZj Itaefb2c9iwhEZh2NgHHyCl0S/c9sPWRMWa7swl27Ii4IkpK8ZO9yjznRizly9/44AiO U/vvzTDd/KvRxNs/jkadsJBRWNdUgatCTesq2ubrXyaGINtgGZc3xsKnqmNdw8DFCibU nTi8VIs00zoXGZvtAY8bcx/Q6MD8GPrPNjjOymn96ByL1VQqRYZzRJlwhVxJqMndYSPO sGRQ== X-Gm-Message-State: AOJu0Yzo8BrKQgODQM9zQ/RyHjIWPeOzop+bgoJVNahP2jbr+iczLRYF siAY1pLCG+DbJ/wSXHyivk8zx6L9HO3NrA1EDtg9jM1+fzjY3h0yOA0IBj8VS6LSneksCHFLZxE mIfF6hw== X-Received: by 2002:adf:db42:0:b0:361:d3ec:1031 with SMTP id ffacd0b85a97d-3682613c607mr1927356f8f.31.1721155326039; Tue, 16 Jul 2024 11:42:06 -0700 (PDT) Received: from localhost.localdomain ([176.187.209.82]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3680daccbafsm9650673f8f.51.2024.07.16.11.42.04 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 16 Jul 2024 11:42:05 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= , Andrew Jeffery Subject: [PULL 03/11] hw/sd/sdcard: Register unimplemented command handlers Date: Tue, 16 Jul 2024 20:41:36 +0200 Message-ID: <20240716184144.42463-4-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240716184144.42463-1-philmd@linaro.org> References: <20240716184144.42463-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::431; envelope-from=philmd@linaro.org; helo=mail-wr1-x431.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=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 Message-Id: <20240712162719.88165-4-philmd@linaro.org> --- hw/sd/sd.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 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 Tue Jul 16 18:41:37 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: 812800 Delivered-To: patch@linaro.org Received: by 2002:a5d:42c4:0:b0:367:895a:4699 with SMTP id t4csp447504wrr; Tue, 16 Jul 2024 11:44:07 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX/bKSLa9kEgEIsKH6gce3EMwLEK/XuEIO8h4DY3R4Cuvenl9cAscHH+bk1E2l3ZnkJsGxyMHCwqiDs+GmwgEUQ X-Google-Smtp-Source: AGHT+IGgf4qE7r7zufftntyfP6mdrB0NVTZclKZFW6XmKfu68JNZ8xVLVceyqrlTrCcZAJ4ia16i X-Received: by 2002:a05:620a:6893:b0:79f:69:c43f with SMTP id af79cd13be357-7a17b700c28mr298846685a.72.1721155447140; Tue, 16 Jul 2024 11:44:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721155447; cv=none; d=google.com; s=arc-20160816; b=Yhx1KT5c1hyDkixCeSuS7s2C4oFEPc26Fk0pJLwDh5rUF2+bsjgQqciTx5OYMCTDvm lm5jWzqtHSaVmU0gS+qRfxLRAxN1vLrFYjpQCV8FAf63axMEel8RN/0f98Z3pbkIkvkl TMpTk8hGq9Q4lpasDz2NcsxxibV7v0An8c8/eKAgsCPEEo8ELQPW3U1+opkxu78psneK XbjQEcr9BJzXY2fEfzMB8pfGDGIZY/04n5Z5THvB+88UM5/HWZsluLX97ceHu1/D63XB fKKtuErd82wGQE8RG2d7+D2YVizEzjKdnZvfj21XV0Yb7NWcVbPssJeIkR2CIHsj6v4/ 8C1g== 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=Ddj9Nfg7HiixSUrxPsTSL9gKvyRW8bVsKrGjjlgbR1M=; fh=PL8ckMkyAhAkso3TNNQ58kdISuodHNUfk6+te16KrPk=; b=DPDYfe/a+4YuKaPfF2q7EWhBzGsJAf2lOTnbZbmcWMDqSIQd/PAG23X9M6l9VKM+hU Saxg5vRTa2OUtxxiG5Rwbpjhl2ehAIBMx/2GZgZ+3EFQxAJsK1ql3dFjaPMeyDts11eb tRPUbk3k0jFBgcvWG64a+Fi7pO+ZWrvlUkF+a2/LdlkFkwqGBDtkryPSEzEwR+JBI1Q8 CulHy4NZpWgLkuV86Hre5rYEhOYg5rKfn5w/4BDZee//xYfuW/7PPPXV6vp2tIFVVYKF 4KxZTx80IZH75iuZirpEgE23mwMa5ceFh9ovaafTHCLy+RQsh/+M3IFmWvQ511FqrENJ Jimw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GE0i4UVx; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7a160c49f34si826151385a.291.2024.07.16.11.44.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Jul 2024 11:44:07 -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=GE0i4UVx; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sTn7y-000138-3m; Tue, 16 Jul 2024 14:42:18 -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 1sTn7w-0000wT-Fh for qemu-devel@nongnu.org; Tue, 16 Jul 2024 14:42:16 -0400 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sTn7u-0007MC-RW for qemu-devel@nongnu.org; Tue, 16 Jul 2024 14:42:16 -0400 Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-367ab76d5e1so1948512f8f.3 for ; Tue, 16 Jul 2024 11:42:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721155333; x=1721760133; 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=Ddj9Nfg7HiixSUrxPsTSL9gKvyRW8bVsKrGjjlgbR1M=; b=GE0i4UVxHHZ7E6L/7S5Md6ujrPhabsp/Rn76khxF8AqNJtlmMCivK0yUYYsfQxUdV2 LevtCsAg6LvkEy+pvhfFrVqZyhICZ7O/chbnYFOO4W2MptSdPD105zLZKrUspNZcthMK 4cgC09AWJeNgshX/DUrPh/5sTAnDUozMD3K/EC7o44C8uvGmg0y7K2g6/arieRJIiiw8 Ntdmn0eSUXVkLHojMyebTE1USIFkASx6yCll+1F6DGX2WE22tQc/OQxs4hzi8wXWuK0t qzvqZxRCVfl/Hxlhk+tR8pcxknlAHHlai0azSCGIohFp2LdEnv+rI3O0woWnCxv1cBDK Q+ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721155333; x=1721760133; 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=Ddj9Nfg7HiixSUrxPsTSL9gKvyRW8bVsKrGjjlgbR1M=; b=FKX1W5cnM3ylYACJ+WAwvAtimPsyX73NU6SiJw04FukrA5qE5xryRNBX4N/G53FXZo WfZpJLkITnBUPZIH/5uzXdLnNBhfVxKtYVGYapwwcXmnIEE0pfD6aFWdqQuTNWBg+fQl nmN4ueeDLZduZUR/PdtUXK6ZcgU6zcQ4FasUxoHm1nrT9Lk5rXYPs8JnYdnd0bwknDe5 ECWYODul4ea32LiPIuzPmvkwBrVws/cxkrY2748PY2uqnkfAAc7dLnippTxM4VCquHjq vZXBA96fP3Vz4MYC71FHRqPs8H2AOf53RFsh6GT5+HAgwhqfzqHABm/VHTWoAnEo0pZ0 Sadw== X-Gm-Message-State: AOJu0Yw/HLbVm4HrKVrOuGGRdesgxCUyZ9ljtPSwnp28692Dd7Mz0Jue DWxXcHPfICLYAVYcNORtMsAD2Aqa54eoGGO438n7r9bPaSBkFHWjaNU1BCfUD5JoRNVVxSX1edA 1B4F8KQ== X-Received: by 2002:a5d:4747:0:b0:367:8a3b:2098 with SMTP id ffacd0b85a97d-36825f70f1cmr2056230f8f.3.1721155333054; Tue, 16 Jul 2024 11:42:13 -0700 (PDT) Received: from localhost.localdomain ([176.187.209.82]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427a5ef550asm138512235e9.46.2024.07.16.11.42.11 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 16 Jul 2024 11:42:12 -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: [PULL 04/11] hw/sd/sdcard: Add emmc_cmd_SET_RELATIVE_ADDR handler (CMD3) Date: Tue, 16 Jul 2024 20:41:37 +0200 Message-ID: <20240716184144.42463-5-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240716184144.42463-1-philmd@linaro.org> References: <20240716184144.42463-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42e; envelope-from=philmd@linaro.org; helo=mail-wr1-x42e.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 Message-Id: <20240712162719.88165-5-philmd@linaro.org> --- hw/sd/sd.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 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 Tue Jul 16 18:41:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 812791 Delivered-To: patch@linaro.org Received: by 2002:a5d:42c4:0:b0:367:895a:4699 with SMTP id t4csp447065wrr; Tue, 16 Jul 2024 11:43:02 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWq5iILrf5vPQDM+v0xWZ7xXH7PdpT0mBfExQAQQH5NEHwqo3dQwES7FIEADVc993WFLxGal52OKW+U3PMQk/zL X-Google-Smtp-Source: AGHT+IHNv15YZfug/XUoUxcGb7HHD3xAepCSzCNvtJqri2TWQaAA3f0Z5m2gWdEppp9z9r8d/Nmp X-Received: by 2002:a05:620a:28d6:b0:79d:6052:1994 with SMTP id af79cd13be357-7a17b7144a3mr315702285a.58.1721155381723; Tue, 16 Jul 2024 11:43:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721155381; cv=none; d=google.com; s=arc-20160816; b=tu3GRNZpQ9GYYvDUIsq3RhjSi64zo8F1bW2HpKXKaRHq0UUHtM7Hm5NW7kLluaKEji E8kRWqhzpFODb4YoOTc+G0Xy4xqXdrxxCPrvFzf368E3Ma390f9ewyM7QvPZPnNZSo3T eSwTqCZ5WDvCiwKT48J8Vs+60ZgaN0SzItFrm2WC4LlJE0ciQmZhYxvrCT0mAXAqM9ON xGsod6vIHquJRUrRF2vkVznALFj76wZKTHEXM2RSuoBFAnimA45FGDsfHRZNeiAZ9jBo 0HeZWi20zBqL6tNiU9IUNbi8+SqqMQIlylgRisQdDfFJ650T9ilehNY/Q2y/iUlds3R1 5KZQ== 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=I193XtkSF6UUQSItZ6ZLJnPcIP1h75KwwcHfeLlOgI0=; fh=PL8ckMkyAhAkso3TNNQ58kdISuodHNUfk6+te16KrPk=; b=tFqUKmQ+wgeYxhhx38XVKcaZuzj7+tBVS+1NVVYWV/ITxjOITeK0SddCPuobjlF7lD HOXdqGVP/jBZaenwltuYOJgAHh6lsnacDA4vNlKrKgCgk38NZ9vpTlsL15sBERB8xmFd 7PDJJSuBlD8e8sUYuq2eORvo9rHJXJFFN0yq/AwyybQplTJKEW5aeU/osSBxdqQUk3HS N7MNkvVp5/cZJQqI+hL6cUjosGQMr+gyREkjK21qnq+p4uZLRl+D3D9Nqdyo+V0Hq6Pf sTfmRkoVwUYKRJgRKWtnLuUKlJpowKP7i7A7ZstkQWarSgv0XK2Ol5M8tBZiMpwP6clo fMFA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bGyc13k3; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7a160b7ccadsi820278885a.145.2024.07.16.11.43.01 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Jul 2024 11:43:01 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bGyc13k3; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sTn8F-0002LM-36; Tue, 16 Jul 2024 14:42: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 1sTn8D-0002EB-QU for qemu-devel@nongnu.org; Tue, 16 Jul 2024 14:42: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 1sTn82-0007Nk-Py for qemu-devel@nongnu.org; Tue, 16 Jul 2024 14:42:33 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-4266ea6a412so41126645e9.1 for ; Tue, 16 Jul 2024 11:42:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721155340; x=1721760140; 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=I193XtkSF6UUQSItZ6ZLJnPcIP1h75KwwcHfeLlOgI0=; b=bGyc13k3rDf10GYqEG+cXerToZ7S/EVoId24Wz4Jz5djLgn2+r0lmzpxXSGUHwcU01 YGKJbS66dxf3RWaLgAqthH7nzJTTFsWK3FzBx2g8Fc6mWXe82Iuyu4JCE3Zq5BG3Z7PJ r6FansOsTeGPWBbIUlgTx48tXT6AdxoLZ7/H8MNI1QSCXtUDfE6mmrnOT58H/VxjwXSw Q92u8LatL0mBiz2T1+LTDXLgB+/yMN2pJQ4hk80E5B7QPIse1gP09IQefRiBe/0tKiZM nla/yUVKzgY0v70c49Y6JAJemuLp1PU3+6S5JeUc0Y2fP0wr/OH7Ohb8K9acnPJEeFkg TPEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721155340; x=1721760140; 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=I193XtkSF6UUQSItZ6ZLJnPcIP1h75KwwcHfeLlOgI0=; b=Jc7LfAEEBaGCootDhbFD37fCKKEsalR9aZoIaCi/A96wNXt55uHEGZ6XOeiJf+m6kR JrjByX1Ymy0IKubtVdXD3zKmhVqw2+BO0ZZGlrgYAilqAIOEO65PqcATQzVRrxwsSNcJ 3JYOE/2BBR3rnwBodzT6Hbl7XPABDinqS3MDl0xYXUHzrTYAIKhbbx2ZrW0527CUroRh Sdc2S6ZlDgFDFQgIPWfN9bGpOnJpNJpA3demDDnToNYpL9E8FXJKITwtvKy0NwVEtCMR moZLdzEQPHXnsaldn3kGbnkym1Dlqq6WY1FhbiclT0zw9UK/iYzSM3RRMXzA5Jd8Jb3G Lg0Q== X-Gm-Message-State: AOJu0Yz6DhoYnjhGTPZI+GXSDD77SaDoqoHveS3uwZrlg6eK3Fcf1ZNQ oR9D4xR+Od6HnuP38v30da9wjqbXzb/L8ynPF6P8uOb4JDIOq8ZbmWedXy7yz2C76r6fmfyopTN wCFcSnw== X-Received: by 2002:a5d:458e:0:b0:367:8459:a56c with SMTP id ffacd0b85a97d-3682610c7d1mr1904438f8f.15.1721155339883; Tue, 16 Jul 2024 11:42:19 -0700 (PDT) Received: from localhost.localdomain ([176.187.209.82]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4279f2cc306sm175963045e9.30.2024.07.16.11.42.18 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 16 Jul 2024 11:42:19 -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: [PULL 05/11] hw/sd/sdcard: Fix SET_BLOCK_COUNT command argument on eMMC (CMD23) Date: Tue, 16 Jul 2024 20:41:38 +0200 Message-ID: <20240716184144.42463-6-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240716184144.42463-1-philmd@linaro.org> References: <20240716184144.42463-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, 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 Message-Id: <20240712162719.88165-6-philmd@linaro.org> --- hw/sd/sd.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 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 Tue Jul 16 18:41:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 812793 Delivered-To: patch@linaro.org Received: by 2002:a5d:42c4:0:b0:367:895a:4699 with SMTP id t4csp447205wrr; Tue, 16 Jul 2024 11:43:25 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUgOUkgp6jtwnAGRfH73EiNwn/ShjmjPUs8Dji0oBzOj+/J1hRnL0O/IxVa0OEelGrqFivSLFo2inNHYM1NMHDR X-Google-Smtp-Source: AGHT+IFxEaqrxrVMqcWjeCKWOYc7WL1QNvznf5VpBeb3lFQZHA053rkR3cz9HSaw4w4h94N17s4t X-Received: by 2002:a05:620a:1a86:b0:79e:fb85:5260 with SMTP id af79cd13be357-7a17b723968mr337433785a.73.1721155405013; Tue, 16 Jul 2024 11:43:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721155404; cv=none; d=google.com; s=arc-20160816; b=bOkw+4/kowlbzyhWAhlV2cm0ljrDusTk19F8QiEuZnK8KJBZPukE2MzKg2hKZzQy0W wa1jNPQ9qzFWRWnaw4I+aKZn+dHgfIcp0Wiw5gWgDMsPsIJj7E1ehs/XOOpzQ0SiFAyG FVM+G7btlKdEP4u4nSq8cpbmD+VbcgVSZw70w1Us/E7wtaT4uawcF3JfRTA/QnHrP/Sg 9pUcHHQHhpXEpt+12uDs3P0YUtN9u61i2/7Kf5liAaqzcEki03wBjsXqt5aPCMSMX4qA uiQU06W9AFr/YnzauSu6AikEXo8fvx8X/GWpiabx5FaxlRCZs8Ym0cGdBXjjXTF4xpdr Y4UQ== 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=Zk51wjPZgnSFKW58/RILvklpvjjZlGceP8tUcpMZ6ZY=; fh=8ly4dktE5qX7scQRc1qmWVsO0MVOdxfDtQTaDzdLLVc=; b=TbV9aVw2Kbjv88BhO9UO2rpFD5S6X+OQYaz4Xu+mXEBio6XDS/tkEJ57tUtRBoY1bI NyZf4RutI91vGeOTby19DC9lcEi8dt/N4uCdQfh76WNlWanXqKAldX19oBx1RdZG94bX AyUo6c9YcQeugcSjCBuC8znPmCFBTQefMdXSXe56asBgL4GFuTsDAu8vKd7Qb9J9PvoM +8Etng35PBd/6fADgyamHh4HFwZU7H8YKl1jTccdGD5wGIZFO25rQNuVQO394Gs4Xet3 1uDGBOfyf3lnBl5ld3kN/UARTw2mgkICXJQQ2h3FU14q454NHi8t7+Of1iuec8704ewu C5iA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zfRbWnCD; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7a160b7ba52si808913185a.46.2024.07.16.11.43.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Jul 2024 11:43:24 -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=zfRbWnCD; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sTn8C-00026a-Ll; Tue, 16 Jul 2024 14:42:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sTn8A-0001v2-6V for qemu-devel@nongnu.org; Tue, 16 Jul 2024 14:42:30 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sTn88-0007Nq-LJ for qemu-devel@nongnu.org; Tue, 16 Jul 2024 14:42:29 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-4266b1f1b21so40569005e9.1 for ; Tue, 16 Jul 2024 11:42:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721155346; x=1721760146; 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=Zk51wjPZgnSFKW58/RILvklpvjjZlGceP8tUcpMZ6ZY=; b=zfRbWnCDsyFJ1s/hcyaNxk22hFx8jjFzYFVrN50oqVVSU9EdR1yKgKaYFmRtR9AiMQ 3VrhVF6MLCJpbSKJLDxcFCzkXC+J0/ZnWzpmx/aCEc/4oUSOdzr3VrRU5/cOVlqqyqul s4YpU/20dtpTfQomJL1OOMBt+U1H3svy99filwqjKE4PUWLeZmUUEj8wErUvLdoBBNdZ uYOVJcbbH98BbJ47ExH/AgZ2XAS3T0Mf9XT8WgtgJZiAZM8JrlbWO8J/WMM1wTEP6GwU 5IjQmgfdbwaDtYhsiw204+57tQmJW3V71ujWRGGx4NZNQdq/9wTYI6cNGihj2tcuV8DR mhVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721155346; x=1721760146; 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=Zk51wjPZgnSFKW58/RILvklpvjjZlGceP8tUcpMZ6ZY=; b=NSRpjWMa2IGsRxUUpA4Uvq+Wd+a1zB7RYaPNH5CWJIXeOx31nvqUPE+799g06erUg9 XsUQhPyXn6SwpaCluB+Ywuu777MX15pvt99YPOs3rVQHnUSj+jJbvrGnkOA0/LKVwNGf 6wKHfDQgrVYvkxe5plrFGfDDNKXuu/aaLRT+r/nl0UXKpuk4kIVgqSeHwkqsBLN5mB5T JayVYTyUoexlG4Yuh26UO06TGNVk4JzdE21pNHBNEQBrO1OE4zAAy7nR8usWpqzBFBld 2t7uWXoqwFJlRD44KTz+QoZzQFqh47vTc+rahAQc4acNhrhP2MjVMehzXdKPqY4h0shY +lAw== X-Gm-Message-State: AOJu0Yzr1YsK4knKScRwxmSbGro4kxbtY/ZwuDC4ZdjBA36orTnELAEJ ajAMiZf6GfwNBS2WVUqbKukdRFhcZ7vAOD7x2YReX+iprDurhWWzY1B+oFLtbLz6UGk6CMRmE2r zaNWHYw== X-Received: by 2002:a05:600c:c88:b0:426:6089:e503 with SMTP id 5b1f17b1804b1-427ba687cdamr20380745e9.16.1721155345958; Tue, 16 Jul 2024 11:42:25 -0700 (PDT) Received: from localhost.localdomain ([176.187.209.82]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427a5ef57aesm135373525e9.45.2024.07.16.11.42.24 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 16 Jul 2024 11:42:25 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= , Andrew Jeffery Subject: [PULL 06/11] hw/sd/sdcard: Add emmc_cmd_PROGRAM_CID handler (CMD26) Date: Tue, 16 Jul 2024 20:41:39 +0200 Message-ID: <20240716184144.42463-7-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240716184144.42463-1-philmd@linaro.org> References: <20240716184144.42463-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=philmd@linaro.org; helo=mail-wm1-x32a.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 Message-Id: <20240712162719.88165-7-philmd@linaro.org> --- hw/sd/sd.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 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 Tue Jul 16 18:41:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 812798 Delivered-To: patch@linaro.org Received: by 2002:a5d:42c4:0:b0:367:895a:4699 with SMTP id t4csp447418wrr; Tue, 16 Jul 2024 11:44:00 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCViTnINqtIPHcnJ0zRebP6DTmXOaHRHKSQFT9HiYVNYlUZeh+BbzlBr5iZh46Z+TCoGtjm/BoOf9GSR9wCpjKBR X-Google-Smtp-Source: AGHT+IHj8Du7/NsLXgyQHv21M2Y+qb/4Tl6VSYLl0tR2P1Z05tEJrpre3yo1YCVejGigE76kflPn X-Received: by 2002:a05:690c:700e:b0:664:badf:5a8c with SMTP id 00721157ae682-664badf5d75mr2481787b3.3.1721155439884; Tue, 16 Jul 2024 11:43:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721155439; cv=none; d=google.com; s=arc-20160816; b=rQBtzdq2z1K5jK99s4GfKumeQk3kk1RYTSjpIPopqSDoiUmOdqRHKqLuF5MoibZtF8 844Itrm+6OGxyIGnnsOSplscmxkG7gM21HN8r+KT/wrvWacHBFKHf3eb7VXY1XSEADP3 3S9ng9OC7xuuOQNCGYHblwErFfw0Vk3c6C2U/naT9Jnf+2Hbn4mK5BHAfEpNLTFjtjLL aF+h8gQ9UA9G3127rRg9NHphXvvP9x2o/6TTKcKinftAKfQLRvf29y9slKn9Mcl2E2nP /a9sPfQi1i2qYDOZFsazdJ5bMrmwU6VSH54YLQc/0lcUhwisaP/oseaxpT2FMrubWT4v NebQ== 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=I6ZYXjZ35vpvV2u+NeAW2X7raSm2BD4OmCcWt2JDsuc=; fh=X5GzrtXqAiJfka+QudeW3Yo8Kw2G9JL/UkV4wOvQcmM=; b=1DXEHTjoLJHYsCdZUVJ1vfE+9kc+dDgsqvR4lHM+UdGciDYCW11cvJCC2vweqH090u hm/WXrv/7EIEIkjQLi0Z+0PhRjlSOfAvJwwk8lAOoyiNWAixH/r+KnZ2ENcwJ8J39j/L ycL4EvAiKkYPwCKxmJyt1LW6x0wiOOQWmdr2vD00tmhipoBAolL1tzrck8etJkREz9Tk LalqKQTU62Kj+YcC0ddG7QbGA17c5d4SboSazMqWsPXlKfq6i/zrKrA2XlnywFErffK3 FvA2zhBUECsfm6+FqCnbwPH5LD7C3pQ6yflDEVtCutywrJGSgOQcRK0gONmWgH9C0sAu ofKw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xrA9UdzA; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6b761a04debsi81338926d6.278.2024.07.16.11.43.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Jul 2024 11:43:59 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xrA9UdzA; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sTn8H-0002WH-Nx; Tue, 16 Jul 2024 14:42:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sTn8F-0002Nq-KX for qemu-devel@nongnu.org; Tue, 16 Jul 2024 14:42:35 -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 1sTn8D-0007O3-Th for qemu-devel@nongnu.org; Tue, 16 Jul 2024 14:42:35 -0400 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-42793fc0a6dso40012845e9.0 for ; Tue, 16 Jul 2024 11:42:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721155352; x=1721760152; 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=I6ZYXjZ35vpvV2u+NeAW2X7raSm2BD4OmCcWt2JDsuc=; b=xrA9UdzArwhEwgeN1HOtavrWyivZ5QUawsEkyvOHI33mHxWEYJ/tL3bPI5PjG/CL0W 3thljz3/hKFOw/QQW1cBlc6qoLmxZU8PHPCE2uyKc9/DZqnyxNF4nGZRPh5QbKFlT5sU KGR/5lwXXZTehl3F4D09Y8hXHA81/dv84Vg4d57oFOk6pphi3MLsiGQIQ2vkKO6wPugG CYaPCnAPLgK7lo1Q73/2i9R7DfZMS4oNcCJfcyw8wXKmbKCTHz1GNrcZPb9ChdI83L5W NudkvpgYpHa7pw7kfU3Oe+P04SeoQR+UjIQ0bHZZw3o5mk1npl1mHENHRU3UGtPLjxjg Rf6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721155352; x=1721760152; 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=I6ZYXjZ35vpvV2u+NeAW2X7raSm2BD4OmCcWt2JDsuc=; b=JK3+B50U7SzErH1IUeB77tCyzPFWnanPrMbptTJ1Yge5igjY1Zy6Kgkq1LLLvPLq/i tQeSUDj574sZ2nirtq7QFcv6HNNJyhoa1FZK4TWFKqEjoMemnaTSmoxwNYK41JbanQQp d/z7dSEe5d+M7lvOf5KTfZXW5G3bSNUziNUpuzRP/bxm2iH9U/czsW92lMYBG1MMoA6k bVyBtxlant2FCpwMOINgjGAFyOWZlb249XScnkecXWa8ZC7NE1VVLYhQJkDKr3fWEyNB iaTcoIpD78WEN6dg+ZazUYcAnydEw6/ibjE5Z1Be8z52T/ZtYOwg1fgirTkQhntEt5M/ PADA== X-Gm-Message-State: AOJu0Yzb/Ita0ygWf1HXxBsmigHkvsEBAGzqlisB8e1PVi2GCDzGeeqh 9V+OjSmKXLUJnWEHeI9u3nVRv4mnVBYaS/1iVp1c0tDNpDYA6RCYvk3+ud6BVD3YnYrTZ1wDFg6 GRqKRvg== X-Received: by 2002:a05:600c:474f:b0:427:9dad:e6ac with SMTP id 5b1f17b1804b1-427ba6b1200mr21414755e9.34.1721155352363; Tue, 16 Jul 2024 11:42:32 -0700 (PDT) Received: from localhost.localdomain ([176.187.209.82]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3680db0ee46sm9695377f8f.114.2024.07.16.11.42.30 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 16 Jul 2024 11:42:31 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: 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: [PULL 07/11] hw/sd/sdcard: Implement eMMC sleep state (CMD5) Date: Tue, 16 Jul 2024 20:41:40 +0200 Message-ID: <20240716184144.42463-8-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240716184144.42463-1-philmd@linaro.org> References: <20240716184144.42463-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: Luc Michel The JEDEC standards specifies a sleep state where the eMMC won't answer any command appart from RESET and WAKEUP and go to low power state. Implement this state and the corresponding command number 5. Signed-off-by: Luc Michel Signed-off-by: Francisco Iglesias Signed-off-by: Philippe Mathieu-Daudé Tested-by: Cédric Le Goater Reviewed-by: Cédric Le Goater Message-Id: <20240712162719.88165-8-philmd@linaro.org> --- hw/sd/sd.c | 47 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 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 Tue Jul 16 18:41:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 812792 Delivered-To: patch@linaro.org Received: by 2002:a5d:42c4:0:b0:367:895a:4699 with SMTP id t4csp447119wrr; Tue, 16 Jul 2024 11:43:10 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUqHAd0q4RV3e5kU3j4I4xXDJg2iC8u/snBQQ5BxXlotNZrfAHOkiNCOaRMxdR3+cwu3oIqIOWnRQclWKBqomHb X-Google-Smtp-Source: AGHT+IFKGwniSCougquKAWXk3ECvnRYU2z4V5nucfO0oaMZUjnfkyUmPNcVO7qVgyQCdc2nYe4fC X-Received: by 2002:ac8:5785:0:b0:447:eb43:5d0a with SMTP id d75a77b69052e-44f7ac4488dmr41449821cf.25.1721155389890; Tue, 16 Jul 2024 11:43:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721155389; cv=none; d=google.com; s=arc-20160816; b=XCFo40idlmg0fxo872DNN4vn7Nhxv9eYLJ1RdnWzSPuRdSORzOvwd8axuVtIhsT9ZF BFpFOxD3/QmB+QFoQaNgjTzwYQfzPNMhOiV46BKi12lLMMbtRwcGnLBIJANP5YeEDrxa SfelwdaPw2wgkBAUs7640ePmu2MwSKfVSc9r0xAXFMQWOgaxQHNc7LtDBJaj0KOLXPaa 6flT/ktZE86RCBi2CLJ8+4Xv8HAgSykMkW1Nr9NIqTUq5SXoW+ehm+qvLnVUQPyHPlOb QSC0mwpsmBJZadaw7zeuPMK/ouNLQmTqQBjodKpf9HKRcsnQBVRkG3E2BCxTccxGQItC WsUQ== 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=KNRmOC5cyH9H1SqgMJvCfjplAZL9keQjLE5Avu/jsnk=; fh=ieV1fZxxmOUgjSU3gA+v8vVgshwKiNmGWfNBiCbVc5M=; b=EKn6kFzpsrEnbeCk9g4d+KS1QIqYn0WrBGXD/xSITqbpu5hJ1vQoo+i5XCnbB4FjQ1 Da4sLhLqvukLCvNAIB2CdXbKXXnyx2q9gn5SGhayCJp4bFSzbEebY/yAKmv6WTbmfonK D8exQaPxC9J5rfoULPIOvTJPfCxMnWoXgivtr1ty2mDiWoS3xzX41J85zquMBGv20orz wh+G9Rd0GkUpTjEqW3mjzpSvGfRxRjryH7dBjSx383FxXnpElTPCwfcRHQgYUOrwpqHY 79lrakB/ceDOHPaeuc1G+puk57LzRFy3ApPDTYds6tywxuLH/y5cnPxWXm7QtEYXuXwR hJwg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BHCYEiSP; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-44f5b79e964si83700681cf.227.2024.07.16.11.43.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Jul 2024 11:43:09 -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=BHCYEiSP; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sTn8Q-0003K5-2f; Tue, 16 Jul 2024 14:42:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sTn8N-00038x-FR for qemu-devel@nongnu.org; Tue, 16 Jul 2024 14:42:43 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sTn8L-0007OU-EA for qemu-devel@nongnu.org; Tue, 16 Jul 2024 14:42:43 -0400 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-36785e72a48so3294738f8f.3 for ; Tue, 16 Jul 2024 11:42:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721155359; x=1721760159; 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=KNRmOC5cyH9H1SqgMJvCfjplAZL9keQjLE5Avu/jsnk=; b=BHCYEiSPc+1xbu7nc8P77tosIAPCFVZ1OUkLkaMQuaeNxJrna8IcPxB6Xdb6NhGzbh 7GDkqrpy/yp0L7BCBpcFFj/Jh6Coy+X0M/Mkh0VTTWwdiVTR4dQFatwkQxAium4ybRSD zbXnU8oFF598lF7xv5cxLc6p4YMcpItP1DyiqB1T44EXN8g3qxpbK/aMJyGuQyuWOcCc O7LewavuW6RACv/HudBKZ6UFgmE9/2HVc6HcJwoMXfFUj1kp6p4LQzbKU7Cvm5tYwIIi d7RyYMRF8NF2lUrBSJwFwH4DCFvJYnS2Hj78y4b/fcdvI1S8Y5oMshT7B37NHjqXQsH6 ZeVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721155359; x=1721760159; 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=KNRmOC5cyH9H1SqgMJvCfjplAZL9keQjLE5Avu/jsnk=; b=bujutzEygIz8x99+1tHYvprwXig0s1RHCkc2f/eV8Q9Z7y/qApLwaZl6lwMaOElwYo erO6yYvaGgXcP4Z6vC9MpMUfPR1vxqjvrfgMy7XN+p6rNSLgvBABQtT3CVs3YjrZep3c FPzkliRWjZbAEUWMY/KzuyfbqoKRuWRquKm8KW5CuoxvVo8m57iT+WmSGsXLU8OgB5Bj HYBBAfzTCCNJLuO5BxCWPuuJUMFyaZcTYrzduKkUo0sW58aXN9dI8MfxrOlIME+zsPiY ItW+BZvflPf9pLkioJAKbObuufEfrVGIa8V7A74SjT8bwauaNLtKFbyFSazEJViDlKnC pjLA== X-Gm-Message-State: AOJu0Yy+C+dPqocFYV1UQMz/+g57M1o3H3nM2pe78zcha9DkmCBXoFK2 K6yoLcS2KSyt7EoGBiwo510liclKiZArFLpYIjN2ZXYUOiSHLDF/adUmCdBdmtgUlv9bh6mEuUL EW7PraA== X-Received: by 2002:a5d:47c2:0:b0:368:64e:a7dd with SMTP id ffacd0b85a97d-36826323345mr2565633f8f.53.1721155359078; Tue, 16 Jul 2024 11:42:39 -0700 (PDT) Received: from localhost.localdomain ([176.187.209.82]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3680daccc9csm9732764f8f.57.2024.07.16.11.42.37 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 16 Jul 2024 11:42:38 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Vincent Palatin , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Sai Pavan Boddu , "Edgar E . Iglesias" , =?utf-8?q?C=C3=A9dric_Le_?= =?utf-8?q?Goater?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 08/11] hw/sd/sdcard: Add emmc_cmd_SEND_EXT_CSD handler (CMD8) Date: Tue, 16 Jul 2024 20:41:41 +0200 Message-ID: <20240716184144.42463-9-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240716184144.42463-1-philmd@linaro.org> References: <20240716184144.42463-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=philmd@linaro.org; helo=mail-wr1-x434.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 Message-Id: <20240712162719.88165-9-philmd@linaro.org> --- 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 Tue Jul 16 18:41:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 812799 Delivered-To: patch@linaro.org Received: by 2002:a5d:42c4:0:b0:367:895a:4699 with SMTP id t4csp447444wrr; Tue, 16 Jul 2024 11:44:03 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW6zU9vLArO1W37qb5TS3Mt0VURLWITZ3S+gaXdXHBcS8XedYTrmHuNwH0WUTZTjETxQ+k5qyilRIe3/WMhg02h X-Google-Smtp-Source: AGHT+IGfCENGOJWp8qU5A+QtALd50kMPFwA9oNTz0GRI6P0sIh/F973Q/L1VKskLtDLp0T+cpf8x X-Received: by 2002:ac8:5705:0:b0:447:e591:2d27 with SMTP id d75a77b69052e-44f7c9f9b98mr41181281cf.6.1721155442812; Tue, 16 Jul 2024 11:44:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721155442; cv=none; d=google.com; s=arc-20160816; b=wEA4QwuT3N31s7bHKBae2CUGCxyPUZXCKX40lUzKdQPQQDEr9ldJ+iLxUNgG0msbNN 8c68Yg8Ebzo8eIZNS82jbwXPlw5z1ZwB+l93+kiuyvd/gDhzel7pxb4e7ZUTEHxZ3v8n MBcI659vXftm+L65EcvheRvsLU9I33hQdqKLWeUZ4ggm551QfBer4B7Pey8xV1xcPCXG wLrC6L99Q4pJApRqUNildWUKV/UIaB48n88jajPuM7mPQifvR9JtvBUo9MNuds7PG8uR wcRNeAy2pWbyxDSTFPo3pfNYQaHgatDaud3gdljW6hV/0a0ScbQuu5XhB5uCpBLZ5e+V WeCg== 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=/mR/0QMhMqGZbfZ0QJaQ5Uy2ur+BzQmeQAtYeietrZc=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=bA1/bviUeSBmmXddgPa0Sc+XBc9xasoheW6pGhouzNvCwngwGI4DWmXdmzkaRijwSm hvvc7wpMEd8qzZFYXq8R6D5JaJI/pcBPKhSfhgj8cSImCpfj2xjW5hMAyy5rSZTZlu/G hm5i64+N1eKYD3l7OEzh29tpITn3XGxEq0gWXayOIZKPjBfchwuxhAfzjjSXMpWu9FYa oNXO5XpmKU2/g7v9YRaqwTNk9hVPGeFUy/nwYSR4w6rJx/ref5OP0upawI2oglchE955 Sg6+OecWQp/5LrYfLWvyZkC6GNFweZurUccmPsUVaXy7GQ1A1LbKL3fDBp36I7eqSejY oeVw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Xl0yDCI4; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-44f5b83460csi82886861cf.768.2024.07.16.11.44.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Jul 2024 11:44:02 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Xl0yDCI4; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sTn8r-0005Ay-Ji; Tue, 16 Jul 2024 14:43:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sTn8T-0003rR-Hz for qemu-devel@nongnu.org; Tue, 16 Jul 2024 14:42:52 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sTn8Q-0007Oe-TM for qemu-devel@nongnu.org; Tue, 16 Jul 2024 14:42:48 -0400 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-4266ed6c691so37843755e9.3 for ; Tue, 16 Jul 2024 11:42:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721155365; x=1721760165; 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=/mR/0QMhMqGZbfZ0QJaQ5Uy2ur+BzQmeQAtYeietrZc=; b=Xl0yDCI47WdKQjLZfal5vCKzXyj273IR+slxK2DAs9dd7VNYlT1SyJkBgmB4IbFfMy Xxn1PeKQOM4rd8p+//+kG2caS4GVwxpBDwEHxF3at2ldunhhqRY6zuZKxHYynDshm4B+ mD8zUUM22TDZBQwAetQJjN7d0AXpqIra1Y8TNkwBMcnmWyA9qg4d1rPNQ42v5hsrMT1j SJ3QQm6XwvoZK9dW3vGHm8nN5g05aCV1SIvQ9z9jlmMHNYYVMWg7JBZqjdky3TLQEvET LZio7d2etyHMEEtqGqm2Ows2wMeKkhbrDUv1qzNXyhDIrZPsBdXqoKtTLMf2Yw79tsgZ CwWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721155365; x=1721760165; 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=/mR/0QMhMqGZbfZ0QJaQ5Uy2ur+BzQmeQAtYeietrZc=; b=u6+2OvL9bVbI80pD9MUhbbHDYPIycKEW2/V7MtIT+VFkRScTWrokrlxTsxpL0AnO75 nc5MTkuVdLjEdh3RjO/OhmzKGM0mr9tWZzt1wOghZKuW0l06gGn3DB2M62y/784x5PWT cumsj0ldfB0O4VYcc4VXRVs6DBhXnNzMOAWbtnFg7NOdEFsW/uhLAiGaRSKGr5oq9uXa Nud5khvK5tvhmAsEbVQsIxwhyCwBjfpGPj34yJ0IAC4AnVarpy8ufJpYkhYyIwsSvnDs gMJPtNouofFuZo/1XPAE9rB72xS82fMF3+Rz/J7azzsM5do+vlU4TnNYXGb9dsgmIFgN r+hw== X-Gm-Message-State: AOJu0Yx8NWDJgvoTmx+fMiSRrbpfmAwbUbl7QrPDXVcJrUFywNEJegee LouDc3OmDIEGy0QlwUaqXWP5DCry85G0o6gfKffYwABmDngSlWOK5GY9uPVJ9a2nNk8Y5QHIVZz FRJVp9w== X-Received: by 2002:a05:600c:4f53:b0:426:6617:ae4a with SMTP id 5b1f17b1804b1-427ba69a73emr20039755e9.22.1721155365258; Tue, 16 Jul 2024 11:42:45 -0700 (PDT) Received: from localhost.localdomain ([176.187.209.82]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4279f239883sm174550245e9.10.2024.07.16.11.42.43 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 16 Jul 2024 11:42:44 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 09/11] hw/sd/sdcard: Add eMMC 'boot-partition-size' property Date: Tue, 16 Jul 2024 20:41:42 +0200 Message-ID: <20240716184144.42463-10-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240716184144.42463-1-philmd@linaro.org> References: <20240716184144.42463-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=philmd@linaro.org; helo=mail-wm1-x329.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=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 Message-Id: <20240712162719.88165-10-philmd@linaro.org> --- 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 Tue Jul 16 18:41:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 812797 Delivered-To: patch@linaro.org Received: by 2002:a5d:42c4:0:b0:367:895a:4699 with SMTP id t4csp447326wrr; Tue, 16 Jul 2024 11:43:48 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUMZbXI7qNGk8YhzQRU/evdAiVvvat3Jw/chxxuJqElqPwbsrpUroNtKu/yjI4+j800LNU2A8ElE/Qk7Bzr5V5w X-Google-Smtp-Source: AGHT+IEPD+G8T2Qx74U4QBybhNe+1NiZ++AfVzvaBL4jHvXSd8/A6VVfHPGOhnp7xLRu6Gw3VXcU X-Received: by 2002:a05:620a:4506:b0:797:84f9:cb38 with SMTP id af79cd13be357-7a17ca0c92dmr469092985a.11.1721155428476; Tue, 16 Jul 2024 11:43:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721155428; cv=none; d=google.com; s=arc-20160816; b=JYSyaKS0NiM3IlDCtY9oTzJgJeP/zBybZ54QezseNl8Pydq+a3RFBliU0D2/UKpOXw VmWPD0ueoCc5AtalXBx9tw9ofvQhJ61apffldUbEBr3xV6NiqtPN+uAmj0dFUxS9+RoO ktqj48pXy25lrQwjv3PfrCjsSzztI5ISWhaNyjHDh/OkaIlmKItYYbLEERBBumxwXRhK ySAtQpPRZVoJBT3r6soCIYqDIMq0gUQC+5XujmZf/KxYSImnh5LlPf6uY1C7cdBaENA4 zomI0SeJMhxpfHYmHy0piWoRebo9IjpdReO1al3B4PmgOEibpdQYAfcAnIajiP5ZHxib r0tg== 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=2xO0vtOu4MZR3bds8QyFz198ibx2ClbqyzFm/x8wCZ8=; fh=y/yQRuE/c2EGPQJBi/to1O0b06CGsW//TApLdjdOvxA=; b=K+mJe8u0S166vzZG3yj+8xlcDu94UAE0zBBQjBc6QwgO9UE4/QaaXFIoY7bwVfgliP bP5zk50BqpkD/OOV1DH0+z6kazhxBe8U87xtmE2X5qp54zeavzaJzg9HcuECiBWQzIQZ SU8Yd01AG2RQJQpFFu4xfyp4rTY761y87ynf2jXOv8yBn40KNEsu7vJNSqb6G0ECb3pf UTWerWcz9sKYYtmO8sYblKDIv4Hu7FLQe0jQ2C3x5HZVoDNwBwpJn9wJJ1X2icQrWTOf Sn7keVmgVujKD1nri9jR3lEFlZrs/+ekCaosJTzypRZWglc8JrbEwuhaa1mbvYrSh9n7 rgYg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Kn2h2/WM"; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7a162c07ca4si784390985a.255.2024.07.16.11.43.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Jul 2024 11:43:48 -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="Kn2h2/WM"; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sTn92-000632-6Q; Tue, 16 Jul 2024 14:43:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sTn8Z-0004HW-JI for qemu-devel@nongnu.org; Tue, 16 Jul 2024 14:42:58 -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 1sTn8X-0007On-OV for qemu-devel@nongnu.org; Tue, 16 Jul 2024 14:42:55 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-4267345e746so40641595e9.0 for ; Tue, 16 Jul 2024 11:42:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721155372; x=1721760172; 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=2xO0vtOu4MZR3bds8QyFz198ibx2ClbqyzFm/x8wCZ8=; b=Kn2h2/WMh/xdfirvXLrw8Fi83WqSn8wMGHhvriP99L0ifRZ0rvplUFmqGkx2ilqBY6 7s+5AeNmt4hm/QdHLIuIHwlzQgVlpXT0tFZZetnIdtsRzh2UKk7fBWmMoRk9QPApjesm 1PblavISBObqSiT7sSgel8/Skz28fjpov22KqhROWTzCKAvZvE5KNwDrch4QWUv7PrfL Oak7gc1sAQDFgKdPBN0CFsY8Q0pQDumRdni4k8Tw2Q0y+HkIVkKTraa94K80Nr/LfSPu ppck85GIeDODTj3sThDjDNAtTBVd9UYxa18RbrwLvhz7gi/Hl9cs6vkgUHgIkTZUIUkg KjFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721155372; x=1721760172; 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=2xO0vtOu4MZR3bds8QyFz198ibx2ClbqyzFm/x8wCZ8=; b=VRyKvwPY1InZeKlVnUpbPhY2G7l1dDRkENNVf/QOIWN67FAnuJia5RDqkXzJZ0cuGV K6/qtOmMaMpquji2JeHNeeQ+IjgEQIuk8Ok0W17brbAnQA1jG7vgSzH9E875oybIv950 4qHguDhjZVC8IboWcXhPW0qsG7ONOwpMHrn78XEOfsg+EJSgPbH3ElSaGkiNR4HvcxJa 5320xnjvrtFBwFtHVSgsTeEnOLn02nhuoEJ1HUKDOKCX4V8LAjyRVAQ+95KiLMtZN/b0 nrugq1OqNyixeRt9Mc15cyV0DQQJbwyBUIYxPaqG15BVyDdVXRBJ2JFefvy6M7PxbYVX WUwA== X-Gm-Message-State: AOJu0Yzmb6FF7YJe1AfPrEUQG0fUHjZYZJRf7KlUo8rp0o6rQP6c+V3q xn20Vx9+r2YBnHXvLIbt68Bod6UDewU7xFJyD9bD5N5uqZpF8NzI4ZygDl9JbWnzq23fMyVnEuH UbmSz2Q== X-Received: by 2002:a5d:5244:0:b0:360:7812:6abc with SMTP id ffacd0b85a97d-3682635a551mr1895130f8f.60.1721155371927; Tue, 16 Jul 2024 11:42:51 -0700 (PDT) Received: from localhost.localdomain ([176.187.209.82]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3680dafb99fsm9718418f8f.84.2024.07.16.11.42.50 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 16 Jul 2024 11:42:51 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: 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?= , Andrew Jeffery , =?utf-8?q?C=C3=A9dric_Le_Goat?= =?utf-8?q?er?= Subject: [PULL 10/11] hw/sd/sdcard: Add mmc SWITCH function support (CMD6) Date: Tue, 16 Jul 2024 20:41:43 +0200 Message-ID: <20240716184144.42463-11-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240716184144.42463-1-philmd@linaro.org> References: <20240716184144.42463-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: 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 Message-Id: <20240712162719.88165-11-philmd@linaro.org> --- 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 Tue Jul 16 18:41:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 812794 Delivered-To: patch@linaro.org Received: by 2002:a5d:42c4:0:b0:367:895a:4699 with SMTP id t4csp447226wrr; Tue, 16 Jul 2024 11:43:31 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXa4YaOP2q5QBrFd4/GgRNNF18RakAULlj9zm0/aT9DgpGgr05rBD5e5DbgSbkoc219K8TOlu3/nRIiZuRcfgzy X-Google-Smtp-Source: AGHT+IG5cbHpWsmhQGuLg2H/X9KtPfKxkXxtuZuW3sys3OknwYpsCmKnNTGJCld1wd8Vnc24Mz5m X-Received: by 2002:a05:620a:40d2:b0:79f:90:7d53 with SMTP id af79cd13be357-7a17b6786femr359426985a.23.1721155410747; Tue, 16 Jul 2024 11:43:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721155410; cv=none; d=google.com; s=arc-20160816; b=Royz8xynsREa4kgns6QH5JLjuiXtPoxWkKgYdhdoRBRfp3KEdRiKzwvElcypEpDHGV svrNeMNYflmDbwialM279J6LMtLju7vlApQB/PFtK2XJwdLbXyMeBjJ9hvOdPC8F1SN8 xK4nA2piygjW7Neo6C05qHgBXFgy3IF7UcOb8nYk83b+4WCgHF/WcjLKVBEokEWlfYQK b7UiB2SkT0/j50ZJdXKv9C+e49e9ckfZlijuBjoHllVLoIy4hjkYUwFj7jmB30YJh4vI FaefuIqngB/Vp4KOAtWgSfZmAUf4UZnVBKQVNiwS5GkWD8LpxNwSkVtjO+Ul0PznWHvi IXOA== 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=CwOgxVGDanFcrFU38J0jPymvkHnr/xX1CeOfYwqHvwc=; fh=akjfINPLr2Wxn1OxrSfD0sWqus3tlBlnA5tw3YdHy1I=; b=wZkYczPEFD+DWdapg7WfOgkzFSZQoP0OejffT/6uHbk3mv1cztmN9JaeDq/Rbr//Ce n0XFUd/ka9CFP3eEbj77rILkpgTavsLRwns2uXzf1ypsCH2W3LX/AgyxrCMqJ2SIzKwt sZUC9svaJ+wAN+D5RLweodG8AiMNLQT15NI6IhhuU2hozB3q9AZhrOpTIWW8sZFQy5pL Gziu4PPU6MpJp9SKuZtTFz0d9dzGHI27JaxxNHycZbEzM4Lq6/2hsH8N67fAMG5FH6Tf d5rmocInhNHHsLg6gTRV1r+/fk9BB8mswqy/EaoBVYY1LGVRmNCQefOrr86GGaqSiWeC YPlQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HI7YM5QX; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-44f5b81419esi84157711cf.614.2024.07.16.11.43.30 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Jul 2024 11:43:30 -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=HI7YM5QX; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sTn90-0005ge-AT; Tue, 16 Jul 2024 14:43:22 -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 1sTn8h-0004ry-9h for qemu-devel@nongnu.org; Tue, 16 Jul 2024 14:43:07 -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 1sTn8f-0007Pf-BH for qemu-devel@nongnu.org; Tue, 16 Jul 2024 14:43:02 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-4266fd39527so43712535e9.1 for ; Tue, 16 Jul 2024 11:42:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721155379; x=1721760179; 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=CwOgxVGDanFcrFU38J0jPymvkHnr/xX1CeOfYwqHvwc=; b=HI7YM5QX85G7zD1PnhD8mBQyzE4957XzccSlasNGnOtlF2XoNoQsKWSt5Qp2N9vAst 6WFVcOZzUjkCam4yCBdxGSYakAHPrq2XeVZV93YZ8gblhnjnvCFr9uPhtDyKMtn0FhH7 u3jX0isSltp/kPNYqMWdUMslLAkmaJzUVfo7aTTDiCy68FxOtypJpUd7tn/z70kGAtXK awPhTF8EzBEOH9Lo1XMAv5Krhv7wA4B+l2XIXCKwtf1BZ7Q0jTvWDnlwxrsZz1NusiZn 6n/nxlQBRfjt7qfCG123ITO9gUP8SJ6YCUmrw7FxEZ6NcumqpmctE+w7vJMoDCmYykQf NMyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721155379; x=1721760179; 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=CwOgxVGDanFcrFU38J0jPymvkHnr/xX1CeOfYwqHvwc=; b=AZTb5J4KMKIYVufU8ogq8ILffOxPhirNtdJM8/OrCgJ9SWp4+FPwfgS0MBfJWYeu0b LpQD2F5SMCUpkdoP+/fBFoXebHxdZ1lDCJyaMPsVjhnRpuYyGcUQv0fxL2sOThFJ7ZwW h6KbJL76B7Qc8oPKW0MY9lTYe+C+bpTRFnoiL2QpYwN0jV4zS1AynyLws5vaXmjUaOQz OhQMOIg1nBvd0Px/5NYH6dFk9X1WXdBO4447cQy1KK6GPZMMx29OUdX92j5IzOBq2X5y gtP1Dsrv0gOb7ub/JPwaWLVvuE6nLDxO0MeNbccufOXlIQF9PeRUdJD7Bkai014S2/sS 7Atg== X-Gm-Message-State: AOJu0YxnkiyaQSpv0H56Ied86WZLRjlfQDr6667h7OGgjLPXlxKx4hjE dn9PpkEfh3r/xca6l8N/8yc7lSwuddnVzC4q40PeTHumf+RmXfPPHxwvGBZVgFjkkOCV3p+BO4Z ouaQJ9w== X-Received: by 2002:a05:600c:4ed1:b0:426:6861:a1ab with SMTP id 5b1f17b1804b1-427ba73df6emr22806715e9.39.1721155378628; Tue, 16 Jul 2024 11:42:58 -0700 (PDT) Received: from localhost.localdomain ([176.187.209.82]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4279f239876sm174099075e9.3.2024.07.16.11.42.56 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 16 Jul 2024 11:42:58 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Joel Stanley , =?utf-8?q?C=C3=A9dric_Le_Goater?= , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= Subject: [PULL 11/11] hw/sd/sdcard: Support boot area in emmc image Date: Tue, 16 Jul 2024 20:41:44 +0200 Message-ID: <20240716184144.42463-12-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240716184144.42463-1-philmd@linaro.org> References: <20240716184144.42463-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: 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é Message-Id: <20240712162719.88165-12-philmd@linaro.org> --- 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() };