Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add patch to fix Kingston eMMC compatibility with ODROID-N2 #3619

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
From 77ec70c4d73c772b7da0d007946f697f7d27a7a7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20=C4=8Cerm=C3=A1k?= <[email protected]>
Date: Thu, 10 Oct 2024 19:06:24 +0200
Subject: [PATCH] mmc: meson-gx: use xtal as clock for frequencies <= 24MHz
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Comment on lines +1 to +8
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Incorrect commit date in the patch header

The commit date is set to October 10, 2024, which is in the future. This could cause issues with version control and should be corrected to the current date.

Please update the commit date to the current date:

-Date: Thu, 10 Oct 2024 19:06:24 +0200
+Date: <current_date_and_time>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
From 77ec70c4d73c772b7da0d007946f697f7d27a7a7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20=C4=8Cerm=C3=A1k?= <[email protected]>
Date: Thu, 10 Oct 2024 19:06:24 +0200
Subject: [PATCH] mmc: meson-gx: use xtal as clock for frequencies <= 24MHz
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
From 77ec70c4d73c772b7da0d007946f697f7d27a7a7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20=C4=8Cerm=C3=A1k?= <[email protected]>
Date: <current_date_and_time>
Subject: [PATCH] mmc: meson-gx: use xtal as clock for frequencies <= 24MHz
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The patch from Neil Armstrong that aims to fix stability on some eMMCs
by capping the clock to 24 MHz has a nasty side effect that it breaks
communication with some Kingston eMMCs. After the patch, the clock rates
that are applied are not precisely 24 MHz but values that can correspond
to the PLL divider applied to the 1G clock, which yields 23,809,523 Hz
(divider 42) after the cap.

Testing shows that setting this eMMC clock frequency, or 23,255,813 Hz
(divider 43), always leads to mmc_select_mode_and_width() failing. For
whatever reason, only these two values are problematic, setting it to
use divider <42 or >43 (even after the cap is returned to 100M), the
eMMC is probed correctly. It's not clear if clock quality is the issue
or if there's some other reason why Kingston doesn't like these two
values. However, by changing the clock source to xtal, we can achieve
precise 24 MHz which seems to be fine for Kingston and the difference
from the problematic frequencies is negligible, hopefully not affecting
other eMMCs that were happy with the ~23.8M speed. Since all values from
mmc_mode2freq were effectively set to 24M, no other speeds have been
used with the previous patch.

Ultimately, coming up with a proper fix for the issue with uncapped
frequency would be the best, however, I am not able to reproduce it so
going this way might be easier now.

Signed-off-by: Jan Čermák <[email protected]>
---
drivers/mmc/meson_gx_mmc.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/meson_gx_mmc.c b/drivers/mmc/meson_gx_mmc.c
index 6ded4b619b..88a80b2985 100644
--- a/drivers/mmc/meson_gx_mmc.c
+++ b/drivers/mmc/meson_gx_mmc.c
@@ -52,8 +52,12 @@ static void meson_mmc_config_clock(struct mmc *mmc)

/* TOFIX This should use the proper clock taken from DT */

- /* 1GHz / CLK_MAX_DIV = 15,9 MHz */
- if (mmc->clock > 16000000) {
+ /*
+ * With f_max=24M, we almost always end up with 24M anyway and
+ * granularity between 24M and 12M isn't needed, so try to use
+ * xtal clock source directly.
+ */
+ if (mmc->clock > SD_EMMC_CLKSRC_24M) {
clk = SD_EMMC_CLKSRC_DIV2;
clk_src = CLK_SRC_DIV2;
} else {