public inbox for linux-omap@vger.kernel.org
 help / color / mirror / Atom feed
* [patch 2.6.27-omap-git+ 0/5] twl4030 GPIO updates
@ 2008-10-13 19:59 David Brownell
  2008-10-14 19:01 ` [patch 2.6.27-omap-git+ 6/5] twl4030 MMC card detction David Brownell
  2008-10-16 21:26 ` [patch 2.6.27-omap-git+ 0/5] twl4030 GPIO updates Tony Lindgren
  0 siblings, 2 replies; 4+ messages in thread
From: David Brownell @ 2008-10-13 19:59 UTC (permalink / raw)
  To: linux-omap

Following this are several patches making the twl4030 GPIO code
fit better into the GPIO framework, updating its only current
user (hsmmc glue) and adding one more (Beagle).

 - gpio_request()/gpio_free() hook, now in MM for 2.6.28-rc merge
 - use that mechanism for twl4040 GPIOs
 - remove most twl-specific calls from mach-omap2/hsmmc.c glue
 - support LEDA and LEDB as output-only GPIOs
 - support those two LED signals on Beagle (one is a real LED!)

This goes on top of the preceding patches to update IRQ handling
for the twl core.

Capsule summary:  the only remaining twl40-specific GPIO calls
are to enable hardware debouncing, with potential upstream generic
support soon; and disabled linkages of the MMC power supplies to
those card detect lines (best suited IMO to platform_data, once
it's tested).

Which makes twl4030-gpio nearly ready to go upstream.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [patch 2.6.27-omap-git+ 6/5] twl4030 MMC card detction
  2008-10-13 19:59 [patch 2.6.27-omap-git+ 0/5] twl4030 GPIO updates David Brownell
@ 2008-10-14 19:01 ` David Brownell
  2008-10-16 22:33   ` David Brownell
  2008-10-16 21:26 ` [patch 2.6.27-omap-git+ 0/5] twl4030 GPIO updates Tony Lindgren
  1 sibling, 1 reply; 4+ messages in thread
From: David Brownell @ 2008-10-14 19:01 UTC (permalink / raw)
  To: linux-omap

From: David Brownell <dbrownell@users.sourceforge.net>

Replace stubbed-out card-detect support for twl4030 GPIOs with
a simpler platform_data mechanism.  As before, no current users.
Sanity tested by enabling this on Beagle; it booted OK with
root on MMC.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
---
 drivers/gpio/twl4030-gpio.c |   52 +++++++++---------------------------------
 include/linux/i2c/twl4030.h |    3 ++
 2 files changed, 15 insertions(+), 40 deletions(-)

--- a/drivers/gpio/twl4030-gpio.c
+++ b/drivers/gpio/twl4030-gpio.c
@@ -46,8 +46,6 @@
  * intended to support multiple hosts.
  *
  * There are also two LED pins used sometimes as output-only GPIOs.
- *
- * FIXME code currently only handles the first IRQ line.
  */
 
 
@@ -235,41 +233,6 @@ int twl4030_set_gpio_debounce(int gpio, 
 }
 EXPORT_SYMBOL(twl4030_set_gpio_debounce);
 
-#if 0
-/*
- * Configure Card detect for GPIO pin on TWL4030
- *
- * This means:  VMMC1 or VMMC2 is enabled or disabled based
- * on the status of GPIO-0 or GPIO-1 pins (respectively).
- */
-int twl4030_set_gpio_card_detect(int gpio, int enable)
-{
-	u8 reg = 0;
-	u8 msk = (1 << gpio);
-	int ret = 0;
-
-	/* Only GPIO 0 or 1 can be used for CD feature.. */
-	if (unlikely((gpio >= TWL4030_GPIO_MAX)
-		|| !(gpio_usage_count & BIT(gpio))
-		|| (gpio >= TWL4030_GPIO_MAX_CD))) {
-		return -EPERM;
-	}
-
-	mutex_lock(&gpio_lock);
-	ret = gpio_twl4030_read(REG_GPIO_CTRL);
-	if (ret >= 0) {
-		if (enable)
-			reg = (u8) (ret | msk);
-		else
-			reg = (u8) (ret & ~msk);
-
-		ret = gpio_twl4030_write(REG_GPIO_CTRL, reg);
-	}
-	mutex_unlock(&gpio_lock);
-	return ret;
-}
-#endif
-
 /*----------------------------------------------------------------------*/
 
 static int twl_request(struct gpio_chip *chip, unsigned offset)
@@ -317,9 +280,18 @@ static int twl_request(struct gpio_chip 
 	}
 
 	/* on first use, turn GPIO module "on" */
-	if (!gpio_usage_count)
-		status = gpio_twl4030_write(REG_GPIO_CTRL,
-				MASK_GPIO_CTRL_GPIO_ON);
+	if (!gpio_usage_count) {
+		struct twl4030_gpio_platform_data *pdata;
+		u8 value = MASK_GPIO_CTRL_GPIO_ON;
+
+		/* optionally have the first two GPIOs switch vMMC1
+		 * and vMMC2 power supplies based on card presence.
+		 */
+		pdata = chip->dev->platform_data;
+		value |= pdata->mmc_cd & 0x03;
+
+		status = gpio_twl4030_write(REG_GPIO_CTRL, value);
+	}
 
 	if (!status)
 		gpio_usage_count |= (0x1 << offset);
--- a/include/linux/i2c/twl4030.h
+++ b/include/linux/i2c/twl4030.h
@@ -231,6 +231,9 @@ struct twl4030_gpio_platform_data {
 	/* package the two LED signals as output-only GPIOs? */
 	bool		use_leds;
 
+	/* gpio-n should control VMMC(n+1) if BIT(n) in mmc_cd is set */
+	u8		mmc_cd;
+
 	/* For gpio-N, bit (1 << N) in "pullups" is set if that pullup
 	 * should be enabled.  Else, if that bit is set in "pulldowns",
 	 * that pulldown is enabled.  Don't waste power by letting any

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch 2.6.27-omap-git+ 0/5] twl4030 GPIO updates
  2008-10-13 19:59 [patch 2.6.27-omap-git+ 0/5] twl4030 GPIO updates David Brownell
  2008-10-14 19:01 ` [patch 2.6.27-omap-git+ 6/5] twl4030 MMC card detction David Brownell
@ 2008-10-16 21:26 ` Tony Lindgren
  1 sibling, 0 replies; 4+ messages in thread
From: Tony Lindgren @ 2008-10-16 21:26 UTC (permalink / raw)
  To: David Brownell; +Cc: linux-omap

* David Brownell <david-b@pacbell.net> [081013 13:22]:
> Following this are several patches making the twl4030 GPIO code
> fit better into the GPIO framework, updating its only current
> user (hsmmc glue) and adding one more (Beagle).
> 
>  - gpio_request()/gpio_free() hook, now in MM for 2.6.28-rc merge
>  - use that mechanism for twl4040 GPIOs
>  - remove most twl-specific calls from mach-omap2/hsmmc.c glue
>  - support LEDA and LEDB as output-only GPIOs
>  - support those two LED signals on Beagle (one is a real LED!)
> 
> This goes on top of the preceding patches to update IRQ handling
> for the twl core.
> 
> Capsule summary:  the only remaining twl40-specific GPIO calls
> are to enable hardware debouncing, with potential upstream generic
> support soon; and disabled linkages of the MMC power supplies to
> those card detect lines (best suited IMO to platform_data, once
> it's tested).
> 
> Which makes twl4030-gpio nearly ready to go upstream.

Pushing all 6 today.

Tony

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch 2.6.27-omap-git+ 6/5] twl4030 MMC card detction
  2008-10-14 19:01 ` [patch 2.6.27-omap-git+ 6/5] twl4030 MMC card detction David Brownell
@ 2008-10-16 22:33   ` David Brownell
  0 siblings, 0 replies; 4+ messages in thread
From: David Brownell @ 2008-10-16 22:33 UTC (permalink / raw)
  To: linux-omap

On Tuesday 14 October 2008, David Brownell wrote:
> Replace stubbed-out card-detect support for twl4030 GPIOs with
> a simpler platform_data mechanism.  As before, no current users.
> Sanity tested by enabling this on Beagle; it booted OK with
> root on MMC.
> 
> Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
> ---
>  drivers/gpio/twl4030-gpio.c |   52 +++++++++---------------------------------
>  include/linux/i2c/twl4030.h |    3 ++
>  2 files changed, 15 insertions(+), 40 deletions(-)

By the way, a minor comment:  I noticed that there are also
settings in the PM_RECEIVER "dc-to-dc_GLOBAL_CFG" register
to change the card detect signal from active high (which is
the default) to active low.

This patch doesn't support such signal polarity options,
but it'd seem likely to me that some boards will need them.
Someday later than today.  :)

This email is just to note this issue ... fixing it should
be trivial, there are several more bits available in that
byte which could be used to configure polarity.

- Dave

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-10-16 22:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-13 19:59 [patch 2.6.27-omap-git+ 0/5] twl4030 GPIO updates David Brownell
2008-10-14 19:01 ` [patch 2.6.27-omap-git+ 6/5] twl4030 MMC card detction David Brownell
2008-10-16 22:33   ` David Brownell
2008-10-16 21:26 ` [patch 2.6.27-omap-git+ 0/5] twl4030 GPIO updates Tony Lindgren

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox