Skip to contentSkip to conversation

mmc: meson_gx_mmc: change a clock phase to stable value

PATCH New Jaehoon Chung 4 participants 12 messages Nov 9, 2020 – Nov 10, 2020 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): CGME20201109031216epcas1p197a531d87ad92cb02aca01f4b9e2af3a@epcas1p1.samsung.com

#1 lore raw

PATCH 1/1 mmc: meson_gx_mmc: change a clock phase to stable value

Core clock phase value is changed from 180' to 270'. It's more stable than before.
- Odroidn-N2/C4 : Working fine with 52MHz
- VIM3 : Working fine with 52MHz

Before this patch, Odroid-C4 doesn't work fine with 52MHz.

---
 drivers/mmc/meson_gx_mmc.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/mmc/meson_gx_mmc.c +10 -4
index 719dd1e5e570..7c60e0566560 100644
@@ -52,10 +52,16 @@ static void meson_mmc_config_clock(struct mmc *mmc)
 	}
 	clk_div = DIV_ROUND_UP(clk, mmc->clock);
 
-	/* 180 phase core clock */
-	meson_mmc_clk |= CLK_CO_PHASE_180;
-
-	/* 180 phase tx clock */
+	/*
+	 * Clock Phase needs to set a proper value.
+	 * It can be changed to other value.
+	 * Because CORE : 270' Phase and TX : 0' Phase are stable,
+	 * set to them by default.
+	 */
+	/* Core Clock Phase */
+	meson_mmc_clk |= CLK_CO_PHASE_270;
+
+	/* TX Clock Phase */
 	meson_mmc_clk |= CLK_TX_PHASE_000;
 
 	/* clock settings */
Signature · 1 line
2.29.0
#2 lore raw

PATCH 1/1 mmc: meson_gx_mmc: change a clock phase to stable value

Hi,

Quoted 28 lines · Jaehoon Chung

Core clock phase value is changed from 180' to 270'. It's more stable than before.
- Odroidn-N2/C4 : Working fine with 52MHz
- VIM3 : Working fine with 52MHz

Before this patch, Odroid-C4 doesn't work fine with 52MHz.

---
 drivers/mmc/meson_gx_mmc.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/mmc/meson_gx_mmc.c +3 -4
index 719dd1e5e570..7c60e0566560 100644
@@ -52,10 +52,16 @@ static void meson_mmc_config_clock(struct mmc *mmc)
 	}
 	clk_div = DIV_ROUND_UP(clk, mmc->clock);
 
-	/* 180 phase core clock */
-	meson_mmc_clk |= CLK_CO_PHASE_180;
-
-	/* 180 phase tx clock */
+	/*
+	 * Clock Phase needs to set a proper value.
+	 * It can be changed to other value.

drivers/mmc/meson_gx_mmc.c static void meson_mmc_config_clock(struct mmc *mmc) · line 67

Quoted 10 lines
drivers/mmc/meson_gx_mmc.c +7 -0
+	 * Because CORE : 270' Phase and TX : 0' Phase are stable,
+	 * set to them by default.
+	 */
+	/* Core Clock Phase */
+	meson_mmc_clk |= CLK_CO_PHASE_270;
+
+	/* TX Clock Phase */
 	meson_mmc_clk |= CLK_TX_PHASE_000;
 
 	/* clock settings */

The previous values were aligned on the Linux driver, which is functional.

How did you test these ?

Neil

#3 lore raw

PATCH 1/1 mmc: meson_gx_mmc: change a clock phase to stable value

Quoted 42 lines

From: Neil Armstrong <[email protected]>
Date: Mon, 9 Nov 2020 14:37:09 +0100

Hi,

Quoted 36 lines · Jaehoon Chung

Core clock phase value is changed from 180' to 270'. It's more stable than before.
- Odroidn-N2/C4 : Working fine with 52MHz
- VIM3 : Working fine with 52MHz

Before this patch, Odroid-C4 doesn't work fine with 52MHz.

---
 drivers/mmc/meson_gx_mmc.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/mmc/meson_gx_mmc.c +10 -4
index 719dd1e5e570..7c60e0566560 100644
@@ -52,10 +52,16 @@ static void meson_mmc_config_clock(struct mmc *mmc)
 	}
 	clk_div = DIV_ROUND_UP(clk, mmc->clock);
 
-	/* 180 phase core clock */
-	meson_mmc_clk |= CLK_CO_PHASE_180;
-
-	/* 180 phase tx clock */
+	/*
+	 * Clock Phase needs to set a proper value.
+	 * It can be changed to other value.
+	 * Because CORE : 270' Phase and TX : 0' Phase are stable,
+	 * set to them by default.
+	 */
+	/* Core Clock Phase */
+	meson_mmc_clk |= CLK_CO_PHASE_270;
+
+	/* TX Clock Phase */
 	meson_mmc_clk |= CLK_TX_PHASE_000;
 
Quoted 4 lines

drivers/mmc/meson_gx_mmc.c static void meson_mmc_config_clock(struct mmc *mmc) · line 67

Quoted 2 lines
drivers/mmc/meson_gx_mmc.c +0 -0
 	/* clock settings */

The previous values were aligned on the Linux driver, which is functional.

Actually the Linux driver isn't really functional; the 52 MHz high-speed mode doesn't work. But since HS200 does work in Linux, probably nobody noticed this.

That said, I'm not confident a single clock phase setting will work across all Amlogic SoCs and across different boards. Maybe we need something in the device tree such that we can control the values on a per-board level.

#4 lore raw

PATCH 1/1 mmc: meson_gx_mmc: change a clock phase to stable value

Quoted 47 lines · Mark Kettenis
Quoted 42 lines

From: Neil Armstrong <[email protected]>
Date: Mon, 9 Nov 2020 14:37:09 +0100

Hi,

Quoted 36 lines · Jaehoon Chung

Core clock phase value is changed from 180' to 270'. It's more stable than before.
- Odroidn-N2/C4 : Working fine with 52MHz
- VIM3 : Working fine with 52MHz

Before this patch, Odroid-C4 doesn't work fine with 52MHz.

---
 drivers/mmc/meson_gx_mmc.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/mmc/meson_gx_mmc.c +10 -4
index 719dd1e5e570..7c60e0566560 100644
@@ -52,10 +52,16 @@ static void meson_mmc_config_clock(struct mmc *mmc)
 	}
 	clk_div = DIV_ROUND_UP(clk, mmc->clock);
 
-	/* 180 phase core clock */
-	meson_mmc_clk |= CLK_CO_PHASE_180;
-
-	/* 180 phase tx clock */
+	/*
+	 * Clock Phase needs to set a proper value.
+	 * It can be changed to other value.
+	 * Because CORE : 270' Phase and TX : 0' Phase are stable,
+	 * set to them by default.
+	 */
+	/* Core Clock Phase */
+	meson_mmc_clk |= CLK_CO_PHASE_270;
+
+	/* TX Clock Phase */
 	meson_mmc_clk |= CLK_TX_PHASE_000;
 
Quoted 4 lines

drivers/mmc/meson_gx_mmc.c static void meson_mmc_config_clock(struct mmc *mmc) · line 67

Quoted 2 lines
drivers/mmc/meson_gx_mmc.c +0 -0
 	/* clock settings */

The previous values were aligned on the Linux driver, which is functional.

Quoted 9 lines

Actually the Linux driver isn't really functional; the 52 MHz high-speed mode doesn't work. But since HS200 does work in Linux, probably nobody noticed this.

That said, I'm not confident a single clock phase setting will work across all Amlogic SoCs and across different boards. Maybe we need something in the device tree such that we can control the values on a per-board level.

So this is specific to SM1 SoCs then, because others families doesn't have such issues at 52MHz.

So the Linux must be fixes, including the bindings to introduce a new compatible, then ported to U-Boot.

So in the meantime, it's right to limit to 26MHz on SM1 in U-boot until we have all this clarified.

Neil

#5 lore raw

PATCH 1/1 mmc: meson_gx_mmc: change a clock phase to stable value

Hi Neil,

Quoted 62 lines · Neil Armstrong
Quoted 47 lines · Mark Kettenis
Quoted 42 lines

From: Neil Armstrong <[email protected]>
Date: Mon, 9 Nov 2020 14:37:09 +0100

Hi,

Quoted 36 lines · Jaehoon Chung

Core clock phase value is changed from 180' to 270'. It's more stable than before.
- Odroidn-N2/C4 : Working fine with 52MHz
- VIM3 : Working fine with 52MHz

Before this patch, Odroid-C4 doesn't work fine with 52MHz.

---
 drivers/mmc/meson_gx_mmc.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/mmc/meson_gx_mmc.c +10 -4
index 719dd1e5e570..7c60e0566560 100644
@@ -52,10 +52,16 @@ static void meson_mmc_config_clock(struct mmc *mmc)
    }
    clk_div = DIV_ROUND_UP(clk, mmc->clock);
 
-   /* 180 phase core clock */
-   meson_mmc_clk |= CLK_CO_PHASE_180;
-
-   /* 180 phase tx clock */
+   /*
+    * Clock Phase needs to set a proper value.
+    * It can be changed to other value.
+    * Because CORE : 270' Phase and TX : 0' Phase are stable,
+    * set to them by default.
+    */
+   /* Core Clock Phase */
+   meson_mmc_clk |= CLK_CO_PHASE_270;
+
+   /* TX Clock Phase */
    meson_mmc_clk |= CLK_TX_PHASE_000;
 
Quoted 4 lines

drivers/mmc/meson_gx_mmc.c static void meson_mmc_config_clock(struct mmc *mmc) · line 67

Quoted 2 lines
drivers/mmc/meson_gx_mmc.c +0 -0
    /* clock settings */

The previous values were aligned on the Linux driver, which is functional.

Quoted 9 lines

Actually the Linux driver isn't really functional; the 52 MHz high-speed mode doesn't work. But since HS200 does work in Linux, probably nobody noticed this.

That said, I'm not confident a single clock phase setting will work across all Amlogic SoCs and across different boards. Maybe we need something in the device tree such that we can control the values on a per-board level.

So this is specific to SM1 SoCs then, because others families doesn't have such issues at 52MHz.

Quoted 7 lines

So the Linux must be fixes, including the bindings to introduce a new compatible, then ported to U-Boot.

So in the meantime, it's right to limit to 26MHz on SM1 in U-boot until we have all this clarified.

Neil

Earlier I had a similar approach for this FIX but somehow it did not get merged.

Please add my

Best Regards
-Anand

#6 lore raw

PATCH 1/1 mmc: meson_gx_mmc: change a clock phase to stable value

Dear Anand,

Quoted 71 lines · Anand Moon

Hi Neil,

Quoted 68 lines · Neil Armstrong
Quoted 47 lines · Mark Kettenis
Quoted 42 lines

From: Neil Armstrong <[email protected]>
Date: Mon, 9 Nov 2020 14:37:09 +0100

Hi,

Quoted 36 lines · Jaehoon Chung

Core clock phase value is changed from 180' to 270'. It's more stable than before.
- Odroidn-N2/C4 : Working fine with 52MHz
- VIM3 : Working fine with 52MHz

Before this patch, Odroid-C4 doesn't work fine with 52MHz.

---
 drivers/mmc/meson_gx_mmc.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/mmc/meson_gx_mmc.c +10 -4
index 719dd1e5e570..7c60e0566560 100644
@@ -52,10 +52,16 @@ static void meson_mmc_config_clock(struct mmc *mmc)
    }
    clk_div = DIV_ROUND_UP(clk, mmc->clock);
 
-   /* 180 phase core clock */
-   meson_mmc_clk |= CLK_CO_PHASE_180;
-
-   /* 180 phase tx clock */
+   /*
+    * Clock Phase needs to set a proper value.
+    * It can be changed to other value.
+    * Because CORE : 270' Phase and TX : 0' Phase are stable,
+    * set to them by default.
+    */
+   /* Core Clock Phase */
+   meson_mmc_clk |= CLK_CO_PHASE_270;
+
+   /* TX Clock Phase */
    meson_mmc_clk |= CLK_TX_PHASE_000;
 
Quoted 4 lines

drivers/mmc/meson_gx_mmc.c static void meson_mmc_config_clock(struct mmc *mmc) · line 67

Quoted 2 lines
drivers/mmc/meson_gx_mmc.c +0 -0
    /* clock settings */

The previous values were aligned on the Linux driver, which is functional.

Quoted 9 lines

Actually the Linux driver isn't really functional; the 52 MHz high-speed mode doesn't work. But since HS200 does work in Linux, probably nobody noticed this.

That said, I'm not confident a single clock phase setting will work across all Amlogic SoCs and across different boards. Maybe we need something in the device tree such that we can control the values on a per-board level.

So this is specific to SM1 SoCs then, because others families doesn't have such issues at 52MHz.

So the Linux must be fixes, including the bindings to introduce a new compatible, then ported to U-Boot.

So in the meantime, it's right to limit to 26MHz on SM1 in U-boot until we have all this clarified.

Quoted 6 lines
Quoted 1 line

Neil

Earlier I had a similar approach for this FIX but somehow it did not get merged.

Please add my

Thanks for testing!

Best Regards,
Jaehoon Chung

Quoted 4 lines

Best Regards
-Anand

#7 lore raw

PATCH 1/1 mmc: meson_gx_mmc: change a clock phase to stable value

In reply to Neil Armstrong
Quoted 52 lines · Neil Armstrong
Quoted 51 lines · Mark Kettenis
Quoted 42 lines

From: Neil Armstrong <[email protected]>
Date: Mon, 9 Nov 2020 14:37:09 +0100

Hi,

Quoted 36 lines · Jaehoon Chung

Core clock phase value is changed from 180' to 270'. It's more stable than before.
- Odroidn-N2/C4 : Working fine with 52MHz
- VIM3 : Working fine with 52MHz

Before this patch, Odroid-C4 doesn't work fine with 52MHz.

---
 drivers/mmc/meson_gx_mmc.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/mmc/meson_gx_mmc.c +10 -4
index 719dd1e5e570..7c60e0566560 100644
@@ -52,10 +52,16 @@ static void meson_mmc_config_clock(struct mmc *mmc)
 	}
 	clk_div = DIV_ROUND_UP(clk, mmc->clock);
 
-	/* 180 phase core clock */
-	meson_mmc_clk |= CLK_CO_PHASE_180;
-
-	/* 180 phase tx clock */
+	/*
+	 * Clock Phase needs to set a proper value.
+	 * It can be changed to other value.
+	 * Because CORE : 270' Phase and TX : 0' Phase are stable,
+	 * set to them by default.
+	 */
+	/* Core Clock Phase */
+	meson_mmc_clk |= CLK_CO_PHASE_270;
+
+	/* TX Clock Phase */
 	meson_mmc_clk |= CLK_TX_PHASE_000;
 
Quoted 4 lines

drivers/mmc/meson_gx_mmc.c static void meson_mmc_config_clock(struct mmc *mmc) · line 67

Quoted 2 lines
drivers/mmc/meson_gx_mmc.c +0 -0
 	/* clock settings */

The previous values were aligned on the Linux driver, which is functional.

Actually the Linux driver isn't really functional; the 52 MHz high-speed mode doesn't work. But since HS200 does work in Linux, probably nobody noticed this.

Quoted 8 lines
Quoted 5 lines

That said, I'm not confident a single clock phase setting will work across all Amlogic SoCs and across different boards. Maybe we need something in the device tree such that we can control the values on a per-board level.

So this is specific to SM1 SoCs then, because others families doesn't have such issues at 52MHz.

I don't have much knowledge of SM1 SoCs. But how did its phase value select them on Linux driver?

Quoted 6 lines

So the Linux must be fixes, including the bindings to introduce a new compatible, then ported to U-Boot.

So in the meantime, it's right to limit to 26MHz on SM1 in U-boot until we have all this clarified.

If you want to limit to 26MHz, I don't have any objection about your opinion.
But I wonder how to clarify all. And I also wonder that values what is used on Linux kernel are really right.

Best Regards,
Jaehoon Chung

Quoted 3 lines

Neil

#8 lore raw

PATCH 1/1 mmc: meson_gx_mmc: change a clock phase to stable value

Quoted 65 lines · Jaehoon Chung
Quoted 52 lines · Neil Armstrong
Quoted 51 lines · Mark Kettenis
Quoted 42 lines

From: Neil Armstrong <[email protected]>
Date: Mon, 9 Nov 2020 14:37:09 +0100

Hi,

Quoted 36 lines · Jaehoon Chung

Core clock phase value is changed from 180' to 270'. It's more stable than before.
- Odroidn-N2/C4 : Working fine with 52MHz
- VIM3 : Working fine with 52MHz

Before this patch, Odroid-C4 doesn't work fine with 52MHz.

---
 drivers/mmc/meson_gx_mmc.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/mmc/meson_gx_mmc.c +10 -4
index 719dd1e5e570..7c60e0566560 100644
@@ -52,10 +52,16 @@ static void meson_mmc_config_clock(struct mmc *mmc)
 	}
 	clk_div = DIV_ROUND_UP(clk, mmc->clock);
 
-	/* 180 phase core clock */
-	meson_mmc_clk |= CLK_CO_PHASE_180;
-
-	/* 180 phase tx clock */
+	/*
+	 * Clock Phase needs to set a proper value.
+	 * It can be changed to other value.
+	 * Because CORE : 270' Phase and TX : 0' Phase are stable,
+	 * set to them by default.
+	 */
+	/* Core Clock Phase */
+	meson_mmc_clk |= CLK_CO_PHASE_270;
+
+	/* TX Clock Phase */
 	meson_mmc_clk |= CLK_TX_PHASE_000;
 
Quoted 4 lines

drivers/mmc/meson_gx_mmc.c static void meson_mmc_config_clock(struct mmc *mmc) · line 67

Quoted 2 lines
drivers/mmc/meson_gx_mmc.c +0 -0
 	/* clock settings */

The previous values were aligned on the Linux driver, which is functional.

Actually the Linux driver isn't really functional; the 52 MHz high-speed mode doesn't work. But since HS200 does work in Linux, probably nobody noticed this.

Quoted 8 lines
Quoted 5 lines

That said, I'm not confident a single clock phase setting will work across all Amlogic SoCs and across different boards. Maybe we need something in the device tree such that we can control the values on a per-board level.

So this is specific to SM1 SoCs then, because others families doesn't have such issues at 52MHz.

I don't have much knowledge of SM1 SoCs. But how did its phase value select them on Linux driver?

Quoted 1 line
Quoted 7 lines
Quoted 5 lines

So the Linux must be fixes, including the bindings to introduce a new compatible, then ported to U-Boot.

So in the meantime, it's right to limit to 26MHz on SM1 in U-boot until we have all this clarified.

If you want to limit to 26MHz, I don't have any objection about your opinion.
But I wonder how to clarify all. And I also wonder that values what is used on Linux kernel are really right.

OK, I'm not a MMC & SDCard expert on Amlogic, all the work was done in Linux.

I just want to keep a working and stable SDCard & eMMC support for the 7 SoCs Families.

Could you rewrite my "[PATCH 2/3] mmc: meson-gx: limit max frequency on SM1 SoCs" by instead changing the clock phase only for SM1 ?
I'll then apply it with the 2 other patches and push then for the current development cycle.

The driver is functional for all the other SoCs, and I want to keep it stable unless extensively tested.

Neil

Quoted 8 lines

Best Regards,
Jaehoon Chung

Quoted 3 lines

Neil

#9 lore raw

PATCH 1/1 mmc: meson_gx_mmc: change a clock phase to stable value

Quoted 74 lines · Neil Armstrong
Quoted 65 lines · Jaehoon Chung
Quoted 52 lines · Neil Armstrong
Quoted 51 lines · Mark Kettenis
Quoted 42 lines

From: Neil Armstrong <[email protected]>
Date: Mon, 9 Nov 2020 14:37:09 +0100

Hi,

Quoted 36 lines · Jaehoon Chung

Core clock phase value is changed from 180' to 270'. It's more stable than before.
- Odroidn-N2/C4 : Working fine with 52MHz
- VIM3 : Working fine with 52MHz

Before this patch, Odroid-C4 doesn't work fine with 52MHz.

---
 drivers/mmc/meson_gx_mmc.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/mmc/meson_gx_mmc.c +10 -4
index 719dd1e5e570..7c60e0566560 100644
@@ -52,10 +52,16 @@ static void meson_mmc_config_clock(struct mmc *mmc)
 	}
 	clk_div = DIV_ROUND_UP(clk, mmc->clock);
 
-	/* 180 phase core clock */
-	meson_mmc_clk |= CLK_CO_PHASE_180;
-
-	/* 180 phase tx clock */
+	/*
+	 * Clock Phase needs to set a proper value.
+	 * It can be changed to other value.
+	 * Because CORE : 270' Phase and TX : 0' Phase are stable,
+	 * set to them by default.
+	 */
+	/* Core Clock Phase */
+	meson_mmc_clk |= CLK_CO_PHASE_270;
+
+	/* TX Clock Phase */
 	meson_mmc_clk |= CLK_TX_PHASE_000;
 
Quoted 4 lines

drivers/mmc/meson_gx_mmc.c static void meson_mmc_config_clock(struct mmc *mmc) · line 67

Quoted 2 lines
drivers/mmc/meson_gx_mmc.c +0 -0
 	/* clock settings */

The previous values were aligned on the Linux driver, which is functional.

Actually the Linux driver isn't really functional; the 52 MHz high-speed mode doesn't work. But since HS200 does work in Linux, probably nobody noticed this.

Quoted 8 lines
Quoted 5 lines

That said, I'm not confident a single clock phase setting will work across all Amlogic SoCs and across different boards. Maybe we need something in the device tree such that we can control the values on a per-board level.

So this is specific to SM1 SoCs then, because others families doesn't have such issues at 52MHz.

I don't have much knowledge of SM1 SoCs. But how did its phase value select them on Linux driver?

Quoted 1 line
Quoted 7 lines
Quoted 5 lines

So the Linux must be fixes, including the bindings to introduce a new compatible, then ported to U-Boot.

So in the meantime, it's right to limit to 26MHz on SM1 in U-boot until we have all this clarified.

If you want to limit to 26MHz, I don't have any objection about your opinion.
But I wonder how to clarify all. And I also wonder that values what is used on Linux kernel are really right.

Quoted 7 lines

OK, I'm not a MMC & SDCard expert on Amlogic, all the work was done in Linux.

I just want to keep a working and stable SDCard & eMMC support for the 7 SoCs Families.

Could you rewrite my "[PATCH 2/3] mmc: meson-gx: limit max frequency on SM1 SoCs" by instead changing the clock phase only for SM1 ?
I'll then apply it with the 2 other patches and push then for the current development cycle.

Ok. I will rewrite with you patch. Is it ok that i send the patch on Tomorrow?

Quoted 2 lines

The driver is functional for all the other SoCs, and I want to keep it stable unless extensively tested.

Agreed. If i can test all Amlogic SoCs, I want to do that..But it's impossible to me. In future, i hope that it will be fixed with generic approach.

Best Regards,
Jaehoon Chung

Quoted 13 lines

Neil

Quoted 8 lines

Best Regards,
Jaehoon Chung

Quoted 3 lines

Neil

#10 lore raw

PATCH 1/1 mmc: meson_gx_mmc: change a clock phase to stable value

Quoted 77 lines · Jaehoon Chung
Quoted 76 lines · Neil Armstrong
Quoted 65 lines · Jaehoon Chung
Quoted 52 lines · Neil Armstrong
Quoted 51 lines · Mark Kettenis
Quoted 42 lines

From: Neil Armstrong <[email protected]>
Date: Mon, 9 Nov 2020 14:37:09 +0100

Hi,

Quoted 36 lines · Jaehoon Chung

Core clock phase value is changed from 180' to 270'. It's more stable than before.
- Odroidn-N2/C4 : Working fine with 52MHz
- VIM3 : Working fine with 52MHz

Before this patch, Odroid-C4 doesn't work fine with 52MHz.

---
 drivers/mmc/meson_gx_mmc.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/mmc/meson_gx_mmc.c +10 -4
index 719dd1e5e570..7c60e0566560 100644
@@ -52,10 +52,16 @@ static void meson_mmc_config_clock(struct mmc *mmc)
 	}
 	clk_div = DIV_ROUND_UP(clk, mmc->clock);
 
-	/* 180 phase core clock */
-	meson_mmc_clk |= CLK_CO_PHASE_180;
-
-	/* 180 phase tx clock */
+	/*
+	 * Clock Phase needs to set a proper value.
+	 * It can be changed to other value.
+	 * Because CORE : 270' Phase and TX : 0' Phase are stable,
+	 * set to them by default.
+	 */
+	/* Core Clock Phase */
+	meson_mmc_clk |= CLK_CO_PHASE_270;
+
+	/* TX Clock Phase */
 	meson_mmc_clk |= CLK_TX_PHASE_000;
 
Quoted 4 lines

drivers/mmc/meson_gx_mmc.c static void meson_mmc_config_clock(struct mmc *mmc) · line 67

Quoted 2 lines
drivers/mmc/meson_gx_mmc.c +0 -0
 	/* clock settings */

The previous values were aligned on the Linux driver, which is functional.

Actually the Linux driver isn't really functional; the 52 MHz high-speed mode doesn't work. But since HS200 does work in Linux, probably nobody noticed this.

Quoted 8 lines
Quoted 5 lines

That said, I'm not confident a single clock phase setting will work across all Amlogic SoCs and across different boards. Maybe we need something in the device tree such that we can control the values on a per-board level.

So this is specific to SM1 SoCs then, because others families doesn't have such issues at 52MHz.

I don't have much knowledge of SM1 SoCs. But how did its phase value select them on Linux driver?

Quoted 1 line
Quoted 7 lines
Quoted 5 lines

So the Linux must be fixes, including the bindings to introduce a new compatible, then ported to U-Boot.

So in the meantime, it's right to limit to 26MHz on SM1 in U-boot until we have all this clarified.

If you want to limit to 26MHz, I don't have any objection about your opinion.
But I wonder how to clarify all. And I also wonder that values what is used on Linux kernel are really right.

OK, I'm not a MMC & SDCard expert on Amlogic, all the work was done in Linux.

Quoted 7 lines
Quoted 5 lines

I just want to keep a working and stable SDCard & eMMC support for the 7 SoCs Families.

Could you rewrite my "[PATCH 2/3] mmc: meson-gx: limit max frequency on SM1 SoCs" by instead changing the clock phase only for SM1 ?
I'll then apply it with the 2 other patches and push then for the current development cycle.

Ok. I will rewrite with you patch. Is it ok that i send the patch on Tomorrow?

Agreed

Quoted 6 lines
Quoted 3 lines

The driver is functional for all the other SoCs, and I want to keep it stable unless extensively tested.

Agreed. If i can test all Amlogic SoCs, I want to do that..But it's impossible to me. In future, i hope that it will be fixed with generic approach.

Sure, thanks for your work & testing !

Neil

Quoted 18 lines

Best Regards,
Jaehoon Chung

Quoted 13 lines

Neil

Quoted 8 lines

Best Regards,
Jaehoon Chung

Quoted 3 lines

Neil

#11 lore raw

PATCH 1/1 mmc: meson_gx_mmc: change a clock phase to stable value

In reply to Mark Kettenis

Hi,

Quoted 42 lines · Mark Kettenis
Quoted 42 lines

From: Neil Armstrong <[email protected]>
Date: Mon, 9 Nov 2020 14:37:09 +0100

Hi,

Quoted 36 lines · Jaehoon Chung

Core clock phase value is changed from 180' to 270'. It's more stable than before.
- Odroidn-N2/C4 : Working fine with 52MHz
- VIM3 : Working fine with 52MHz

Before this patch, Odroid-C4 doesn't work fine with 52MHz.

---
 drivers/mmc/meson_gx_mmc.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/mmc/meson_gx_mmc.c +10 -4
index 719dd1e5e570..7c60e0566560 100644
@@ -52,10 +52,16 @@ static void meson_mmc_config_clock(struct mmc *mmc)
 	}
 	clk_div = DIV_ROUND_UP(clk, mmc->clock);
 
-	/* 180 phase core clock */
-	meson_mmc_clk |= CLK_CO_PHASE_180;
-
-	/* 180 phase tx clock */
+	/*
+	 * Clock Phase needs to set a proper value.
+	 * It can be changed to other value.
+	 * Because CORE : 270' Phase and TX : 0' Phase are stable,
+	 * set to them by default.
+	 */
+	/* Core Clock Phase */
+	meson_mmc_clk |= CLK_CO_PHASE_270;
+
+	/* TX Clock Phase */
 	meson_mmc_clk |= CLK_TX_PHASE_000;
 
Quoted 8 lines
Quoted 4 lines

drivers/mmc/meson_gx_mmc.c static void meson_mmc_config_clock(struct mmc *mmc) · line 67

Quoted 2 lines
drivers/mmc/meson_gx_mmc.c +0 -0
 	/* clock settings */

The previous values were aligned on the Linux driver, which is functional.

Actually the Linux driver isn't really functional; the 52 MHz high-speed mode doesn't work. But since HS200 does work in Linux, probably nobody noticed this.

Well, i didn't check Linux driver. but i can also check on Linux side.

Quoted 5 lines

That said, I'm not confident a single clock phase setting will work across all Amlogic SoCs and across different boards. Maybe we need something in the device tree such that we can control the values on a per-board level.

Agreed. I can't mention that "it's working fine about all Amlogic SoCs".
In exynos's case, there are sdr and ddr timing about mmc/sd IP.
sdr/ddr timing are trying to get from dt's property, because it's possible that all Exynos SoCs have different values.

I think that Amlogic SoCs also needs to apply similar approach.

Best Regards,
Jaehoon Chung

Quoted 1 line
#12 lore raw

PATCH 1/1 mmc: meson_gx_mmc: change a clock phase to stable value

In reply to Neil Armstrong
Quoted 39 lines · Neil Armstrong

Hi,

Quoted 36 lines · Jaehoon Chung

Core clock phase value is changed from 180' to 270'. It's more stable than before.
- Odroidn-N2/C4 : Working fine with 52MHz
- VIM3 : Working fine with 52MHz

Before this patch, Odroid-C4 doesn't work fine with 52MHz.

---
 drivers/mmc/meson_gx_mmc.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/mmc/meson_gx_mmc.c +10 -4
index 719dd1e5e570..7c60e0566560 100644
@@ -52,10 +52,16 @@ static void meson_mmc_config_clock(struct mmc *mmc)
 	}
 	clk_div = DIV_ROUND_UP(clk, mmc->clock);
 
-	/* 180 phase core clock */
-	meson_mmc_clk |= CLK_CO_PHASE_180;
-
-	/* 180 phase tx clock */
+	/*
+	 * Clock Phase needs to set a proper value.
+	 * It can be changed to other value.
+	 * Because CORE : 270' Phase and TX : 0' Phase are stable,
+	 * set to them by default.
+	 */
+	/* Core Clock Phase */
+	meson_mmc_clk |= CLK_CO_PHASE_270;
+
+	/* TX Clock Phase */
 	meson_mmc_clk |= CLK_TX_PHASE_000;
 
Quoted 6 lines

drivers/mmc/meson_gx_mmc.c static void meson_mmc_config_clock(struct mmc *mmc) · line 67

Quoted 2 lines
drivers/mmc/meson_gx_mmc.c +0 -0
 	/* clock settings */

The previous values were aligned on the Linux driver, which is functional.

How did you test these ?

Actually, i have tested about all cases on targets what i have. (VIM3/Odroid-N2/Odroid-C4) I also have VIM3L, but i didn't test on VIM3L. (I can test with VIM3L)
If check with oscilloscope, it will be a good way to find what's wrong.

When i have enabled MMC_DEBUG, it was always returned -5 (IO) error during switching mode.
In meson_gx_mmc.c, meson_dm_mmc_send_cmd() is returned to -5.
When i have checked status register, CRC error status bit (BIT[10]) is set. It means that clock timing is wrong.
In my experiment, my debugging about CRC error is
1) GPIO setting
2) clock value
3) Driver strength
4) clock phase value

I assume that 1~3) are correct. So checked PHASE values.

I didn't check yet how to set value on Linux driver.

Best Regards,
Jaehoon Chung

Quoted 3 lines

Neil