diff options
author | Ravindra Lokhande <rlokhande@nvidia.com> | 2013-03-19 18:56:02 +0530 |
---|---|---|
committer | Dan Willemsen <dwillemsen@nvidia.com> | 2013-09-14 13:04:36 -0700 |
commit | 3900262fa3136605796b70ca6fa5ba2f1ee53d39 (patch) | |
tree | eb2bbe362a34b9976b0aca533a39d43bfe6c6273 /drivers/mfd/tlv320aic3256-i2c.c | |
parent | c327b463ace7b079339cb273e2ebe61026e76f53 (diff) |
drivers: mfd: Add support for TI aic325x codec
AIC3033 is register compatible with aic3206 which is strip down
version of aic3256.
This code is from TI
Change-Id: I15b6ac2ae52f5b39e5036a5028cf537c93b66134
Signed-off-by: Ravindra Lokhande <rlokhande@nvidia.com>
Reviewed-on: http://git-master/r/210808
GVS: Gerrit_Virtual_Submit
Reviewed-by: Scott Peterson <speterson@nvidia.com>
Diffstat (limited to 'drivers/mfd/tlv320aic3256-i2c.c')
-rw-r--r-- | drivers/mfd/tlv320aic3256-i2c.c | 112 |
1 files changed, 112 insertions, 0 deletions
diff --git a/drivers/mfd/tlv320aic3256-i2c.c b/drivers/mfd/tlv320aic3256-i2c.c new file mode 100644 index 000000000000..6d947494005e --- /dev/null +++ b/drivers/mfd/tlv320aic3256-i2c.c @@ -0,0 +1,112 @@ +/* + * tlv320aic325x-i2c.c -- driver for TLV320AIC3XXX + * + * Author: Mukund Navada <navada@ti.com> + * Mehar Bajwa <mehar.bajwa@ti.com> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * 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 St, Fifth Floor, Boston, MA + * 02110-1301 USA + * + */ + +#include <linux/kernel.h> +#include <linux/err.h> +#include <linux/i2c.h> +#include <linux/module.h> +#include <linux/pm_runtime.h> +#include <linux/regmap.h> +#include <linux/regulator/consumer.h> +#include <linux/slab.h> + +#include <linux/mfd/tlv320aic325x-core.h> + +struct regmap_config aic325x_i2c_regmap = { + .reg_bits = 8, + .val_bits = 8, + .cache_type = REGCACHE_NONE, +}; + +static __devinit int aic325x_i2c_probe(struct i2c_client *i2c, + const struct i2c_device_id *id) +{ + struct aic325x *aic325x; + const struct regmap_config *regmap_config; + int ret; + + switch (id->driver_data) { +#ifdef CONFIG_AIC3262_CORE + case TLV320AIC3262: + regmap_config = &aic325x_i2c_regmap; + break; +#endif + case TLV320AIC3256: + regmap_config = &aic325x_i2c_regmap; + break; + + default: + dev_err(&i2c->dev, "Unknown device type %ld\n", + id->driver_data); + return -EINVAL; + } + + aic325x = devm_kzalloc(&i2c->dev, sizeof(*aic325x), GFP_KERNEL); + if (aic325x == NULL) + return -ENOMEM; + + aic325x->regmap = devm_regmap_init_i2c(i2c, regmap_config); + + if (IS_ERR(aic325x->regmap)) { + ret = PTR_ERR(aic325x->regmap); + dev_err(&i2c->dev, "Failed to allocate register map: %d\n", + ret); + return ret; + } + + aic325x->type = id->driver_data; + aic325x->dev = &i2c->dev; + aic325x->irq = i2c->irq; + + return aic325x_device_init(aic325x); +} + +static int __devexit aic325x_i2c_remove(struct i2c_client *i2c) +{ + struct aic325x *aic325x = dev_get_drvdata(&i2c->dev); + + aic325x_device_exit(aic325x); + return 0; +} + +static const struct i2c_device_id aic325x_i2c_id[] = { + {"tlv320aic3262", TLV320AIC3262}, + {"tlv320aic325x", TLV320AIC3256}, + { } +}; +MODULE_DEVICE_TABLE(i2c, aic325x_i2c_id); + +static struct i2c_driver aic325x_i2c_driver = { + .driver = { + .name = "tlv320aic325x", + .owner = THIS_MODULE, + }, + .probe = aic325x_i2c_probe, + .remove = __devexit_p(aic325x_i2c_remove), + .id_table = aic325x_i2c_id, +}; + +module_i2c_driver(aic325x_i2c_driver); + +MODULE_DESCRIPTION("TLV320AIC3XXX I2C bus interface"); +MODULE_AUTHOR("Mukund Navada <navada@ti.com>"); +MODULE_LICENSE("GPL"); |