diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-10-05 12:01:30 +0900 | 
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-10-05 12:01:30 +0900 | 
| commit | 578f1ef91aa92beb571bfb9af8f4d18f405f3b9e (patch) | |
| tree | 8ff59e772d09180b7e7f952a8c90a1bcf25e1d19 /drivers/gpio/gpio-twl6040.c | |
| parent | ecefbd94b834fa32559d854646d777c56749ef1c (diff) | |
| parent | 74d8378159de16a0a1d1975d4778120d263d6000 (diff) | |
| download | olio-linux-3.10-578f1ef91aa92beb571bfb9af8f4d18f405f3b9e.tar.xz olio-linux-3.10-578f1ef91aa92beb571bfb9af8f4d18f405f3b9e.zip  | |
Merge tag 'mfd-3.7-1' of git://git.kernel.org/pub/scm/linux/kernel/git/sameo/mfd-2.6
Pull MFD changes from Samuel Ortiz:
 "MFD bits for the 3.7 merge window.
  As usual we have a few new drivers:
   - TI LP8788
   - TI OMAP USB TLL
   - Maxim MAX8907
   - SMSC ECE1099
   - Dialog Semiconductor DA9055
   - A simpler syscon driver that allow us to get rid of the anatop one.
  Drivers are also gradually getting Device Tree and IRQ domain support.
  The following drivers got DT support:
   - palmas, 88pm860x, tc3589x and twl4030-audio
  And those ones now use the IRQ domain APIs:
   - 88pm860x, tc3589x, db8500_prcmu
  Also some other interesting changes:
   - Intel's ICH LPC now supports Lynx Point
   - TI's twl4030-audio added a GPO child
   - tps6527 enabled its backlight subdevice
   - The twl6030 pwm driver moved to the new PWM subsystem
  And finally a bunch of cleanup and casual fixes for mc13xxx, 88pm860x,
  palmas, ab8500, wm8994, wm5110, max8907 and the tps65xxx family."
Fix up various annoying conflicts: the DT and IRQ domain support came in
twice and was already in 3.6. And then it was apparently rebased.
Guys, DON'T REBASE!
* tag 'mfd-3.7-1' of git://git.kernel.org/pub/scm/linux/kernel/git/sameo/mfd-2.6: (89 commits)
  ARM: dts: Enable 88pm860x pmic
  mfd: 88pm860x: Move gpadc init into touch
  mfd: 88pm860x: Device tree support
  mfd: 88pm860x: Use irqdomain
  mfd: smsc: Add support for smsc gpio io/keypad driver
  backlight: tps65217_bl: Add missing platform_set_drvdata in tps65217_bl_probe
  mfd: DA9055 core driver
  mfd: tps65910: Add alarm interrupt of TPS65910 RTC to mfd device list
  mfd: wm5110: Add register patches for revision B
  mfd: wm5110: Disable control interface error report for WM5110 rev B
  mfd: max8907: Remove regulator-compatible from DT docs
  backlight: Add TPS65217 WLED driver
  mfd: Add backlight as subdevice to the tps65217
  mfd: Provide the PRCMU with its own IRQ domain
  mfd: Fix max8907 sparse warning
  mfd: Add lp8788 mfd driver
  mfd: dbx500: Provide a more accurate smp_twd clock
  mfd: rc5t583: Fix warning messages
  regulator: palmas: Add DT support
  mfd: palmas: Change regulator defns to better suite DT
  ...
Diffstat (limited to 'drivers/gpio/gpio-twl6040.c')
| -rw-r--r-- | drivers/gpio/gpio-twl6040.c | 137 | 
1 files changed, 137 insertions, 0 deletions
diff --git a/drivers/gpio/gpio-twl6040.c b/drivers/gpio/gpio-twl6040.c new file mode 100644 index 00000000000..dd58e8b2504 --- /dev/null +++ b/drivers/gpio/gpio-twl6040.c @@ -0,0 +1,137 @@ +/* + * Access to GPOs on TWL6040 chip + * + * Copyright (C) 2012 Texas Instruments, Inc. + * + * Authors: + *	Sergio Aguirre <saaguirre@ti.com> + *	Peter Ujfalusi <peter.ujfalusi@ti.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA + */ + +#include <linux/module.h> +#include <linux/init.h> +#include <linux/kthread.h> +#include <linux/irq.h> +#include <linux/gpio.h> +#include <linux/platform_device.h> +#include <linux/of.h> + +#include <linux/mfd/twl6040.h> + +static struct gpio_chip twl6040gpo_chip; + +static int twl6040gpo_get(struct gpio_chip *chip, unsigned offset) +{ +	struct twl6040 *twl6040 = dev_get_drvdata(chip->dev->parent); +	int ret = 0; + +	ret = twl6040_reg_read(twl6040, TWL6040_REG_GPOCTL); +	if (ret < 0) +		return ret; + +	return (ret >> offset) & 1; +} + +static int twl6040gpo_direction_out(struct gpio_chip *chip, unsigned offset, +				    int value) +{ +	/* This only drives GPOs, and can't change direction */ +	return 0; +} + +static void twl6040gpo_set(struct gpio_chip *chip, unsigned offset, int value) +{ +	struct twl6040 *twl6040 = dev_get_drvdata(chip->dev->parent); +	int ret; +	u8 gpoctl; + +	ret = twl6040_reg_read(twl6040, TWL6040_REG_GPOCTL); +	if (ret < 0) +		return; + +	if (value) +		gpoctl = ret | (1 << offset); +	else +		gpoctl = ret & ~(1 << offset); + +	twl6040_reg_write(twl6040, TWL6040_REG_GPOCTL, gpoctl); +} + +static struct gpio_chip twl6040gpo_chip = { +	.label			= "twl6040", +	.owner			= THIS_MODULE, +	.get			= twl6040gpo_get, +	.direction_output	= twl6040gpo_direction_out, +	.set			= twl6040gpo_set, +	.can_sleep		= 1, +}; + +/*----------------------------------------------------------------------*/ + +static int __devinit gpo_twl6040_probe(struct platform_device *pdev) +{ +	struct twl6040_gpo_data *pdata = pdev->dev.platform_data; +	struct device *twl6040_core_dev = pdev->dev.parent; +	struct twl6040 *twl6040 = dev_get_drvdata(twl6040_core_dev); +	int ret; + +	if (pdata) +		twl6040gpo_chip.base = pdata->gpio_base; +	else +		twl6040gpo_chip.base = -1; + +	if (twl6040_get_revid(twl6040) < TWL6041_REV_ES2_0) +		twl6040gpo_chip.ngpio = 3; /* twl6040 have 3 GPO */ +	else +		twl6040gpo_chip.ngpio = 1; /* twl6041 have 1 GPO */ + +	twl6040gpo_chip.dev = &pdev->dev; +#ifdef CONFIG_OF_GPIO +	twl6040gpo_chip.of_node = twl6040_core_dev->of_node; +#endif + +	ret = gpiochip_add(&twl6040gpo_chip); +	if (ret < 0) { +		dev_err(&pdev->dev, "could not register gpiochip, %d\n", ret); +		twl6040gpo_chip.ngpio = 0; +	} + +	return ret; +} + +static int __devexit gpo_twl6040_remove(struct platform_device *pdev) +{ +	return gpiochip_remove(&twl6040gpo_chip); +} + +/* Note:  this hardware lives inside an I2C-based multi-function device. */ +MODULE_ALIAS("platform:twl6040-gpo"); + +static struct platform_driver gpo_twl6040_driver = { +	.driver = { +		.name	= "twl6040-gpo", +		.owner	= THIS_MODULE, +	}, +	.probe		= gpo_twl6040_probe, +	.remove		= gpo_twl6040_remove, +}; + +module_platform_driver(gpo_twl6040_driver); + +MODULE_AUTHOR("Texas Instruments, Inc."); +MODULE_DESCRIPTION("GPO interface for TWL6040"); +MODULE_LICENSE("GPL");  |