linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: linux@arm.linux.org.uk (Russell King - ARM Linux)
To: linux-arm-kernel@lists.infradead.org
Subject: IMX6 USDHC card detection
Date: Thu, 3 Oct 2013 20:36:23 +0100	[thread overview]
Message-ID: <20131003193623.GF12758@n2100.arm.linux.org.uk> (raw)

Having spent many hours chasing around wondering why controller based
card detection doesn't work on IMX6, I've finally found it.

The hardware is setup such that we have a card detect signal routed to
GPIO 4.  If we try and use the host controller's built-in card detection,
things go awry - the host controller believes that a card is always
inserted.

This appears to be because the kernel sets the D3CD bit in the PROT_CTRL
register.  This enables card detection via the DAT3 signal, which
indicates a logic '1' level when a card is inserted.  SD cards have a 50k
pullup internally which provides the card detection mechanism, and hosts
are expected to have a weak pull-down on this signal.

However, the default setup of the SD data lines in IOMUX is this (eg):

             MX6QDL_PAD_SD2_DAT0__SD2_DATA0 0x17059
             MX6QDL_PAD_SD2_DAT1__SD2_DATA1 0x17059
             MX6QDL_PAD_SD2_DAT2__SD2_DATA2 0x17059
             MX6QDL_PAD_SD2_DAT3__SD2_DATA3 0x17059

Bits 14 and 15 indicate "pull this pin up via a 22K resistor".

What you end up with is the SD controller believes that a card is always
inserted no matter what you do.  You can see this through the PRES_STATE
register - you see bit 18 assert/deassert appropriately on card insertion
and removals indicating that the socket CD signal is changing state, but
you don't see the card inserted bit (bit 16) ever change.  Neither does
the kernel react in any way.

So, are the defaults for DATA3 signals really appropriate, or should they
be adjusted (in other words, 0x13059 for DATA3).  The alternative is to
ignore the built-in host card detection, and configure the CD pin as a
GPIO instead.

             reply	other threads:[~2013-10-03 19:36 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-03 19:36 Russell King - ARM Linux [this message]
2013-10-04 16:07 ` IMX6 USDHC card detection Fabio Estevam
2013-10-05  9:20   ` Shawn Guo
2013-10-05  9:35     ` Russell King - ARM Linux
2013-10-05 10:11       ` Shawn Guo
2013-10-05 14:24     ` Fabio Estevam
2013-10-05  8:45 ` Shawn Guo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20131003193623.GF12758@n2100.arm.linux.org.uk \
    --to=linux@arm.linux.org.uk \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).