From patchwork Thu Jun 27 17:10: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: 807882 Delivered-To: patch@linaro.org Received: by 2002:adf:e842:0:b0:362:4979:7f74 with SMTP id d2csp913113wrn; Thu, 27 Jun 2024 10:12:17 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU/abe+REO5UCHIjFR0C28Qbekt5IiqFg34CKV0TmXvkRlGZ6R24AZpPOOSEOU/3ueP65nX+fi9L+FLQhd5dj+p X-Google-Smtp-Source: AGHT+IHEkloYXPiq279yd+mFyFtrI8kW/0trt5XNG/8zayllCgs0ClXJQtl2LaCByu0M9SY/o0Wv X-Received: by 2002:a05:620a:4110:b0:79b:b571:4c09 with SMTP id af79cd13be357-79be47e06ffmr1677818585a.63.1719508336956; 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=AZ/tUe+ijsIrUlrur4W2pm+4hCebmjjlIzYuGD27Qolxi3mU+1YPfSK1rZpeL9f40r nvnA8EfquVyatF1+z1+RY1ba27w/jayizZQEyxZ4RPDLjPLBWvQ2yEmwwT3H9B/b41qw pCHDZ9VK4SkSSleEltJeaM4pfjZCWDuNPf2gTB9oNsCSF0IWEleceBT+RbH/a0O4cIXy P45stl4baZOgo0uwz/XDMAyeWIH8rkz3GCKAckf9yzjruUT0RhdB/mO7EpMa2IcPGaj2 fNM9ruBQiCoyNw1BMgKGe+eo8fmaPKy32hCfWLiF5vkwqPXECFlygAH2isMYiNK6lzlx p8eQ== 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=DS5w/rOHX5RjJWkmyFPsFftFPu5c4nwaKlj59xhrXaU=; fh=WUqfD5CNolTLXU3odpyK/irI96uSRBSbw3kHmNv9290=; b=y1LzTx1NS8VEB6dnID7IenaWJ6YniOQGJMFN4LmIv5QQixcXWuS5XPV9ylcGtJYQWE kV0CYx9QPnmXDMah4mO4ITFXw0lnfUX3kbUbqfFawoRIG8l2EkqEjWchFcbLQ6jdaXTT 1DPrI1F1YzLjWsWgLyRWUEefE186ElC5SZm7X3snLuSxEhGxzVjeAbPXHxl1yI/38zSN XaTj4NYXSpYfxfRbiNAqk2lggV4VoraAbG4XA9vgh4e5payvf45jV6F4b7Z+Y3qMkU5g 52S2Y2G8JnRz3bYO6pQd9noxYh4HfJFn5N1vzQ1MPUX9vrGzXVgc/c0sP8p0ODJKKNfa z9lQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OLy6oP86; 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-79d5c8ecc72si192136685a.691.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=OLy6oP86; 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 1sMsen-0007F9-3Q; Thu, 27 Jun 2024 13:11:38 -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 1sMsed-0007Cr-Kg for qemu-devel@nongnu.org; Thu, 27 Jun 2024 13:11:28 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMseY-0001pF-EW for qemu-devel@nongnu.org; Thu, 27 Jun 2024 13:11:26 -0400 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-364ff42999eso6367614f8f.3 for ; Thu, 27 Jun 2024 10:11:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719508280; x=1720113080; 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=DS5w/rOHX5RjJWkmyFPsFftFPu5c4nwaKlj59xhrXaU=; b=OLy6oP86eACS3NFEB6NuEPDLQ+Gbw9jYDuzlhXDEQiJonewp2Dzw/xdPOhxiofcFXb J+ii/xMPs/MjiLGrOoSLQemhrZOImMsVkbCL0C4jcd0ixMqmQf/yLL6qfcJQn9oifyYj 8AarjOwAayfLJhCNQ0Lx/1wqiBRro/kwW9uQU0kZpXs5lLl7cK6uv7nFAD83ZOTYlIM1 8JfppXRICM8Z+EXQHSN0gpayNsauu8vd002G5k9jAbzBpCE+1HwxaGhf0QxAKpisEZOu xJOYOIzZo6RfuY8VI1xGNVBj8s4/N4hzGKUdivUHmgBuFIDiDYytF/EG43DVdMOHOsq2 JXrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719508280; x=1720113080; 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=DS5w/rOHX5RjJWkmyFPsFftFPu5c4nwaKlj59xhrXaU=; b=n2cWRHda+U4ol6Q5063uArNZeQdGaBuwWdId7iQB8l1jUZQQ1Tm9i4EqB1E30FNRHe gZ1zUq8mafk6ZJPxNxNLoCd1zZnmHHgJAtj18kR4d/gRqCYGDiiSNzR9LW14b/Zplwao Yb7z/KVB7oHF4AtOYdSH7S5sstpqaWLbm9m0wwYm0m8kPxyVYqIuZ7z8YVUJm9sYGKpl wJcAIOJ0++Jr7NpcmM5lnrrKilGf3Qcsm66thkJZwy18tm7MCL2RZ3REPInm4WdR27KX WCjE2uY5LUWhuPV7OxIsod8XNbZA828rWOB5AaY/acDc1j7GSyjTdQ6dYoKFnUGJgtVm lcoA== X-Gm-Message-State: AOJu0YwFwGNNkstD2phygh2WP01YrliSJds3sh+HGRDLmrsT9C/QKTMZ 9Nx9+KNoJNhr9wyyTF0KmOiR8K44BJoc5Ge0ve8w8nP5Nm2Wz7d3dQGaElRpPxYxIoG34RU3XjD MvVo= X-Received: by 2002:a5d:6482:0:b0:366:e986:22ef with SMTP id ffacd0b85a97d-366e9862451mr15683222f8f.4.1719508280679; Thu, 27 Jun 2024 10:11:20 -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-3674357c173sm2534594f8f.18.2024.06.27.10.11.15 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 10:11:20 -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 01/19] hw/sd/sdcard: Introduce set_csd/set_cid handlers Date: Thu, 27 Jun 2024 19:10:41 +0200 Message-ID: <20240627171059.84349-2-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::436; envelope-from=philmd@linaro.org; helo=mail-wr1-x436.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, T_SPF_TEMPERROR=0.01 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é --- 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 c1a35ab420..0d6d9e452b 100644 --- a/include/hw/sd/sd.h +++ b/include/hw/sd/sd.h @@ -127,6 +127,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 a0da06e017..b0ef252001 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -671,6 +671,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; @@ -691,8 +692,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); @@ -2472,6 +2473,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; }