From patchwork Mon Jul 3 13:24:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?C=C3=A9dric_Le_Goater?= X-Patchwork-Id: 698678 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp1755059wrs; Mon, 3 Jul 2023 06:37:40 -0700 (PDT) X-Google-Smtp-Source: APBJJlENOtWIuMOfZoDlLXO+E6iXo2rfMu+qKiGo2dOZ2BsO1mEXoHPKD7LAavtdhuUGvJlPzTx/ X-Received: by 2002:ad4:5cc9:0:b0:635:f3c2:e88f with SMTP id iu9-20020ad45cc9000000b00635f3c2e88fmr12023530qvb.33.1688391460032; Mon, 03 Jul 2023 06:37:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688391460; cv=none; d=google.com; s=arc-20160816; b=qw6sdYXI1ym/q6u24fnyI3R0ug08GbtzAzxajQZu3okV3wWQCgAhcQ9iVzqMP7svkR lco2QTs7ILpa98pIXh5bBIoLFqYu7sXPhWw+wo29WVLl9mp0viWbiVy2e5ioBHdAEosO Rc2mQqYxWcXic37k3qavwvTyrIN24B3hvkoE9hW1Xwd+az8D8Zux83954mWFteUzpiej 31qgWj7EhQSx6zkNhPwa8JhwwcRDU4mxhEQYq2QyK3zWpY5yBgsr7p3sS/qesJpnwZWh owj/CYU8RtK/tEriEANBrlaCyKCveEMPW0oc1UgOLPyentznZNTllJRtrkwzUU4bsnZ5 v3wA== 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; bh=YDHsc8T11o7nqfHIXKtCwbmZOjk0kXgowsn57lzGibo=; fh=1TrT0PYyEK7er4Ab9GZHs8q84ATye5Z3OY6erb1zI7k=; b=c/h8xQo5Up/XeyEFE068r3YEVlxMTxAWK1PQ0VjAfiW3+vgZT/4pbmxiCUZMYRFCKX qAkU01/v9s4dORh+EtsLu6hRq8q2L6QBjLL1YPr6V5LryJCiy7Ze2v5N+rlDls07Bb08 EJJVlYgpt8bcEUZTsAES97r1qBHYjd+0RRzFdbSvy/N7n2Y/sZT9233WkXW9ZSrfJqU1 50OUfcIh9Gl5GXM9Lin+IGoTp2Tqwf6xhyO5uyZJe8K2v51+Y+fizNLjGgMdL1YlEo0/ ye/Oxmt9GWY8lhT4xZmikykFAVLimHn0LHfEMahGn/htZhx5rlEDhWi8gqH8qKGBMH51 vjQg== ARC-Authentication-Results: i=1; mx.google.com; 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" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id r14-20020a056214124e00b005eee3411598si11925303qvv.145.2023.07.03.06.37.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 03 Jul 2023 06:37:40 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; 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" Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qGJZ7-0000CT-JC; Mon, 03 Jul 2023 09:26:05 -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 1qGJZ6-0000Br-1p for qemu-devel@nongnu.org; Mon, 03 Jul 2023 09:26:04 -0400 Received: from mail.ozlabs.org ([2404:9400:2221:ea00::3] helo=gandalf.ozlabs.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qGJZ3-0000nL-4d for qemu-devel@nongnu.org; Mon, 03 Jul 2023 09:26:03 -0400 Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4Qvms42TRbz4wqZ; Mon, 3 Jul 2023 23:26:00 +1000 (AEST) Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 4Qvms16R0Dz4wqX; Mon, 3 Jul 2023 23:25:57 +1000 (AEST) From: =?utf-8?q?C=C3=A9dric_Le_Goater?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Bin Meng , Peter Maydell , Lucien Murray-Pitts , =?utf-8?q?Philippe_Mathieu-D?= =?utf-8?q?aud=C3=A9?= , =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH 14/32] hw/sd: Basis for eMMC support Date: Mon, 3 Jul 2023 15:24:51 +0200 Message-ID: <20230703132509.2474225-15-clg@kaod.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230703132509.2474225-1-clg@kaod.org> References: <20230703132509.2474225-1-clg@kaod.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2404:9400:2221:ea00::3; envelope-from=SRS0=mKPa=CV=kaod.org=clg@ozlabs.org; helo=gandalf.ozlabs.org X-Spam_score_int: -39 X-Spam_score: -4.0 X-Spam_bar: ---- X-Spam_report: (-4.0 / 5.0 requ) BAYES_00=-1.9, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Philippe Mathieu-Daudé The initial eMMC support from Vincent Palatin was largely reworked to match the current SD framework. Signed-off-by: Cédric Le Goater --- include/hw/sd/sd.h | 3 +++ hw/sd/sd.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/include/hw/sd/sd.h b/include/hw/sd/sd.h index 2c8748fb9b97..da97400469a0 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 03fdb3addc38..409fbbcbd8d7 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -2171,6 +2171,20 @@ static const SDProto sd_proto_sd = { }, }; +static const SDProto sd_proto_emmc = { + .name = "eMMC", + .cmd = { + [0] = sd_cmd_GO_IDLE_STATE, + [5] = sd_cmd_illegal, + [19] = sd_cmd_SEND_TUNING_BLOCK, + [23] = sd_cmd_SET_BLOCK_COUNT, + [41] = sd_cmd_illegal, + [52 ... 54] = sd_cmd_illegal, + [58] = sd_cmd_illegal, + [59] = sd_cmd_illegal, + }, +}; + static void sd_instance_init(Object *obj) { SDState *sd = SD_CARD(obj); @@ -2307,10 +2321,40 @@ static const TypeInfo sd_spi_info = { .class_init = sd_spi_class_init, }; +static void emmc_realize(DeviceState *dev, Error **errp) +{ + SDState *sd = SD_CARD(dev); + + if (sd->spec_version < SD_PHY_SPECv3_01_VERS) { + error_setg(errp, "Minimum spec for eMMC is v3.01"); + 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 emmc_info = { + .name = TYPE_EMMC, + .parent = TYPE_SD_CARD, + .class_init = emmc_class_init, + }; + + static void sd_register_types(void) { type_register_static(&sd_info); type_register_static(&sd_spi_info); + type_register_static(&emmc_info); } type_init(sd_register_types)