Odroid n2 using eMMC would fail to boot up
Subsystems (3)
v5 cover Odroid n2 using eMMC would fail to boot up
Here are some small changes to fix booting of Odroid N2 using eMMC. Fixed the clk tunnig during mmc initialization.
Added two new patches to fix warning
Build and tested on top of below patches
[0] https://patchwork.ozlabs.org/patch/1213648/
[1] https://patchwork.ozlabs.org/patch/1213650/
Tested on below eMMC module on Odroid N2 and C2
new orange - eMMC AJNB4R 14.6 GiB MMC 5.1
old back - eMMC CGND3R 58.2 GiB MMC 5.0
Prevoius changes:
Fixed the clk tuning as per mainline kernel
[3]v1 https://patchwork.ozlabs.org/cover/1201206/
[4]v2 https://patchwork.ozlabs.org/cover/1215217/
[5]v3 https://www.mail-archive.com/u-boot at lists.denx.de/msg351859.html [6]v4 https://patchwork.ozlabs.org/cover/1227205/
-Anand
Anand Moon (5):
mmc: meson-gx: Fix clk phase tuning for MMC
mmc: meson-gx: Use proper compatible string as per the dts
arm: dts: gx: Move common nodes to the -u-boot.dtsi
arm: dts: g12: Move common nodes to the -u-boot.dtsi
arm: dts: s400: Move common nodes to the -u-boot.dtsi
arch/arm/dts/meson-axg-s400-u-boot.dtsi | 16 +++++ arch/arm/dts/meson-axg-s400.dts | 9 --- arch/arm/dts/meson-g12-common-u-boot.dtsi | 12 ++++ arch/arm/dts/meson-g12a-sei510.dts | 9 --- arch/arm/dts/meson-g12a-u200.dts | 9 --- arch/arm/dts/meson-g12b-odroid-n2.dts | 9 --- arch/arm/dts/meson-gx-u-boot.dtsi | 15 +++++ arch/arm/dts/meson-gxbb-nanopi-k2.dts | 9 --- arch/arm/dts/meson-gxbb-odroidc2.dts | 9 --- arch/arm/dts/meson-gxbb-p20x.dtsi | 9 --- arch/arm/dts/meson-gxl-s805x-libretech-ac.dts | 10 --- arch/arm/dts/meson-gxl-s905x-khadas-vim.dts | 5 -- arch/arm/dts/meson-gxl-s905x-libretech-cc.dts | 9 --- arch/arm/dts/meson-gxl-s905x-p212.dtsi | 10 --- arch/arm/dts/meson-gxm-khadas-vim2.dts | 10 --- arch/arm/dts/meson-khadas-vim3.dtsi | 9 --- arch/arm/dts/meson-sm1-sei610.dts | 9 --- arch/arm/include/asm/arch-meson/sd_emmc.h | 35 +++++++--- drivers/mmc/meson_gx_mmc.c | 66 ++++++++++++++++--- 19 files changed, 126 insertions(+), 143 deletions(-)
Signature · 1 line
2.25.0
PATCH v5 1/5 mmc: meson-gx: Fix clk phase tuning for MMC
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.
--- arch/arm/include/asm/arch-meson/sd_emmc.h | 28 ++++++++++++------ drivers/mmc/meson_gx_mmc.c | 36 +++++++++++++++++++---- 2 files changed, 50 insertions(+), 14 deletions(-)
arch/arm/include/asm/arch-meson/sd_emmc.h +19 -9
@@ -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)
drivers/mmc/meson_gx_mmc.c +31 -5
@@ -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;
Signature · 1 line
2.25.0
Jerome Brunet
reviewerPATCH v5 1/5 mmc: meson-gx: Fix clk phase tuning for MMC
Quoted 79 lines · Anand Moon
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 <[email protected]>--- arch/arm/include/asm/arch-meson/sd_emmc.h | 28 ++++++++++++------ drivers/mmc/meson_gx_mmc.c | 36 +++++++++++++++++++---- 2 files changed, 50 insertions(+), 14 deletions(-)arch/arm/include/asm/arch-meson/sd_emmc.h +19
-9@@ -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)drivers/mmc/meson_gx_mmc.c +4
-3@@ -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 ; -
drivers/mmc/meson_gx_mmc.c static void meson_mmc_config_clock(struct mmc *mmc) · line 65
Quoted 10 lines
drivers/mmc/meson_gx_mmc.c +8
-2-/* 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 );
I think I mentionned already but this is not aligned with the setting used by the linux driver. If you have problems with these, please report it to the linux mailing list
drivers/mmc/meson_gx_mmc.c static void meson_mmc_config_clock(struct mmc *mmc) · line 73
Quoted 8 lines
drivers/mmc/meson_gx_mmc.c +8
-0+/* 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 ;
Why do you need to this ?
Quoted 14 lines
drivers/mmc/meson_gx_mmc.c +11
-0+/* 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;
PATCH v5 1/5 mmc: meson-gx: Fix clk phase tuning for MMC
Hi Jerome,
Thanks for your review,
Quoted 89 lines · Jerome Brunet
Quoted 85 lines · Anand Moon
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 <[email protected]>--- arch/arm/include/asm/arch-meson/sd_emmc.h | 28 ++++++++++++------ drivers/mmc/meson_gx_mmc.c | 36 +++++++++++++++++++---- 2 files changed, 50 insertions(+), 14 deletions(-)arch/arm/include/asm/arch-meson/sd_emmc.h +19
-9@@ -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)drivers/mmc/meson_gx_mmc.c +8
-5@@ -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 );
Quoted 8 lines
drivers/mmc/meson_gx_mmc.c static void meson_mmc_config_clock(struct mmc *mmc) · line 65
Quoted 4 lines
drivers/mmc/meson_gx_mmc.c +4
-0+/* 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 );I think I mentionned already but this is not aligned with the setting used by the linux driver. If you have problems with these, please report it to the linux mailing list
Yes I will try to send this changes to linux driver since these are the recommend
default values as per the datasheets, see below.Cfg_tx_phase: TX clock phase 0: 0 phase, 1: 90 phase, 2: 180 phase, 3:
270 phase. Recommended value: 2
Quoted 11 lines
drivers/mmc/meson_gx_mmc.c static void meson_mmc_config_clock(struct mmc *mmc) · line 73
Quoted 9 lines
drivers/mmc/meson_gx_mmc.c +8
-0+/* 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 ;Why do you need to this ?
As these are part of the linux driver, I added these, I will check if this changes are needed in u-boot.
Quoted 13 lines
Quoted 13 lines
drivers/mmc/meson_gx_mmc.c +11
-0+/* 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
Quoted 3 lines
drivers/mmc/meson_gx_mmc.c static void meson_mmc_config_clock(struct mmc *mmc) · line 87
Quoted 2 lines
drivers/mmc/meson_gx_mmc.c +0
-0/* clock settings */ meson_mmc_clk |= clk_src;
-Anand
Jerome Brunet
reviewerPATCH v5 1/5 mmc: meson-gx: Fix clk phase tuning for MMC
Quoted 11 lines · Anand Moon
Hi Jerome,
Thanks for your review,
Quoted 6 lines · Jerome Brunet
Quoted 2 lines · Anand Moon
As per mainline line kernel fix the clk tuning phase for mmc, set Core=180, Tx=180, Rx=0 clk phase for mmc initialization.
Which version ?
I don't recall any version of mainline linux kernel which has used these default settings.
Quoted 92 lines
Quoted 83 lines
Quoted 83 lines
As per S905, S905X, AGX and S922X datasheet set the default values for clk tuning.
Signed-off-by Anand Moon <[email protected]>--- arch/arm/include/asm/arch-meson/sd_emmc.h | 28 ++++++++++++------ drivers/mmc/meson_gx_mmc.c | 36 +++++++++++++++++++---- 2 files changed, 50 insertions(+), 14 deletions(-)arch/arm/include/asm/arch-meson/sd_emmc.h +19
-9@@ -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)drivers/mmc/meson_gx_mmc.c +8
-5@@ -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 );Quoted 8 lines
drivers/mmc/meson_gx_mmc.c static void meson_mmc_config_clock(struct mmc *mmc) · line 65
Quoted 4 lines
drivers/mmc/meson_gx_mmc.c +4
-0+/* 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 );I think I mentionned already but this is not aligned with the setting used by the linux driver. If you have problems with these, please report it to the linux mailing list
Quoted 5 lines
Yes I will try to send this changes to linux driver since these are the recommend
default values as per the datasheets, see below.Cfg_tx_phase: TX clock phase 0: 0 phase, 1: 90 phase, 2: 180 phase, 3:
270 phase. Recommended value: 2
Well we already had that discussion 2 years ago regarding the recommended setting. The fact is that it did not work that well.
Please the try the setting implemented in the linux driver
Core: 180, Tx: 0, Rx:0 and report issue to linux-ml. Thx
Quoted 13 lines
Quoted 12 lines
drivers/mmc/meson_gx_mmc.c static void meson_mmc_config_clock(struct mmc *mmc) · line 73
Quoted 10 lines
drivers/mmc/meson_gx_mmc.c +8
-0+/* 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 ;Why do you need to this ?
Quoted 2 lines
As these are part of the linux driver, I added these, I will check if this changes are needed in u-boot.
The linux driver never wrote the MASK value to register, which would set all the bits to 1. It does not make sense.
The fact is that the linux kernel has not been using the rx and tx delays at all since v5.2
It would better to just let these values alone.
Quoted 18 lines
Quoted 13 lines
Quoted 13 lines
drivers/mmc/meson_gx_mmc.c +11
-0+/* 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 Quoted 3 lines
drivers/mmc/meson_gx_mmc.c static void meson_mmc_config_clock(struct mmc *mmc) · line 87
Quoted 2 lines
drivers/mmc/meson_gx_mmc.c +0
-0/* clock settings */ meson_mmc_clk |= clk_src;-Anand
PATCH v5 1/5 mmc: meson-gx: Fix clk phase tuning for MMC
Hi Jerome,
Thanks for your review comments,
Quoted 11 lines · Jerome Brunet
Quoted 7 lines · Anand Moon
Hi Jerome,
Thanks for your review,
Quoted 2 lines · Jerome Brunet
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines · Anand Moon
Quoted 3 lines
As per mainline line kernel fix the clk tuning phase for mmc, set Core=180, Tx=180, Rx=0 clk phase for mmc initialization.
Which version ?
I don't recall any version of mainline linux kernel which has used these default settings.
Ok typo, I was just referring the datasheet for the default values,
Quoted 99 lines
Quoted 93 lines
Quoted 84 lines
Quoted 84 lines
As per S905, S905X, AGX and S922X datasheet set the default values for clk tuning.
Signed-off-by Anand Moon <[email protected]>--- arch/arm/include/asm/arch-meson/sd_emmc.h | 28 ++++++++++++------ drivers/mmc/meson_gx_mmc.c | 36 +++++++++++++++++++---- 2 files changed, 50 insertions(+), 14 deletions(-)arch/arm/include/asm/arch-meson/sd_emmc.h +19
-9@@ -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)drivers/mmc/meson_gx_mmc.c +8
-5@@ -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 );Quoted 8 lines
drivers/mmc/meson_gx_mmc.c static void meson_mmc_config_clock(struct mmc *mmc) · line 65
Quoted 4 lines
drivers/mmc/meson_gx_mmc.c +4
-0+/* 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 );I think I mentionned already but this is not aligned with the setting used by the linux driver. If you have problems with these, please report it to the linux mailing list
Quoted 5 lines
Yes I will try to send this changes to linux driver since these are the recommend
default values as per the datasheets, see below.Cfg_tx_phase: TX clock phase 0: 0 phase, 1: 90 phase, 2: 180 phase, 3:
270 phase. Recommended value: 2
Quoted 6 lines
Well we already had that discussion 2 years ago regarding the recommended setting. The fact is that it did not work that well.
Please the try the setting implemented in the linux driver
Core: 180, Tx: 0, Rx:0 and report issue to linux-ml. Thx
Ok I will used the linux-ml setting over here as well in u-boot.
Quoted 16 lines
Quoted 13 lines
Quoted 12 lines
drivers/mmc/meson_gx_mmc.c static void meson_mmc_config_clock(struct mmc *mmc) · line 73
Quoted 10 lines
drivers/mmc/meson_gx_mmc.c +8
-0+/* 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 ;Why do you need to this ?
Quoted 2 lines
As these are part of the linux driver, I added these, I will check if this changes are needed in u-boot.
Quoted 7 lines
The linux driver never wrote the MASK value to register, which would set all the bits to 1. It does not make sense.
The fact is that the linux kernel has not been using the rx and tx delays at all since v5.2
It would better to just let these values alone.
Ok. I will drop this changes and stick to linux-ml changes for u-boot driver.
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
drivers/mmc/meson_gx_mmc.c +11
-0+/* 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
Quoted 6 lines
Quoted 5 lines
Quoted 3 lines
drivers/mmc/meson_gx_mmc.c static void meson_mmc_config_clock(struct mmc *mmc) · line 87
Quoted 2 lines
drivers/mmc/meson_gx_mmc.c +0
-0/* clock settings */ meson_mmc_clk |= clk_src;-Anand
-Anand
PATCH v5 2/5 mmc: meson-gx: Use proper compatible string as per the dts
In reply to Anand MoonUse proper compatible string as per the dts so that mmc driver could be tuned properly. SoC family S905, S905X have common clk tuning parameters setting, while AGX and G12 have common clk tuning parameters setting for mmc driver.
---
New patch in this series.
---
--- arch/arm/include/asm/arch-meson/sd_emmc.h | 7 +++ drivers/mmc/meson_gx_mmc.c | 62 +++++++++++++++-------- 2 files changed, 49 insertions(+), 20 deletions(-)
arch/arm/include/asm/arch-meson/sd_emmc.h +7 -0
@@ -13,6 +13,12 @@#define SDIO_PORT_B 1#define SDIO_PORT_C 2 +enum mmc_compatible { +MMC_COMPATIBLE_GXBB , +MMC_COMPATIBLE_GX , +MMC_COMPATIBLE_AXG , +}; +#define SD_EMMC_CLKSRC_24M 24000000/* 24 MHz */ #define SD_EMMC_CLKSRC_DIV2 1000000000/* 1 GHz */
@@ -91,6 +97,7 @@struct meson_mmc_platdata {struct mmc_config cfg;struct mmc mmc; +int compat;void *regbase;void *w_buf; };
drivers/mmc/meson_gx_mmc.c +42 -20
89 lines not on this page · raw message
Signature · 1 line
2.25.0
PATCH v5 3/5 arm: dts: gx: Move common nodes to the -u-boot.dtsi
In reply to Anand MoonMove u-boot specific common nodes in the dts files to meson-gx-u-boot.dtsi. This allows us to keep the basic dts[i] files up-to-date with the ones in kernel, but at the same time allowing the u-boot to add its own properties to the existing nodes.
Also add missing mmc alias to dts nodes to avoid below debug warning.
mmc_bind: alias ret=-2, devnum=-1mmc_bind: alias ret=-2, devnum=-1
---
New patch in this series
--- arch/arm/dts/meson-gx-u-boot.dtsi | 15 +++++++++++++++ arch/arm/dts/meson-gxbb-nanopi-k2.dts | 9 --------- arch/arm/dts/meson-gxbb-odroidc2.dts | 9 --------- arch/arm/dts/meson-gxbb-p20x.dtsi | 9 --------- arch/arm/dts/meson-gxl-s805x-libretech-ac.dts | 10 ---------- arch/arm/dts/meson-gxl-s905x-khadas-vim.dts | 5 ----- arch/arm/dts/meson-gxl-s905x-libretech-cc.dts | 9 --------- arch/arm/dts/meson-gxl-s905x-p212.dtsi | 10 ---------- arch/arm/dts/meson-gxm-khadas-vim2.dts | 10 ---------- 9 files changed, 15 insertions(+), 71 deletions(-)
arch/arm/dts/meson-gx-u-boot.dtsi +15 -0
@@ -8,6 +8,21 @@ soc { u-boot,dm-pre-reloc; }; + + aliases { + serial0 = &uart_AO; + serial1 = &uart_A; + serial2 = &uart_AO_B; + ethernet0 = ðmac; + spi0 = &spifc; + mmc0 = &sd_emmc_a; + mmc1 = &sd_emmc_b; + mmc2 = &sd_emmc_c; + }; + + chosen { + stdout-path = "serial0:115200n8"; + }; }; &vpu {
arch/arm/dts/meson-gxbb-nanopi-k2.dts +0 -9
@@ -11,15 +11,6 @@ / { compatible = "friendlyarm,nanopi-k2", "amlogic,meson-gxbb"; - aliases { - serial0 = &uart_AO; - ethernet0 = ðmac; - }; - - chosen { - stdout-path = "serial0:115200n8"; - }; - memory at 0 { device_type = "memory"; reg = <0x0 0x0 0x0 0x80000000>;
arch/arm/dts/meson-gxbb-odroidc2.dts +0 -9
@@ -14,15 +14,6 @@ compatible = "hardkernel,odroid-c2", "amlogic,meson-gxbb"; model = "Hardkernel ODROID-C2"; - aliases { - serial0 = &uart_AO; - ethernet0 = ðmac; - }; - - chosen { - stdout-path = "serial0:115200n8"; - }; - memory at 0 { device_type = "memory"; reg = <0x0 0x0 0x0 0x80000000>;
arch/arm/dts/meson-gxbb-p20x.dtsi +0 -9
@@ -8,15 +8,6 @@ #include "meson-gxbb.dtsi" / { - aliases { - serial0 = &uart_AO; - ethernet0 = ðmac; - }; - - chosen { - stdout-path = "serial0:115200n8"; - }; - memory at 0 { device_type = "memory"; reg = <0x0 0x0 0x0 0x40000000>;
arch/arm/dts/meson-gxl-s805x-libretech-ac.dts +0 -10
@@ -16,16 +16,6 @@ "amlogic,meson-gxl"; model = "Libre Computer Board AML-S805X-AC"; - aliases { - serial0 = &uart_AO; - ethernet0 = ðmac; - spi0 = &spifc; - }; - - chosen { - stdout-path = "serial0:115200n8"; - }; - cvbs-connector { /* * The pads are present but no connector is soldered on
arch/arm/dts/meson-gxl-s905x-khadas-vim.dts +0 -5
@@ -26,11 +26,6 @@ }; }; - aliases { - serial2 = &uart_AO_B; - ethernet0 = ðmac; - }; - gpio-keys-polled { compatible = "gpio-keys-polled"; #address-cells = <1>;
arch/arm/dts/meson-gxl-s905x-libretech-cc.dts +0 -9
@@ -15,15 +15,6 @@ compatible = "libretech,cc", "amlogic,s905x", "amlogic,meson-gxl"; model = "Libre Computer Board AML-S905X-CC"; - aliases { - serial0 = &uart_AO; - ethernet0 = ðmac; - }; - - chosen { - stdout-path = "serial0:115200n8"; - }; - cvbs-connector { compatible = "composite-video-connector";
arch/arm/dts/meson-gxl-s905x-p212.dtsi +0 -10
@@ -13,16 +13,6 @@ #include "meson-gxl-s905x.dtsi" / { - aliases { - serial0 = &uart_AO; - serial1 = &uart_A; - ethernet0 = ðmac; - }; - - chosen { - stdout-path = "serial0:115200n8"; - }; - memory at 0 { device_type = "memory"; reg = <0x0 0x0 0x0 0x80000000>;
arch/arm/dts/meson-gxm-khadas-vim2.dts +0 -10
@@ -16,16 +16,6 @@ compatible = "khadas,vim2", "amlogic,s912", "amlogic,meson-gxm"; model = "Khadas VIM2"; - aliases { - serial0 = &uart_AO; - serial1 = &uart_A; - serial2 = &uart_AO_B; - }; - - chosen { - stdout-path = "serial0:115200n8"; - }; - memory at 0 { device_type = "memory"; reg = <0x0 0x0 0x0 0x80000000>;
Signature · 1 line
2.25.0
PATCH v5 4/5 arm: dts: g12: Move common nodes to the -u-boot.dtsi
In reply to Anand MoonMove u-boot specific common nodes in the dts files to meson-g12-common-u-boot.dtsi. This allows us to keep the basic dts[i] files up-to-date with the ones in kernel,
but at the same time allowing the u-boot to add its own properties to the existing nodes.
Also add missing mmc alias to dts nodes to avoid below debug warning.
mmc_bind: alias ret=-2, devnum=-1mmc_bind: alias ret=-2, devnum=-1
---
New patch in this series
--- arch/arm/dts/meson-g12-common-u-boot.dtsi | 12 ++++++++++++ arch/arm/dts/meson-g12a-sei510.dts | 9 --------- arch/arm/dts/meson-g12a-u200.dts | 9 --------- arch/arm/dts/meson-g12b-odroid-n2.dts | 9 --------- arch/arm/dts/meson-khadas-vim3.dtsi | 9 --------- arch/arm/dts/meson-sm1-sei610.dts | 9 --------- 6 files changed, 12 insertions(+), 45 deletions(-)
arch/arm/dts/meson-g12-common-u-boot.dtsi +12 -0
@@ -8,6 +8,18 @@ soc { u-boot,dm-pre-reloc; }; + + aliases { + serial0 = &uart_AO; + ethernet0 = ðmac; + mmc0 = &sd_emmc_a; + mmc1 = &sd_emmc_b; + mmc2 = &sd_emmc_c; + }; + + chosen { + stdout-path = "serial0:115200n8"; + }; }; &canvas {
arch/arm/dts/meson-g12a-sei510.dts +0 -9
@@ -28,11 +28,6 @@ }; }; - aliases { - serial0 = &uart_AO; - ethernet0 = ðmac; - }; - mono_dac: audio-codec-0 { compatible = "maxim,max98357a"; #sound-dai-cells = <0>;
@@ -49,10 +44,6 @@ sound-name-prefix = "MIC"; }; - chosen { - stdout-path = "serial0:115200n8"; - }; - cvbs-connector { compatible = "composite-video-connector";
arch/arm/dts/meson-g12a-u200.dts +0 -9
@@ -13,15 +13,6 @@ compatible = "amlogic,u200", "amlogic,g12a"; model = "Amlogic Meson G12A U200 Development Board"; - aliases { - serial0 = &uart_AO; - ethernet0 = ðmac; - }; - - chosen { - stdout-path = "serial0:115200n8"; - }; - cvbs-connector { compatible = "composite-video-connector";
arch/arm/dts/meson-g12b-odroid-n2.dts +0 -9
@@ -15,15 +15,6 @@ compatible = "hardkernel,odroid-n2", "amlogic,g12b"; model = "Hardkernel ODROID-N2"; - aliases { - serial0 = &uart_AO; - ethernet0 = ðmac; - }; - - chosen { - stdout-path = "serial0:115200n8"; - }; - memory at 0 { device_type = "memory"; reg = <0x0 0x0 0x0 0x40000000>;
arch/arm/dts/meson-khadas-vim3.dtsi +0 -9
@@ -11,15 +11,6 @@ / { model = "Khadas VIM3"; - aliases { - serial0 = &uart_AO; - ethernet0 = ðmac; - }; - - chosen { - stdout-path = "serial0:115200n8"; - }; - memory at 0 { device_type = "memory"; reg = <0x0 0x0 0x0 0x80000000>;
arch/arm/dts/meson-sm1-sei610.dts +0 -9
@@ -14,15 +14,6 @@ compatible = "seirobotics,sei610", "amlogic,sm1"; model = "SEI Robotics SEI610"; - aliases { - serial0 = &uart_AO; - ethernet0 = ðmac; - }; - - chosen { - stdout-path = "serial0:115200n8"; - }; - emmc_pwrseq: emmc-pwrseq { compatible = "mmc-pwrseq-emmc"; reset-gpios = <&gpio BOOT_12 GPIO_ACTIVE_LOW>;
Signature · 1 line
2.25.0
PATCH v5 5/5 arm: dts: s400: Move common nodes to the -u-boot.dtsi
In reply to Anand MoonMove u-boot specific common nodes in the dts files to meson-axg-s400-u-boot.dtsi. This allows us to keep the basic dts[i] files up-to-date with the ones in kernel, but at the same time allowing the u-boot to add its own properties to the existing nodes.
Also add missing mmc alias to dts nodes to avoid below debug warning.
mmc_bind: alias ret=-2, devnum=-1mmc_bind: alias ret=-2, devnum=-1
---
New patch is the series
--- arch/arm/dts/meson-axg-s400-u-boot.dtsi | 16 ++++++++++++++++ arch/arm/dts/meson-axg-s400.dts | 9 --------- 2 files changed, 16 insertions(+), 9 deletions(-)
arch/arm/dts/meson-axg-s400-u-boot.dtsi +16 -0
@@ -2,6 +2,22 @@ /* * Copyright (c) 2017 Amlogic, Inc. All rights reserved. */ +/ { + soc { + u-boot,dm-pre-reloc; + }; + + aliases { + serial0 = &uart_AO; + serial1 = &uart_A; + mmc1 = &sd_emmc_b; + mmc2 = &sd_emmc_c; + }; + + chosen { + stdout-path = "serial0:115200n8"; + }; +}; /* wifi module */ &sd_emmc_b {
arch/arm/dts/meson-axg-s400.dts +0 -9
@@ -55,11 +55,6 @@ }; }; - aliases { - serial0 = &uart_AO; - serial1 = &uart_A; - }; - linein: audio-codec at 0 { #sound-dai-cells = <0>; compatible = "everest,es7241";
@@ -100,10 +95,6 @@ reset-gpios = <&gpio BOOT_9 GPIO_ACTIVE_LOW>; }; - chosen { - stdout-path = "serial0:115200n8"; - }; - memory at 0 { device_type = "memory"; reg = <0x0 0x0 0x0 0x40000000>;
Signature · 1 line
2.25.0