From patchwork Tue Jul 9 15:25:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 811445 Delivered-To: patch@linaro.org Received: by 2002:adf:ee12:0:b0:367:895a:4699 with SMTP id y18csp345574wrn; Tue, 9 Jul 2024 08:27:33 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXY5ZUhYT8FtmVsfV1o9ZvfWZ6gpm++lP8+cqEEi47NInB64Ymob+sc89hPVomLx3uIx9IUujklAWIxSIUzbBPO X-Google-Smtp-Source: AGHT+IGvJC6cSIkrt/ILJVDFrJn+dDbDfO7IyCnEfKuacl1LKH0cIHpDQsBhUxaCVu9JLZQSOMGF X-Received: by 2002:a05:6214:407:b0:6b5:e9f9:f1b2 with SMTP id 6a1803df08f44-6b61bc83c12mr37268316d6.13.1720538852891; Tue, 09 Jul 2024 08:27:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720538852; cv=none; d=google.com; s=arc-20160816; b=ntcNPNPVk9TRs+kCGyV7CiCAsiAJi/9acyHjEoiiBW18hEgS46KLhHuICdaVuZOkFV j2NZTCRPzPgB/1W6Y2kIPn7gTL3SVCr0XztCDd2D6C8K/6fBb0J6T2b+0Tk/ax7GQjyf 80WbCUqOA55KeyPlXyziGJ1/g3c7+R0uaiAk9QZmuZtmvSba396uYwJU3hrtGdZT/cqo LTLhSBtWG0FhUXAVORb3PVjt1x2F+Zds54os6UH+pqVsR0wukt9V0NqGv7XnxIRMWYOD pmftdp0Mq4qO2VaPGDC3FWQNO7AHtTSNl566u2O50L0nVHnkxhvMQswHBRTQCJQfTPLB WudA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=60ugG7sbucLNOSaT9RRMMhTNzSMzLQ61ZmEDNwXQ9Yk=; fh=Txzf7K5YV+qryaChbcvqA4D4sw+KVK3yVi4ERabJCxo=; b=qfvEzerAo9RyuAuq+yHYcDGN2znQzZoz6yCuatTldadgbcRNdU3qScKvJQcbrK8eYg JlMYq0XFYuQcQRfm3AAHUmWmdqPCCVvxrywiCkrNHtoZOop3wWJqfFdb4P7tYBjukOY/ Wb/IGTq6j5J4/ufi/+welj0C8pj4AFacpl+/quy1PL6bnF+Ll9AfEighrE8JghVW9ueb 1QgRBy5aj0B9+5FCNraN6pGuwz0DeFjuvYcIgyd1Zhd+l/7XBZZtYyMx1aFoyXo/kUk+ A7AOcTQY9oyEh9T5haNI/CdFWTG8RuxGVzs823946FB2+IMZCXs+zvrGfCE44zfTM5c8 9L2A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=J9jg8Rg9; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6b61baf1d5bsi24691416d6.504.2024.07.09.08.27.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Jul 2024 08:27:32 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=J9jg8Rg9; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sRCjp-0003yD-DD; Tue, 09 Jul 2024 11:26:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sRCje-0003mV-Uc for qemu-devel@nongnu.org; Tue, 09 Jul 2024 11:26:32 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sRCjc-0006Em-FK for qemu-devel@nongnu.org; Tue, 09 Jul 2024 11:26:30 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-4266eda81c5so12836165e9.0 for ; Tue, 09 Jul 2024 08:26:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720538786; x=1721143586; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=60ugG7sbucLNOSaT9RRMMhTNzSMzLQ61ZmEDNwXQ9Yk=; b=J9jg8Rg9JWoABE0qMwy7A+vzGeCVlheESLswLIhW9km776dchOcDogVPSA65ghbV8y /ElUvgKR89Xb/LOlDmOS4ueACfzZmHY9d14+eBB7kdNKaHwG5UG8HbJiF4l3nohPFZsc EM7YqP/5aVslqGqFWmBOwUi+bDgymJTQeKumiLnkb+Jj9uY5ScFlLbPE7H6H3eB942f2 fsiPVsCd0f4nGu9tWxwn80l5UFGsgF57EqEHctlhrIefdB/s3BLQuQd2RInSCzWg/+73 mQPQGn02dE//YOzbnx7genwmgPYQCsRs9kkS5+24JyNAzoVF/FiCepxow6JNjWL3sDLN T9Jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720538786; x=1721143586; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=60ugG7sbucLNOSaT9RRMMhTNzSMzLQ61ZmEDNwXQ9Yk=; b=BBfL9FyCG8iCf70Tops2nFrLNuf//J9kzKk+SKsvWhjC0JT7ARoJppHaJJlBrHOHCy lTLjkiPwT+n58CMOl+TNI/+lrKLD/kImmc6llCkJhYP5SRMpHdEmPuwktWbPyC6zXMYz YdKzhR5iFNVUJEepHjYZG2pzm6WfWV07/9fnjAcjmnidnURgidnVe/lKU5rmAxl/qmwM u9jfwSdtISK5FpDRM09/DRjm0Gk32a4C5E7Gcn8Vtkq1R2Q5z4bynBK9s3kmPNNF500k 91xWp014dSz6F3DKA9EPAwBo4de3p80E2uhNnTrXWCgoLIx2rD4n6BUSiFFekYR9/q9e dvyg== X-Gm-Message-State: AOJu0YxUjluX76v1NLbbFVmsitxQBP6TXMnhgz6GprtMvzrAnUKCvtmf kkypEoDfqdsYAHjfgroI/HscnlnQSSuEF6xQPhh70+MthrQZHyrnzYjWgDkeGd9d0Yd3xr1F4ql o X-Received: by 2002:a05:600c:22d4:b0:425:81bd:e5ee with SMTP id 5b1f17b1804b1-426707d07c5mr25276565e9.16.1720538786629; Tue, 09 Jul 2024 08:26:26 -0700 (PDT) Received: from m1x-phil.lan (vau06-h02-176-184-43-20.dsl.sta.abo.bbox.fr. [176.184.43.20]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427270238a6sm12770615e9.20.2024.07.09.08.26.24 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 09 Jul 2024 08:26:26 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Peter Maydell , Andrew Jeffery , qemu-block@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= , Bin Meng , Joel Stanley , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , Jamin Lin , Steven Lee , Troy Lee Subject: [PATCH v47 04/19] hw/sd/sdcard: Implement emmc_set_cid() Date: Tue, 9 Jul 2024 17:25:41 +0200 Message-ID: <20240709152556.52896-5-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240709152556.52896-1-philmd@linaro.org> References: <20240709152556.52896-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=philmd@linaro.org; helo=mail-wm1-x32e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org eMMC CID register is slightly different from SD: - One extra PNM (5 -> 6) - MDT is only 1 byte (2 -> 1). Signed-off-by: Philippe Mathieu-Daudé --- hw/sd/sd.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 097c9cc61f..2d737a836f 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -446,6 +446,23 @@ static void sd_set_cid(SDState *sd) sd->cid[15] = (sd_crc7(sd->cid, 15) << 1) | 1; } +static void emmc_set_cid(SDState *sd) +{ + sd->cid[0] = MID; /* Fake card manufacturer ID (MID) */ + sd->cid[1] = 0b01; /* CBX: BGA */ + sd->cid[2] = OID[0]; /* OEM/Application ID (OID) */ + sd->cid[3] = PNM[0]; /* Fake product name (PNM) */ + sd->cid[4] = PNM[1]; + sd->cid[5] = PNM[2]; + sd->cid[6] = PNM[3]; + sd->cid[7] = PNM[4]; + sd->cid[8] = PNM[4]; + sd->cid[9] = PRV; /* Fake product revision (PRV) */ + stl_be_p(&sd->cid[10], 0xdeadbeef); /* Fake serial number (PSN) */ + sd->cid[14] = (MDT_MON << 4) | (MDT_YR - 1997); /* Manufacture date (MDT) */ + sd->cid[15] = (sd_crc7(sd->cid, 15) << 1) | 1; +} + /* Card-Specific Data register */ #define HWBLOCK_SHIFT 9 /* 512 bytes */ @@ -2581,6 +2598,8 @@ static void emmc_class_init(ObjectClass *klass, void *data) dc->user_creatable = false; sc->proto = &sd_proto_emmc; + + sc->set_cid = emmc_set_cid; } static const TypeInfo sd_types[] = {