diff options
author | Nancy Chen <Nancy.Chen@freescale.com> | 2010-10-11 16:03:44 -0500 |
---|---|---|
committer | Nancy Chen <Nancy.Chen@freescale.com> | 2010-10-15 15:36:17 -0500 |
commit | 0a135664fb54237749f037c1975a6c906fa7443b (patch) | |
tree | f5065bbbd8c8f01863a25ae7f29202675297de70 /drivers/mfd | |
parent | 6c345886f8e27097179ddd1455f6b74657d5a2e8 (diff) |
ENGR00124788-1 Add Linear PMIC support
Add Linear PMIC support.
Signed-off-by: Nancy Chen <Nancy.Chen@freescale.com>
Diffstat (limited to 'drivers/mfd')
-rw-r--r-- | drivers/mfd/Kconfig | 9 | ||||
-rw-r--r-- | drivers/mfd/Makefile | 2 | ||||
-rw-r--r-- | drivers/mfd/ltc3589-i2c.c | 121 |
3 files changed, 132 insertions, 0 deletions
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index 92d59373b0cf..410497d638a3 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -347,6 +347,15 @@ config MFD_WM8994 core support for the WM8994, in order to use the actual functionaltiy of the device other drivers must be enabled. +config MFD_LTC3589 + bool + depends on GENERIC_HARDIRQS + +config MFD_LTC3589_I2C + bool "Support for Linear LTC3589 with I2C" + select MFD_LTC3589 + depends on I2C=y && GENERIC_HARDIRQS + config MFD_PCF50633 tristate "Support for NXP PCF50633" depends on I2C diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index 3c4a3b53fafd..292123173bb9 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile @@ -29,6 +29,8 @@ obj-$(CONFIG_MFD_WM8350) += wm8350.o obj-$(CONFIG_MFD_WM8350_I2C) += wm8350-i2c.o obj-$(CONFIG_MFD_WM8994) += wm8994-core.o wm8994-irq.o +obj-$(CONFIG_REGULATOR_LTC3589) += ltc3589-i2c.o + obj-$(CONFIG_TPS65010) += tps65010.o obj-$(CONFIG_TPS6507X) += tps6507x.o obj-$(CONFIG_MENELAUS) += menelaus.o diff --git a/drivers/mfd/ltc3589-i2c.c b/drivers/mfd/ltc3589-i2c.c new file mode 100644 index 000000000000..db0017e30827 --- /dev/null +++ b/drivers/mfd/ltc3589-i2c.c @@ -0,0 +1,121 @@ +/* + * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved. + * + * 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., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +/*! + * @file ltc3589-i2c.c + * @brief This is the generic I2C driver for Linear 3589 PMIC. + * + * @ingroup PMIC_CORE + */ + +#include <linux/module.h> +#include <linux/moduleparam.h> +#include <linux/init.h> +#include <linux/i2c.h> +#include <linux/platform_device.h> +#include <linux/mfd/ltc3589/core.h> +#include <linux/uaccess.h> +#include <linux/slab.h> + +static inline int ltc3589_i2c_read(struct ltc3589 *ltc, u8 reg) +{ + return i2c_smbus_read_byte_data(ltc->i2c_client, reg); +} + +static inline int ltc3589_i2c_write(struct ltc3589 *ltc, u8 reg, u8 val) +{ + return i2c_smbus_write_byte_data(ltc->i2c_client, reg, val); +} + +static int ltc3589_i2c_probe(struct i2c_client *i2c, + const struct i2c_device_id *id) +{ + struct ltc3589 *ltc3589; + struct ltc3589_platform_data *plat_data = i2c->dev.platform_data; + int ret = 0; + + ltc3589 = kzalloc(sizeof(struct ltc3589), GFP_KERNEL); + if (ltc3589 == NULL) + return -ENOMEM; + + i2c_set_clientdata(i2c, ltc3589); + ltc3589->dev = &i2c->dev; + ltc3589->i2c_client = i2c; + ltc3589->read_dev = ltc3589_i2c_read; + ltc3589->write_dev = ltc3589_i2c_write; + + if (ltc3589_i2c_read(ltc3589, 0x33) < 0) { + kfree(ltc3589); + return -ENODEV; + } + + /* so far, we got matched chip on board */ + + ltc3589_client = i2c; + if (plat_data && plat_data->init) { + ret = plat_data->init(ltc3589); + if (ret != 0) + return -EINVAL; + } + + dev_info(&i2c->dev, "Loaded\n"); + + return 0; +} + +static int ltc3589_i2c_remove(struct i2c_client *i2c) +{ + struct ltc3589 *ltc3589 = i2c_get_clientdata(i2c); + + kfree(ltc3589); + return 0; +} + +static const struct i2c_device_id ltc3589_id[] = { + { "ltc3589", 0 }, + { } +}; +MODULE_DEVICE_TABLE(i2c, ltc3589_id); + + +static struct i2c_driver ltc3589_i2c_driver = { + .driver = { + .name = "ltc3589", + .owner = THIS_MODULE, + }, + .probe = ltc3589_i2c_probe, + .remove = ltc3589_i2c_remove, + .id_table = ltc3589_id, +}; + +static int __init ltc3589_i2c_init(void) +{ + return i2c_add_driver(<c3589_i2c_driver); +} +/* init early so consumer devices can complete system boot */ +subsys_initcall(ltc3589_i2c_init); + +static void __exit ltc3589_i2c_exit(void) +{ + i2c_del_driver(<c3589_i2c_driver); +} +module_exit(ltc3589_i2c_exit); + +MODULE_AUTHOR("Freescale Semiconductor, Inc."); +MODULE_DESCRIPTION("I2C support for the Linear PMIC"); +MODULE_LICENSE("GPL"); |