From nobody Wed Oct 8 14:52:41 2025 Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 80B2E2EAB96; Thu, 26 Jun 2025 14:44:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.193 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750949064; cv=none; b=hlnFyny0jUQrANepqBNnJsPS8wCAimHCaIXAOp0c9FIQK87ijvlzDtwFI1p92Tuu7eVNOAduYH4RSlEc0DIUo+lQTbzmuy8jMIDl7vvVfmtaU+p87llbqmlEuXjFfw1AblTZabWy64RRhmSQwkVOL6I4A6hiA79j8d18CUUEld0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750949064; c=relaxed/simple; bh=fukcXIXMQoVZn94YvDdjm8nFKb8RmuU90szx32AqnB0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=tTR162lSMx9qWNMno7Xdzv/P7x3HdAiymBdwjzOto9QmumuvOxyiK+pf+AlXOCeV5LOr+webqeuL6YACbXYJau/cbFvsXy4qGuJBAuer0i/ct1yez4POaizmscC3nkityJWsSSSdHaXpaVDj0ZuLMp4gdG927vIXtVfJwxI1LHY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=UfnshkbR; arc=none smtp.client-ip=217.70.183.193 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="UfnshkbR" Received: by mail.gandi.net (Postfix) with ESMTPSA id 3958E43A12; Thu, 26 Jun 2025 14:44:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1750949054; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TL3SbPdWICbQ9mpLgPyWfu19LSVtxwepVcgJQRcbOzM=; b=UfnshkbR/9+AhrRyWniTdHHpUQLl14+QYhvLOlTYT/vtUzZLHJ3QORpLwToRmilhuQZUH3 nCZR6WCjv8ex62fWAMP6lEAZ8DxkIALwktqbSkrAOu0GFp2wyfR0hnBSQl013Hr7F89fSq /yl52qmaszzJTipQe+iiAa9AgLT7nP0ZbBHYDgrfXhL8fs2VTO8xnASSSIGrPg/AgJFNFV 7nJ3jJSjOWmM0cFBbhYM3k2RvWsXG6vFYdA43SNHuw0yZPRuF4xi6OLOSLn/2vHj2FVNfI zLmQmcJsYrA3FRro1n0J5nRS8ieTAehJmkwwUrUxv6zha4vFlMytG9kU3q0FYA== From: =?UTF-8?q?Beno=C3=AEt=20Monin?= To: Adrian Hunter , Ulf Hansson Cc: =?UTF-8?q?Beno=C3=AEt=20Monin?= , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, Vladimir Kondratiev , Tawfik Bayouk , Gregory CLEMENT , =?UTF-8?q?Th=C3=A9o=20Lebrun?= , "Thomas Petazzoni" Subject: [PATCH 1/2] mmc: sdhci-cadence: use of_property_present Date: Thu, 26 Jun 2025 16:43:31 +0200 Message-ID: X-Mailer: git-send-email 2.50.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-GND-State: clean X-GND-Score: -100 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgdeghecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfitefpfffkpdcuggftfghnshhusghstghrihgsvgenuceurghilhhouhhtmecufedtudenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvvefufffkofgjfhggtgfgsehtkeertdertdejnecuhfhrohhmpeeuvghnohpfthcuofhonhhinhcuoegsvghnohhithdrmhhonhhinhessghoohhtlhhinhdrtghomheqnecuggftrfgrthhtvghrnhepvdfffeeiieejkeevuefhvdeggeefudffueeuffehffehffevjedugfdtueegtddvnecukfhppedvrgdtudemtggsudegmeehheeimeejrgdttdemudehfeejmehffeehmeelfeeiugemvgelvdehnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepvdgrtddumegtsgdugeemheehieemjegrtddtmeduheefjeemfhefheemleefiegumegvledvhedphhgvlhhopehfrhgrmhgvfihorhhkpdhmrghilhhfrhhomhepsggvnhhoihhtrdhmohhnihhnsegsohhothhlihhnrdgtohhmpdhnsggprhgtphhtthhopedutddprhgtphhtthhopegrughrihgrnhdrhhhunhhtvghrsehinhhtvghlrdgtohhmpdhrtghpthhtohepuhhlfhdrhhgrnhhsshhonheslhhinhgrrhhordhorhhgpdhrtghpthhtohepsggvnhhoihhtrdhmohhnihhnsegsohhothhlihhnrdgtohhmpdhrtghpthhtoheplhhinhhugidqm hhmtgesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehvlhgrughimhhirhdrkhhonhgurhgrthhivghvsehmohgsihhlvgihvgdrtghomhdprhgtphhtthhopehtrgiffhhikhdrsggrhihouhhksehmohgsihhlvgihvgdrtghomhdprhgtphhtthhopehgrhgvghhorhihrdgtlhgvmhgvnhhtsegsohhothhlihhnrdgtohhm X-GND-Sasl: benoit.monin@bootlin.com Instead of using of_property_read_bool to check the presence of the cdns,phy-* properties in the device tree, use of_property_present in function sdhci_cdns_phy_param_count. This silences the following warning messages since the cdns,phy-* properties are all u32, not boolean. OF: /soc/sdhci@d8010000: Read of boolean property 'cdns,phy-input-delay-leg= acy' with a value. OF: /soc/sdhci@d8010000: Read of boolean property 'cdns,phy-input-delay-mmc= -highspeed' with a value. OF: /soc/sdhci@d8010000: Read of boolean property 'cdns,phy-input-delay-mmc= -ddr' with a value. OF: /soc/sdhci@d8010000: Read of boolean property 'cdns,phy-dll-delay-sdclk= ' with a value. OF: /soc/sdhci@d8010000: Read of boolean property 'cdns,phy-dll-delay-sdclk= -hsmmc' with a value. Signed-off-by: Beno=C3=AEt Monin --- drivers/mmc/host/sdhci-cadence.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mmc/host/sdhci-cadence.c b/drivers/mmc/host/sdhci-cade= nce.c index a94b297fcf2a..27bd2eb29948 100644 --- a/drivers/mmc/host/sdhci-cadence.c +++ b/drivers/mmc/host/sdhci-cadence.c @@ -144,7 +144,7 @@ static unsigned int sdhci_cdns_phy_param_count(struct d= evice_node *np) int i; =20 for (i =3D 0; i < ARRAY_SIZE(sdhci_cdns_phy_cfgs); i++) - if (of_property_read_bool(np, sdhci_cdns_phy_cfgs[i].property)) + if (of_property_present(np, sdhci_cdns_phy_cfgs[i].property)) count++; =20 return count; From nobody Wed Oct 8 14:52:41 2025 Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A78112EAD18; Thu, 26 Jun 2025 14:44:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.193 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750949065; cv=none; b=ryYQUY7g7HhTeV/caZxcNGhQ0VhPKv9naWRK8Isl5T8PQWkkezqMo669YrHf2sly4BCHzetm8wHWqtId+F8K1MAugHV8T1P7TWPKiPnmi1fY7bEp6875mQYalPCappYzovt6dIOL29BB4WdgBVQURJA8CcotzscDLh2rNKEE2Ew= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750949065; c=relaxed/simple; bh=RMDC8L847CO+NOAgqQLroJyTjebc1kwbRbZj2Nv0Reo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=gnTl/8KI4VnuInm4i7Pb94F2FyTaxgib3J9sOgxIykRg/7CfGbzp1QTeGFiFh0QoWNL2ZrregPLZ7BAINwW+4IjakLUTCvfFlH4/PQ5NCn7KiTOUwSh6wjU88oBLQYienV4uP6+s08XryOeczNkWcH5p/izCbEnjwiZLEcrcxus= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=kC9OaLDG; arc=none smtp.client-ip=217.70.183.193 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="kC9OaLDG" Received: by mail.gandi.net (Postfix) with ESMTPSA id A2B3A43A2A; Thu, 26 Jun 2025 14:44:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1750949055; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hUJjSHPpez+43GXduk92GH0CAHcL/H7h99xXDtOUhT8=; b=kC9OaLDGQFkw/rhvM6I4hrTaEVabYactQ7/spHRdwl5AgZwjKZ4XOaqe8Wcfn4giSBjMyv 03w/jVmp4R0h8wJzCt+b+CJdKssQE9qbh1VYYUu2D8mzLB6EA3ykQzadJEAop9TgIerNvp 7cMQyyYEA1anSwNsYFytsunQdxPU9SKMP44t4Q1EAfgQuDgTANQ0eaewunAGI4CK1OvoRm W98WE+17SVGcTIwOtr1e05OCvj3xkvKZyPx4ABN9o2GYgf7KTENUOY4UV9AzyxVfsDaxW7 UkKTyI/NgQOTAbQGC7Wp5SIHy9zpCS8yQmNHGODC+QkUHt0cgheGd+xWoqG4hg== From: =?UTF-8?q?Beno=C3=AEt=20Monin?= To: Adrian Hunter , Ulf Hansson Cc: =?UTF-8?q?Beno=C3=AEt=20Monin?= , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, Vladimir Kondratiev , Tawfik Bayouk , Gregory CLEMENT , =?UTF-8?q?Th=C3=A9o=20Lebrun?= , "Thomas Petazzoni" , Vladimir Kondratiev Subject: [PATCH 2/2] mmc: sdhci-cadence: tune multi-block read gap Date: Thu, 26 Jun 2025 16:43:32 +0200 Message-ID: <2a43386ffef4012530ca2421ad81ad21c36c8a25.1750943549.git.benoit.monin@bootlin.com> X-Mailer: git-send-email 2.50.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-GND-State: clean X-GND-Score: -100 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgdeghecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfitefpfffkpdcuggftfghnshhusghstghrihgsvgenuceurghilhhouhhtmecufedtudenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvvefufffkofgjfhggtgfgsehtkeertdertdejnecuhfhrohhmpeeuvghnohpfthcuofhonhhinhcuoegsvghnohhithdrmhhonhhinhessghoohhtlhhinhdrtghomheqnecuggftrfgrthhtvghrnhepvdfffeeiieejkeevuefhvdeggeefudffueeuffehffehffevjedugfdtueegtddvnecukfhppedvrgdtudemtggsudegmeehheeimeejrgdttdemudehfeejmehffeehmeelfeeiugemvgelvdehnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepvdgrtddumegtsgdugeemheehieemjegrtddtmeduheefjeemfhefheemleefiegumegvledvhedphhgvlhhopehfrhgrmhgvfihorhhkpdhmrghilhhfrhhomhepsggvnhhoihhtrdhmohhnihhnsegsohhothhlihhnrdgtohhmpdhnsggprhgtphhtthhopeduuddprhgtphhtthhopegrughrihgrnhdrhhhunhhtvghrsehinhhtvghlrdgtohhmpdhrtghpthhtohepuhhlfhdrhhgrnhhsshhonheslhhinhgrrhhordhorhhgpdhrtghpthhtohepsggvnhhoihhtrdhmohhnihhnsegsohhothhlihhnrdgtohhmpdhrtghpthhtoheplhhinhhugidqm hhmtgesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehvlhgrughimhhirhdrkhhonhgurhgrthhivghvsehmohgsihhlvgihvgdrtghomhdprhgtphhtthhopehtrgiffhhikhdrsggrhihouhhksehmohgsihhlvgihvgdrtghomhdprhgtphhtthhopehgrhgvghhorhihrdgtlhgvmhgvnhhtsegsohhothhlihhnrdgtohhm X-GND-Sasl: benoit.monin@bootlin.com From: Vladimir Kondratiev Additional tuning required for multi-block read command. Implement it accordingly to Cadence recommendation. 2 registers used: HRS37 and HRS38. To HRS37, SD interface mode programmed, this selects HRS38 slot - there is separate slot for every SD interface mode. HRS38 contains gap parameter, it is selected by starting with gap=3D0 and sending multi-block read comman= d. gap incremented until multi-block read succeeds. As of now, this tuning executed for HS200 only Signed-off-by: Vladimir Kondratiev Signed-off-by: Beno=C3=AEt Monin --- drivers/mmc/host/sdhci-cadence.c | 142 ++++++++++++++++++++++++++++++- 1 file changed, 141 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/host/sdhci-cadence.c b/drivers/mmc/host/sdhci-cade= nce.c index 27bd2eb29948..6dcf7ae0c99d 100644 --- a/drivers/mmc/host/sdhci-cadence.c +++ b/drivers/mmc/host/sdhci-cadence.c @@ -36,6 +36,23 @@ #define SDHCI_CDNS_HRS06_MODE_MMC_HS400 0x5 #define SDHCI_CDNS_HRS06_MODE_MMC_HS400ES 0x6 =20 +/* Read block gap */ +#define SDHCI_CDNS_HRS37 0x94 /* interface mode select */ +#define SDHCI_CDNS_HRS37_MODE_DS 0x0 +#define SDHCI_CDNS_HRS37_MODE_HS 0x1 +#define SDHCI_CDNS_HRS37_MODE_UDS_SDR12 0x8 +#define SDHCI_CDNS_HRS37_MODE_UDS_SDR25 0x9 +#define SDHCI_CDNS_HRS37_MODE_UDS_SDR50 0xa +#define SDHCI_CDNS_HRS37_MODE_UDS_SDR104 0xb +#define SDHCI_CDNS_HRS37_MODE_UDS_DDR50 0xc +#define SDHCI_CDNS_HRS37_MODE_MMC_LEGACY 0x20 +#define SDHCI_CDNS_HRS37_MODE_MMC_SDR 0x21 +#define SDHCI_CDNS_HRS37_MODE_MMC_DDR 0x22 +#define SDHCI_CDNS_HRS37_MODE_MMC_HS200 0x23 +#define SDHCI_CDNS_HRS37_MODE_MMC_HS400 0x24 +#define SDHCI_CDNS_HRS37_MODE_MMC_HS400ES 0x25 +#define SDHCI_CDNS_HRS38 0x98 /* Read block gap coefficient */ +#define SDHCI_CDNS_HRS38_BLKGAP_MAX 0xf /* SRS - Slot Register Set (SDHCI-compatible) */ #define SDHCI_CDNS_SRS_BASE 0x200 =20 @@ -251,6 +268,123 @@ static int sdhci_cdns_set_tune_val(struct sdhci_host = *host, unsigned int val) return 0; } =20 +/** + * mmc_send_mb_read() - send multi-block read command + * @host: MMC host + * + * Sends multi-block read command, CMD23/CMD18/CMD12, ignore read data + * + * Return: error code + */ +static int mmc_send_mb_read(struct mmc_host *host) +{ + const int blksz =3D 512; + const int blocks =3D 32; + struct scatterlist sg; + struct mmc_command sbc =3D { + .opcode =3D MMC_SET_BLOCK_COUNT, + .arg =3D blocks, + .flags =3D MMC_RSP_R1 | MMC_CMD_AC, + }; + struct mmc_command cmd =3D { + .opcode =3D MMC_READ_MULTIPLE_BLOCK, + .arg =3D 0, + .flags =3D MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_ADTC, + }; + struct mmc_command stop =3D { + .opcode =3D MMC_STOP_TRANSMISSION, + .arg =3D 0, + .flags =3D MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_AC, + }; + struct mmc_data data =3D { + .flags =3D MMC_DATA_READ, + .blksz =3D blksz, + .blocks =3D blocks, + .blk_addr =3D 0, + .timeout_ns =3D 800000000, /* 800ms */ + .timeout_clks =3D 1000, + .sg =3D &sg, + .sg_len =3D 1, + }; + struct mmc_request mrq =3D { + .sbc =3D &sbc, + .cmd =3D &cmd, + .data =3D &data, + .stop =3D &stop, + }; + int size =3D blksz * blocks, err =3D 0; + u8 *data_buf; + + data_buf =3D kzalloc(size, GFP_KERNEL); + if (!data_buf) + return -ENOMEM; + + sg_init_one(&sg, data_buf, size); + + mmc_wait_for_req(host, &mrq); + + if (sbc.error) { + err =3D sbc.error; + goto out; + } + + if (cmd.error) { + err =3D cmd.error; + goto out; + } + + if (data.error) { + err =3D data.error; + goto out; + } + +out: + kfree(data_buf); + return err; +} + +/** + * sdhci_cdns_tune_blkgap() - tune multi-block read gap + * @mmc: MMC host + * + * Tune delay used in multi block read. To do so, + * try sending multi-block read command with incremented gap, unless + * it succeeds. + * + * Return: error code + */ +static int sdhci_cdns_tune_blkgap(struct mmc_host *mmc) +{ + struct sdhci_host *host =3D mmc_priv(mmc); + struct sdhci_pltfm_host *pltfm_host =3D sdhci_priv(host); + struct sdhci_cdns_priv *priv =3D sdhci_pltfm_priv(pltfm_host); + void __iomem *hrs37_reg =3D priv->hrs_addr + SDHCI_CDNS_HRS37; + void __iomem *hrs38_reg =3D priv->hrs_addr + SDHCI_CDNS_HRS38; + bool tuned =3D false; + u8 gap; + u8 hrs37_mode; + + switch (host->timing) { + case MMC_TIMING_MMC_HS200: + hrs37_mode =3D SDHCI_CDNS_HRS37_MODE_MMC_HS200; + break; + default: + return 0; /* no tuning in this mode */ + } + + writel(hrs37_mode, hrs37_reg); + + for (gap =3D 0; gap <=3D SDHCI_CDNS_HRS38_BLKGAP_MAX; gap++) { + writel(gap, hrs38_reg); + tuned =3D !mmc_send_mb_read(mmc); + if (tuned) + break; + } + dev_dbg(mmc_dev(mmc), "read block gap tune %s, gap %d\n", + tuned ? "OK" : "failed", gap); + return tuned ? 0 : -EIO; +} + /* * In SD mode, software must not use the hardware tuning and instead perfo= rm * an almost identical procedure to eMMC. @@ -261,6 +395,7 @@ static int sdhci_cdns_execute_tuning(struct sdhci_host = *host, u32 opcode) int max_streak =3D 0; int end_of_streak =3D 0; int i; + int ret; =20 /* * Do not execute tuning for UHS_SDR50 or UHS_DDR50. @@ -288,7 +423,12 @@ static int sdhci_cdns_execute_tuning(struct sdhci_host= *host, u32 opcode) return -EIO; } =20 - return sdhci_cdns_set_tune_val(host, end_of_streak - max_streak / 2); + ret =3D sdhci_cdns_set_tune_val(host, end_of_streak - max_streak / 2); + + if (!ret) + ret =3D sdhci_cdns_tune_blkgap(host->mmc); + + return ret; } =20 static void sdhci_cdns_set_uhs_signaling(struct sdhci_host *host,