[PATCH 16/46] davinci: Add MMC/SD support for DA830/OMAP-L137 EVM

Mark A. Greer mgreer at mvista.com
Mon Oct 19 12:39:37 EDT 2009


On Mon, Oct 19, 2009 at 03:07:52PM +0100, Russell King - ARM Linux wrote:
> On Fri, Oct 16, 2009 at 12:09:20PM -0700, Kevin Hilman wrote:
> > From: David A. Griego <dgriego at mvista.com>
> > 
> > Add pinmux settings, etc. to enable the MMC/SC hardware.
> > 
> > Signed-off-by: David A. Griego <dgriego at mvista.com>
> > Signed-off-by: Mark A. Greer <mgreer at mvista.com>
> > Signed-off-by: Kevin Hilman <khilman at deeprootsystems.com>
> > ---
> >  arch/arm/mach-davinci/board-da830-evm.c |   43 +++++++++++++++++++++++++++++++
> >  1 files changed, 43 insertions(+), 0 deletions(-)
> > 
> > diff --git a/arch/arm/mach-davinci/board-da830-evm.c b/arch/arm/mach-davinci/board-da830-evm.c
> > index 39711c1..69a791a 100644
> > --- a/arch/arm/mach-davinci/board-da830-evm.c
> > +++ b/arch/arm/mach-davinci/board-da830-evm.c
> > @@ -23,6 +23,7 @@
> >  #include <mach/irqs.h>
> >  #include <mach/cp_intc.h>
> >  #include <mach/mux.h>
> > +#include <mach/gpio.h>
> 
> linux/gpio.h

Oops.

> > +static int da830_evm_mmc_get_ro(int index)
> > +{
> > +	int val, status, gpio_num = 33;
> > +
> > +	status = gpio_request(gpio_num, "MMC WP\n");
> > +	if (status < 0) {
> > +		pr_warning("%s can not open GPIO %d\n", __func__, gpio_num);
> > +		return 0;
> > +	}
> > +	gpio_direction_input(gpio_num);
> > +	val = gpio_get_value(gpio_num);
> > +	gpio_free(gpio_num);
> 
> Should this really be requesting the gpio every time it wants to be
> read?  This approach sounds wrong.  Why not just request the GPIO in
> the platform initialisation code, setting its direction, and merely
> reading it in this function?

This routine doesn't get called on every read.  AFAICT, its only called
by mmc_sd_init_card() which is called during init and resume.  That seems
like the logical time to check if the card is set to read-only since cards
can be inserted and removed while the system is running.

Mark
--



More information about the linux-arm-kernel mailing list