Skip to content

sdhci-esdhc-imx: use gpio for write protection and card detection

Eric Benard linux-arm-kernel linux-mmc 2 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest posting 2/20 of 5 patches 0 repliesNew
  2. v3 posting 1/20 of 5 patches 0 repliesSuperseded

Patches in v3 posting 2/2 No applies recorded yet

None of the 5 patches the cover letter announces are in this archive.

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v3 yet.

Read the v3 thread

Cover letter [PATCH V3 0/5] sdhci-esdhc-imx: use gpio for write protection and card detection

Hi,

Quoted 8 lines · Arnaud Patard (Rtp)
Quoted 2 lines · Eric Benard

may you please test the attached patch. It may give someone with a better knowledge of sdhci than me an idea of what is wrong.

I've tested this patch on my efikamx and this patch does solve the issue. I didn't test on the efika smartbook but I guess it'll be fine here too. Thanks.

good. Now we have to find can how this code be integrated properly in the sdhci driver.

Quoted 10 lines
Quoted 6 lines

Here are the workaround this patch add :
- we can't let enable or disable irq enabled when the card is present/not present, else the irq triger again which explains why you get the freeze -> so we must rely on the card presence bit to enable the right interrupt,

so, we're getting an interrupt storm, right ? can't it be fixed by setting a different irq type ?

no this seems to be the way the SDHCI works, at least the i.MX51 ref manual says :
- When the CRM bit is cleared, if no card is inserted it is immediately set
again: this can be prevented by clearing the card removal status enable bit in interrupt status enable register.
- When the CIN bit is cleared, if a card is inserted it is immediately set
again: this can be prevented by clearing the card inserted status enable bit in interrupt status enable register.

As, unless I'm mistaken, sdhci host actually consider card detect as broken by default, I think this code in not actually used so it may not be really tested.

Quoted 5 lines
Quoted 5 lines

- we can't turn the clock off if we want the card detect to work when the card is removed -> as a quick workaround this patch prevents sdhci_set_clock from turning off the clocks when the SDHCI_INT_CARD_INSERT interrupt is enabled.

Quoted 8 lines
Quoted 5 lines

Also, I had to change the MX51_PAD_GPIO1_0__SD1_CD pad setting as follows to enable the internal pull up :
_MX51_PAD_GPIO1_0__SD1_CD | MUX_PAD_CTRL(PAD_CTL_PUS_22K_UP |
PAD_CTL_PKE | PAD_CTL_SRE_FAST | PAD_CTL_DSE_HIGH | PAD_CTL_PUE | PAD_CTL_HYS),

It worked without changing this.

this could mean you have an external pull up resistor on the board which was not the case on the prototype I was working on which is partially mounted ;-)

Eric