From: Anand Moon <linux.amoon@gmail.com>
To: Neil Armstrong <narmstrong@baylibre.com>,
Jerome Brunet <jbrunet@baylibre.com>, Peng Fan <peng.fan@nxp.com>,
Jaehoon Chung <jh80.chung@samsung.com>,
u-boot-amlogic@groups.io, u-boot@lists.denx.de
Subject: [PATCHv5 1/5] mmc: meson-gx: Fix clk phase tuning for MMC
Date: Mon, 3 Feb 2020 15:13:19 +0000 [thread overview]
Message-ID: <20200203151323.4615-2-linux.amoon@gmail.com> (raw)
In-Reply-To: <20200203151323.4615-1-linux.amoon@gmail.com>
As per mainline line kernel fix the clk tuning phase for mmc,
set Core=180, Tx=180, Rx=0 clk phase for mmc initialization.
As per S905, S905X, AGX and S922X datasheet set the default
values for clk tuning.
Signed-off-by: Anand Moon <linux.amoon@gmail.com>
---
arch/arm/include/asm/arch-meson/sd_emmc.h | 28 ++++++++++++------
drivers/mmc/meson_gx_mmc.c | 36 +++++++++++++++++++----
2 files changed, 50 insertions(+), 14 deletions(-)
diff --git a/arch/arm/include/asm/arch-meson/sd_emmc.h b/arch/arm/include/asm/arch-meson/sd_emmc.h
index e3a72c8b66..b7a99947b3 100644
--- a/arch/arm/include/asm/arch-meson/sd_emmc.h
+++ b/arch/arm/include/asm/arch-meson/sd_emmc.h
@@ -7,6 +7,7 @@
#define __SD_EMMC_H__
#include <mmc.h>
+#include <linux/bitops.h>
#define SDIO_PORT_A 0
#define SDIO_PORT_B 1
@@ -19,15 +20,24 @@
#define CLK_MAX_DIV 63
#define CLK_SRC_24M (0 << 6)
#define CLK_SRC_DIV2 (1 << 6)
-#define CLK_CO_PHASE_000 (0 << 8)
-#define CLK_CO_PHASE_090 (1 << 8)
-#define CLK_CO_PHASE_180 (2 << 8)
-#define CLK_CO_PHASE_270 (3 << 8)
-#define CLK_TX_PHASE_000 (0 << 10)
-#define CLK_TX_PHASE_090 (1 << 10)
-#define CLK_TX_PHASE_180 (2 << 10)
-#define CLK_TX_PHASE_270 (3 << 10)
-#define CLK_ALWAYS_ON BIT(24)
+
+#define CRYSTAL_24MHZ 0
+#define CLK_PHASE_0 0
+#define CLK_PHASE_180 2
+
+#define CLK_DIV_MASK GENMASK(5, 0)
+#define CLK_SRC_MASK GENMASK(7, 6)
+#define CLK_CORE_PHASE_MASK GENMASK(9, 8)
+#define CLK_TX_PHASE_MASK GENMASK(11, 10)
+#define CLK_RX_PHASE_MASK GENMASK(13, 12)
+
+#define CLK_V2_TX_DELAY_MASK GENMASK(19, 16)
+#define CLK_V2_RX_DELAY_MASK GENMASK(23, 20)
+#define CLK_V2_ALWAYS_ON BIT(24)
+
+#define CLK_V3_TX_DELAY_MASK GENMASK(21, 16)
+#define CLK_V3_RX_DELAY_MASK GENMASK(27, 22)
+#define CLK_V3_ALWAYS_ON BIT(28)
#define MESON_SD_EMMC_CFG 0x44
#define CFG_BUS_WIDTH_MASK GENMASK(1, 0)
diff --git a/drivers/mmc/meson_gx_mmc.c b/drivers/mmc/meson_gx_mmc.c
index 86c1a7164a..03fb70e717 100644
--- a/drivers/mmc/meson_gx_mmc.c
+++ b/drivers/mmc/meson_gx_mmc.c
@@ -16,6 +16,10 @@
#include <asm/arch/sd_emmc.h>
#include <linux/log2.h>
+#include <linux/bitops.h>
+#include <linux/compat.h>
+#include <linux/bitfield.h>
+
static inline void *get_regbase(const struct mmc *mmc)
{
struct meson_mmc_platdata *pdata = mmc->priv;
@@ -51,11 +55,33 @@ 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 */
- meson_mmc_clk |= CLK_TX_PHASE_000;
+ /* Clock divider */
+ meson_mmc_clk |= CLK_DIV_MASK;
+ /* Clock source : Crystal 24MHz */
+ meson_mmc_clk |= FIELD_PREP(CLK_SRC_MASK, CRYSTAL_24MHZ);
+ /* Core clock phase 2:180 */
+ meson_mmc_clk |= FIELD_PREP(CLK_CORE_PHASE_MASK, CLK_PHASE_180);
+ /* TX clock phase 2:180 */
+ meson_mmc_clk |= FIELD_PREP(CLK_TX_PHASE_MASK, CLK_PHASE_180);
+ /* RX clock phase 0:180 */
+ meson_mmc_clk |= FIELD_PREP(CLK_RX_PHASE_MASK, CLK_PHASE_0);
+
+#ifdef CONFIG_MESON_GX
+ /* TX clock delay line */
+ meson_mmc_clk |= CLK_V2_TX_DELAY_MASK;
+ /* RX clock delay line */
+ meson_mmc_clk |= CLK_V2_RX_DELAY_MASK;
+ /* clk always on */
+ meson_mmc_clk |= CLK_V2_ALWAYS_ON;
+#endif
+#if (defined(CONFIG_MESON_AXG) || defined(CONFIG_MESON_G12A))
+ /* TX clock delay line */
+ meson_mmc_clk |= CLK_V3_TX_DELAY_MASK;
+ /* RX clock delay line */
+ meson_mmc_clk |= CLK_V3_RX_DELAY_MASK;
+ /* clk always on */
+ meson_mmc_clk |= CLK_V3_ALWAYS_ON;
+#endif
/* clock settings */
meson_mmc_clk |= clk_src;
--
2.25.0
WARNING: multiple messages have this Message-ID (diff)
From: Anand Moon <linux.amoon@gmail.com>
To: u-boot@lists.denx.de
Subject: [PATCHv5 1/5] mmc: meson-gx: Fix clk phase tuning for MMC
Date: Mon, 3 Feb 2020 15:13:19 +0000 [thread overview]
Message-ID: <20200203151323.4615-2-linux.amoon@gmail.com> (raw)
In-Reply-To: <20200203151323.4615-1-linux.amoon@gmail.com>
As per mainline line kernel fix the clk tuning phase for mmc,
set Core=180, Tx=180, Rx=0 clk phase for mmc initialization.
As per S905, S905X, AGX and S922X datasheet set the default
values for clk tuning.
Signed-off-by: Anand Moon <linux.amoon@gmail.com>
---
arch/arm/include/asm/arch-meson/sd_emmc.h | 28 ++++++++++++------
drivers/mmc/meson_gx_mmc.c | 36 +++++++++++++++++++----
2 files changed, 50 insertions(+), 14 deletions(-)
diff --git a/arch/arm/include/asm/arch-meson/sd_emmc.h b/arch/arm/include/asm/arch-meson/sd_emmc.h
index e3a72c8b66..b7a99947b3 100644
--- a/arch/arm/include/asm/arch-meson/sd_emmc.h
+++ b/arch/arm/include/asm/arch-meson/sd_emmc.h
@@ -7,6 +7,7 @@
#define __SD_EMMC_H__
#include <mmc.h>
+#include <linux/bitops.h>
#define SDIO_PORT_A 0
#define SDIO_PORT_B 1
@@ -19,15 +20,24 @@
#define CLK_MAX_DIV 63
#define CLK_SRC_24M (0 << 6)
#define CLK_SRC_DIV2 (1 << 6)
-#define CLK_CO_PHASE_000 (0 << 8)
-#define CLK_CO_PHASE_090 (1 << 8)
-#define CLK_CO_PHASE_180 (2 << 8)
-#define CLK_CO_PHASE_270 (3 << 8)
-#define CLK_TX_PHASE_000 (0 << 10)
-#define CLK_TX_PHASE_090 (1 << 10)
-#define CLK_TX_PHASE_180 (2 << 10)
-#define CLK_TX_PHASE_270 (3 << 10)
-#define CLK_ALWAYS_ON BIT(24)
+
+#define CRYSTAL_24MHZ 0
+#define CLK_PHASE_0 0
+#define CLK_PHASE_180 2
+
+#define CLK_DIV_MASK GENMASK(5, 0)
+#define CLK_SRC_MASK GENMASK(7, 6)
+#define CLK_CORE_PHASE_MASK GENMASK(9, 8)
+#define CLK_TX_PHASE_MASK GENMASK(11, 10)
+#define CLK_RX_PHASE_MASK GENMASK(13, 12)
+
+#define CLK_V2_TX_DELAY_MASK GENMASK(19, 16)
+#define CLK_V2_RX_DELAY_MASK GENMASK(23, 20)
+#define CLK_V2_ALWAYS_ON BIT(24)
+
+#define CLK_V3_TX_DELAY_MASK GENMASK(21, 16)
+#define CLK_V3_RX_DELAY_MASK GENMASK(27, 22)
+#define CLK_V3_ALWAYS_ON BIT(28)
#define MESON_SD_EMMC_CFG 0x44
#define CFG_BUS_WIDTH_MASK GENMASK(1, 0)
diff --git a/drivers/mmc/meson_gx_mmc.c b/drivers/mmc/meson_gx_mmc.c
index 86c1a7164a..03fb70e717 100644
--- a/drivers/mmc/meson_gx_mmc.c
+++ b/drivers/mmc/meson_gx_mmc.c
@@ -16,6 +16,10 @@
#include <asm/arch/sd_emmc.h>
#include <linux/log2.h>
+#include <linux/bitops.h>
+#include <linux/compat.h>
+#include <linux/bitfield.h>
+
static inline void *get_regbase(const struct mmc *mmc)
{
struct meson_mmc_platdata *pdata = mmc->priv;
@@ -51,11 +55,33 @@ 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 */
- meson_mmc_clk |= CLK_TX_PHASE_000;
+ /* Clock divider */
+ meson_mmc_clk |= CLK_DIV_MASK;
+ /* Clock source : Crystal 24MHz */
+ meson_mmc_clk |= FIELD_PREP(CLK_SRC_MASK, CRYSTAL_24MHZ);
+ /* Core clock phase 2:180 */
+ meson_mmc_clk |= FIELD_PREP(CLK_CORE_PHASE_MASK, CLK_PHASE_180);
+ /* TX clock phase 2:180 */
+ meson_mmc_clk |= FIELD_PREP(CLK_TX_PHASE_MASK, CLK_PHASE_180);
+ /* RX clock phase 0:180 */
+ meson_mmc_clk |= FIELD_PREP(CLK_RX_PHASE_MASK, CLK_PHASE_0);
+
+#ifdef CONFIG_MESON_GX
+ /* TX clock delay line */
+ meson_mmc_clk |= CLK_V2_TX_DELAY_MASK;
+ /* RX clock delay line */
+ meson_mmc_clk |= CLK_V2_RX_DELAY_MASK;
+ /* clk always on */
+ meson_mmc_clk |= CLK_V2_ALWAYS_ON;
+#endif
+#if (defined(CONFIG_MESON_AXG) || defined(CONFIG_MESON_G12A))
+ /* TX clock delay line */
+ meson_mmc_clk |= CLK_V3_TX_DELAY_MASK;
+ /* RX clock delay line */
+ meson_mmc_clk |= CLK_V3_RX_DELAY_MASK;
+ /* clk always on */
+ meson_mmc_clk |= CLK_V3_ALWAYS_ON;
+#endif
/* clock settings */
meson_mmc_clk |= clk_src;
--
2.25.0
next prev parent reply other threads:[~2020-02-03 15:13 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-03 15:13 [PATCHv5 0/5]Odroid n2 using eMMC would fail to boot up Anand Moon
2020-02-03 15:13 ` Anand Moon
2020-02-03 15:13 ` Anand Moon [this message]
2020-02-03 15:13 ` [PATCHv5 1/5] mmc: meson-gx: Fix clk phase tuning for MMC Anand Moon
2020-02-03 15:41 ` Jerome Brunet
2020-02-03 15:41 ` Jerome Brunet
2020-02-03 16:38 ` Anand Moon
2020-02-03 16:38 ` Anand Moon
2020-02-03 17:44 ` Jerome Brunet
2020-02-03 17:44 ` Jerome Brunet
2020-02-04 3:09 ` Anand Moon
2020-02-04 3:09 ` Anand Moon
2020-02-03 15:13 ` [PATCHv5 2/5] mmc: meson-gx: Use proper compatible string as per the dts Anand Moon
2020-02-03 15:13 ` Anand Moon
2020-02-03 15:13 ` [PATCHv5 3/5] arm: dts: gx: Move common nodes to the -u-boot.dtsi Anand Moon
2020-02-03 15:13 ` Anand Moon
2020-02-03 15:13 ` [PATCHv5 4/5] arm: dts: g12: " Anand Moon
2020-02-03 15:13 ` Anand Moon
2020-02-03 15:13 ` [PATCHv5 5/5] arm: dts: s400: " Anand Moon
2020-02-03 15:13 ` Anand Moon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200203151323.4615-2-linux.amoon@gmail.com \
--to=linux.amoon@gmail.com \
--cc=jbrunet@baylibre.com \
--cc=jh80.chung@samsung.com \
--cc=narmstrong@baylibre.com \
--cc=peng.fan@nxp.com \
--cc=u-boot-amlogic@groups.io \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.