From patchwork Thu Jun 27 17:10:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 807881 Delivered-To: patch@linaro.org Received: by 2002:adf:e842:0:b0:362:4979:7f74 with SMTP id d2csp913103wrn; Thu, 27 Jun 2024 10:12:16 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUfvhrTRVRwZCN2lGHkxAVGL1uidmqKi+OTSB3LTdGs1gcf/tDAx5G/8dcejRni8CAUw5bpo1W66P0dmMXy3AZP X-Google-Smtp-Source: AGHT+IETUfItRRJJVqgDMt0pL+FW/lWI4LVg1nzkFsVVXuDDeuYNrSNFwdH0PpFklKGi6kxELCR8 X-Received: by 2002:a05:620a:4049:b0:79d:59a1:fb16 with SMTP id af79cd13be357-79d59a202a3mr433440985a.39.1719508336435; Thu, 27 Jun 2024 10:12:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719508336; cv=none; d=google.com; s=arc-20160816; b=0kI40ALK0Vr8yN9tdrPPdzcdOats4y1YqGhiJUKC4hWjvgICcQ7UZSmNbQDRVpdZF+ 4OYHw3TvaIRg6SFUgh5+cunRN75DsnCMkm64EjeIqI3PiX5B5zDpYWejxErzrMaFsY34 TAc0+qD+ijEU6vR24BIvAM0XLSzNfC9hX5UDeQ82krvBv7WV5MGLVCIZ67Hft/zkhwNH wreHxYWEgS3OYZDQJmqYIUEG+dLTTwBi5d5gutkbEEoAnpYqBLMCDcoQ3skJKq8+0lVi e+drC4tKKngtQT0wq15Njhim/FgvP5UYk7hn8wpOlVvFnpHlXMDBAN4bhU9fScDDUu9t iGLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=dtkOlWWAl+ZO/rW9NaCd8yU+f3fnPw9yKybdzc1seps=; fh=WUqfD5CNolTLXU3odpyK/irI96uSRBSbw3kHmNv9290=; b=PYMxz+gv67bPyDqndgtAMRooFHY9r6HQ+QCJu9ju5QHflOvP567DxHGWqFvAKbIvob Od4JUzsnP6W5/ZQjrTIQSqxomEdaG+96752AJuYNhBNunQ6BExQhdiwR6Tk7Tf9gSPq5 ygcehUQYTizq/rgM5TciJaTiq8YlKKOyVRvqb3rcQkP4wOuiRUE8fvEfWohhHepMarS1 TWGYv/EvG35xdW+Y4juKJqA2c+E4AroZui36QK38Y3lunUyz/W2E/I58ATK8U0lkZsc3 dJx20eckOkdZTFYoy6i6FrhwN7qUxBeneg8vh2mfWoqWwBCCvTatlgvNdt1RoasE31e9 G+qA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LFxi6UZT; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-79d5c8c45besi166078085a.564.2024.06.27.10.12.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 27 Jun 2024 10:12:16 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LFxi6UZT; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMsf2-0007Uj-Ro; Thu, 27 Jun 2024 13:11:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sMsez-0007Mu-Hv for qemu-devel@nongnu.org; Thu, 27 Jun 2024 13:11:51 -0400 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMsev-00024s-3z for qemu-devel@nongnu.org; Thu, 27 Jun 2024 13:11:47 -0400 Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-3626c29d3f0so4320061f8f.1 for ; Thu, 27 Jun 2024 10:11:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719508302; x=1720113102; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=dtkOlWWAl+ZO/rW9NaCd8yU+f3fnPw9yKybdzc1seps=; b=LFxi6UZTzQPP+HiVBGfYDtJZFI+eUYLjSUBPcPywkbiRyAgXH5YMWjprRMqnQooZz9 ZY3tjGaCRQAy6TTl6TqVW9ECs1n0waIhMamtnhoBx5FABR/G3xiYZuzFJodDh7y2BLZ8 +ZA/qnJ0HC/Vkq0tlCuMM5idLEisR0WvfF2EQ/BIo8dywg+1GcipN/BSufg7/wHCQbOU lzgZzVqGs0RAK/PCW50XECLBpsdm+DeSz7TAImDr3jG1HhSIEkC8b4FSA8TDUGARmZSb 0JDSU1W5fWMlJl81l+yY4B28EzG3cGrO8O1s1KXx8N5WFMSrDFguYqZYHzYr+iOM3Fsq T45g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719508302; x=1720113102; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dtkOlWWAl+ZO/rW9NaCd8yU+f3fnPw9yKybdzc1seps=; b=tEzH1Aan8HTBNpZQE3GM2It90qccgO4joFTu7a+ImOWJDIQl2U83oI+sQJjG1pE1SS iHLXXvfdzF0dwtJsdkvqzeA2LMXaaTqbEz3Rp+fPymCV6j6bVcGZ6/GMBqbt3lSkad5c Gy5WnaOh9FjLIxgqRMAcS+RUdKiPza8vnXJeMVFjkadN3F6MuDBYXuusPB4+QMWRk7Vm sGVURVA4T/BMMLptL4lQtmHWoQqdyxUoI9/M3JLswxjM1qPnZVzhle3/Tl/X90YYEBfg +d0thT4h2L/K2D0a4yk+OWo3TfjV7pFrebfHwfwU/tpZfVCLkivH811WwPsm6s9RA+Kl 2t4g== X-Gm-Message-State: AOJu0Ywp9VweRsqfgJPmYGA4Zo/QdMKZjvVYDjgtHqv2ioUVeSdZXcX4 XX9NWgtiARjrQhPRyNMCYdA2eouTeJNRfmnRMrlYzvvu3JIufnMcCgq52Et1DfP0xRAYcvq5fxf vQyA= X-Received: by 2002:a05:6000:4021:b0:364:d2b6:4520 with SMTP id ffacd0b85a97d-366e937af09mr14977181f8f.0.1719508302067; Thu, 27 Jun 2024 10:11:42 -0700 (PDT) Received: from localhost.localdomain (33.red-95-127-46.staticip.rima-tde.net. [95.127.46.33]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3674357c0f5sm2518803f8f.4.2024.06.27.10.11.38 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 10:11:41 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Joel Stanley , Luc Michel , Francisco Iglesias , qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Vincent Palatin , Sai Pavan Boddu , Bin Meng , =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH 03/19] hw/sd/sdcard: Basis for eMMC support Date: Thu, 27 Jun 2024 19:10:43 +0200 Message-ID: <20240627171059.84349-4-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627171059.84349-1-philmd@linaro.org> References: <20240627171059.84349-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::432; envelope-from=philmd@linaro.org; helo=mail-wr1-x432.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Cédric Le Goater Signed-off-by: Cédric Le Goater Signed-off-by: Philippe Mathieu-Daudé --- include/hw/sd/sd.h | 3 +++ hw/sd/sd.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/include/hw/sd/sd.h b/include/hw/sd/sd.h index 0d6d9e452b..d35a839f5e 100644 --- a/include/hw/sd/sd.h +++ b/include/hw/sd/sd.h @@ -96,6 +96,9 @@ OBJECT_DECLARE_TYPE(SDState, SDCardClass, SD_CARD) #define TYPE_SD_CARD_SPI "sd-card-spi" DECLARE_INSTANCE_CHECKER(SDState, SD_CARD_SPI, TYPE_SD_CARD_SPI) +#define TYPE_EMMC "emmc" +DECLARE_INSTANCE_CHECKER(SDState, EMMC, TYPE_EMMC) + struct SDCardClass { /*< private >*/ DeviceClass parent_class; diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 92ac57a648..249fad0468 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -2379,6 +2379,13 @@ static const SDProto sd_proto_sd = { }, }; +static const SDProto sd_proto_emmc = { + /* Only v4.5 is supported */ + .name = "eMMC", + .cmd = { + }, +}; + static void sd_instance_init(Object *obj) { SDState *sd = SD_CARD(obj); @@ -2504,6 +2511,28 @@ static void sd_spi_class_init(ObjectClass *klass, void *data) sc->proto = &sd_proto_spi; } +static void emmc_realize(DeviceState *dev, Error **errp) +{ + SDState *sd = SD_CARD(dev); + + if (sd->spec_version == SD_PHY_SPECv2_00_VERS) { + error_setg(errp, "eMMC can not use spec v2.00"); + return; + } + + sd_realize(dev, errp); +} + +static void emmc_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(klass); + SDCardClass *sc = SD_CARD_CLASS(klass); + + dc->desc = "eMMC"; + dc->realize = emmc_realize; + sc->proto = &sd_proto_emmc; +} + static const TypeInfo sd_types[] = { { .name = TYPE_SD_CARD, @@ -2519,6 +2548,11 @@ static const TypeInfo sd_types[] = { .parent = TYPE_SD_CARD, .class_init = sd_spi_class_init, }, + { + .name = TYPE_EMMC, + .parent = TYPE_SD_CARD, + .class_init = emmc_class_init, + }, }; DEFINE_TYPES(sd_types)