public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding@avionic-design.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v3 0/4] mmc: Implement central card-detection.
Date: Tue, 20 Dec 2011 21:16:13 +0100	[thread overview]
Message-ID: <20111220201613.GA29763@avionic-0098.mockup.avionic-design.de> (raw)
In-Reply-To: <201112201231.10509.vapier@gentoo.org>

* Mike Frysinger wrote:
> On Tuesday 20 December 2011 03:52:39 Thierry Reding wrote:
> > This series of patches implements central card-detection within the MMC
> > framework. Before this patch series, many boards actually did implement
> > the board_mmc_getcd() function, but it wasn't used except by one driver
> > (fsl_esdhc). Unfortunately, implementations interpreted the meaning of
> > the cd parameter differently, some taking it to signal card absence and
> > others using it to detect card presence. Furthermore, the signature of
> > the board_mmc_getcd() function was not at all consistent with other MMC
> > related functions.
> 
> as you've seen, GPIO pin detection is not novel or unique to any driver/SoC.  
> i'd suggest instead finding a way to move this into "struct mmc".  perhaps 
> something like:
> 
> include/mmc.h:
> struct mmc {
> 	...
> #ifdef CONFIG_MMC_GPIO_CD
> 	unsigned gpio_cd;
> #endif
> 	...
> };
> 
> and then the default mmc_register() func can do:
> #ifdef CONFIG_MMC_GPIO_CD
> 	if (!mmc->getcd)
> 		mmc->getcd = mmc_getcd_gpio;
> #endif
> 
> and we can have the drivers/mmc/mmc.c:
> #ifdef CONFIG_MMC_GPIO_CD
> int mmc_getcd_gpio(struct mmc *mmc)
> {
> 	return !gpio_get_value(mmc->getcd);
> }
> #endif
> 
> then mmc drivers can extend their register function to take a GPIO number (if 
> they don't already).  and then they get everything else for free.

Yes, there is some potential for refactoring drivers, though only a very
limited number of boards actually implement card-detection. I guess something
like what you are proposing could be added on top of the series. That would
hard-code the fact that card-detect GPIOs are always low-active, though. Can
we live with that? If a board handles that differently they can always
override the behaviour by specifying their own board_mmc_getcd().

Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20111220/5ee0dfa7/attachment.pgp>

  reply	other threads:[~2011-12-20 20:16 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-20  8:52 [U-Boot] [PATCH v3 0/4] mmc: Implement central card-detection Thierry Reding
2011-12-20  8:52 ` [U-Boot] [PATCH v3 1/4] mmc: Change board_mmc_getcd() function prototype Thierry Reding
2011-12-20  8:52 ` [U-Boot] [PATCH v3 2/4] mmc: Implement card detection Thierry Reding
2011-12-20  8:52 ` [U-Boot] [PATCH v3 3/4] mmc: fsl_esdhc: Implement card-detect hook Thierry Reding
2011-12-20  8:52 ` [U-Boot] [PATCH v3 4/4] mmc: tegra2: " Thierry Reding
2011-12-20 17:31 ` [U-Boot] [PATCH v3 0/4] mmc: Implement central card-detection Mike Frysinger
2011-12-20 20:16   ` Thierry Reding [this message]
2011-12-30  6:11 ` Andy Fleming
2012-01-02 11:24   ` Thierry Reding
2012-01-02 17:00     ` Andy Fleming
2012-01-09  3:45 ` Andy Fleming

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=20111220201613.GA29763@avionic-0098.mockup.avionic-design.de \
    --to=thierry.reding@avionic-design.de \
    --cc=u-boot@lists.denx.de \
    /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