Skip to contentSkip to conversation

Add Support for eMMC boot in AM65x and J721e

PATCH Superseded Faiz Abbas 9 participants 57 messages Jan 24, 2020 – Feb 18, 2020

Subsystems (5)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Faiz Abbas

author
#0 lore raw

v2 cover Add Support for eMMC boot in AM65x and J721e

The following patches add support for eMMC boot in TI's Am65x and J721e devices.

v2:
1. Reordered the patches according to Lokesh's preference
2. Fixed patch 2 breaking platforms where DM_MMC is not enabled.

Faiz Abbas (10):
mmc: Add a saved_clock member
mmc: Add init() API
mmc: Merge SD_LEGACY and MMC_LEGACY bus modes
mmc: sdhci: Expose sdhci_init() as non-static
mmc: am654_sdhci: Update output tap delay writes
mmc: am654_sdhci: Implement workaround for card detect
spl: mmc: Fix spl_mmc_get_uboot_raw_sector() implementation
arm: K3: sysfw-loader: Add a config_pm_pre_callback()
configs: am65x_evm: Add CONFIG_SUPPORT_EMMC_BOOT
configs: j721e_evm: Add Support for eMMC boot

 arch/arm/dts/k3-am65-main.dtsi               |  12 ++-
 arch/arm/dts/k3-am654-base-board-u-boot.dtsi |  11 +-
 arch/arm/dts/k3-j721e-main.dtsi              |  15 ++-
 arch/arm/mach-imx/imx8/image.c               |   3 +-
 arch/arm/mach-k3/am6_init.c                  |  33 +++++-
 arch/arm/mach-k3/include/mach/sysfw-loader.h |   2 +-
 arch/arm/mach-k3/j721e_init.c                |  33 +++++-
 arch/arm/mach-k3/sysfw-loader.c              |   6 +-
 common/spl/spl_mmc.c                         |  11 +-
 configs/am65x_evm_a53_defconfig              |   1 +
 configs/am65x_evm_r5_defconfig               |   1 +
 configs/j721e_evm_a72_defconfig              |   3 +
 configs/j721e_evm_r5_defconfig               |   3 +
 drivers/mmc/am654_sdhci.c                    | 105 ++++++++++++++++---
 drivers/mmc/fsl_esdhc_imx.c                  |   1 -
 drivers/mmc/mmc.c                            |  31 +++---
 drivers/mmc/omap_hsmmc.c                     |   1 -
 drivers/mmc/sdhci.c                          |   2 +-
 drivers/mmc/zynq_sdhci.c                     |   1 -
 include/configs/am65x_evm.h                  |   2 -
 include/mmc.h                                |   9 +-
 include/sdhci.h                              |   1 +
 22 files changed, 235 insertions(+), 52 deletions(-)
Signature · 1 line
2.19.2
author
#1 lore raw

PATCH v2 1/10 mmc: Add a saved_clock member

Add a saved_clock member to struct mmc to store the previous clock speed in the clock needs to be stopped for some time.

---
 include/mmc.h | 1 +
 1 file changed, 1 insertion(+)
include/mmc.h +1 -0
index b5cb514f57..2f21dbf1b7 100644
@@ -602,6 +602,7 @@ struct mmc {
 	bool clk_disable; /* true if the clock can be turned off */
 	uint bus_width;
 	uint clock;
+	uint saved_clock;
 	enum mmc_voltage signal_voltage;
 	uint card_caps;
 	uint host_caps;
Signature · 1 line
2.19.2
#2 lore raw

PATCH v2 1/10 mmc: Add a saved_clock member

Quoted 2 lines · Faiz Abbas

Add a saved_clock member to struct mmc to store the previous clock speed in the clock needs to be stopped for some time.

I think that it doesn't need to add saved_clock for mmc member. This is for only yours. Does it impossible to add saved_clock in platdata?

And i'm not sure but mmc->tran_speed should be kept previous speed. I will check it

Best Regards,
Jaehoon Chung

Quoted 20 lines
---
 include/mmc.h | 1 +
 1 file changed, 1 insertion(+)
include/mmc.h +1 -0
index b5cb514f57..2f21dbf1b7 100644
@@ -602,6 +602,7 @@ struct mmc {
 	bool clk_disable; /* true if the clock can be turned off */
 	uint bus_width;
 	uint clock;
+	uint saved_clock;
 	enum mmc_voltage signal_voltage;
 	uint card_caps;
 	uint host_caps;
author
#3 lore raw

PATCH v2 2/10 mmc: Add init() API

In reply to Faiz Abbas

Add an init() API for platform specific init() operations.

---
 drivers/mmc/mmc.c | 13 ++++++-------
 include/mmc.h     |  7 +++++++
 2 files changed, 13 insertions(+), 7 deletions(-)
drivers/mmc/mmc.c +6 -7
index d43983d4a6..50df8c8626 100644
@@ -2787,14 +2787,13 @@ int mmc_get_op_cond(struct mmc *mmc)
 	}
 	if (err)
 		return err;
-
 #if CONFIG_IS_ENABLED(DM_MMC)
-	/* The device has already been probed ready for use */
-#else
-	/* made sure it's not NULL earlier */
-	err = mmc->cfg->ops->init(mmc);
-	if (err)
-		return err;
+	struct dm_mmc_ops *ops = mmc_get_ops(mmc->dev);
+	if (ops->init) {
+		err = ops->init(mmc->dev);
+		if (err)
+			return err;
+	}
 #endif
 	mmc->ddr_mode = 0;
 
include/mmc.h +7 -0
index 2f21dbf1b7..6aef125f25 100644
@@ -406,6 +406,13 @@ struct mmc;
 
 #if CONFIG_IS_ENABLED(DM_MMC)
 struct dm_mmc_ops {
+	/**
+	 * init() - platform specific initialization for the host controller
+	 *
+	 * @dev:	Device to init
+	 * @return 0 if Ok, -ve if error
+	 */
+	int (*init)(struct udevice *dev);
 	/**
 	 * send_cmd() - Send a command to the MMC device
 	 *
Signature · 1 line
2.19.2
#4 lore raw

PATCH v2 2/10 mmc: Add init() API

Quoted 2 lines · Faiz Abbas

Add an init() API for platform specific init() operations.

Could you describe why this cannot be done in the probe callback? It's not easily visible as the function you changed (mmc_get_op_cond) doesn't even have a comment to describe what it does...

In general, I think commit messages could be more detailed than one line. If only to make it easier in the future to recap why things have been done.

Quoted 14 lines
---
 drivers/mmc/mmc.c | 13 ++++++-------
 include/mmc.h     |  7 +++++++
 2 files changed, 13 insertions(+), 7 deletions(-)
drivers/mmc/mmc.c +0 -0
index d43983d4a6..50df8c8626 100644
@@ -2787,14 +2787,13 @@ int mmc_get_op_cond(struct mmc *mmc)
        }

drivers/mmc/mmc.c int mmc_get_op_cond(struct mmc *mmc) · line 2797

Quoted 10 lines
drivers/mmc/mmc.c +0 -7
        if (err)
                return err;
-
 #if CONFIG_IS_ENABLED(DM_MMC)
-       /* The device has already been probed ready for use */
-#else
-       /* made sure it's not NULL earlier */
-       err = mmc->cfg->ops->init(mmc);
-       if (err)
-               return err;

You're removing the init code for non-DM MMC here and did not describe it in the commit message. Is this change intended at all?

Regards,
Simon

Quoted 30 lines
drivers/mmc/mmc.c +6 -0
+       struct dm_mmc_ops *ops = mmc_get_ops(mmc->dev);
+       if (ops->init) {
+               err = ops->init(mmc->dev);
+               if (err)
+                       return err;
+       }
 #endif
        mmc->ddr_mode = 0;
 
include/mmc.h +7 -1
index 2f21dbf1b7..6aef125f25 100644
@@ -406,6 +406,13 @@ struct mmc;
 
 #if CONFIG_IS_ENABLED(DM_MMC)
 struct dm_mmc_ops {
+       /**
+        * init() - platform specific initialization for the host controller
+        *
+        * @dev:        Device to init
+        * @return 0 if Ok, -ve if error
+        */
+       int (*init)(struct udevice *dev);
        /**
         * send_cmd() - Send a command to the MMC device
         *
--

2.19.2

#5 lore raw

PATCH v2 2/10 mmc: Add init() API

Forgot to ask: why isn't the subsystem maintainer on CC?
If you would use patman to send patches or at least the get_maintainer script, he would have been...

Regards,
Simon

Quoted 73 lines · Simon Goldschmidt
Quoted 2 lines · Faiz Abbas

Add an init() API for platform specific init() operations.

Could you describe why this cannot be done in the probe callback? It's not easily visible as the function you changed (mmc_get_op_cond) doesn't even have a comment to describe what it does...

In general, I think commit messages could be more detailed than one line. If only to make it easier in the future to recap why things have been done.

Quoted 14 lines
---
 drivers/mmc/mmc.c | 13 ++++++-------
 include/mmc.h     |  7 +++++++
 2 files changed, 13 insertions(+), 7 deletions(-)
drivers/mmc/mmc.c +0 -0
index d43983d4a6..50df8c8626 100644
@@ -2787,14 +2787,13 @@ int mmc_get_op_cond(struct mmc *mmc)
        }

drivers/mmc/mmc.c int mmc_get_op_cond(struct mmc *mmc) · line 2797

Quoted 10 lines
drivers/mmc/mmc.c +0 -7
        if (err)
                return err;
-
 #if CONFIG_IS_ENABLED(DM_MMC)
-       /* The device has already been probed ready for use */
-#else
-       /* made sure it's not NULL earlier */
-       err = mmc->cfg->ops->init(mmc);
-       if (err)
-               return err;

You're removing the init code for non-DM MMC here and did not describe it in the commit message. Is this change intended at all?

Regards,
Simon

Quoted 30 lines
drivers/mmc/mmc.c +6 -0
+       struct dm_mmc_ops *ops = mmc_get_ops(mmc->dev);
+       if (ops->init) {
+               err = ops->init(mmc->dev);
+               if (err)
+                       return err;
+       }
 #endif
        mmc->ddr_mode = 0;
 
include/mmc.h +7 -1
index 2f21dbf1b7..6aef125f25 100644
@@ -406,6 +406,13 @@ struct mmc;
 
 #if CONFIG_IS_ENABLED(DM_MMC)
 struct dm_mmc_ops {
+       /**
+        * init() - platform specific initialization for the host controller
+        *
+        * @dev:        Device to init
+        * @return 0 if Ok, -ve if error
+        */
+       int (*init)(struct udevice *dev);
        /**
         * send_cmd() - Send a command to the MMC device
         *
--

2.19.2

author
#6 lore raw

PATCH v2 2/10 mmc: Add init() API

Hi,

+Lokesh, Tom

Quoted 4 lines · Simon Goldschmidt

Forgot to ask: why isn't the subsystem maintainer on CC?
If you would use patman to send patches or at least the get_maintainer script, he would have been...

I did use get_maintainer for my send-email CC list but everyone other than Michal seems to have been dropped. Here is an excerpt from the email header I received:

From: Faiz Abbas <[email protected]>
To: <[email protected]>
CC: <[email protected]>, <[email protected]>, <[email protected]>,

	<[email protected]>, <[email protected]>

Subject: [PATCH v2 02/10] mmc: Add init() API
Date: Fri, 24 Jan 2020 17:22:44 +0530

But in the patchworks and in your reply, only Michal is remaining:
https://patchwork.ozlabs.org/patch/1228781/

Michal,

What do you see in your message header? Does it have other people copied?

Thanks,
Faiz

#7 lore raw

PATCH v2 2/10 mmc: Add init() API

Quoted 22 lines · Faiz Abbas

Hi,

+Lokesh, Tom

Quoted 4 lines · Simon Goldschmidt

Forgot to ask: why isn't the subsystem maintainer on CC?
If you would use patman to send patches or at least the get_maintainer script, he would have been...

I did use get_maintainer for my send-email CC list but everyone other than Michal seems to have been dropped. Here is an excerpt from the email header I received:

From: Faiz Abbas <[email protected]>
To: <[email protected]>
CC: <[email protected]>, <[email protected]>, <[email protected]>,

	<[email protected]>, <[email protected]>

Subject: [PATCH v2 02/10] mmc: Add init() API
Date: Fri, 24 Jan 2020 17:22:44 +0530

Quoted 6 lines

But in the patchworks and in your reply, only Michal is remaining:
https://patchwork.ozlabs.org/patch/1228781/

Michal,

What do you see in your message header? Does it have other people copied?

[u-boot]$ ./scripts/get_maintainer.pl -f drivers/mmc/mmc.c Peng Fan <[email protected]> (maintainer:MMC) u-boot at lists.denx.de (open list)

I see Peng there.

Thanks,
Michal

author
#8 lore raw

PATCH v2 2/10 mmc: Add init() API

Hi Michal,

Quoted 28 lines · Michal Simek
Quoted 27 lines · Faiz Abbas

Hi,

+Lokesh, Tom

Quoted 4 lines · Simon Goldschmidt

Forgot to ask: why isn't the subsystem maintainer on CC?
If you would use patman to send patches or at least the get_maintainer script, he would have been...

I did use get_maintainer for my send-email CC list but everyone other than Michal seems to have been dropped. Here is an excerpt from the email header I received:

From: Faiz Abbas <[email protected]>
To: <[email protected]>
CC: <[email protected]>, <[email protected]>, <[email protected]>,

	<[email protected]>, <[email protected]>

Subject: [PATCH v2 02/10] mmc: Add init() API
Date: Fri, 24 Jan 2020 17:22:44 +0530

But in the patchworks and in your reply, only Michal is remaining:
https://patchwork.ozlabs.org/patch/1228781/

Michal,

Quoted 8 lines
Quoted 1 line

What do you see in your message header? Does it have other people copied?

[u-boot]$ ./scripts/get_maintainer.pl -f drivers/mmc/mmc.c Peng Fan <[email protected]> (maintainer:MMC) u-boot at lists.denx.de (open list)

I see Peng there.

You misunderstood. I am not asking if you see Peng in the get_maintainer output. Do you see him CC'd in the original patch email?

Thanks,
Faiz

#9 lore raw

PATCH v2 2/10 mmc: Add init() API

Quoted 37 lines · Faiz Abbas

Hi Michal,

Quoted 34 lines · Michal Simek
Quoted 22 lines · Faiz Abbas

Hi,

+Lokesh, Tom

Quoted 4 lines · Simon Goldschmidt

Forgot to ask: why isn't the subsystem maintainer on CC?
If you would use patman to send patches or at least the get_maintainer script, he would have been...

I did use get_maintainer for my send-email CC list but everyone other than Michal seems to have been dropped. Here is an excerpt from the email header I received:

From: Faiz Abbas <[email protected]>
To: <[email protected]>
CC: <[email protected]>, <[email protected]>, <[email protected]>,

	<[email protected]>, <[email protected]>

Subject: [PATCH v2 02/10] mmc: Add init() API
Date: Fri, 24 Jan 2020 17:22:44 +0530

Quoted 6 lines

But in the patchworks and in your reply, only Michal is remaining:
https://patchwork.ozlabs.org/patch/1228781/

Michal,

What do you see in your message header? Does it have other people copied?

[u-boot]$ ./scripts/get_maintainer.pl -f drivers/mmc/mmc.c Peng Fan <[email protected]> (maintainer:MMC) u-boot at lists.denx.de (open list)

Quoted 5 lines
Quoted 2 lines

I see Peng there.

You misunderstood. I am not asking if you see Peng in the get_maintainer output. Do you see him CC'd in the original patch email?

Nope. I can't see him there.

M

#10 lore raw

PATCH v2 2/10 mmc: Add init() API

Quoted 38 lines · Michal Simek
Quoted 37 lines · Faiz Abbas

Hi Michal,

Quoted 34 lines · Michal Simek
Quoted 22 lines · Faiz Abbas

Hi,

+Lokesh, Tom

Quoted 4 lines · Simon Goldschmidt

Forgot to ask: why isn't the subsystem maintainer on CC?
If you would use patman to send patches or at least the get_maintainer script, he would have been...

I did use get_maintainer for my send-email CC list but everyone other than Michal seems to have been dropped. Here is an excerpt from the email header I received:

From: Faiz Abbas <[email protected]>
To: <[email protected]>
CC: <[email protected]>, <[email protected]>, <[email protected]>,

	<[email protected]>, <[email protected]>

Subject: [PATCH v2 02/10] mmc: Add init() API
Date: Fri, 24 Jan 2020 17:22:44 +0530

Quoted 6 lines

But in the patchworks and in your reply, only Michal is remaining:
https://patchwork.ozlabs.org/patch/1228781/

Michal,

What do you see in your message header? Does it have other people copied?

[u-boot]$ ./scripts/get_maintainer.pl -f drivers/mmc/mmc.c Peng Fan <[email protected]> (maintainer:MMC) u-boot at lists.denx.de (open list)

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

I see Peng there.

You misunderstood. I am not asking if you see Peng in the get_maintainer output. Do you see him CC'd in the original patch email?

Nope. I can't see him there.

Wolfgang, is there some mailman setting that needs tweaking or looking at here? Thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200130/bbe1d7b4/attachment.sig>
#11 lore raw

PATCH v2 2/10 mmc: Add init() API

Tom Rini <[email protected]> schrieb am Do., 30. Jan. 2020, 16:32:

Quoted 45 lines · Michal Simek
Quoted 12 lines · Faiz Abbas
Quoted 11 lines

Hi Michal,

Quoted 8 lines · Michal Simek
Quoted 7 lines · Faiz Abbas

Hi,

+Lokesh, Tom

Quoted 2 lines · Simon Goldschmidt

Forgot to ask: why isn't the subsystem maintainer on CC? If you would use patman to send patches or at least the

get_maintainer script,

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 2 lines

he would have been...

I did use get_maintainer for my send-email CC list but everyone other than Michal seems to have been dropped. Here is an excerpt from the email header I received:

From: Faiz Abbas <[email protected]>
To: <[email protected]>
CC: <[email protected]>, <[email protected]>, <

lokeshvutla at ti.com>,

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

<[email protected]>, <[email protected]>
Subject: [PATCH v2 02/10] mmc: Add init() API
Date: Fri, 24 Jan 2020 17:22:44 +0530

But in the patchworks and in your reply, only Michal is remaining:
https://patchwork.ozlabs.org/patch/1228781/

Michal,

What do you see in your message header? Does it have other people

copied?

Quoted 8 lines
Quoted 8 lines
Quoted 7 lines

[u-boot]$ ./scripts/get_maintainer.pl -f drivers/mmc/mmc.c Peng Fan <[email protected]> (maintainer:MMC) u-boot at lists.denx.de (open list)

I see Peng there.

Quoted 9 lines
Quoted 1 line
Quoted 1 line

You misunderstood. I am not asking if you see Peng in the

get_maintainer

Quoted 3 lines
Quoted 1 line

output. Do you see him CC'd in the original patch email?

Nope. I can't see him there.

Wolfgang, is there some mailman setting that needs tweaking or looking at here? Thanks!

Can this be a mailman issue? If Michal was CCed, is mailman involved in the way to him? I would have thought that mail got delivered directly.

Regards,
Simon

#12 lore raw

PATCH v2 2/10 mmc: Add init() API

Quoted 51 lines · Simon Goldschmidt

Tom Rini <[email protected]> schrieb am Do., 30. Jan. 2020, 16:32:

Quoted 49 lines · Michal Simek
Quoted 12 lines · Faiz Abbas
Quoted 11 lines

Hi Michal,

Quoted 8 lines · Michal Simek
Quoted 7 lines · Faiz Abbas

Hi,

+Lokesh, Tom

Quoted 2 lines · Simon Goldschmidt

Forgot to ask: why isn't the subsystem maintainer on CC? If you would use patman to send patches or at least the

get_maintainer script,

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 2 lines

he would have been...

I did use get_maintainer for my send-email CC list but everyone other than Michal seems to have been dropped. Here is an excerpt from the email header I received:

From: Faiz Abbas <[email protected]>
To: <[email protected]>
CC: <[email protected]>, <[email protected]>, <

lokeshvutla at ti.com>,

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

<[email protected]>, <[email protected]>
Subject: [PATCH v2 02/10] mmc: Add init() API
Date: Fri, 24 Jan 2020 17:22:44 +0530

But in the patchworks and in your reply, only Michal is remaining:
https://patchwork.ozlabs.org/patch/1228781/

Michal,

What do you see in your message header? Does it have other people

copied?

Quoted 9 lines
Quoted 9 lines
Quoted 7 lines

[u-boot]$ ./scripts/get_maintainer.pl -f drivers/mmc/mmc.c Peng Fan <[email protected]> (maintainer:MMC) u-boot at lists.denx.de (open list)

I see Peng there.

You misunderstood. I am not asking if you see Peng in the

get_maintainer

Quoted 2 lines
Quoted 1 line

output. Do you see him CC'd in the original patch email?

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Nope. I can't see him there.

Wolfgang, is there some mailman setting that needs tweaking or looking at here? Thanks!

Can this be a mailman issue? If Michal was CCed, is mailman involved in the way to him? I would have thought that mail got delivered directly.

I was thinking about the setting on if you get your own messages / ones you're on CC to or not, and if that was the copy say in Michal's inbox or U-Boot folder.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200130/dafbdd9c/attachment.sig>
#13 lore raw

PATCH v2 2/10 mmc: Add init() API

Dear Tom,

Quoted 6 lines · In message <20200130153827.GY13379@bill-the-cat> you wrote:
Quoted 2 lines

way to him? I would have thought that mail got delivered directly.

I was thinking about the setting on if you get your own messages / ones you're on CC to or not, and if that was the copy say in Michal's inbox or U-Boot folder.

Yes, but thisis a secondaryquestion here. The more interesting one (especially for patchwork etc.) is where the Cc: header lost the additional addresses - was it at the sender's MUA, the sender's MTA or on lists.denx.de ; I don't really trust mailman if it's getting dark outside, but I have no good way to check this.

Best regards,

Wolfgang Denk

Signature · 7 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
The Buddha, the Godhead, resides quite as comfortably in the circuits
of a digital computer or the gears of a cycle transmission as he does
at the top of a mountain or in the petals of a flower.
            - R.  Pirsig, "Zen and the Art of Motorcycle Maintenance"
#14 lore raw

PATCH v2 2/10 mmc: Add init() API

In reply to Tom Rini

Michal,

Quoted 58 lines · Tom Rini
Quoted 57 lines · Simon Goldschmidt

Tom Rini <[email protected]> schrieb am Do., 30. Jan. 2020, 16:32:

Quoted 54 lines · Michal Simek
Quoted 12 lines · Faiz Abbas
Quoted 11 lines

Hi Michal,

Quoted 8 lines · Michal Simek
Quoted 7 lines · Faiz Abbas

Hi,

+Lokesh, Tom

Quoted 2 lines · Simon Goldschmidt

Forgot to ask: why isn't the subsystem maintainer on CC? If you would use patman to send patches or at least the

get_maintainer script,

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 2 lines

he would have been...

I did use get_maintainer for my send-email CC list but everyone other than Michal seems to have been dropped. Here is an excerpt from the email header I received:

From: Faiz Abbas <[email protected]>
To: <[email protected]>
CC: <[email protected]>, <[email protected]>, <

lokeshvutla at ti.com>,

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

<[email protected]>, <[email protected]>
Subject: [PATCH v2 02/10] mmc: Add init() API
Date: Fri, 24 Jan 2020 17:22:44 +0530

But in the patchworks and in your reply, only Michal is remaining:
https://patchwork.ozlabs.org/patch/1228781/

Michal,

What do you see in your message header? Does it have other people

copied?

Quoted 9 lines
Quoted 9 lines
Quoted 7 lines

[u-boot]$ ./scripts/get_maintainer.pl -f drivers/mmc/mmc.c Peng Fan <[email protected]> (maintainer:MMC) u-boot at lists.denx.de (open list)

I see Peng there.

You misunderstood. I am not asking if you see Peng in the

get_maintainer

Quoted 3 lines
Quoted 1 line

output. Do you see him CC'd in the original patch email?

Nope. I can't see him there.

Wolfgang, is there some mailman setting that needs tweaking or looking at here? Thanks!

Quoted 6 lines
Quoted 2 lines

Can this be a mailman issue? If Michal was CCed, is mailman involved in the way to him? I would have thought that mail got delivered directly.

I was thinking about the setting on if you get your own messages / ones you're on CC to or not, and if that was the copy say in Michal's inbox or U-Boot folder.

Can you confirm how you received the message, directly or through the list?

The TI e-mail team says the CCs were not removed prior to leaving TI.

Thanks,
Sekhar

#15 lore raw

PATCH v2 2/10 mmc: Add init() API

Quoted 64 lines · Sekhar Nori

Michal,

Quoted 61 lines · Tom Rini
Quoted 59 lines · Simon Goldschmidt

Tom Rini <[email protected]> schrieb am Do., 30. Jan. 2020, 16:32:

Quoted 45 lines · Michal Simek
Quoted 12 lines · Faiz Abbas
Quoted 11 lines

Hi Michal,

Quoted 8 lines · Michal Simek
Quoted 7 lines · Faiz Abbas

Hi,

+Lokesh, Tom

Quoted 2 lines · Simon Goldschmidt

Forgot to ask: why isn't the subsystem maintainer on CC? If you would use patman to send patches or at least the

get_maintainer script,

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 2 lines

he would have been...

I did use get_maintainer for my send-email CC list but everyone other than Michal seems to have been dropped. Here is an excerpt from the email header I received:

From: Faiz Abbas <[email protected]>
To: <[email protected]>
CC: <[email protected]>, <[email protected]>, <

lokeshvutla at ti.com>,

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

<[email protected]>, <[email protected]>
Subject: [PATCH v2 02/10] mmc: Add init() API
Date: Fri, 24 Jan 2020 17:22:44 +0530

But in the patchworks and in your reply, only Michal is remaining:
https://patchwork.ozlabs.org/patch/1228781/

Michal,

What do you see in your message header? Does it have other people

copied?

Quoted 8 lines
Quoted 8 lines
Quoted 7 lines

[u-boot]$ ./scripts/get_maintainer.pl -f drivers/mmc/mmc.c Peng Fan <[email protected]> (maintainer:MMC) u-boot at lists.denx.de (open list)

I see Peng there.

Quoted 9 lines
Quoted 1 line
Quoted 1 line

You misunderstood. I am not asking if you see Peng in the

get_maintainer

Quoted 3 lines
Quoted 1 line

output. Do you see him CC'd in the original patch email?

Nope. I can't see him there.

Wolfgang, is there some mailman setting that needs tweaking or looking at here? Thanks!

Can this be a mailman issue? If Michal was CCed, is mailman involved in the way to him? I would have thought that mail got delivered directly.

Quoted 7 lines
Quoted 3 lines

I was thinking about the setting on if you get your own messages / ones you're on CC to or not, and if that was the copy say in Michal's inbox or U-Boot folder.

Can you confirm how you received the message, directly or through the list?

The TI e-mail team says the CCs were not removed prior to leaving TI.

It looks like it went through list.

M

#16 lore raw

PATCH v2 2/10 mmc: Add init() API

In reply to Simon Goldschmidt

Dear Simon,

Quoted 3 lines · In message <CAAh8qswkmJhpgSZx4KcGiXrEugS47M+_VB7Nkcs27kpDLpVcAQ@mail.gmail.com>…

Can this be a mailman issue? If Michal was CCed, is mailman involved in the way to him? I would have thought that mail got delivered directly.

Correct, it's the sender's MTA who handles the action transmission. The question here is if there was actually more than the single address in the Cc: header when the message to the list got sent. For example, it would be interesting to know if any of the people who were supposed to be on the Cc: list (but now don't show up) got a mesage directly, or only through the mailing list.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"355/113 -- Not the famous irrational number PI,  but  an  incredible
simulation!"
#17 lore raw

PATCH v2 2/10 mmc: Add init() API

In reply to Tom Rini

Dear Tom,

Quoted 8 lines · In message <20200130153216.GX13379@bill-the-cat> you wrote:
Quoted 5 lines
Quoted 3 lines

You misunderstood. I am not asking if you see Peng in the get_maintainer output. Do you see him CC'd in the original patch email?

Nope. I can't see him there.

Wolfgang, is there some mailman setting that needs tweaking or looking at here? Thanks!

I'm not sure. I cannot see any trae of the Cc: s at list.denx.de, as this is handled by the poster's MTA. I can only see the posting as it arrived at the list server, and this has just

From: Faiz Abbas <[email protected]>
To: <[email protected]>
Cc: michal.simek at xilinx.com

It would be interesting to check the MTA los on the sender side if the Cc:s were actually sent...

Best regards,

Wolfgang Denk

Signature · 8 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Ill-chosen abstraction is particularly evident in the design  of  the
ADA  runtime  system.  The  interface to the ADA runtime system is so
opaque that it is impossible to model  or  predict  its  performance,
making it effectively useless for real-time systems.
                              - Marc D.  Donner and David H. Jameson.
#18 lore raw

PATCH v2 2/10 mmc: Add init() API

In reply to Faiz Abbas

Faiz Abbas <[email protected]> schrieb am Do., 30. Jan. 2020, 16:01:

Quoted 18 lines

Hi,

+Lokesh, Tom

Quoted 2 lines · Simon Goldschmidt

Forgot to ask: why isn't the subsystem maintainer on CC?
If you would use patman to send patches or at least the get_maintainer

script,

Quoted 2 lines

he would have been...

I did use get_maintainer for my send-email CC list but everyone other than Michal seems to have been dropped. Here is an excerpt from the email header I received:

From: Faiz Abbas <[email protected]>
To: <[email protected]>
CC: <[email protected]>, <[email protected]>, <[email protected]>,

Quoted 7 lines
        <[email protected]>, <[email protected]>

Subject: [PATCH v2 02/10] mmc: Add init() API
Date: Fri, 24 Jan 2020 17:22:44 +0530

But in the patchworks and in your reply, only Michal is remaining:
https://patchwork.ozlabs.org/patch/1228781/

I hit reply all in the gmail web interface. My header only shows Michal.

Regards,
Simon

Quoted 9 lines

Michal,

What do you see in your message header? Does it have other people copied?

Thanks,
Faiz

author
#19 lore raw

PATCH v2 2/10 mmc: Add init() API

In reply to Simon Goldschmidt

Hi Simon,

Quoted 7 lines · Simon Goldschmidt
Quoted 2 lines · Faiz Abbas

Add an init() API for platform specific init() operations.

Could you describe why this cannot be done in the probe callback? It's not easily visible as the function you changed (mmc_get_op_cond) doesn't even have a comment to describe what it does...

The reason is detailed in 06/10 patch description. probe() is always called for all MMC instances. I only want to switch on power (by calling sdhci_init()) and suffer the 1 second wait time when there is actually a card in the slot and user wants to access it.

Quoted 4 lines

In general, I think commit messages could be more detailed than one line. If only to make it easier in the future to recap why things have been done.

You're right. I will add a more detailed patch description in v2.

Thanks,
Faiz

#20 lore raw

PATCH v2 2/10 mmc: Add init() API

Quoted 18 lines

Subject: Re: [PATCH v2 02/10] mmc: Add init() API

Hi Simon,

Quoted 7 lines · Simon Goldschmidt
Quoted 2 lines · Faiz Abbas

Add an init() API for platform specific init() operations.

Could you describe why this cannot be done in the probe callback? It's not easily visible as the function you changed (mmc_get_op_cond) doesn't even have a comment to describe what it does...

The reason is detailed in 06/10 patch description. probe() is always called for all MMC instances. I only want to switch on power (by calling sdhci_init()) and suffer the 1 second wait time when there is actually a card in the slot and user wants to access it.

Quoted 1 line
Quoted 6 lines
Quoted 2 lines

In general, I think commit messages could be more detailed than one line. If only to make it easier in the future to recap why things have been

done.

Quoted 1 line

You're right. I will add a more detailed patch description in v2.

This patch is v2. Please v3.

Could a quirk be added in probe and if card not there, just bypass? Or you want quick boot to avoid probe all the controllers?

Regards,
Peng.

Quoted 3 lines

Thanks,
Faiz

author
#21 lore raw

PATCH v2 2/10 mmc: Add init() API

Hi Peng,

Quoted 23 lines · Peng Fan
Quoted 23 lines

Subject: Re: [PATCH v2 02/10] mmc: Add init() API

Hi Simon,

Quoted 7 lines · Simon Goldschmidt
Quoted 2 lines · Faiz Abbas

Add an init() API for platform specific init() operations.

Could you describe why this cannot be done in the probe callback? It's not easily visible as the function you changed (mmc_get_op_cond) doesn't even have a comment to describe what it does...

The reason is detailed in 06/10 patch description. probe() is always called for all MMC instances. I only want to switch on power (by calling sdhci_init()) and suffer the 1 second wait time when there is actually a card in the slot and user wants to access it.

Quoted 3 lines

In general, I think commit messages could be more detailed than one line. If only to make it easier in the future to recap why things have been

done.

Quoted 1 line
Quoted 7 lines
Quoted 1 line

You're right. I will add a more detailed patch description in v2.

This patch is v2. Please v3.

Could a quirk be added in probe and if card not there, just bypass? Or you want quick boot to avoid probe all the controllers?

The issue is that we need to wait for 1 second to detect the card itself. I want to move that delay out from probe().

BTW did you receive this mail directly or through the list? I had CC'd you but its not there in the patchwork headers.

Thanks,
Faiz

#22 lore raw

PATCH v2 2/10 mmc: Add init() API

Quoted 33 lines

Subject: Re: [PATCH v2 02/10] mmc: Add init() API

Hi Peng,

Quoted 4 lines · Peng Fan
Quoted 4 lines

Subject: Re: [PATCH v2 02/10] mmc: Add init() API

Hi Simon,

Quoted 8 lines
Quoted 8 lines · Simon Goldschmidt
Quoted 7 lines · Faiz Abbas
Quoted 2 lines

Add an init() API for platform specific init() operations.

Could you describe why this cannot be done in the probe callback? It's not easily visible as the function you changed (mmc_get_op_cond) doesn't even have a comment to describe what it

does...

Quoted 15 lines
Quoted 14 lines

The reason is detailed in 06/10 patch description. probe() is always called for all MMC instances. I only want to switch on power (by calling
sdhci_init()) and suffer the 1 second wait time when there is actually a card in the slot and user wants to access it.

Quoted 4 lines

In general, I think commit messages could be more detailed than one line. If only to make it easier in the future to recap why things have been

done.

Quoted 1 line

You're right. I will add a more detailed patch description in v2.

Quoted 8 lines
Quoted 5 lines

This patch is v2. Please v3.

Could a quirk be added in probe and if card not there, just bypass? Or you want quick boot to avoid probe all the controllers?

The issue is that we need to wait for 1 second to detect the card itself. I want to move that delay out from probe().

Understand. Then I am ok for patch.

Please add more info in commit log in new version patchset.

Quoted 3 lines

BTW did you receive this mail directly or through the list? I had CC'd you but its not there in the patchwork headers.

I am in the cc list of your first mail, but not from Simon's reply mail.

Thanks,
Peng.

Quoted 3 lines

Thanks,
Faiz

author
#23 lore raw

PATCH v2 2/10 mmc: Add init() API

Hi Tom, Wolfgang,

Quoted 44 lines · Peng Fan
Quoted 33 lines

Subject: Re: [PATCH v2 02/10] mmc: Add init() API

Hi Peng,

Quoted 4 lines · Peng Fan
Quoted 4 lines

Subject: Re: [PATCH v2 02/10] mmc: Add init() API

Hi Simon,

Quoted 8 lines
Quoted 8 lines · Simon Goldschmidt
Quoted 7 lines · Faiz Abbas
Quoted 2 lines

Add an init() API for platform specific init() operations.

Could you describe why this cannot be done in the probe callback? It's not easily visible as the function you changed (mmc_get_op_cond) doesn't even have a comment to describe what it

does...

Quoted 15 lines
Quoted 14 lines

The reason is detailed in 06/10 patch description. probe() is always called for all MMC instances. I only want to switch on power (by calling
sdhci_init()) and suffer the 1 second wait time when there is actually a card in the slot and user wants to access it.

Quoted 4 lines

In general, I think commit messages could be more detailed than one line. If only to make it easier in the future to recap why things have been

done.

Quoted 1 line

You're right. I will add a more detailed patch description in v2.

Quoted 8 lines
Quoted 5 lines

This patch is v2. Please v3.

Could a quirk be added in probe and if card not there, just bypass? Or you want quick boot to avoid probe all the controllers?

The issue is that we need to wait for 1 second to detect the card itself. I want to move that delay out from probe().

Understand. Then I am ok for patch.

Quoted 8 lines

Please add more info in commit log in new version patchset.

Quoted 3 lines

BTW did you receive this mail directly or through the list? I had CC'd you but its not there in the patchwork headers.

I am in the cc list of your first mail, but not from Simon's reply mail.

So Peng got the email but the list is dropping CCs after it gets them. How do I avoid this in the future? Should I always add maintainers in To?

Thanks,
Faiz

#24 lore raw

PATCH v2 2/10 mmc: Add init() API

Dear Faiz,

Quoted 5 lines · In message <[email protected]> you wrote:
Quoted 2 lines

I am in the cc list of your first mail, but not from Simon's reply mail.

So Peng got the email but the list is dropping CCs after it gets them. How do I avoid this in the future? Should I always add maintainers in To?

We are investigating this. I _think_ (but this needs to be verified, I just had a short look) that Mailman might try to bee too clever; my speculation is that it might remove addresses from the
Cc: list wich have the "nodupes" option set in their profile. Maybe mailman "thinks" that this is what it should do - otherwise the recipient would receive dupes at least for a reply-to-all, one trough the mailing list and the other through the Cc:

But as mentioned, this needs to be investigated.

I can see this ancient bug report [1], where a reply reads:

In any case, this behavior is intentional by design. Cc:
recipients who are list members with their 'avoid duplicates' option set are removed from the Cc: list to keep that list from growing excessively in long threads with many 'reply-all' replies.

[1] https://bugs.launchpad.net/mailman/+bug/1216960

So apparently a solution/workaoround could be to globally remove the "nodupes" option for all subscribers, but I'm not sure if this is what we should do.

I feel the key problem here is that we expect something from the mailing list that it has not been designed for - the differentiation between "this is just some random posting" and "this is a posting which is specifically addressed to you". this may or may not work, and it depends on several factors - how the mailing list tool works, and how the recipient filters his incoming e-mail.

But I don't have any clever solution either.

Best regards,

Wolfgang Denk

Signature · 6 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
A Sense of humor can help you overlook the unattractive, tolerate the
unpleasant,  cope  with  the  unexpected  and   smile   through   the
unbearable.                                           - Moshe Waldoks
#25 lore raw

PATCH v2 2/10 mmc: Add init() API

Quoted 35 lines · Wolfgang Denk

Dear Faiz,

Quoted 5 lines · In message <[email protected]> you wrote:
Quoted 2 lines

I am in the cc list of your first mail, but not from Simon's reply mail.

So Peng got the email but the list is dropping CCs after it gets them. How do I avoid this in the future? Should I always add maintainers in To?

We are investigating this. I _think_ (but this needs to be verified, I just had a short look) that Mailman might try to bee too clever; my speculation is that it might remove addresses from the
Cc: list wich have the "nodupes" option set in their profile. Maybe mailman "thinks" that this is what it should do - otherwise the recipient would receive dupes at least for a reply-to-all, one trough the mailing list and the other through the Cc:

But as mentioned, this needs to be investigated.

I can see this ancient bug report [1], where a reply reads:

In any case, this behavior is intentional by design. Cc:
recipients who are list members with their 'avoid duplicates' option set are removed from the Cc: list to keep that list from growing excessively in long threads with many 'reply-all' replies.

[1] https://bugs.launchpad.net/mailman/+bug/1216960

So apparently a solution/workaoround could be to globally remove the "nodupes" option for all subscribers, but I'm not sure if this is what we should do.

Quoted 8 lines

I feel the key problem here is that we expect something from the mailing list that it has not been designed for - the differentiation between "this is just some random posting" and "this is a posting which is specifically addressed to you". this may or may not work, and it depends on several factors - how the mailing list tool works, and how the recipient filters his incoming e-mail.

But I don't have any clever solution either.

I'm a little wary of changing the global setting for everyone as well. Perhaps we just need to note the problem happened for now and see if it really happens again in the future, such that we need to consider such a heavy-handed work-around. Thanks for looking into this more!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200210/62ecf3c3/attachment.sig>
#26 lore raw

PATCH v2 2/10 mmc: Add init() API

Dear Tom,

Quoted 5 lines · In message <20200210142800.GJ13379@bill-the-cat> you wrote:

I'm a little wary of changing the global setting for everyone as well. Perhaps we just need to note the problem happened for now and see if it really happens again in the future, such that we need to consider such a heavy-handed work-around. Thanks for looking into this more!

We will continue to look into this a bit deeper; I will report back.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Do not follow where the path may lead....go instead where there is no
path and leave a trail.
#27 lore raw

PATCH v2 2/10 mmc: Add init() API

Dear Tom,

Quoted 7 lines · In message <[email protected]> I wrote:
Quoted 5 lines

I'm a little wary of changing the global setting for everyone as well. Perhaps we just need to note the problem happened for now and see if it really happens again in the future, such that we need to consider such a heavy-handed work-around. Thanks for looking into this more!

We will continue to look into this a bit deeper; I will report back.

Running some more tests confirms that

1) mailman indeed removes entries from the Cc: address list, if these refer to subscribers _and_ these have the "nodupes" flag set;

2) unsetting the "nodupes" option makes the problem go away.

The statement in [1] suggests that this is considered "intentional by design", though I cannot follow the argument that otherwise Cc:
lists would grow in long threads. Apparently there are many different opinions, see for example [3].

The code snippet given in the original bug description [2] is still about the same in the version of mailman which we are running (v2.1.26) so it should be easy to remove the responsible "else" branch...

So an easy work around for the problem is to clear the "nodupes" setting in your subscription - alternatively we can try and patch mailman to behave like we want it.

What do you think should we do?

[1] https://bugs.launchpad.net/mailman/+bug/1216960/comments/1
[2] https://bugs.launchpad.net/mailman/+bug/1216960
[3] https://bugs.launchpad.net/mailman/+bug/266682

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"All my life I wanted to be someone; I guess I should have been  more
specific."                                              - Jane Wagner
#28 lore raw

PATCH v2 2/10 mmc: Add init() API

Dear Tom,

Quoted 4 lines · In message <[email protected]> I wrote:

So an easy work around for the problem is to clear the "nodupes" setting in your subscription - alternatively we can try and patch mailman to behave like we want it.

There is even a clean approach upstream [1]:

[1] https://bazaar.launchpad.net/~mailman-coders/mailman/2.1/revision/1825

Apparently the first RC where this commit is included is mailman 2.1.30rc1; we expect it will take ~ 1 month for v2.1.30 to get released, 2 months max. If it's OK we will jsut wait for this release, then upgrade, and configure with this option set:

1446 # The process which avoids sending a list copy of a message to a member who 1447 # is also directly addressed in To: or Cc: can drop the address from Cc: to 1448 # avoid growing a long Cc: list in long threads. This can be undesirable as 1449 # it can break DKIM signatures and possibly cause confusion. To avoid changes 1450 # to Cc: headers, set the list's drop_cc to No.
1451 DEFAULT_DROP_CC = Yes

Agreed?

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"If a computer can't directly address all the RAM you can  use,  it's
just a toy."         - anonymous comp.sys.amiga posting, non-sequitir
#29 lore raw

PATCH v2 2/10 mmc: Add init() API

Quoted 26 lines · Wolfgang Denk

Dear Tom,

Quoted 4 lines · In message <[email protected]> I wrote:

So an easy work around for the problem is to clear the "nodupes" setting in your subscription - alternatively we can try and patch mailman to behave like we want it.

There is even a clean approach upstream [1]:

[1] https://bazaar.launchpad.net/~mailman-coders/mailman/2.1/revision/1825

Apparently the first RC where this commit is included is mailman 2.1.30rc1; we expect it will take ~ 1 month for v2.1.30 to get released, 2 months max. If it's OK we will jsut wait for this release, then upgrade, and configure with this option set:

1446 # The process which avoids sending a list copy of a message to a member who 1447 # is also directly addressed in To: or Cc: can drop the address from Cc: to 1448 # avoid growing a long Cc: list in long threads. This can be undesirable as 1449 # it can break DKIM signatures and possibly cause confusion. To avoid changes 1450 # to Cc: headers, set the list's drop_cc to No.
1451 DEFAULT_DROP_CC = Yes

Quoted 1 line

Agreed?

Agreed, thanks again!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200211/e25a853d/attachment.sig>
author
#30 lore raw

PATCH v2 3/10 mmc: Merge SD_LEGACY and MMC_LEGACY bus modes

In reply to Faiz Abbas

MMC_LEGACY & SD_LEGACY are not differentiated timings in the spec and don't have any meaningful differences. Therefore, get rid of all references to SD_LEGACY and use MMC_LEGACY to mean both of them.

---
 drivers/mmc/fsl_esdhc_imx.c |  1 -
 drivers/mmc/mmc.c           | 18 ++++++++----------
 drivers/mmc/omap_hsmmc.c    |  1 -
 drivers/mmc/zynq_sdhci.c    |  1 -
 include/mmc.h               |  1 -
 5 files changed, 8 insertions(+), 14 deletions(-)
drivers/mmc/fsl_esdhc_imx.c +0 -1
index 462ad2878a..6555639fdf 100644
@@ -741,7 +741,6 @@ static int esdhc_set_timing(struct mmc *mmc)
 
 	switch (mmc->selected_mode) {
 	case MMC_LEGACY:
-	case SD_LEGACY:
 		esdhc_reset_tuning(mmc);
 		writel(mixctrl, &regs->mixctrl);
 		break;
drivers/mmc/mmc.c +8 -10
index 50df8c8626..c49e892e73 100644
@@ -136,7 +136,6 @@ const char *mmc_mode_name(enum bus_mode mode)
 {
 	static const char *const names[] = {
 	      [MMC_LEGACY]	= "MMC legacy",
-	      [SD_LEGACY]	= "SD Legacy",
 	      [MMC_HS]		= "MMC High Speed (26MHz)",
 	      [SD_HS]		= "SD High Speed (50MHz)",
 	      [UHS_SDR12]	= "UHS SDR12 (25MHz)",
@@ -162,7 +161,6 @@ static uint mmc_mode2freq(struct mmc *mmc, enum bus_mode mode)
 {
 	static const int freqs[] = {
 	      [MMC_LEGACY]	= 25000000,
-	      [SD_LEGACY]	= 25000000,
 	      [MMC_HS]		= 26000000,
 	      [SD_HS]		= 50000000,
 	      [MMC_HS_52]	= 52000000,
@@ -1241,7 +1239,7 @@ static int sd_get_capabilities(struct mmc *mmc)
 	u32 sd3_bus_mode;
 #endif
 
-	mmc->card_caps = MMC_MODE_1BIT | MMC_CAP(SD_LEGACY);
+	mmc->card_caps = MMC_MODE_1BIT | MMC_CAP(MMC_LEGACY);
 
 	if (mmc_host_is_spi(mmc))
 		return 0;
@@ -1354,7 +1352,7 @@ static int sd_set_card_speed(struct mmc *mmc, enum bus_mode mode)
 		return 0;
 
 	switch (mode) {
-	case SD_LEGACY:
+	case MMC_LEGACY:
 		speed = UHS_SDR12_BUS_SPEED;
 		break;
 	case SD_HS:
@@ -1697,7 +1695,7 @@ static const struct mode_width_tuning sd_modes_by_pref[] = {
 	},
 #endif
 	{
-		.mode = SD_LEGACY,
+		.mode = MMC_LEGACY,
 		.widths = MMC_MODE_4BIT | MMC_MODE_1BIT,
 	}
 };
@@ -1727,7 +1725,7 @@ static int sd_select_mode_and_width(struct mmc *mmc, uint card_caps)
 
 	if (mmc_host_is_spi(mmc)) {
 		mmc_set_bus_width(mmc, 1);
-		mmc_select_mode(mmc, SD_LEGACY);
+		mmc_select_mode(mmc, MMC_LEGACY);
 		mmc_set_clock(mmc, mmc->tran_speed, MMC_CLK_ENABLE);
 		return 0;
 	}
@@ -1786,7 +1784,7 @@ static int sd_select_mode_and_width(struct mmc *mmc, uint card_caps)
 
 error:
 				/* revert to a safer bus speed */
-				mmc_select_mode(mmc, SD_LEGACY);
+				mmc_select_mode(mmc, MMC_LEGACY);
 				mmc_set_clock(mmc, mmc->tran_speed,
 						MMC_CLK_ENABLE);
 			}
@@ -2563,7 +2561,7 @@ static int mmc_startup(struct mmc *mmc)
 
 #if CONFIG_IS_ENABLED(MMC_TINY)
 	mmc_set_clock(mmc, mmc->legacy_speed, false);
-	mmc_select_mode(mmc, IS_SD(mmc) ? SD_LEGACY : MMC_LEGACY);
+	mmc_select_mode(mmc, MMC_LEGACY);
 	mmc_set_bus_width(mmc, 1);
 #else
 	if (IS_SD(mmc)) {
@@ -2844,8 +2842,8 @@ int mmc_start_init(struct mmc *mmc)
 	 * all hosts are capable of 1 bit bus-width and able to use the legacy
 	 * timings.
 	 */
-	mmc->host_caps = mmc->cfg->host_caps | MMC_CAP(SD_LEGACY) |
-			 MMC_CAP(MMC_LEGACY) | MMC_MODE_1BIT;
+	mmc->host_caps = mmc->cfg->host_caps | MMC_CAP(MMC_LEGACY) |
+			 MMC_MODE_1BIT;
 
 #if !defined(CONFIG_MMC_BROKEN_CD)
 	no_card = mmc_getcd(mmc) == 0;
drivers/mmc/omap_hsmmc.c +0 -1
index 5d0cfb2ebd..5e79fa517d 100644
@@ -390,7 +390,6 @@ static void omap_hsmmc_set_timing(struct mmc *mmc)
 		break;
 	case MMC_LEGACY:
 	case MMC_HS:
-	case SD_LEGACY:
 	case UHS_SDR12:
 		val |= AC12_UHSMC_SDR12;
 		break;
drivers/mmc/zynq_sdhci.c +0 -1
index 529eec9c45..fc638649bd 100644
@@ -35,7 +35,6 @@ struct arasan_sdhci_priv {
 
 static const u8 mode2timing[] = {
 	[MMC_LEGACY] = UHS_SDR12_BUS_SPEED,
-	[SD_LEGACY] = UHS_SDR12_BUS_SPEED,
 	[MMC_HS] = HIGH_SPEED_BUS_SPEED,
 	[SD_HS] = HIGH_SPEED_BUS_SPEED,
 	[MMC_HS_52] = HIGH_SPEED_BUS_SPEED,
include/mmc.h +0 -1
index 6aef125f25..a96833c1ca 100644
@@ -539,7 +539,6 @@ struct sd_ssr {
 
 enum bus_mode {
 	MMC_LEGACY,
-	SD_LEGACY,
 	MMC_HS,
 	SD_HS,
 	MMC_HS_52,
Signature · 1 line
2.19.2
author
#31 lore raw

PATCH v2 4/10 mmc: sdhci: Expose sdhci_init() as non-static

In reply to Faiz Abbas

Expose sdhci_init() as non-static.

---
 drivers/mmc/sdhci.c | 2 +-
 include/sdhci.h     | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/mmc/sdhci.c +1 -1
index 01fa5a9d4d..4fce85a0ea 100644
@@ -618,7 +618,7 @@ static int sdhci_set_ios(struct mmc *mmc)
 	return 0;
 }
 
-static int sdhci_init(struct mmc *mmc)
+int sdhci_init(struct mmc *mmc)
 {
 	struct sdhci_host *host = mmc->priv;
 #if CONFIG_IS_ENABLED(DM_MMC) && CONFIG_IS_ENABLED(DM_GPIO)
include/sdhci.h +1 -0
index 01addb7a60..0830e05d53 100644
@@ -487,6 +487,7 @@ void sdhci_set_uhs_timing(struct sdhci_host *host);
 #ifdef CONFIG_DM_MMC
 /* Export the operations to drivers */
 int sdhci_probe(struct udevice *dev);
+int sdhci_init(struct mmc *mmc);
 int sdhci_set_clock(struct mmc *mmc, unsigned int clock);
 extern const struct dm_mmc_ops sdhci_ops;
 #else
Signature · 1 line
2.19.2
#32 lore raw

PATCH v2 4/10 mmc: sdhci: Expose sdhci_init() as non-static

Quoted 1 line · Faiz Abbas

Expose sdhci_init() as non-static.

Does it need to change to non-static?

Best Regards,
Jaehoon Chung

Quoted 34 lines
---
 drivers/mmc/sdhci.c | 2 +-
 include/sdhci.h     | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/mmc/sdhci.c +1 -1
index 01fa5a9d4d..4fce85a0ea 100644
@@ -618,7 +618,7 @@ static int sdhci_set_ios(struct mmc *mmc)
 	return 0;
 }
 
-static int sdhci_init(struct mmc *mmc)
+int sdhci_init(struct mmc *mmc)
 {
 	struct sdhci_host *host = mmc->priv;
 #if CONFIG_IS_ENABLED(DM_MMC) && CONFIG_IS_ENABLED(DM_GPIO)
include/sdhci.h +1 -0
index 01addb7a60..0830e05d53 100644
@@ -487,6 +487,7 @@ void sdhci_set_uhs_timing(struct sdhci_host *host);
 #ifdef CONFIG_DM_MMC
 /* Export the operations to drivers */
 int sdhci_probe(struct udevice *dev);
+int sdhci_init(struct mmc *mmc);
 int sdhci_set_clock(struct mmc *mmc, unsigned int clock);
 extern const struct dm_mmc_ops sdhci_ops;
 #else
#33 lore raw

PATCH v2 4/10 mmc: sdhci: Expose sdhci_init() as non-static

Quoted 5 lines · Jaehoon Chung
Quoted 1 line · Faiz Abbas

Expose sdhci_init() as non-static.

Does it need to change to non-static?

And even if it needs to, can we have a reason *why* in the commit message?

Thanks,
Simon

Quoted 39 lines

Best Regards,
Jaehoon Chung

Quoted 34 lines
---
 drivers/mmc/sdhci.c | 2 +-
 include/sdhci.h     | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/mmc/sdhci.c +1 -1
index 01fa5a9d4d..4fce85a0ea 100644
@@ -618,7 +618,7 @@ static int sdhci_set_ios(struct mmc *mmc)
      return 0;
 }
 
-static int sdhci_init(struct mmc *mmc)
+int sdhci_init(struct mmc *mmc)
 {
      struct sdhci_host *host = mmc->priv;
 #if CONFIG_IS_ENABLED(DM_MMC) && CONFIG_IS_ENABLED(DM_GPIO)
include/sdhci.h +1 -0
index 01addb7a60..0830e05d53 100644
@@ -487,6 +487,7 @@ void sdhci_set_uhs_timing(struct sdhci_host *host);
 #ifdef CONFIG_DM_MMC
 /* Export the operations to drivers */
 int sdhci_probe(struct udevice *dev);
+int sdhci_init(struct mmc *mmc);
 int sdhci_set_clock(struct mmc *mmc, unsigned int clock);
 extern const struct dm_mmc_ops sdhci_ops;
 #else
#34 lore raw

PATCH v2 4/10 mmc: sdhci: Expose sdhci_init() as non-static

Hi Simon,

Quoted 8 lines · Simon Goldschmidt
Quoted 5 lines · Jaehoon Chung
Quoted 1 line · Faiz Abbas

Expose sdhci_init() as non-static.

Does it need to change to non-static?

And even if it needs to, can we have a reason *why* in the commit message?

When i read entire your series, it seems that doesn't need to change to non-static. All of change that touched MMC code are only for your board.
I don't know Peng's opinion, but it's not my prefer.

Best Regards,
Jaehoon Chung

Quoted 45 lines

Thanks,
Simon

Quoted 39 lines

Best Regards,
Jaehoon Chung

Quoted 34 lines
---
 drivers/mmc/sdhci.c | 2 +-
 include/sdhci.h     | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/mmc/sdhci.c +1 -1
index 01fa5a9d4d..4fce85a0ea 100644
@@ -618,7 +618,7 @@ static int sdhci_set_ios(struct mmc *mmc)
      return 0;
 }
 
-static int sdhci_init(struct mmc *mmc)
+int sdhci_init(struct mmc *mmc)
 {
      struct sdhci_host *host = mmc->priv;
 #if CONFIG_IS_ENABLED(DM_MMC) && CONFIG_IS_ENABLED(DM_GPIO)
include/sdhci.h +1 -0
index 01addb7a60..0830e05d53 100644
@@ -487,6 +487,7 @@ void sdhci_set_uhs_timing(struct sdhci_host *host);
 #ifdef CONFIG_DM_MMC
 /* Export the operations to drivers */
 int sdhci_probe(struct udevice *dev);
+int sdhci_init(struct mmc *mmc);
 int sdhci_set_clock(struct mmc *mmc, unsigned int clock);
 extern const struct dm_mmc_ops sdhci_ops;
 #else
#35 lore raw

PATCH v2 4/10 mmc: sdhci: Expose sdhci_init() as non-static

Am 30.01.2020 um 23:21 schrieb Jaehoon Chung:

Quoted 8 lines

Hi Simon,

Quoted 5 lines · Simon Goldschmidt
Quoted 4 lines · Jaehoon Chung
Quoted 1 line · Faiz Abbas

Expose sdhci_init() as non-static.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Does it need to change to non-static?

And even if it needs to, can we have a reason *why* in the commit message?

When i read entire your series, it seems that doesn't need to change to non-static. All of change that touched MMC code are only for your board.
I don't know Peng's opinion, but it's not my prefer.

+1!

We need to keep the core code clean of such hacks in order to keep the size small for constrained targets!

Regards,
Simon

Quoted 50 lines

Best Regards,
Jaehoon Chung

Quoted 45 lines

Thanks,
Simon

Quoted 39 lines

Best Regards,
Jaehoon Chung

Quoted 34 lines
---
  drivers/mmc/sdhci.c | 2 +-
  include/sdhci.h     | 1 +
  2 files changed, 2 insertions(+), 1 deletion(-)
drivers/mmc/sdhci.c +1 -1
index 01fa5a9d4d..4fce85a0ea 100644
@@ -618,7 +618,7 @@ static int sdhci_set_ios(struct mmc *mmc)
       return 0;
  }
 
-static int sdhci_init(struct mmc *mmc)
+int sdhci_init(struct mmc *mmc)
  {
       struct sdhci_host *host = mmc->priv;
  #if CONFIG_IS_ENABLED(DM_MMC) && CONFIG_IS_ENABLED(DM_GPIO)
include/sdhci.h +1 -0
index 01addb7a60..0830e05d53 100644
@@ -487,6 +487,7 @@ void sdhci_set_uhs_timing(struct sdhci_host *host);
  #ifdef CONFIG_DM_MMC
  /* Export the operations to drivers */
  int sdhci_probe(struct udevice *dev);
+int sdhci_init(struct mmc *mmc);
  int sdhci_set_clock(struct mmc *mmc, unsigned int clock);
  extern const struct dm_mmc_ops sdhci_ops;
  #else
author
#36 lore raw

PATCH v2 4/10 mmc: sdhci: Expose sdhci_init() as non-static

Hi,

Quoted 20 lines · Simon Goldschmidt

Am 30.01.2020 um 23:21 schrieb Jaehoon Chung:

Quoted 11 lines

Hi Simon,

Quoted 8 lines · Simon Goldschmidt
Quoted 5 lines · Jaehoon Chung
Quoted 1 line · Faiz Abbas

Expose sdhci_init() as non-static.

Does it need to change to non-static?

Quoted 7 lines
Quoted 2 lines

And even if it needs to, can we have a reason *why* in the commit message?

When i read entire your series, it seems that doesn't need to change to non-static.
All of change that touched MMC code are only for your board. I don't know Peng's opinion, but it's not my prefer.

Quoted 5 lines

+1!

We need to keep the core code clean of such hacks in order to keep the size small for constrained targets!

Peng can you comment on this?

Jaehoon, I am not sure what you mean by "it doesn't need to change to non-static". How would I call the sdhci_init() function from my platform driver otherwise?

Thanks,
Faiz

#37 lore raw

PATCH v2 4/10 mmc: sdhci: Expose sdhci_init() as non-static

Quoted 25 lines

Subject: Re: [PATCH v2 04/10] mmc: sdhci: Expose sdhci_init() as non-static

Hi,

Quoted 20 lines · Simon Goldschmidt

Am 30.01.2020 um 23:21 schrieb Jaehoon Chung:

Quoted 18 lines

Hi Simon,

Quoted 10 lines · Simon Goldschmidt
Quoted 5 lines · Jaehoon Chung
Quoted 1 line · Faiz Abbas

Expose sdhci_init() as non-static.

Does it need to change to non-static?

And even if it needs to, can we have a reason *why* in the commit message?

When i read entire your series, it seems that doesn't need to change to non-static.
All of change that touched MMC code are only for your board. I don't know Peng's opinion, but it's not my prefer.

Quoted 7 lines
Quoted 5 lines

+1!

We need to keep the core code clean of such hacks in order to keep the size small for constrained targets!

Peng can you comment on this?

Just one more question, does kernel has same issue, how resolved? Could U-Boot follow similar approach?

Actually I am fine with platform specific approach , considering your platform issue.

But since Simon and Jaehoon has concerns, not sure whether Simon and Jaehoon have good ideas.

Regards,
Peng.

Quoted 7 lines

Jaehoon, I am not sure what you mean by "it doesn't need to change to non-static". How would I call the sdhci_init() function from my platform driver otherwise?

Thanks,
Faiz

author
#38 lore raw

PATCH v2 4/10 mmc: sdhci: Expose sdhci_init() as non-static

Hi Peng,

Quoted 27 lines · Peng Fan
Quoted 27 lines

Subject: Re: [PATCH v2 04/10] mmc: sdhci: Expose sdhci_init() as non-static

Hi,

Quoted 22 lines · Simon Goldschmidt

Am 30.01.2020 um 23:21 schrieb Jaehoon Chung:

Quoted 11 lines

Hi Simon,

Quoted 8 lines · Simon Goldschmidt
Quoted 5 lines · Jaehoon Chung
Quoted 1 line · Faiz Abbas

Expose sdhci_init() as non-static.

Does it need to change to non-static?

Quoted 7 lines
Quoted 2 lines

And even if it needs to, can we have a reason *why* in the commit message?

When i read entire your series, it seems that doesn't need to change to non-static.
All of change that touched MMC code are only for your board. I don't know Peng's opinion, but it's not my prefer.

+1!

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

We need to keep the core code clean of such hacks in order to keep the size small for constrained targets!

Peng can you comment on this?

Just one more question, does kernel has same issue, how resolved? Could U-Boot follow similar approach?

Kernel has interrupts enabled. So software just has to wait for the card detect interrupt to arrive rather than poll on anything.

Quoted 7 lines

Actually I am fine with platform specific approach , considering your platform issue.

But since Simon and Jaehoon has concerns, not sure whether Simon and Jaehoon have good ideas.

Ok. Lets see if they have some better ideas.

Thanks,
Faiz

#39 lore raw

PATCH v2 4/10 mmc: sdhci: Expose sdhci_init() as non-static

Hi,

Quoted 43 lines · Faiz Abbas

Hi Peng,

Quoted 27 lines · Peng Fan
Quoted 27 lines

Subject: Re: [PATCH v2 04/10] mmc: sdhci: Expose sdhci_init() as non-static

Hi,

Quoted 22 lines · Simon Goldschmidt

Am 30.01.2020 um 23:21 schrieb Jaehoon Chung:

Quoted 11 lines

Hi Simon,

Quoted 8 lines · Simon Goldschmidt
Quoted 5 lines · Jaehoon Chung
Quoted 1 line · Faiz Abbas

Expose sdhci_init() as non-static.

Does it need to change to non-static?

Quoted 7 lines
Quoted 2 lines

And even if it needs to, can we have a reason *why* in the commit message?

When i read entire your series, it seems that doesn't need to change to non-static.
All of change that touched MMC code are only for your board. I don't know Peng's opinion, but it's not my prefer.

+1!

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

We need to keep the core code clean of such hacks in order to keep the size small for constrained targets!

Peng can you comment on this?

Just one more question, does kernel has same issue, how resolved? Could U-Boot follow similar approach?

Kernel has interrupts enabled. So software just has to wait for the card detect interrupt to arrive rather than poll on anything.

Quoted 1 line
Quoted 8 lines
Quoted 6 lines

Actually I am fine with platform specific approach , considering your platform issue.

But since Simon and Jaehoon has concerns, not sure whether Simon and Jaehoon have good ideas.

Ok. Lets see if they have some better ideas.

Well, Your code needs to call am654_sdhci_init() before sdhci_init(), right?

ops->init() -> am654_sdhci_init -> sdhci_init().
If am654_sdhci_init is called for preset, how about adding pre_init() or other ops callback. (pre_init is just example.)

ops->pre_init = am654_sdhci_init; or ops->preset = am654_sdhci_preset;

In mmc.

ops->preset or ops->pre_init -> ops->init

How about adding plotform specific init callback? Then someone can also use it for platform specific things in future.

Best Regards,
Jaehoon Chung

Quoted 6 lines

Thanks,
Faiz

author
#40 lore raw

PATCH v2 4/10 mmc: sdhci: Expose sdhci_init() as non-static

Jaehoon,

Quoted 61 lines · Jaehoon Chung

Hi,

Quoted 43 lines · Faiz Abbas

Hi Peng,

Quoted 27 lines · Peng Fan
Quoted 27 lines

Subject: Re: [PATCH v2 04/10] mmc: sdhci: Expose sdhci_init() as non-static

Hi,

Quoted 22 lines · Simon Goldschmidt

Am 30.01.2020 um 23:21 schrieb Jaehoon Chung:

Quoted 11 lines

Hi Simon,

Quoted 8 lines · Simon Goldschmidt
Quoted 5 lines · Jaehoon Chung
Quoted 1 line · Faiz Abbas

Expose sdhci_init() as non-static.

Does it need to change to non-static?

Quoted 7 lines
Quoted 2 lines

And even if it needs to, can we have a reason *why* in the commit message?

When i read entire your series, it seems that doesn't need to change to non-static.
All of change that touched MMC code are only for your board. I don't know Peng's opinion, but it's not my prefer.

+1!

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

We need to keep the core code clean of such hacks in order to keep the size small for constrained targets!

Peng can you comment on this?

Just one more question, does kernel has same issue, how resolved? Could U-Boot follow similar approach?

Kernel has interrupts enabled. So software just has to wait for the card detect interrupt to arrive rather than poll on anything.

Quoted 1 line
Quoted 8 lines
Quoted 6 lines

Actually I am fine with platform specific approach , considering your platform issue.

But since Simon and Jaehoon has concerns, not sure whether Simon and Jaehoon have good ideas.

Ok. Lets see if they have some better ideas.

Well, Your code needs to call am654_sdhci_init() before sdhci_init(), right?

ops->init() -> am654_sdhci_init -> sdhci_init().
If am654_sdhci_init is called for preset, how about adding pre_init() or other ops callback. (pre_init is just example.)

Quoted 8 lines

ops->pre_init = am654_sdhci_init; or ops->preset = am654_sdhci_preset;

In mmc.

ops->preset or ops->pre_init -> ops->init

How about adding plotform specific init callback? Then someone can also use it for platform specific things in future.

So we basically want an init() callback even in sdhci.c.

I have to create one more wrapper sdhci_pltaform_init() API in the sdhci driver that just calls a platform init function inside it. So its

include/sdhci.h:

struct sdhci_ops {
..
+ int (*platform_init)()

and then drivers/mmc/sdhci.c:

+sdhci_platform_init()
+{
+...
+ host->ops->platform_init();
+}

const struct dm_mmc_ops sdhci_ops = {
...
+ .init = sdhci_platform_init,
};

Right?

Thanks,
Faiz

#41 lore raw

PATCH v2 4/10 mmc: sdhci: Expose sdhci_init() as non-static

Hi Faiz,

Quoted 70 lines · Faiz Abbas

Jaehoon,

Quoted 67 lines · Jaehoon Chung

Hi,

Quoted 43 lines · Faiz Abbas

Hi Peng,

Quoted 27 lines · Peng Fan
Quoted 27 lines

Subject: Re: [PATCH v2 04/10] mmc: sdhci: Expose sdhci_init() as non-static

Hi,

Quoted 22 lines · Simon Goldschmidt

Am 30.01.2020 um 23:21 schrieb Jaehoon Chung:

Quoted 11 lines

Hi Simon,

Quoted 8 lines · Simon Goldschmidt
Quoted 5 lines · Jaehoon Chung
Quoted 1 line · Faiz Abbas

Expose sdhci_init() as non-static.

Does it need to change to non-static?

Quoted 7 lines
Quoted 2 lines

And even if it needs to, can we have a reason *why* in the commit message?

When i read entire your series, it seems that doesn't need to change to non-static.
All of change that touched MMC code are only for your board. I don't know Peng's opinion, but it's not my prefer.

+1!

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

We need to keep the core code clean of such hacks in order to keep the size small for constrained targets!

Peng can you comment on this?

Just one more question, does kernel has same issue, how resolved? Could U-Boot follow similar approach?

Kernel has interrupts enabled. So software just has to wait for the card detect interrupt to arrive rather than poll on anything.

Quoted 1 line
Quoted 8 lines
Quoted 6 lines

Actually I am fine with platform specific approach , considering your platform issue.

But since Simon and Jaehoon has concerns, not sure whether Simon and Jaehoon have good ideas.

Ok. Lets see if they have some better ideas.

Well, Your code needs to call am654_sdhci_init() before sdhci_init(), right?

ops->init() -> am654_sdhci_init -> sdhci_init().
If am654_sdhci_init is called for preset, how about adding pre_init() or other ops callback. (pre_init is just example.)

ops->pre_init = am654_sdhci_init; or ops->preset = am654_sdhci_preset;

In mmc.

ops->preset or ops->pre_init -> ops->init

Quoted 7 lines
Quoted 2 lines

How about adding plotform specific init callback? Then someone can also use it for platform specific things in future.

So we basically want an init() callback even in sdhci.c.

I have to create one more wrapper sdhci_pltaform_init() API in the sdhci driver that just calls a platform init function inside it. So its

Yes, I checked wrong sequence. Sorry.

When i have checked, some functions are needs.

Quoted 16 lines

include/sdhci.h:

struct sdhci_ops {
..
+ int (*platform_init)()

and then drivers/mmc/sdhci.c:

(quoted diff) +5 -0
+sdhci_platform_init()
+{
+...
+       host->ops->platform_init();
+}
Quoted 6 lines

const struct dm_mmc_ops sdhci_ops = {
...
+ .init = sdhci_platform_init,
};

Right?

Right. but not init. Just platform_init?

Well, if you want, i will make patch about callback function.

Best Regards,
Jaehoon Chung

Quoted 5 lines

Thanks,
Faiz

#42 lore raw

PATCH v2 4/10 mmc: sdhci: Expose sdhci_init() as non-static

Hi Faiz,

Quoted 106 lines · Jaehoon Chung

Hi Faiz,

Quoted 70 lines · Faiz Abbas

Jaehoon,

Quoted 67 lines · Jaehoon Chung

Hi,

Quoted 43 lines · Faiz Abbas

Hi Peng,

Quoted 27 lines · Peng Fan
Quoted 27 lines

Subject: Re: [PATCH v2 04/10] mmc: sdhci: Expose sdhci_init() as non-static

Hi,

Quoted 22 lines · Simon Goldschmidt

Am 30.01.2020 um 23:21 schrieb Jaehoon Chung:

Quoted 11 lines

Hi Simon,

Quoted 8 lines · Simon Goldschmidt
Quoted 5 lines · Jaehoon Chung
Quoted 1 line · Faiz Abbas

Expose sdhci_init() as non-static.

Does it need to change to non-static?

Quoted 7 lines
Quoted 2 lines

And even if it needs to, can we have a reason *why* in the commit message?

When i read entire your series, it seems that doesn't need to change to non-static.
All of change that touched MMC code are only for your board. I don't know Peng's opinion, but it's not my prefer.

+1!

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

We need to keep the core code clean of such hacks in order to keep the size small for constrained targets!

Peng can you comment on this?

Just one more question, does kernel has same issue, how resolved? Could U-Boot follow similar approach?

Kernel has interrupts enabled. So software just has to wait for the card detect interrupt to arrive rather than poll on anything.

Quoted 1 line
Quoted 8 lines
Quoted 6 lines

Actually I am fine with platform specific approach , considering your platform issue.

But since Simon and Jaehoon has concerns, not sure whether Simon and Jaehoon have good ideas.

Ok. Lets see if they have some better ideas.

Well, Your code needs to call am654_sdhci_init() before sdhci_init(), right?

ops->init() -> am654_sdhci_init -> sdhci_init().
If am654_sdhci_init is called for preset, how about adding pre_init() or other ops callback. (pre_init is just example.)

ops->pre_init = am654_sdhci_init; or ops->preset = am654_sdhci_preset;

In mmc.

ops->preset or ops->pre_init -> ops->init

Quoted 7 lines
Quoted 2 lines

How about adding plotform specific init callback? Then someone can also use it for platform specific things in future.

So we basically want an init() callback even in sdhci.c.

I have to create one more wrapper sdhci_pltaform_init() API in the sdhci driver that just calls a platform init function inside it. So its

Yes, I checked wrong sequence. Sorry.

When i have checked, some functions are needs.

Quoted 21 lines

include/sdhci.h:

struct sdhci_ops {
..
+ int (*platform_init)()

and then drivers/mmc/sdhci.c:

(quoted diff) +5 -0
+sdhci_platform_init()
+{
+...
+       host->ops->platform_init();
+}

const struct dm_mmc_ops sdhci_ops = {
...
+ .init = sdhci_platform_init,
};

Quoted 5 lines
Quoted 1 line

Right?

Right. but not init. Just platform_init?

Well, if you want, i will make patch about callback function.

How about below codes? Then you can just add am654_sdhci_deferred_probe { ... return sdhci_probe() .. }

drivers/mmc/mmc-uclass.c +15 -0
index 0b90a97650..c75892a72c 100644
@@ -138,6 +138,21 @@ int mmc_host_power_cycle(struct mmc *mmc)
 	return dm_mmc_host_power_cycle(mmc->dev);
 }
 
+int dm_mmc_deferred_probe(struct udevice *dev)
+{
+	struct dm_mmc_ops *ops = mmc_get_ops(dev);
+
+	if (ops->deferred_probe)
+		return ops->deferred_probe(dev);
+
+	return 0;
+}
+
+int mmc_deferred_probe(struct mmc *mmc)
+{
+	return dm_mmc_deferred_probe(mmc->dev);
+}
+
 int mmc_of_parse(struct udevice *dev, struct mmc_config *cfg)
 {
 	int val;
drivers/mmc/mmc.c +1 -0
index d43983d4a6..9eae538af4 100644
@@ -2790,6 +2790,7 @@ int mmc_get_op_cond(struct mmc *mmc)
 
 #if CONFIG_IS_ENABLED(DM_MMC)
 	/* The device has already been probed ready for use */
+	mmc_deferred_probe(mmc);
 #else
 	/* made sure it's not NULL earlier */
 	err = mmc->cfg->ops->init(mmc);
drivers/mmc/sdhci.c +15 -0
index 01fa5a9d4d..9ff37b888b 100644
@@ -661,6 +661,20 @@ int sdhci_probe(struct udevice *dev)
 	return sdhci_init(mmc);
 }
 
+static int sdhci_deferred_probe(struct udevice *dev)
+{
+	int err;
+	struct mmc *mmc = mmc_get_mmc_dev(dev);
+	struct sdhci_host *host = mmc->priv;
+
+	if (host->ops && host->ops->deferred_probe) {
+		err = host->ops->deferred_probe(host);
+		if (err)
+			return err;
+	}
+	return 0;
+}
+
 static int sdhci_get_cd(struct udevice *dev)
 {
 	struct mmc *mmc = mmc_get_mmc_dev(dev);
@@ -695,6 +709,7 @@ const struct dm_mmc_ops sdhci_ops = {
 	.send_cmd	= sdhci_send_command,
 	.set_ios	= sdhci_set_ios,
 	.get_cd		= sdhci_get_cd,
+	.deferred_probe	= sdhci_deferred_probe,
 #ifdef MMC_SUPPORTS_TUNING
 	.execute_tuning	= sdhci_execute_tuning,
 #endif
include/mmc.h +4 -0
index b5cb514f57..b362b7f4c7 100644
@@ -477,6 +477,8 @@ struct dm_mmc_ops {
 	 * @return 0 if not present, 1 if present, -ve on error
 	 */
 	int (*host_power_cycle)(struct udevice *dev);
+
+	int (*deferred_probe)(struct udevice *dev);
 };
 
 #define mmc_get_ops(dev)        ((struct dm_mmc_ops *)(dev)->driver->ops)
@@ -489,6 +491,7 @@ int dm_mmc_get_wp(struct udevice *dev);
 int dm_mmc_execute_tuning(struct udevice *dev, uint opcode);
 int dm_mmc_wait_dat0(struct udevice *dev, int state, int timeout_us);
 int dm_mmc_host_power_cycle(struct udevice *dev);
+int dm_mmc_deferred_probe(struct udevice *dev);
 
 /* Transition functions for compatibility */
 int mmc_set_ios(struct mmc *mmc);
@@ -498,6 +501,7 @@ int mmc_execute_tuning(struct mmc *mmc, uint opcode);
 int mmc_wait_dat0(struct mmc *mmc, int state, int timeout_us);
 int mmc_set_enhanced_strobe(struct mmc *mmc);
 int mmc_host_power_cycle(struct mmc *mmc);
+int mmc_deferred_probe(struct mmc *mmc);
 
 #else
 struct mmc_ops {
include/sdhci.h +1 -0
index 01addb7a60..1276f43935 100644
@@ -267,6 +267,7 @@ struct sdhci_ops {
 	void	(*set_clock)(struct sdhci_host *host, u32 div);
 	int (*platform_execute_tuning)(struct mmc *host, u8 opcode);
 	void (*set_delay)(struct sdhci_host *host);
+	int	(*deferred_probe)(struct sdhci_host *host);
 };
 
 #if CONFIG_IS_ENABLED(MMC_SDHCI_ADMA)
Quoted 12 lines

Best Regards,
Jaehoon Chung

Quoted 5 lines

Thanks,
Faiz

author
#43 lore raw

PATCH v2 4/10 mmc: sdhci: Expose sdhci_init() as non-static

Jaehoon,

Quoted 17 lines · Jaehoon Chung

Hi Faiz,

Quoted 14 lines · Jaehoon Chung

Hi Faiz,

Quoted 11 lines · Faiz Abbas

Jaehoon,

Quoted 8 lines · Jaehoon Chung

Hi,

Quoted 5 lines · Faiz Abbas

Hi Peng,

Quoted 2 lines · Peng Fan
Quoted 2 lines

Subject: Re: [PATCH v2 04/10] mmc: sdhci: Expose sdhci_init() as non-static

...

Quoted 119 lines
Quoted 2 lines

Well, if you want, i will make patch about callback function.

How about below codes? Then you can just add am654_sdhci_deferred_probe { ... return sdhci_probe() .. }

drivers/mmc/mmc-uclass.c +15 -0
index 0b90a97650..c75892a72c 100644
@@ -138,6 +138,21 @@ int mmc_host_power_cycle(struct mmc *mmc)
 	return dm_mmc_host_power_cycle(mmc->dev);
 }
 
+int dm_mmc_deferred_probe(struct udevice *dev)
+{
+	struct dm_mmc_ops *ops = mmc_get_ops(dev);
+
+	if (ops->deferred_probe)
+		return ops->deferred_probe(dev);
+
+	return 0;
+}
+
+int mmc_deferred_probe(struct mmc *mmc)
+{
+	return dm_mmc_deferred_probe(mmc->dev);
+}
+
 int mmc_of_parse(struct udevice *dev, struct mmc_config *cfg)
 {
 	int val;
drivers/mmc/mmc.c +1 -0
index d43983d4a6..9eae538af4 100644
@@ -2790,6 +2790,7 @@ int mmc_get_op_cond(struct mmc *mmc)
 
 #if CONFIG_IS_ENABLED(DM_MMC)
 	/* The device has already been probed ready for use */
+	mmc_deferred_probe(mmc);
 #else
 	/* made sure it's not NULL earlier */
 	err = mmc->cfg->ops->init(mmc);
drivers/mmc/sdhci.c +15 -0
index 01fa5a9d4d..9ff37b888b 100644
@@ -661,6 +661,20 @@ int sdhci_probe(struct udevice *dev)
 	return sdhci_init(mmc);
 }
 
+static int sdhci_deferred_probe(struct udevice *dev)
+{
+	int err;
+	struct mmc *mmc = mmc_get_mmc_dev(dev);
+	struct sdhci_host *host = mmc->priv;
+
+	if (host->ops && host->ops->deferred_probe) {
+		err = host->ops->deferred_probe(host);
+		if (err)
+			return err;
+	}
+	return 0;
+}
+
 static int sdhci_get_cd(struct udevice *dev)
 {
 	struct mmc *mmc = mmc_get_mmc_dev(dev);
@@ -695,6 +709,7 @@ const struct dm_mmc_ops sdhci_ops = {
 	.send_cmd	= sdhci_send_command,
 	.set_ios	= sdhci_set_ios,
 	.get_cd		= sdhci_get_cd,
+	.deferred_probe	= sdhci_deferred_probe,
 #ifdef MMC_SUPPORTS_TUNING
 	.execute_tuning	= sdhci_execute_tuning,
 #endif
include/mmc.h +4 -0
index b5cb514f57..b362b7f4c7 100644
@@ -477,6 +477,8 @@ struct dm_mmc_ops {
 	 * @return 0 if not present, 1 if present, -ve on error
 	 */
 	int (*host_power_cycle)(struct udevice *dev);
+
+	int (*deferred_probe)(struct udevice *dev);
 };
 
 #define mmc_get_ops(dev)        ((struct dm_mmc_ops *)(dev)->driver->ops)
@@ -489,6 +491,7 @@ int dm_mmc_get_wp(struct udevice *dev);
 int dm_mmc_execute_tuning(struct udevice *dev, uint opcode);
 int dm_mmc_wait_dat0(struct udevice *dev, int state, int timeout_us);
 int dm_mmc_host_power_cycle(struct udevice *dev);
+int dm_mmc_deferred_probe(struct udevice *dev);
 
 /* Transition functions for compatibility */
 int mmc_set_ios(struct mmc *mmc);
@@ -498,6 +501,7 @@ int mmc_execute_tuning(struct mmc *mmc, uint opcode);
 int mmc_wait_dat0(struct mmc *mmc, int state, int timeout_us);
 int mmc_set_enhanced_strobe(struct mmc *mmc);
 int mmc_host_power_cycle(struct mmc *mmc);
+int mmc_deferred_probe(struct mmc *mmc);
 
 #else
 struct mmc_ops {
include/sdhci.h +1 -0
index 01addb7a60..1276f43935 100644
@@ -267,6 +267,7 @@ struct sdhci_ops {
 	void	(*set_clock)(struct sdhci_host *host, u32 div);
 	int (*platform_execute_tuning)(struct mmc *host, u8 opcode);
 	void (*set_delay)(struct sdhci_host *host);
+	int	(*deferred_probe)(struct sdhci_host *host);
 };
 
 #if CONFIG_IS_ENABLED(MMC_SDHCI_ADMA)
Quoted 1 line
Quoted 1 line

This does look like the cleanest solution. Will add in a v3.

Thanks,
Faiz

#44 lore raw

PATCH v2 4/10 mmc: sdhci: Expose sdhci_init() as non-static

Quoted 138 lines · Faiz Abbas

Jaehoon,

Quoted 17 lines · Jaehoon Chung

Hi Faiz,

Quoted 14 lines · Jaehoon Chung

Hi Faiz,

Quoted 11 lines · Faiz Abbas

Jaehoon,

Quoted 8 lines · Jaehoon Chung

Hi,

Quoted 5 lines · Faiz Abbas

Hi Peng,

Quoted 2 lines · Peng Fan
Quoted 2 lines

Subject: Re: [PATCH v2 04/10] mmc: sdhci: Expose sdhci_init() as non-static

...

Quoted 117 lines
Quoted 2 lines

Well, if you want, i will make patch about callback function.

How about below codes? Then you can just add am654_sdhci_deferred_probe { ... return sdhci_probe() .. }

drivers/mmc/mmc-uclass.c +15 -0
index 0b90a97650..c75892a72c 100644
@@ -138,6 +138,21 @@ int mmc_host_power_cycle(struct mmc *mmc)
 	return dm_mmc_host_power_cycle(mmc->dev);
 }
 
+int dm_mmc_deferred_probe(struct udevice *dev)
+{
+	struct dm_mmc_ops *ops = mmc_get_ops(dev);
+
+	if (ops->deferred_probe)
+		return ops->deferred_probe(dev);
+
+	return 0;
+}
+
+int mmc_deferred_probe(struct mmc *mmc)
+{
+	return dm_mmc_deferred_probe(mmc->dev);
+}
+
 int mmc_of_parse(struct udevice *dev, struct mmc_config *cfg)
 {
 	int val;
drivers/mmc/mmc.c +1 -0
index d43983d4a6..9eae538af4 100644
@@ -2790,6 +2790,7 @@ int mmc_get_op_cond(struct mmc *mmc)
 
 #if CONFIG_IS_ENABLED(DM_MMC)
 	/* The device has already been probed ready for use */
+	mmc_deferred_probe(mmc);
 #else
 	/* made sure it's not NULL earlier */
 	err = mmc->cfg->ops->init(mmc);
drivers/mmc/sdhci.c +15 -0
index 01fa5a9d4d..9ff37b888b 100644
@@ -661,6 +661,20 @@ int sdhci_probe(struct udevice *dev)
 	return sdhci_init(mmc);
 }
 
+static int sdhci_deferred_probe(struct udevice *dev)
+{
+	int err;
+	struct mmc *mmc = mmc_get_mmc_dev(dev);
+	struct sdhci_host *host = mmc->priv;
+
+	if (host->ops && host->ops->deferred_probe) {
+		err = host->ops->deferred_probe(host);
+		if (err)
+			return err;
+	}
+	return 0;
+}
+
 static int sdhci_get_cd(struct udevice *dev)
 {
 	struct mmc *mmc = mmc_get_mmc_dev(dev);
@@ -695,6 +709,7 @@ const struct dm_mmc_ops sdhci_ops = {
 	.send_cmd	= sdhci_send_command,
 	.set_ios	= sdhci_set_ios,
 	.get_cd		= sdhci_get_cd,
+	.deferred_probe	= sdhci_deferred_probe,
 #ifdef MMC_SUPPORTS_TUNING
 	.execute_tuning	= sdhci_execute_tuning,
 #endif
include/mmc.h +4 -0
index b5cb514f57..b362b7f4c7 100644
@@ -477,6 +477,8 @@ struct dm_mmc_ops {
 	 * @return 0 if not present, 1 if present, -ve on error
 	 */
 	int (*host_power_cycle)(struct udevice *dev);
+
+	int (*deferred_probe)(struct udevice *dev);
 };
 
 #define mmc_get_ops(dev)        ((struct dm_mmc_ops *)(dev)->driver->ops)
@@ -489,6 +491,7 @@ int dm_mmc_get_wp(struct udevice *dev);
 int dm_mmc_execute_tuning(struct udevice *dev, uint opcode);
 int dm_mmc_wait_dat0(struct udevice *dev, int state, int timeout_us);
 int dm_mmc_host_power_cycle(struct udevice *dev);
+int dm_mmc_deferred_probe(struct udevice *dev);
 
 /* Transition functions for compatibility */
 int mmc_set_ios(struct mmc *mmc);
@@ -498,6 +501,7 @@ int mmc_execute_tuning(struct mmc *mmc, uint opcode);
 int mmc_wait_dat0(struct mmc *mmc, int state, int timeout_us);
 int mmc_set_enhanced_strobe(struct mmc *mmc);
 int mmc_host_power_cycle(struct mmc *mmc);
+int mmc_deferred_probe(struct mmc *mmc);
 
 #else
 struct mmc_ops {
include/sdhci.h +1 -0
index 01addb7a60..1276f43935 100644
@@ -267,6 +267,7 @@ struct sdhci_ops {
 	void	(*set_clock)(struct sdhci_host *host, u32 div);
 	int (*platform_execute_tuning)(struct mmc *host, u8 opcode);
 	void (*set_delay)(struct sdhci_host *host);
+	int	(*deferred_probe)(struct sdhci_host *host);
 };
 
Quoted 5 lines
Quoted 3 lines
include/sdhci.h +0 -0
 #if CONFIG_IS_ENABLED(MMC_SDHCI_ADMA)
Quoted 2 lines

This does look like the cleanest solution. Will add in a v3.

Above code is for just concept. Maybe you need to add/modify code.

Best Regards,
Jaehoon Chung

Quoted 6 lines

Thanks,
Faiz

author
#45 lore raw

PATCH v2 5/10 mmc: am654_sdhci: Update output tap delay writes

In reply to Faiz Abbas

With the latest RIOT, there is a different otap delay value for each speed mode. Add a new binding with every supported speed mode. Also disable a given speed mode in the host caps if its corresponding otap-del-sel is not present.

---
 arch/arm/dts/k3-am65-main.dtsi               | 12 +++-
 arch/arm/dts/k3-am654-base-board-u-boot.dtsi | 11 ++-
 arch/arm/dts/k3-j721e-main.dtsi              | 15 ++++-
 drivers/mmc/am654_sdhci.c                    | 70 +++++++++++++++++---
 4 files changed, 95 insertions(+), 13 deletions(-)
arch/arm/dts/k3-am65-main.dtsi +11 -1
index ab40dafceb..028f57379b 100644
@@ -98,7 +98,17 @@
 		interrupts = <GIC_SPI 136 IRQ_TYPE_LEVEL_HIGH>;
 		mmc-ddr-1_8v;
 		mmc-hs200-1_8v;
-		ti,otap-del-sel = <0x2>;
+		ti,otap-del-sel-legacy = <0x0>;
+		ti,otap-del-sel-mmc-hs = <0x0>;
+		ti,otap-del-sel-sd-hs = <0x0>;
+		ti,otap-del-sel-sdr12 = <0x0>;
+		ti,otap-del-sel-sdr25 = <0x0>;
+		ti,otap-del-sel-sdr50 = <0x8>;
+		ti,otap-del-sel-sdr104 = <0x5>;
+		ti,otap-del-sel-ddr50 = <0x5>;
+		ti,otap-del-sel-ddr52 = <0x5>;
+		ti,otap-del-sel-hs200 = <0x5>;
+		ti,otap-del-sel-hs400 = <0x0>;
 		ti,trm-icp = <0x8>;
 		dma-coherent;
 	};
arch/arm/dts/k3-am654-base-board-u-boot.dtsi +10 -1
index a349edcfa5..54ecb3d444 100644
@@ -29,7 +29,16 @@
 		clock-names = "clk_ahb", "clk_xin";
 		power-domains = <&k3_pds 48 TI_SCI_PD_EXCLUSIVE>;
 		max-frequency = <25000000>;
-		ti,otap-del-sel = <0x2>;
+		ti,otap-del-sel-legacy = <0x0>;
+		ti,otap-del-sel-mmc-hs = <0x0>;
+		ti,otap-del-sel-sd-hs = <0x0>;
+		ti,otap-del-sel-sdr12 = <0x0>;
+		ti,otap-del-sel-sdr25 = <0x0>;
+		ti,otap-del-sel-sdr50 = <0x8>;
+		ti,otap-del-sel-sdr104 = <0x7>;
+		ti,otap-del-sel-ddr50 = <0x4>;
+		ti,otap-del-sel-ddr52 = <0x4>;
+		ti,otap-del-sel-hs200 = <0x7>;
 		ti,trm-icp = <0x8>;
 	};
 
arch/arm/dts/k3-j721e-main.dtsi +13 -2
index 5083a0c3ae..86304015c4 100644
@@ -210,9 +210,14 @@
 		assigned-clocks = <&k3_clks 91 1>;
 		assigned-clock-parents = <&k3_clks 91 2>;
 		bus-width = <8>;
-		ti,otap-del-sel = <0x2>;
 		ti,trm-icp = <0x8>;
 		dma-coherent;
+		mmc-ddr-1_8v;
+		ti,otap-del-sel-legacy = <0x0>;
+		ti,otap-del-sel-mmc-hs = <0x0>;
+		ti,otap-del-sel-ddr52 = <0x5>;
+		ti,otap-del-sel-hs200 = <0x6>;
+		ti,otap-del-sel-hs400 = <0x0>;
 	};
 
 	main_sdhci1: sdhci at 4fb0000 {
@@ -224,7 +229,13 @@
 		clocks = <&k3_clks 92 0>, <&k3_clks 92 5>;
 		assigned-clocks = <&k3_clks 92 0>;
 		assigned-clock-parents = <&k3_clks 92 1>;
-		ti,otap-del-sel = <0x2>;
+		ti,otap-del-sel-legacy = <0x0>;
+		ti,otap-del-sel-sd-hs = <0xf>;
+		ti,otap-del-sel-sdr12 = <0xf>;
+		ti,otap-del-sel-sdr25 = <0xf>;
+		ti,otap-del-sel-sdr50 = <0xc>;
+		ti,otap-del-sel-sdr104 = <0x5>;
+		ti,otap-del-sel-ddr50 = <0xc>;
 		ti,trm-icp = <0x8>;
 		dma-coherent;
 	};
drivers/mmc/am654_sdhci.c +61 -9

122 lines not on this page · raw message

Signature · 1 line
2.19.2
author
#46 lore raw

PATCH v2 6/10 mmc: am654_sdhci: Implement workaround for card detect

In reply to Faiz Abbas

The 4 bit MMC controllers have an internal debounce for the SDCD line with a debounce delay of 1 second. Therefore, after clocks to the IP are enabled, software has to wait for this time before it can power on the controller.

Add an init() callback which polls on sdcd for a maximum of 2 seconds before switching on power to the controller or (in the case of no card) returning a ENOMEDIUM. This pushes the 1 second wait time to when the card is actually needed rather than at every probe() making sure that users who don't insert an SD card in the slot don't have to wait such a long time.

---
 drivers/mmc/am654_sdhci.c | 35 ++++++++++++++++++++++++++++++++---
 1 file changed, 32 insertions(+), 3 deletions(-)
drivers/mmc/am654_sdhci.c +32 -3
index ff0a81eaab..ccae3fea31 100644
@@ -254,7 +254,7 @@ const struct am654_driver_data j721e_4bit_drv_data = {
 	.flags = IOMUX_PRESENT,
 };
 
-int am654_sdhci_init(struct am654_sdhci_plat *plat)
+int am654_sdhci_init_phy(struct am654_sdhci_plat *plat)
 {
 	u32 ctl_cfg_2 = 0;
 	u32 mask, val;
@@ -331,8 +331,37 @@ static int sdhci_am654_get_otap_delay(struct udevice *dev,
 	return 0;
 }
 
+#define MAX_SDCD_DEBOUNCE_TIME 2000
+int am654_sdhci_init(struct udevice *dev)
+{
+	struct am654_sdhci_plat *plat = dev_get_platdata(dev);
+	struct mmc *mmc = mmc_get_mmc_dev(dev);
+	struct sdhci_host *host = mmc->priv;
+	unsigned long start;
+	int val;
+
+	/*
+	 * The controller takes about 1 second to debounce the card detect line
+	 * and doesn't let us power on until that time is up. Instead of waiting
+	 * for 1 second at every stage, poll on the CARD_PRESENT bit upto a
+	 * maximum of 2 seconds to be safe..
+	 */
+	start = get_timer(0);
+	do {
+		if (get_timer(start) > MAX_SDCD_DEBOUNCE_TIME)
+			return -ENOMEDIUM;
+
+		val = mmc_getcd(host->mmc);
+	} while (!val);
+
+	am654_sdhci_init_phy(plat);
+
+	return sdhci_init(mmc);
+}
+
 static int am654_sdhci_probe(struct udevice *dev)
 {
+	struct dm_mmc_ops *ops = mmc_get_ops(dev);
 	struct am654_driver_data *drv_data =
 			(struct am654_driver_data *)dev_get_driver_data(dev);
 	struct am654_sdhci_plat *plat = dev_get_platdata(dev);
@@ -373,9 +402,9 @@ static int am654_sdhci_probe(struct udevice *dev)
 
 	regmap_init_mem_index(dev_ofnode(dev), &plat->base, 1);
 
-	am654_sdhci_init(plat);
+	ops->init = am654_sdhci_init;
 
-	return sdhci_probe(dev);
+	return 0;
 }
 
 static int am654_sdhci_ofdata_to_platdata(struct udevice *dev)
Signature · 1 line
2.19.2
#47 lore raw

PATCH v2 6/10 mmc: am654_sdhci: Implement workaround for card detect

Quoted 71 lines · Faiz Abbas

The 4 bit MMC controllers have an internal debounce for the SDCD line with a debounce delay of 1 second. Therefore, after clocks to the IP are enabled, software has to wait for this time before it can power on the controller.

Add an init() callback which polls on sdcd for a maximum of 2 seconds before switching on power to the controller or (in the case of no card) returning a ENOMEDIUM. This pushes the 1 second wait time to when the card is actually needed rather than at every probe() making sure that users who don't insert an SD card in the slot don't have to wait such a long time.

---
 drivers/mmc/am654_sdhci.c | 35 ++++++++++++++++++++++++++++++++---
 1 file changed, 32 insertions(+), 3 deletions(-)
drivers/mmc/am654_sdhci.c +30 -1
index ff0a81eaab..ccae3fea31 100644
@@ -254,7 +254,7 @@ const struct am654_driver_data j721e_4bit_drv_data = {
        .flags = IOMUX_PRESENT,
 };
 
-int am654_sdhci_init(struct am654_sdhci_plat *plat)
+int am654_sdhci_init_phy(struct am654_sdhci_plat *plat)
 {
        u32 ctl_cfg_2 = 0;
        u32 mask, val;
@@ -331,8 +331,37 @@ static int sdhci_am654_get_otap_delay(struct udevice *dev,
        return 0;
 }
 
+#define MAX_SDCD_DEBOUNCE_TIME 2000
+int am654_sdhci_init(struct udevice *dev)
+{
+       struct am654_sdhci_plat *plat = dev_get_platdata(dev);
+       struct mmc *mmc = mmc_get_mmc_dev(dev);
+       struct sdhci_host *host = mmc->priv;
+       unsigned long start;
+       int val;
+
+       /*
+        * The controller takes about 1 second to debounce the card detect line
+        * and doesn't let us power on until that time is up. Instead of waiting
+        * for 1 second at every stage, poll on the CARD_PRESENT bit upto a
+        * maximum of 2 seconds to be safe..
+        */
+       start = get_timer(0);
+       do {
+               if (get_timer(start) > MAX_SDCD_DEBOUNCE_TIME)
+                       return -ENOMEDIUM;
+
+               val = mmc_getcd(host->mmc);
+       } while (!val);
+
+       am654_sdhci_init_phy(plat);
+
+       return sdhci_init(mmc);
+}
+
 static int am654_sdhci_probe(struct udevice *dev)
 {
+       struct dm_mmc_ops *ops = mmc_get_ops(dev);
        struct am654_driver_data *drv_data =
                        (struct am654_driver_data *)dev_get_driver_data(dev);
        struct am654_sdhci_plat *plat = dev_get_platdata(dev);

drivers/mmc/am654_sdhci.c static int am654_sdhci_probe(struct udevice *dev) · line 405

Quoted 5 lines
drivers/mmc/am654_sdhci.c +1 -1
@@ -373,9 +402,9 @@ static int am654_sdhci_probe(struct udevice *dev)
 
        regmap_init_mem_index(dev_ofnode(dev), &plat->base, 1);
 
-       am654_sdhci_init(plat);
+       ops->init = am654_sdhci_init;

Is this a valid approach? I mean, many drivers create their 'ops' const like this:
static const struct ram_ops altera_gen5_sdram_ops (...)

That would mean you write to a const region. I know the U-Boot sources make this easy for you by providing the ops non-const via mmc_get_ops, but I still think this is not good.

Regards,
Simon

Quoted 9 lines
drivers/mmc/am654_sdhci.c +1 -2
-       return sdhci_probe(dev);
+       return 0;
 }
 
 static int am654_sdhci_ofdata_to_platdata(struct udevice *dev)
--

2.19.2

author
#48 lore raw

PATCH v2 6/10 mmc: am654_sdhci: Implement workaround for card detect

Simon,

Quoted 82 lines · Simon Goldschmidt
Quoted 71 lines · Faiz Abbas

The 4 bit MMC controllers have an internal debounce for the SDCD line with a debounce delay of 1 second. Therefore, after clocks to the IP are enabled, software has to wait for this time before it can power on the controller.

Add an init() callback which polls on sdcd for a maximum of 2 seconds before switching on power to the controller or (in the case of no card) returning a ENOMEDIUM. This pushes the 1 second wait time to when the card is actually needed rather than at every probe() making sure that users who don't insert an SD card in the slot don't have to wait such a long time.

---
 drivers/mmc/am654_sdhci.c | 35 ++++++++++++++++++++++++++++++++---
 1 file changed, 32 insertions(+), 3 deletions(-)
drivers/mmc/am654_sdhci.c +30 -1
index ff0a81eaab..ccae3fea31 100644
@@ -254,7 +254,7 @@ const struct am654_driver_data j721e_4bit_drv_data = {
        .flags = IOMUX_PRESENT,
 };
 
-int am654_sdhci_init(struct am654_sdhci_plat *plat)
+int am654_sdhci_init_phy(struct am654_sdhci_plat *plat)
 {
        u32 ctl_cfg_2 = 0;
        u32 mask, val;
@@ -331,8 +331,37 @@ static int sdhci_am654_get_otap_delay(struct udevice *dev,
        return 0;
 }
 
+#define MAX_SDCD_DEBOUNCE_TIME 2000
+int am654_sdhci_init(struct udevice *dev)
+{
+       struct am654_sdhci_plat *plat = dev_get_platdata(dev);
+       struct mmc *mmc = mmc_get_mmc_dev(dev);
+       struct sdhci_host *host = mmc->priv;
+       unsigned long start;
+       int val;
+
+       /*
+        * The controller takes about 1 second to debounce the card detect line
+        * and doesn't let us power on until that time is up. Instead of waiting
+        * for 1 second at every stage, poll on the CARD_PRESENT bit upto a
+        * maximum of 2 seconds to be safe..
+        */
+       start = get_timer(0);
+       do {
+               if (get_timer(start) > MAX_SDCD_DEBOUNCE_TIME)
+                       return -ENOMEDIUM;
+
+               val = mmc_getcd(host->mmc);
+       } while (!val);
+
+       am654_sdhci_init_phy(plat);
+
+       return sdhci_init(mmc);
+}
+
 static int am654_sdhci_probe(struct udevice *dev)
 {
+       struct dm_mmc_ops *ops = mmc_get_ops(dev);
        struct am654_driver_data *drv_data =
                        (struct am654_driver_data *)dev_get_driver_data(dev);
        struct am654_sdhci_plat *plat = dev_get_platdata(dev);

drivers/mmc/am654_sdhci.c static int am654_sdhci_probe(struct udevice *dev) · line 405

Quoted 5 lines
drivers/mmc/am654_sdhci.c +1 -1
@@ -373,9 +402,9 @@ static int am654_sdhci_probe(struct udevice *dev)
 
        regmap_init_mem_index(dev_ofnode(dev), &plat->base, 1);
 
-       am654_sdhci_init(plat);
+       ops->init = am654_sdhci_init;

Is this a valid approach? I mean, many drivers create their 'ops' const like this:
static const struct ram_ops altera_gen5_sdram_ops (...)

Quoted 4 lines

That would mean you write to a const region. I know the U-Boot sources make this easy for you by providing the ops non-const via mmc_get_ops, but I still think this is not good.

Sorry I missed this earlier.

I do see other drivers following this approach (see drivers/mmc/sdhci-cadence.c). The issue is that I then have to export every API in drivers/mmc/sdhci.c:694

const struct dm_mmc_ops sdhci_ops = {

        .send_cmd       = sdhci_send_command,
        .set_ios        = sdhci_set_ios,
        .get_cd         = sdhci_get_cd,

#ifdef MMC_SUPPORTS_TUNING
.execute_tuning = sdhci_execute_tuning,
#endif
};

and create a duplicate structure in my platform driver with an extra .init

OR

I have to create one more wrapper sdhci_pltaform_init() API in the sdhci driver that just calls a platform init function inside it. So its

include/sdhci.h:

struct sdhci_ops {
..
+ int (*platform_init)()

and then drivers/mmc/sdhci.c:

+dm_sdhci_platform_init()
+{
+...
+ host->ops->platform_init();
+}

const struct dm_mmc_ops sdhci_ops = {
...
+ .init = dm_sdhci_platform_init,
};

Both of these approaches are too much boiler plate code for nothing so its just simpler to use my approach itself.

Anyways, please comment here or in my next version if you have a better idea.

Thanks,
Faiz

#49 lore raw

PATCH v2 6/10 mmc: am654_sdhci: Implement workaround for card detect

+Simon Glass for the xxx_get_ops() functions in DM

Quoted 134 lines · Faiz Abbas

Simon,

Quoted 82 lines · Simon Goldschmidt
Quoted 71 lines · Faiz Abbas

The 4 bit MMC controllers have an internal debounce for the SDCD line with a debounce delay of 1 second. Therefore, after clocks to the IP are enabled, software has to wait for this time before it can power on the controller.

Add an init() callback which polls on sdcd for a maximum of 2 seconds before switching on power to the controller or (in the case of no card) returning a ENOMEDIUM. This pushes the 1 second wait time to when the card is actually needed rather than at every probe() making sure that users who don't insert an SD card in the slot don't have to wait such a long time.

---
 drivers/mmc/am654_sdhci.c | 35 ++++++++++++++++++++++++++++++++---
 1 file changed, 32 insertions(+), 3 deletions(-)
drivers/mmc/am654_sdhci.c +30 -1
index ff0a81eaab..ccae3fea31 100644
@@ -254,7 +254,7 @@ const struct am654_driver_data j721e_4bit_drv_data = {
        .flags = IOMUX_PRESENT,
 };
 
-int am654_sdhci_init(struct am654_sdhci_plat *plat)
+int am654_sdhci_init_phy(struct am654_sdhci_plat *plat)
 {
        u32 ctl_cfg_2 = 0;
        u32 mask, val;
@@ -331,8 +331,37 @@ static int sdhci_am654_get_otap_delay(struct udevice *dev,
        return 0;
 }
 
+#define MAX_SDCD_DEBOUNCE_TIME 2000
+int am654_sdhci_init(struct udevice *dev)
+{
+       struct am654_sdhci_plat *plat = dev_get_platdata(dev);
+       struct mmc *mmc = mmc_get_mmc_dev(dev);
+       struct sdhci_host *host = mmc->priv;
+       unsigned long start;
+       int val;
+
+       /*
+        * The controller takes about 1 second to debounce the card detect line
+        * and doesn't let us power on until that time is up. Instead of waiting
+        * for 1 second at every stage, poll on the CARD_PRESENT bit upto a
+        * maximum of 2 seconds to be safe..
+        */
+       start = get_timer(0);
+       do {
+               if (get_timer(start) > MAX_SDCD_DEBOUNCE_TIME)
+                       return -ENOMEDIUM;
+
+               val = mmc_getcd(host->mmc);
+       } while (!val);
+
+       am654_sdhci_init_phy(plat);
+
+       return sdhci_init(mmc);
+}
+
 static int am654_sdhci_probe(struct udevice *dev)
 {
+       struct dm_mmc_ops *ops = mmc_get_ops(dev);
        struct am654_driver_data *drv_data =
                        (struct am654_driver_data *)dev_get_driver_data(dev);
        struct am654_sdhci_plat *plat = dev_get_platdata(dev);

drivers/mmc/am654_sdhci.c static int am654_sdhci_probe(struct udevice *dev) · line 405

Quoted 5 lines
drivers/mmc/am654_sdhci.c +1 -1
@@ -373,9 +402,9 @@ static int am654_sdhci_probe(struct udevice *dev)
 
        regmap_init_mem_index(dev_ofnode(dev), &plat->base, 1);
 
-       am654_sdhci_init(plat);
+       ops->init = am654_sdhci_init;

Is this a valid approach? I mean, many drivers create their 'ops' const like this:
static const struct ram_ops altera_gen5_sdram_ops (...)

Quoted 4 lines

That would mean you write to a const region. I know the U-Boot sources make this easy for you by providing the ops non-const via mmc_get_ops, but I still think this is not good.

Sorry I missed this earlier.

I do see other drivers following this approach (see drivers/mmc/sdhci-cadence.c). The issue is that I then have to export every API in drivers/mmc/sdhci.c:694

const struct dm_mmc_ops sdhci_ops = {

        .send_cmd       = sdhci_send_command,
        .set_ios        = sdhci_set_ios,
        .get_cd         = sdhci_get_cd,

#ifdef MMC_SUPPORTS_TUNING
.execute_tuning = sdhci_execute_tuning,
#endif
};

and create a duplicate structure in my platform driver with an extra .init

OR

I have to create one more wrapper sdhci_pltaform_init() API in the sdhci driver that just calls a platform init function inside it. So its

include/sdhci.h:

struct sdhci_ops {
..
+ int (*platform_init)()

and then drivers/mmc/sdhci.c:

(quoted diff) +5 -0
+dm_sdhci_platform_init()
+{
+...
+       host->ops->platform_init();
+}

const struct dm_mmc_ops sdhci_ops = {
...
+ .init = dm_sdhci_platform_init,
};

Quoted 5 lines

Both of these approaches are too much boiler plate code for nothing so its just simpler to use my approach itself.

Anyways, please comment here or in my next version if you have a better idea.

Honestly, I don't know the mmc code well enough to give you an alternative.

However, I do know that most drivers define 'ops' as const, so to prevent writing to const memory, mmc_get_ops() and other similar accessors should return a const pointer. I know that they don't currently, but strictly speaking, this is a bug.

Your adding this code here makes it harder to fix that bug and change mmc_get_ops() to return a const pointer.

Regards,
Simon

#50 lore raw

PATCH v2 6/10 mmc: am654_sdhci: Implement workaround for card detect

Hi,

Quoted 146 lines · Simon Goldschmidt

+Simon Glass for the xxx_get_ops() functions in DM

Quoted 134 lines · Faiz Abbas

Simon,

Quoted 82 lines · Simon Goldschmidt
Quoted 71 lines · Faiz Abbas

The 4 bit MMC controllers have an internal debounce for the SDCD line with a debounce delay of 1 second. Therefore, after clocks to the IP are enabled, software has to wait for this time before it can power on the controller.

Add an init() callback which polls on sdcd for a maximum of 2 seconds before switching on power to the controller or (in the case of no card) returning a ENOMEDIUM. This pushes the 1 second wait time to when the card is actually needed rather than at every probe() making sure that users who don't insert an SD card in the slot don't have to wait such a long time.

---
 drivers/mmc/am654_sdhci.c | 35 ++++++++++++++++++++++++++++++++---
 1 file changed, 32 insertions(+), 3 deletions(-)
drivers/mmc/am654_sdhci.c +30 -1
index ff0a81eaab..ccae3fea31 100644
@@ -254,7 +254,7 @@ const struct am654_driver_data j721e_4bit_drv_data = {
        .flags = IOMUX_PRESENT,
 };
 
-int am654_sdhci_init(struct am654_sdhci_plat *plat)
+int am654_sdhci_init_phy(struct am654_sdhci_plat *plat)
 {
        u32 ctl_cfg_2 = 0;
        u32 mask, val;
@@ -331,8 +331,37 @@ static int sdhci_am654_get_otap_delay(struct udevice *dev,
        return 0;
 }
 
+#define MAX_SDCD_DEBOUNCE_TIME 2000
+int am654_sdhci_init(struct udevice *dev)
+{
+       struct am654_sdhci_plat *plat = dev_get_platdata(dev);
+       struct mmc *mmc = mmc_get_mmc_dev(dev);
+       struct sdhci_host *host = mmc->priv;
+       unsigned long start;
+       int val;
+
+       /*
+        * The controller takes about 1 second to debounce the card detect line
+        * and doesn't let us power on until that time is up. Instead of waiting
+        * for 1 second at every stage, poll on the CARD_PRESENT bit upto a
+        * maximum of 2 seconds to be safe..
+        */
+       start = get_timer(0);
+       do {
+               if (get_timer(start) > MAX_SDCD_DEBOUNCE_TIME)
+                       return -ENOMEDIUM;
+
+               val = mmc_getcd(host->mmc);
+       } while (!val);
+
+       am654_sdhci_init_phy(plat);
+
+       return sdhci_init(mmc);
+}
+
 static int am654_sdhci_probe(struct udevice *dev)
 {
+       struct dm_mmc_ops *ops = mmc_get_ops(dev);
        struct am654_driver_data *drv_data =
                        (struct am654_driver_data *)dev_get_driver_data(dev);
        struct am654_sdhci_plat *plat = dev_get_platdata(dev);

drivers/mmc/am654_sdhci.c static int am654_sdhci_probe(struct udevice *dev) · line 405

Quoted 5 lines
drivers/mmc/am654_sdhci.c +1 -1
@@ -373,9 +402,9 @@ static int am654_sdhci_probe(struct udevice *dev)
 
        regmap_init_mem_index(dev_ofnode(dev), &plat->base, 1);
 
-       am654_sdhci_init(plat);
+       ops->init = am654_sdhci_init;

Is this a valid approach? I mean, many drivers create their 'ops' const like this:
static const struct ram_ops altera_gen5_sdram_ops (...)

Quoted 4 lines

That would mean you write to a const region. I know the U-Boot sources make this easy for you by providing the ops non-const via mmc_get_ops, but I still think this is not good.

Sorry I missed this earlier.

I do see other drivers following this approach (see drivers/mmc/sdhci-cadence.c). The issue is that I then have to export every API in drivers/mmc/sdhci.c:694

const struct dm_mmc_ops sdhci_ops = {

        .send_cmd       = sdhci_send_command,
        .set_ios        = sdhci_set_ios,
        .get_cd         = sdhci_get_cd,

#ifdef MMC_SUPPORTS_TUNING
.execute_tuning = sdhci_execute_tuning,
#endif
};

and create a duplicate structure in my platform driver with an extra .init

OR

I have to create one more wrapper sdhci_pltaform_init() API in the sdhci driver that just calls a platform init function inside it. So its

include/sdhci.h:

struct sdhci_ops {
..
+ int (*platform_init)()

and then drivers/mmc/sdhci.c:

(quoted diff) +5 -0
+dm_sdhci_platform_init()
+{
+...
+       host->ops->platform_init();
+}

const struct dm_mmc_ops sdhci_ops = {
...
+ .init = dm_sdhci_platform_init,
};

Quoted 5 lines

Both of these approaches are too much boiler plate code for nothing so its just simpler to use my approach itself.

Anyways, please comment here or in my next version if you have a better idea.

Honestly, I don't know the mmc code well enough to give you an alternative.

Quoted 7 lines

However, I do know that most drivers define 'ops' as const, so to prevent writing to const memory, mmc_get_ops() and other similar accessors should return a const pointer. I know that they don't currently, but strictly speaking, this is a bug.

Your adding this code here makes it harder to fix that bug and change mmc_get_ops() to return a const pointer.

I really don't see why we want mmc_get_ops(). Can we just add the operation to the existing MMC operations struct? What is the disadvantage there?

In general with DM we should avoid callbacks and weak functions since they bypass DM.

Regards,
Simon

author
#51 lore raw

PATCH v2 7/10 spl: mmc: Fix spl_mmc_get_uboot_raw_sector() implementation

In reply to Faiz Abbas

The call to spl_mmc_get_uboot_raw_sector() completely ignores and overwrites the raw_sect value passed from the caller of spl_mmc_load().

Fix this by passing raw_sect to the function and returning the same value in the default case.

---
 arch/arm/mach-imx/imx8/image.c |  3 ++-
 common/spl/spl_mmc.c           | 11 ++++-------
 2 files changed, 6 insertions(+), 8 deletions(-)
arch/arm/mach-imx/imx8/image.c +2 -1
index 58a29e8a03..08b0050f57 100644
@@ -196,7 +196,8 @@ unsigned long spl_spi_get_uboot_offs(struct spi_flash *flash)
 #endif
 
 #ifdef CONFIG_SPL_MMC_SUPPORT
-unsigned long spl_mmc_get_uboot_raw_sector(struct mmc *mmc)
+unsigned long spl_mmc_get_uboot_raw_sector(struct mmc *mmc,
+					   unsigned long raw_sect)
 {
 	int end;
 
common/spl/spl_mmc.c +4 -7
index 3e6a17c110..a2ea363e96 100644
@@ -317,13 +317,10 @@ int spl_boot_partition(const u32 boot_device)
 }
 #endif
 
-unsigned long __weak spl_mmc_get_uboot_raw_sector(struct mmc *mmc)
+unsigned long __weak spl_mmc_get_uboot_raw_sector(struct mmc *mmc,
+						  unsigned long raw_sect)
 {
-#ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR
-	return CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR;
-#else
-	return 0;
-#endif
+	return raw_sect;
 }
 
 int spl_mmc_load(struct spl_image_info *spl_image,
@@ -392,7 +389,7 @@ int spl_mmc_load(struct spl_image_info *spl_image,
 				return err;
 		}
 
-		raw_sect = spl_mmc_get_uboot_raw_sector(mmc);
+		raw_sect = spl_mmc_get_uboot_raw_sector(mmc, raw_sect);
 
 #ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION
 		err = mmc_load_image_raw_partition(spl_image, mmc, raw_part,
Signature · 1 line
2.19.2
author
#52 lore raw

PATCH v2 8/10 arm: K3: sysfw-loader: Add a config_pm_pre_callback()

In reply to Faiz Abbas

System firmware does not guarantee that clocks going out of the device will be stable during power management configuration. There are some DCRC errors when SPL tries to get the next stage during eMMC boot after sysfw pm configuration.

Therefore add a config_pm_pre_callback() to switch off the eMMC clock before power management and restart it after it is done.

---
 arch/arm/mach-k3/am6_init.c                  | 33 +++++++++++++++++++-
 arch/arm/mach-k3/include/mach/sysfw-loader.h |  2 +-
 arch/arm/mach-k3/j721e_init.c                | 33 +++++++++++++++++++-
 arch/arm/mach-k3/sysfw-loader.c              |  6 +++-
 4 files changed, 70 insertions(+), 4 deletions(-)
arch/arm/mach-k3/am6_init.c +32 -1
index 8d107b870b..9d3c62b3f4 100644
@@ -17,6 +17,7 @@
 #include <dm/uclass-internal.h>
 #include <dm/pinctrl.h>
 #include <linux/soc/ti/ti_sci_protocol.h>
+#include <mmc.h>
 
 #ifdef CONFIG_SPL_BUILD
 #ifdef CONFIG_K3_LOAD_SYSFW
@@ -86,6 +87,33 @@ static void store_boot_index_from_rom(void)
 	bootindex = *(u32 *)(CONFIG_SYS_K3_BOOT_PARAM_TABLE_INDEX);
 }
 
+#if defined(CONFIG_K3_LOAD_SYSFW)
+void k3_mmc_stop_clock(void)
+{
+	if (spl_boot_device() == BOOT_DEVICE_MMC1) {
+		struct mmc *mmc = find_mmc_device(0);
+
+		if (!mmc)
+			return;
+
+		mmc->saved_clock = mmc->clock;
+		mmc_set_clock(mmc, 0, true);
+	}
+}
+
+void k3_mmc_restart_clock(void)
+{
+	if (spl_boot_device() == BOOT_DEVICE_MMC1) {
+		struct mmc *mmc = find_mmc_device(0);
+
+		if (!mmc)
+			return;
+
+		mmc_set_clock(mmc, mmc->saved_clock, false);
+	}
+}
+#endif
+
 void board_init_f(ulong dummy)
 {
 #if defined(CONFIG_K3_LOAD_SYSFW) || defined(CONFIG_K3_AM654_DDRSS)
@@ -128,7 +156,10 @@ void board_init_f(ulong dummy)
 	 * callback hook, effectively switching on (or over) the console
 	 * output.
 	 */
-	k3_sysfw_loader(preloader_console_init);
+	k3_sysfw_loader(k3_mmc_stop_clock, k3_mmc_restart_clock);
+
+	/* Prepare console output */
+	preloader_console_init();
 
 	/* Disable ROM configured firewalls right after loading sysfw */
 #ifdef CONFIG_TI_SECURE_DEVICE
arch/arm/mach-k3/include/mach/sysfw-loader.h +1 -1
index 36eb265348..6f5612b4fd 100644
@@ -7,6 +7,6 @@
 #ifndef _SYSFW_LOADER_H_
 #define _SYSFW_LOADER_H_
 
-void k3_sysfw_loader(void (*config_pm_done_callback)(void));
+void k3_sysfw_loader(void (*config_pm_pre_callback)(void), void (*config_pm_done_callback)(void));
 
 #endif
arch/arm/mach-k3/j721e_init.c +32 -1
index f7f7398081..0994522f6c 100644
@@ -18,6 +18,7 @@
 #include <dm.h>
 #include <dm/uclass-internal.h>
 #include <dm/pinctrl.h>
+#include <mmc.h>
 
 #ifdef CONFIG_SPL_BUILD
 #ifdef CONFIG_K3_LOAD_SYSFW
@@ -100,6 +101,33 @@ static void ctrl_mmr_unlock(void)
 	mmr_unlock(CTRL_MMR0_BASE, 7);
 }
 
+#if defined(CONFIG_K3_LOAD_SYSFW)
+void k3_mmc_stop_clock(void)
+{
+	if (spl_boot_device() == BOOT_DEVICE_MMC1) {
+		struct mmc *mmc = find_mmc_device(0);
+
+		if (!mmc)
+			return;
+
+		mmc->saved_clock = mmc->clock;
+		mmc_set_clock(mmc, 0, true);
+	}
+}
+
+void k3_mmc_restart_clock(void)
+{
+	if (spl_boot_device() == BOOT_DEVICE_MMC1) {
+		struct mmc *mmc = find_mmc_device(0);
+
+		if (!mmc)
+			return;
+
+		mmc_set_clock(mmc, mmc->saved_clock, false);
+	}
+}
+#endif
+
 /*
  * This uninitialized global variable would normal end up in the .bss section,
  * but the .bss is cleared between writing and reading this variable, so move
@@ -154,7 +182,10 @@ void board_init_f(ulong dummy)
 	 * callback hook, effectively switching on (or over) the console
 	 * output.
 	 */
-	k3_sysfw_loader(preloader_console_init);
+	k3_sysfw_loader(k3_mmc_stop_clock, k3_mmc_restart_clock);
+
+	/* Prepare console output */
+	preloader_console_init();
 
 	/* Disable ROM configured firewalls right after loading sysfw */
 #ifdef CONFIG_TI_SECURE_DEVICE
arch/arm/mach-k3/sysfw-loader.c +5 -1
index 5903bbe12a..8386499ed6 100644
@@ -172,7 +172,8 @@ static void k3_sysfw_configure_using_fit(void *fit,
 		      ret);
 }
 
-void k3_sysfw_loader(void (*config_pm_done_callback)(void))
+void k3_sysfw_loader(void (*config_pm_pre_callback) (void),
+		     void (*config_pm_done_callback)(void))
 {
 	struct spl_image_info spl_image = { 0 };
 	struct spl_boot_device bootdev = { 0 };
@@ -264,6 +265,9 @@ void k3_sysfw_loader(void (*config_pm_done_callback)(void))
 	/* Parse and apply the different SYSFW configuration fragments */
 	k3_sysfw_configure_using_fit(sysfw_load_address, ti_sci);
 
+	if (config_pm_pre_callback)
+		config_pm_pre_callback();
+
 	/*
 	 * Now that all clocks and PM aspects are setup, invoke a user-
 	 * provided callback function. Usually this callback would be used
Signature · 1 line
2.19.2
#53 lore raw

PATCH v2 8/10 arm: K3: sysfw-loader: Add a config_pm_pre_callback()

Quoted 104 lines · Faiz Abbas

System firmware does not guarantee that clocks going out of the device will be stable during power management configuration. There are some DCRC errors when SPL tries to get the next stage during eMMC boot after sysfw pm configuration.

Therefore add a config_pm_pre_callback() to switch off the eMMC clock before power management and restart it after it is done.

---
 arch/arm/mach-k3/am6_init.c                  | 33 +++++++++++++++++++-
 arch/arm/mach-k3/include/mach/sysfw-loader.h |  2 +-
 arch/arm/mach-k3/j721e_init.c                | 33 +++++++++++++++++++-
 arch/arm/mach-k3/sysfw-loader.c              |  6 +++-
 4 files changed, 70 insertions(+), 4 deletions(-)
arch/arm/mach-k3/am6_init.c +32 -1
index 8d107b870b..9d3c62b3f4 100644
@@ -17,6 +17,7 @@
 #include <dm/uclass-internal.h>
 #include <dm/pinctrl.h>
 #include <linux/soc/ti/ti_sci_protocol.h>
+#include <mmc.h>
 
 #ifdef CONFIG_SPL_BUILD
 #ifdef CONFIG_K3_LOAD_SYSFW
@@ -86,6 +87,33 @@ static void store_boot_index_from_rom(void)
 	bootindex = *(u32 *)(CONFIG_SYS_K3_BOOT_PARAM_TABLE_INDEX);
 }
 
+#if defined(CONFIG_K3_LOAD_SYSFW)
+void k3_mmc_stop_clock(void)
+{
+	if (spl_boot_device() == BOOT_DEVICE_MMC1) {
+		struct mmc *mmc = find_mmc_device(0);
+
+		if (!mmc)
+			return;
+
+		mmc->saved_clock = mmc->clock;
+		mmc_set_clock(mmc, 0, true);
+	}
+}
+
+void k3_mmc_restart_clock(void)
+{
+	if (spl_boot_device() == BOOT_DEVICE_MMC1) {
+		struct mmc *mmc = find_mmc_device(0);
+
+		if (!mmc)
+			return;
+
+		mmc_set_clock(mmc, mmc->saved_clock, false);
+	}
+}
+#endif
+
 void board_init_f(ulong dummy)
 {
 #if defined(CONFIG_K3_LOAD_SYSFW) || defined(CONFIG_K3_AM654_DDRSS)
@@ -128,7 +156,10 @@ void board_init_f(ulong dummy)
 	 * callback hook, effectively switching on (or over) the console
 	 * output.
 	 */
-	k3_sysfw_loader(preloader_console_init);
+	k3_sysfw_loader(k3_mmc_stop_clock, k3_mmc_restart_clock);
+
+	/* Prepare console output */
+	preloader_console_init();
 
 	/* Disable ROM configured firewalls right after loading sysfw */
 #ifdef CONFIG_TI_SECURE_DEVICE
arch/arm/mach-k3/include/mach/sysfw-loader.h +1 -1
index 36eb265348..6f5612b4fd 100644
@@ -7,6 +7,6 @@
 #ifndef _SYSFW_LOADER_H_
 #define _SYSFW_LOADER_H_
 
-void k3_sysfw_loader(void (*config_pm_done_callback)(void));
+void k3_sysfw_loader(void (*config_pm_pre_callback)(void), void (*config_pm_done_callback)(void));
 
 #endif
arch/arm/mach-k3/j721e_init.c +2 -0
index f7f7398081..0994522f6c 100644
@@ -18,6 +18,7 @@
 #include <dm.h>
 #include <dm/uclass-internal.h>
 #include <dm/pinctrl.h>
+#include <mmc.h>
 
 #ifdef CONFIG_SPL_BUILD
 #ifdef CONFIG_K3_LOAD_SYSFW
@@ -100,6 +101,33 @@ static void ctrl_mmr_unlock(void)
 	mmr_unlock(CTRL_MMR0_BASE, 7);
 }
 
+#if defined(CONFIG_K3_LOAD_SYSFW)

arch/arm/mach-k3/j721e_init.c static void ctrl_mmr_unlock(void) · line 114

Quoted 10 lines
arch/arm/mach-k3/j721e_init.c +10 -0
+void k3_mmc_stop_clock(void)
+{
+	if (spl_boot_device() == BOOT_DEVICE_MMC1) {
+		struct mmc *mmc = find_mmc_device(0);
+
+		if (!mmc)
+			return;
+
+		mmc->saved_clock = mmc->clock;
+		mmc_set_clock(mmc, 0, true);

Use MMC_CLK_DISABLE instead of true.

arch/arm/mach-k3/j721e_init.c static void ctrl_mmr_unlock(void) · line 126

Quoted 12 lines
arch/arm/mach-k3/j721e_init.c +12 -0
+	}
+}
+
+void k3_mmc_restart_clock(void)
+{
+	if (spl_boot_device() == BOOT_DEVICE_MMC1) {
+		struct mmc *mmc = find_mmc_device(0);
+
+		if (!mmc)
+			return;
+
+		mmc_set_clock(mmc, mmc->saved_clock, false);

ditto.

Quoted 44 lines
arch/arm/mach-k3/j721e_init.c +8 -1
+	}
+}
+#endif
+
 /*
  * This uninitialized global variable would normal end up in the .bss section,
  * but the .bss is cleared between writing and reading this variable, so move
@@ -154,7 +182,10 @@ void board_init_f(ulong dummy)
 	 * callback hook, effectively switching on (or over) the console
 	 * output.
 	 */
-	k3_sysfw_loader(preloader_console_init);
+	k3_sysfw_loader(k3_mmc_stop_clock, k3_mmc_restart_clock);
+
+	/* Prepare console output */
+	preloader_console_init();
 
 	/* Disable ROM configured firewalls right after loading sysfw */
 #ifdef CONFIG_TI_SECURE_DEVICE
arch/arm/mach-k3/sysfw-loader.c +5 -1
index 5903bbe12a..8386499ed6 100644
@@ -172,7 +172,8 @@ static void k3_sysfw_configure_using_fit(void *fit,
 		      ret);
 }
 
-void k3_sysfw_loader(void (*config_pm_done_callback)(void))
+void k3_sysfw_loader(void (*config_pm_pre_callback) (void),
+		     void (*config_pm_done_callback)(void))
 {
 	struct spl_image_info spl_image = { 0 };
 	struct spl_boot_device bootdev = { 0 };
@@ -264,6 +265,9 @@ void k3_sysfw_loader(void (*config_pm_done_callback)(void))
 	/* Parse and apply the different SYSFW configuration fragments */
 	k3_sysfw_configure_using_fit(sysfw_load_address, ti_sci);
 
+	if (config_pm_pre_callback)
+		config_pm_pre_callback();
+
 	/*
 	 * Now that all clocks and PM aspects are setup, invoke a user-
 	 * provided callback function. Usually this callback would be used
author
#54 lore raw

PATCH v2 8/10 arm: K3: sysfw-loader: Add a config_pm_pre_callback()

Hi,

Quoted 13 lines · Jaehoon Chung
Quoted 12 lines · Faiz Abbas

System firmware does not guarantee that clocks going out of the device will be stable during power management configuration. There are some DCRC errors when SPL tries to get the next stage during eMMC boot after sysfw pm configuration.

Therefore add a config_pm_pre_callback() to switch off the eMMC clock before power management and restart it after it is done.

---

Quoted 13 lines

arch/arm/mach-k3/am6_init.c static void store_boot_index_from_rom(void) · line 100

Quoted 11 lines
arch/arm/mach-k3/am6_init.c +11 -0
+#if defined(CONFIG_K3_LOAD_SYSFW)
+void k3_mmc_stop_clock(void)
+{
+	if (spl_boot_device() == BOOT_DEVICE_MMC1) {
+		struct mmc *mmc = find_mmc_device(0);
+
+		if (!mmc)
+			return;
+
+		mmc->saved_clock = mmc->clock;
+		mmc_set_clock(mmc, 0, true);

Use MMC_CLK_DISABLE instead of true.

Ok.

Quoted 15 lines

arch/arm/mach-k3/am6_init.c static void store_boot_index_from_rom(void) · line 112

Quoted 13 lines
arch/arm/mach-k3/am6_init.c +12 -0
+	}
+}
+
+void k3_mmc_restart_clock(void)
+{
+	if (spl_boot_device() == BOOT_DEVICE_MMC1) {
+		struct mmc *mmc = find_mmc_device(0);
+
+		if (!mmc)
+			return;
+
+		mmc_set_clock(mmc, mmc->saved_clock, false);

ditto.

Ok.

Thanks,
Faiz

author
#55 lore raw

PATCH v2 9/10 configs: am65x_evm: Add CONFIG_SUPPORT_EMMC_BOOT

In reply to Faiz Abbas

With CONFIG_SUPPORT_EMMC_BOOT moved to Kconfig, move it to defconfig files.

---
 configs/am65x_evm_a53_defconfig | 1 +
 configs/am65x_evm_r5_defconfig  | 1 +
 include/configs/am65x_evm.h     | 2 --
 3 files changed, 2 insertions(+), 2 deletions(-)
configs/am65x_evm_a53_defconfig +1 -0
index 079cd912ba..099a9b46cc 100644
@@ -74,6 +74,7 @@ CONFIG_DM_KEYBOARD=y
 CONFIG_DM_MAILBOX=y
 CONFIG_K3_SEC_PROXY=y
 CONFIG_DM_MMC=y
+CONFIG_SUPPORT_EMMC_BOOT=y
 CONFIG_MMC_SDHCI=y
 CONFIG_MMC_SDHCI_ADMA=y
 CONFIG_SPL_MMC_SDHCI_ADMA=y
configs/am65x_evm_r5_defconfig +1 -0
index 69055d5536..b475aceefe 100644
@@ -73,6 +73,7 @@ CONFIG_K3_SEC_PROXY=y
 CONFIG_MISC=y
 CONFIG_K3_AVS0=y
 CONFIG_DM_MMC=y
+CONFIG_SUPPORT_EMMC_BOOT=y
 CONFIG_MMC_SDHCI=y
 CONFIG_SPL_MMC_SDHCI_ADMA=y
 CONFIG_MMC_SDHCI_AM654=y
include/configs/am65x_evm.h +0 -2
index 7d7f86a059..23ee2254ed 100644
@@ -127,8 +127,6 @@
 #define CONFIG_SYS_MMC_ENV_PART	1
 #endif
 
-#define CONFIG_SUPPORT_EMMC_BOOT
-
 /* Now for the remaining common defines */
 #include <configs/ti_armv7_common.h>
 
Signature · 1 line
2.19.2
author
#56 lore raw

PATCH v2 10/10 configs: j721e_evm: Add Support for eMMC boot

In reply to Faiz Abbas

Enable configs to support eMMC boot support.

---
 configs/j721e_evm_a72_defconfig | 3 +++
 configs/j721e_evm_r5_defconfig  | 3 +++
 2 files changed, 6 insertions(+)
configs/j721e_evm_a72_defconfig +3 -0
index d5e54a228d..8320fa8c5b 100644
@@ -26,6 +26,8 @@ CONFIG_SPL_BOARD_INIT=y
 CONFIG_SPL_SYS_MALLOC_SIMPLE=y
 CONFIG_SPL_STACK_R=y
 CONFIG_SPL_SEPARATE_BSS=y
+CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR=y
+CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x1400
 CONFIG_SPL_ENV_SUPPORT=y
 CONFIG_SPL_I2C_SUPPORT=y
 CONFIG_SPL_DM_MAILBOX=y
@@ -90,6 +92,7 @@ CONFIG_SYS_I2C_OMAP24XX=y
 CONFIG_DM_MAILBOX=y
 CONFIG_K3_SEC_PROXY=y
 CONFIG_DM_MMC=y
+CONFIG_SUPPORT_EMMC_BOOT=y
 CONFIG_MMC_SDHCI=y
 CONFIG_MMC_SDHCI_ADMA=y
 CONFIG_SPL_MMC_SDHCI_ADMA=y
configs/j721e_evm_r5_defconfig +3 -0
index a90ab62195..ea726b4c7d 100644
@@ -25,6 +25,8 @@ CONFIG_USE_BOOTCOMMAND=y
 CONFIG_SPL_STACK_R=y
 CONFIG_SPL_SEPARATE_BSS=y
 CONFIG_SPL_EARLY_BSS=y
+CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR=y
+CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x400
 CONFIG_SPL_ENV_SUPPORT=y
 CONFIG_SPL_I2C_SUPPORT=y
 CONFIG_SPL_DM_MAILBOX=y
@@ -72,6 +74,7 @@ CONFIG_MISC=y
 CONFIG_FS_LOADER=y
 CONFIG_K3_AVS0=y
 CONFIG_DM_MMC=y
+CONFIG_SUPPORT_EMMC_BOOT=y
 CONFIG_MMC_SDHCI=y
 CONFIG_SPL_MMC_SDHCI_ADMA=y
 CONFIG_MMC_SDHCI_AM654=y
Signature · 1 line
2.19.2