From patchwork Wed Jul 3 13:43:55 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: 809342 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp696496wru; Wed, 3 Jul 2024 06:45:32 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUOcGyMw2uXXKpJ4HmkhYF2RLyG2386cek00vrOag24PHl+oeuR5DPgQYeyctxT1wtAsDfAUuR/gvpHRh7msa7B X-Google-Smtp-Source: AGHT+IGV02FdnCNGOhAz/EO7IYNPbyGcFjTiXbv7twjYb4Gg95hvIRmRV6VrGQcC1RFUQXzwDEVE X-Received: by 2002:a05:620a:12d8:b0:79d:6fd3:62a4 with SMTP id af79cd13be357-79d7ba0d75bmr1261577385a.35.1720014332257; Wed, 03 Jul 2024 06:45:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720014332; cv=none; d=google.com; s=arc-20160816; b=DgpZ5eqCA2c44IND6EnRRxjyxyfz9Qfljo0QuwUJ4AhwOcOPcAgUM57EXCOxHSJOHf pHamYRT8YBcZpMcDb6wD16pMHcmcv3fuaX9K9MaLg+jbFYZbdR41gF70hxyh10lQvCn7 lCpYGILGtAB3yn5VYrqUv2mYCzkXjqn/p9X3PmVfND01uH3jh9jZeVa2Y1Vn8UN552lj BpgVx7qVlZRnWGX3ydOmRmIIbEWVOmfvuLXXM60Z6Nlo9KUWcDr3mB9fJYgkGaYU8963 9op9jjBkcQGvcgbF5ludEuukYIi7lZ4eqaieR3lePVOwNQNGFX8bHNG8AheMYli04iJT B/cQ== 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=uCXkuyBkm/Q9MWnM3F9F2k54QT0LMAwCrOCsbWSEZjE=; fh=580We8s+CZXLehDdYG4h3k+t/+GrgAxlMdGt4/AfmHA=; b=OYawP1EYoEftYOVQlyNKzBK8MHEwYMsOpriq+Lmf1LkAbNFQLe370ObQdRz5LzOuYQ J4lqc59pRQbB2v3VxCnwPTVf4WJBVyfm/vfqrT1ci6I6eP+4HQ9lShZvmAYXfE2e+ztt 8N3tR/fjXjctfg5YLolRKS3E0E6dsY/mug8f7j2qjqG/3zU3tsCOqIHObhtLNLgPgeHV OIpgqSvg/EVYf88/kiepR8ab6/0lzIxsKadyCvJpJnH1RZI7VRBxpugtrute0jba3OT+ p6Who3N4+uX4R2pxCG8N1cV4i7C9zOGukiSom7+B6A+6utYZ7KaQgf2TKePXOrAgVdCV zaoA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=p0ImoaOG; 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-79d69287919si1225151085a.211.2024.07.03.06.45.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 03 Jul 2024 06:45: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=p0ImoaOG; 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 1sP0IE-0003Px-3t; Wed, 03 Jul 2024 09:45:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sP0Hc-0003FS-80 for qemu-devel@nongnu.org; Wed, 03 Jul 2024 09:44:31 -0400 Received: from mail-lj1-x230.google.com ([2a00:1450:4864:20::230]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sP0Ha-0005Jj-9c for qemu-devel@nongnu.org; Wed, 03 Jul 2024 09:44:27 -0400 Received: by mail-lj1-x230.google.com with SMTP id 38308e7fff4ca-2ee8911b451so3441991fa.2 for ; Wed, 03 Jul 2024 06:44:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720014263; x=1720619063; 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=uCXkuyBkm/Q9MWnM3F9F2k54QT0LMAwCrOCsbWSEZjE=; b=p0ImoaOGjds0rybTcJD/nGpCHH6QBN51ZKu/hgJhQMMDyw+1szQK4Tq1hDSPS/VWG9 XpGLj8qlIEFHwQogu1Q+T3+6maA6t8ENIQclNnmF4bFt0ljH0Pt1cewG19jJtm6pi9eE 21Pp587590nGXaCVkVJjky/dcY0zyvlCRc/j84iJJGM0llwtCqIKU+kTcSPcaV+jY9HX 8y1HxMfGZAQBGYHr5A8ueAlqOEO0Bb14m1x2IVPFI/5PcJHo99d1fTeTP0DQ7WL9MH0Z 0JShd5dIBTt3rv2SBl/g/pGsK4IikD1obxUUUZi6SYL5W+wogK+I55nEAz1i2BkuQGOG FcgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720014263; x=1720619063; 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=uCXkuyBkm/Q9MWnM3F9F2k54QT0LMAwCrOCsbWSEZjE=; b=rpYRaXR5Qn8u+dAerQgJahbYqlQwFIq+6yRsC1WF9wrKGwziObTUqpyYE0mU9h/0B6 QD5d6a1bHQ5oXTT9/fjuvLAYQ/6+Iuz9Z4UYA0s/eez4UjH6u91Vrt5ruSHBIC+IHPuZ JhvufOJf8qMqCDdjXREd5+RjFPPL7k3TTd7/CxAUyjz+ISv6NMSjLyS2Q/t9OBOaFQbQ 3Yp5RIPQf05Hc7vgAghRvgZFkbcIM3lS9RXAd0vYoZXp0I2sbk+a7X5IU+dbBiReeveT b2K1tgJNiF2fvE2Tfag24Xnj27bMWLAKdIUCAUneTmHhtpV08GAvmEBP/vlXzejwZ2Xo PDgQ== X-Gm-Message-State: AOJu0YzM0ujhuzOu8LywbFmfd2TNmOKvB5gs56oHTbox82tlcTPaN0v4 pgzm/hnIyp0uI7hWfapHtMxVuAfZsZnNzU0d/83wYK4wdZAr1i5BV9ogArNXwaEQOI78ejTy+hZ / X-Received: by 2002:a2e:8958:0:b0:2ee:854f:45be with SMTP id 38308e7fff4ca-2ee854f46eemr11466191fa.12.1720014263227; Wed, 03 Jul 2024 06:44:23 -0700 (PDT) Received: from m1x-phil.lan ([176.187.220.97]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36798e435c3sm35788f8f.72.2024.07.03.06.44.21 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 03 Jul 2024 06:44:22 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Manos Pitsidianakis , Marcel Apfelbaum , Yanan Wang , Luc Michel , Bin Meng , =?utf-8?q?C=C3=A9dric_Le_Goater?= , qemu-block@nongnu.org, Eduardo Habkost , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PATCH v46 4/5] hw/sd/sdcard: Introduce set_csd/set_cid handlers Date: Wed, 3 Jul 2024 15:43:55 +0200 Message-ID: <20240703134356.85972-5-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240703134356.85972-1-philmd@linaro.org> References: <20240703134356.85972-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::230; envelope-from=philmd@linaro.org; helo=mail-lj1-x230.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 In preparation of introducing eMMC support which have different CSD/CID structures, introduce a pair of handlers in SDCardClass. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- include/hw/sd/sd.h | 2 ++ hw/sd/sd.c | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/include/hw/sd/sd.h b/include/hw/sd/sd.h index 29c76935a0..bfbc83c110 100644 --- a/include/hw/sd/sd.h +++ b/include/hw/sd/sd.h @@ -128,6 +128,8 @@ struct SDCardClass { void (*enable)(SDState *sd, bool enable); bool (*get_inserted)(SDState *sd); bool (*get_readonly)(SDState *sd); + void (*set_cid)(SDState *sd); + void (*set_csd)(SDState *sd, uint64_t size); const struct SDProto *proto; }; diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 10f2764a53..d46be50760 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -689,6 +689,7 @@ static inline uint64_t sd_addr_to_wpnum(uint64_t addr) static void sd_reset(DeviceState *dev) { SDState *sd = SD_CARD(dev); + SDCardClass *sc = SD_CARD_GET_CLASS(sd); uint64_t size; uint64_t sect; @@ -709,8 +710,8 @@ static void sd_reset(DeviceState *dev) sd->size = size; sd_set_ocr(sd); sd_set_scr(sd); - sd_set_cid(sd); - sd_set_csd(sd, size); + sc->set_cid(sd); + sc->set_csd(sd, size); sd_set_cardstatus(sd); sd_set_sdstatus(sd); @@ -2485,6 +2486,8 @@ static void sd_class_init(ObjectClass *klass, void *data) sc->enable = sd_enable; sc->get_inserted = sd_get_inserted; sc->get_readonly = sd_get_readonly; + sc->set_cid = sd_set_cid; + sc->set_csd = sd_set_csd; sc->proto = &sd_proto_sd; }