aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/gpio/twl4030-gpio.c54
-rw-r--r--include/linux/i2c/twl4030.h9
2 files changed, 26 insertions, 37 deletions
diff --git a/drivers/gpio/twl4030-gpio.c b/drivers/gpio/twl4030-gpio.c
index 37d3eec8730a..afad14792141 100644
--- a/drivers/gpio/twl4030-gpio.c
+++ b/drivers/gpio/twl4030-gpio.c
@@ -202,37 +202,6 @@ static int twl4030_get_gpio_datain(int gpio)
202 return ret; 202 return ret;
203} 203}
204 204
205/*
206 * Configure debounce timing value for a GPIO pin on TWL4030
207 */
208int twl4030_set_gpio_debounce(int gpio, int enable)
209{
210 u8 d_bnk = gpio >> 3;
211 u8 d_msk = BIT(gpio & 0x7);
212 u8 reg = 0;
213 u8 base = 0;
214 int ret = 0;
215
216 if (unlikely((gpio >= TWL4030_GPIO_MAX)
217 || !(gpio_usage_count & BIT(gpio))))
218 return -EPERM;
219
220 base = REG_GPIO_DEBEN1 + d_bnk;
221 mutex_lock(&gpio_lock);
222 ret = gpio_twl4030_read(base);
223 if (ret >= 0) {
224 if (enable)
225 reg = ret | d_msk;
226 else
227 reg = ret & ~d_msk;
228
229 ret = gpio_twl4030_write(base, reg);
230 }
231 mutex_unlock(&gpio_lock);
232 return ret;
233}
234EXPORT_SYMBOL(twl4030_set_gpio_debounce);
235
236/*----------------------------------------------------------------------*/ 205/*----------------------------------------------------------------------*/
237 206
238static int twl_request(struct gpio_chip *chip, unsigned offset) 207static int twl_request(struct gpio_chip *chip, unsigned offset)
@@ -405,6 +374,23 @@ static int __devinit gpio_twl4030_pulls(u32 ups, u32 downs)
405 REG_GPIOPUPDCTR1, 5); 374 REG_GPIOPUPDCTR1, 5);
406} 375}
407 376
377static int __devinit gpio_twl4030_debounce(u32 debounce, u8 mmc_cd)
378{
379 u8 message[4];
380
381 /* 30 msec of debouncing is always used for MMC card detect,
382 * and is optional for everything else.
383 */
384 message[1] = (debounce & 0xff) | (mmc_cd & 0x03);
385 debounce >>= 8;
386 message[2] = (debounce & 0xff);
387 debounce >>= 8;
388 message[3] = (debounce & 0x03);
389
390 return twl4030_i2c_write(TWL4030_MODULE_GPIO, message,
391 REG_GPIO_DEBEN1, 3);
392}
393
408static int gpio_twl4030_remove(struct platform_device *pdev); 394static int gpio_twl4030_remove(struct platform_device *pdev);
409 395
410static int __devinit gpio_twl4030_probe(struct platform_device *pdev) 396static int __devinit gpio_twl4030_probe(struct platform_device *pdev)
@@ -439,6 +425,12 @@ no_irqs:
439 pdata->pullups, pdata->pulldowns, 425 pdata->pullups, pdata->pulldowns,
440 ret); 426 ret);
441 427
428 ret = gpio_twl4030_debounce(pdata->debounce, pdata->mmc_cd);
429 if (ret)
430 dev_dbg(&pdev->dev, "debounce %.03x %.01x --> %d\n",
431 pdata->debounce, pdata->mmc_cd,
432 ret);
433
442 twl_gpiochip.base = pdata->gpio_base; 434 twl_gpiochip.base = pdata->gpio_base;
443 twl_gpiochip.ngpio = TWL4030_GPIO_MAX; 435 twl_gpiochip.ngpio = TWL4030_GPIO_MAX;
444 twl_gpiochip.dev = &pdev->dev; 436 twl_gpiochip.dev = &pdev->dev;
diff --git a/include/linux/i2c/twl4030.h b/include/linux/i2c/twl4030.h
index a8f84c01f82e..8137f660a5cc 100644
--- a/include/linux/i2c/twl4030.h
+++ b/include/linux/i2c/twl4030.h
@@ -234,6 +234,9 @@ struct twl4030_gpio_platform_data {
234 /* gpio-n should control VMMC(n+1) if BIT(n) in mmc_cd is set */ 234 /* gpio-n should control VMMC(n+1) if BIT(n) in mmc_cd is set */
235 u8 mmc_cd; 235 u8 mmc_cd;
236 236
237 /* if BIT(N) is set, or VMMC(n+1) is linked, debounce GPIO-N */
238 u32 debounce;
239
237 /* For gpio-N, bit (1 << N) in "pullups" is set if that pullup 240 /* For gpio-N, bit (1 << N) in "pullups" is set if that pullup
238 * should be enabled. Else, if that bit is set in "pulldowns", 241 * should be enabled. Else, if that bit is set in "pulldowns",
239 * that pulldown is enabled. Don't waste power by letting any 242 * that pulldown is enabled. Don't waste power by letting any
@@ -307,12 +310,6 @@ int twl4030_sih_setup(int module);
307#define TWL4030_VAUX3_DEV_GRP 0x1F 310#define TWL4030_VAUX3_DEV_GRP 0x1F
308#define TWL4030_VAUX3_DEDICATED 0x22 311#define TWL4030_VAUX3_DEDICATED 0x22
309 312
310/*
311 * Exported TWL4030 GPIO APIs
312 *
313 * WARNING -- use standard GPIO and IRQ calls instead; these will vanish.
314 */
315int twl4030_set_gpio_debounce(int gpio, int enable);
316 313
317#if defined(CONFIG_TWL4030_BCI_BATTERY) || \ 314#if defined(CONFIG_TWL4030_BCI_BATTERY) || \
318 defined(CONFIG_TWL4030_BCI_BATTERY_MODULE) 315 defined(CONFIG_TWL4030_BCI_BATTERY_MODULE)