Skip to contentSkip to conversation

mmc: mmci: Gate the clock when freq is 0

PATCH New Ulf Hansson 4 participants 5 messages Dec 12, 2012 – Jan 7, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mmc: mmci: Gate the clock when freq is 0

From: Johan Rudholm <[email protected]>

In the ST Micro variant, the MMCI_CLOCK register should not be used to gate the clock. Use MMCI_POWER to do this.

---
 drivers/mmc/host/mmci.c |    9 +++++++++
 1 file changed, 9 insertions(+)
drivers/mmc/host/mmci.c +9 -0
index edc3e9b..bf07823 100644
@@ -1147,6 +1147,15 @@ static void mmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 		}
 	}
 
+	/*
+	 * If clock = 0 and the block needs a certain value in the clreg
+	 * to function, we need to gate the clock by removing MCI_PWR_ON.
+	 * This is a special case for ST Micro variants, since the power
+	 * register in the ARM legacy case is used for powering the cards.
+	 */
+	if (!ios->clock && variant->clkreg)
+		pwr &= ~MCI_PWR_ON;
+
 	spin_lock_irqsave(&host->lock, flags);
 
 	mmci_set_clkreg(host, ios->clock);
Signature · 1 line
1.7.10
#1 lore raw

PATCH 1/1 mmc: mmci: Gate the clock when freq is 0

Quoted 7 lines · Ulf Hansson

From: Johan Rudholm <[email protected]>

In the ST Micro variant, the MMCI_CLOCK register should not be used to gate the clock. Use MMCI_POWER to do this.

I don't know if I'm qualified to ACK anything more today after misunderstanding so many patches, but this seems correct to me and won't affect any non-ST IP, so:

Yours,
Linus Walleij

#2 lore raw

PATCH 1/1 mmc: mmci: Gate the clock when freq is 0

In reply to Ulf Hansson

drivers/mmc/host/mmci.c static void mmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) · line 1154

Quoted 13 lines · Ulf Hansson
drivers/mmc/host/mmci.c +5 -0
index edc3e9b..bf07823 100644
@@ -1147,6 +1147,15 @@ static void mmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 		}
 	}
 
+	/*
+	 * If clock = 0 and the block needs a certain value in the clreg
+	 * to function, we need to gate the clock by removing MCI_PWR_ON.
+	 * This is a special case for ST Micro variants, since the power
+	 * register in the ARM legacy case is used for powering the cards.

I wish you'd stop using "legacy" when talking about the ARM primecell. How can it be legacy when ARMs current development boards still use this primecell?

drivers/mmc/host/mmci.c static void mmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) · line 1157

Quoted 3 lines
drivers/mmc/host/mmci.c +3 -0
+	 */
+	if (!ios->clock && variant->clkreg)
+		pwr &= ~MCI_PWR_ON;

This is horrid. You're overloading the clkreg default value with another meaning here - "if we have any bits set in the default value for the MCICLOCK register, the MCIPOWER register has special meanings for the power control bits".

When you think about it as I've described it above, do you think this is an acceptable solution to this problem?

#3 lore raw

PATCH 1/1 mmc: mmci: Gate the clock when freq is 0

Quoted 19 lines · Russell King - ARM Linux

drivers/mmc/host/mmci.c static void mmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) · line 1154

Quoted 13 lines · Ulf Hansson
drivers/mmc/host/mmci.c +5 -0
index edc3e9b..bf07823 100644
@@ -1147,6 +1147,15 @@ static void mmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
              }
      }
 
+     /*
+      * If clock = 0 and the block needs a certain value in the clreg
+      * to function, we need to gate the clock by removing MCI_PWR_ON.
+      * This is a special case for ST Micro variants, since the power
+      * register in the ARM legacy case is used for powering the cards.

I wish you'd stop using "legacy" when talking about the ARM primecell. How can it be legacy when ARMs current development boards still use this primecell?

Quoted 8 lines

drivers/mmc/host/mmci.c static void mmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) · line 1157

Quoted 3 lines
drivers/mmc/host/mmci.c +3 -0
+      */
+     if (!ios->clock && variant->clkreg)
+             pwr &= ~MCI_PWR_ON;

This is horrid. You're overloading the clkreg default value with another meaning here - "if we have any bits set in the default value for the MCICLOCK register, the MCIPOWER register has special meanings for the power control bits".

I was hesitating when we decided to use the clkreg value due to what you states here. Just to give you some more background.

By using clkreg default value you will get an implicit sequential dependency that you will write the default value to MMCICLOCK reg, _before_ writing the "power on" bit to the MMCIPOWER reg. Otherwise you will not be able to update MMCICLK reg after the "power on" bit in the MMCIPOWER reg has been set. That was the whole reason to why the clkreg default value was invented.

Anyway, I still think your comment is valid so I suggest we add another variant data which meaning will indicate whether the MMCIPOWER register is used to control the actual power to the card. If that is the case we must not use the MMCIPOWER to gate the clock. Does that make sense?

Quoted 3 lines

When you think about it as I've described it above, do you think this is an acceptable solution to this problem?

Kind regards
Ulf Hansson

#4 lore raw

PATCH 1/1 mmc: mmci: Gate the clock when freq is 0

Quoted 40 lines · Ulf Hansson
Quoted 19 lines · Russell King - ARM Linux

drivers/mmc/host/mmci.c static void mmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) · line 1154

Quoted 13 lines · Ulf Hansson
drivers/mmc/host/mmci.c +5 -0
index edc3e9b..bf07823 100644
@@ -1147,6 +1147,15 @@ static void mmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
              }
      }
 
+     /*
+      * If clock = 0 and the block needs a certain value in the clreg
+      * to function, we need to gate the clock by removing MCI_PWR_ON.
+      * This is a special case for ST Micro variants, since the power
+      * register in the ARM legacy case is used for powering the cards.

I wish you'd stop using "legacy" when talking about the ARM primecell. How can it be legacy when ARMs current development boards still use this primecell?

Quoted 8 lines

drivers/mmc/host/mmci.c static void mmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) · line 1157

Quoted 3 lines
drivers/mmc/host/mmci.c +3 -0
+      */
+     if (!ios->clock && variant->clkreg)
+             pwr &= ~MCI_PWR_ON;

This is horrid. You're overloading the clkreg default value with another meaning here - "if we have any bits set in the default value for the MCICLOCK register, the MCIPOWER register has special meanings for the power control bits".

I was hesitating when we decided to use the clkreg value due to what you states here. Just to give you some more background.

By using clkreg default value you will get an implicit sequential dependency that you will write the default value to MMCICLOCK reg, _before_ writing the "power on" bit to the MMCIPOWER reg. Otherwise you will not be able to update MMCICLK reg after the "power on" bit in the MMCIPOWER reg has been set. That was the whole reason to why the clkreg default value was invented.

Quoted 9 lines

Anyway, I still think your comment is valid so I suggest we add another variant data which meaning will indicate whether the MMCIPOWER register is used to control the actual power to the card. If that is the case we must not use the MMCIPOWER to gate the clock. Does that make sense?

Quoted 3 lines

When you think about it as I've described it above, do you think this is an acceptable solution to this problem?

I just sent out a new patch to handle the clock gating for the ST variants. I decided to add a new variant data which is only indicating whether the power register should be used to gate the clock. It felt like the most proper way of doing this. Please have look when you have the time.

Thanks!
Ulf Hansson