aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/linux/linux-davinci/0003-tps6507x_mfd_driver.patch
diff options
context:
space:
mode:
Diffstat (limited to 'recipes/linux/linux-davinci/0003-tps6507x_mfd_driver.patch')
-rw-r--r--recipes/linux/linux-davinci/0003-tps6507x_mfd_driver.patch214
1 files changed, 214 insertions, 0 deletions
diff --git a/recipes/linux/linux-davinci/0003-tps6507x_mfd_driver.patch b/recipes/linux/linux-davinci/0003-tps6507x_mfd_driver.patch
new file mode 100644
index 0000000000..0acbf8a26b
--- /dev/null
+++ b/recipes/linux/linux-davinci/0003-tps6507x_mfd_driver.patch
@@ -0,0 +1,214 @@
+Index: git/drivers/mfd/Kconfig
+===================================================================
+--- git.orig/drivers/mfd/Kconfig 2010-01-06 16:23:19.000000000 -0600
++++ git/drivers/mfd/Kconfig 2010-01-12 08:43:00.961383768 -0600
+@@ -84,6 +84,17 @@
+ This driver can also be built as a module. If so, the module
+ will be called tps65010.
+
++config TPS6507x
++ tristate "TPS6507x Power Management / Touch Screen chips"
++ depends on I2C
++ help
++ If you say yes here you get support for the TPS6507x series of
++ Power Management / Touch Screen chips. These include voltage
++ regulators, lithium ion/polymer battery charging, touch screen
++ and other features that are often used in portable devices.
++ This driver can also be built as a module. If so, the module
++ will be called tps6507x.
++
+ config MENELAUS
+ bool "Texas Instruments TWL92330/Menelaus PM chip"
+ depends on I2C=y && ARCH_OMAP24XX
+Index: git/drivers/mfd/Makefile
+===================================================================
+--- git.orig/drivers/mfd/Makefile 2010-01-06 16:23:19.000000000 -0600
++++ git/drivers/mfd/Makefile 2010-01-12 08:43:00.961383768 -0600
+@@ -22,6 +22,7 @@
+ obj-$(CONFIG_MFD_WM8350_I2C) += wm8350-i2c.o
+
+ obj-$(CONFIG_TPS65010) += tps65010.o
++obj-$(CONFIG_TPS6507x) += tps6507x.o
+ obj-$(CONFIG_MENELAUS) += menelaus.o
+
+ obj-$(CONFIG_TWL4030_CORE) += twl4030-core.o twl4030-irq.o
+Index: git/drivers/mfd/tps6507x.c
+===================================================================
+--- /dev/null 1970-01-01 00:00:00.000000000 +0000
++++ git/drivers/mfd/tps6507x.c 2010-01-12 08:53:53.009504942 -0600
+@@ -0,0 +1,139 @@
++/*
++ * tps6507x.c -- TPS6507x chip family multi-function driver
++ *
++ * Copyright (c) 2010 RidgeRun (todd.fischer@ridgerun.com)
++ *
++ * Author: Todd Fischer
++ * todd.fischer@ridgerun.com
++ *
++ * Credits:
++ *
++ * Using code from wm8350-i2c.c, Wolfson Microelectronics PLC.
++ *
++ * For licencing details see kernel-base/COPYING
++ *
++ */
++
++#include <linux/module.h>
++#include <linux/moduleparam.h>
++#include <linux/init.h>
++#include <linux/i2c.h>
++#include <linux/platform_device.h>
++#include <linux/mfd/tps6507x.h>
++
++static int tps6507x_i2c_read_device(struct tps6507x_dev *tps6507x, char reg,
++ int bytes, void *dest)
++{
++ int ret;
++
++ ret = i2c_master_send(tps6507x->i2c_client, &reg, 1);
++ if (ret < 0)
++ return ret;
++ ret = i2c_master_recv(tps6507x->i2c_client, dest, bytes);
++ if (ret < 0)
++ return ret;
++ if (ret != bytes)
++ return -EIO;
++ return 0;
++}
++
++static int tps6507x_i2c_write_device(struct tps6507x_dev *tps6507x, char reg,
++ int bytes, void *src)
++{
++ /* we add 1 byte for device register */
++ u8 msg[(TPS6507X_MAX_REGISTER << 1) + 1];
++ int ret;
++
++ if (bytes > ((TPS6507X_MAX_REGISTER << 1) + 1))
++ return -EINVAL;
++
++ msg[0] = reg;
++ memcpy(&msg[1], src, bytes);
++ ret = i2c_master_send(tps6507x->i2c_client, msg, bytes + 1);
++ if (ret < 0)
++ return ret;
++ if (ret != bytes + 1)
++ return -EIO;
++ return 0;
++}
++
++
++int tps6507x_device_init(struct tps6507x_dev *tps6507x, int irq,
++ struct tps6507x_board *pdata)
++{
++ int ret = 0;
++
++ return ret;
++}
++
++static int tps6507x_i2c_probe(struct i2c_client *i2c,
++ const struct i2c_device_id *id)
++{
++ struct tps6507x_dev *tps6507x;
++ int ret = 0;
++
++ tps6507x = kzalloc(sizeof(struct tps6507x_dev), GFP_KERNEL);
++ if (tps6507x == NULL) {
++ kfree(i2c);
++ return -ENOMEM;
++ }
++
++ i2c_set_clientdata(i2c, tps6507x);
++ tps6507x->dev = &i2c->dev;
++ tps6507x->i2c_client = i2c;
++ tps6507x->read_dev = tps6507x_i2c_read_device;
++ tps6507x->write_dev = tps6507x_i2c_write_device;
++ mutex_init(&tps6507x->adc_mutex);
++
++ ret = tps6507x_device_init(tps6507x, i2c->irq, i2c->dev.platform_data);
++ if (ret < 0)
++ goto err;
++
++ return ret;
++
++err:
++ kfree(tps6507x);
++ return ret;
++}
++
++static int tps6507x_i2c_remove(struct i2c_client *i2c)
++{
++ struct tps6507x_dev *tps6507x = i2c_get_clientdata(i2c);
++
++ kfree(tps6507x);
++
++ return 0;
++}
++
++static const struct i2c_device_id tps6507x_i2c_id[] = {
++ { "tps6507x", 0 },
++ { }
++};
++MODULE_DEVICE_TABLE(i2c, tps6507x_i2c_id);
++
++
++static struct i2c_driver tps6507x_i2c_driver = {
++ .driver = {
++ .name = "tps6507x",
++ .owner = THIS_MODULE,
++ },
++ .probe = tps6507x_i2c_probe,
++ .remove = tps6507x_i2c_remove,
++ .id_table = tps6507x_i2c_id,
++};
++
++static int __init tps6507x_i2c_init(void)
++{
++ return i2c_add_driver(&tps6507x_i2c_driver);
++}
++/* init early so consumer devices can complete system boot */
++subsys_initcall(tps6507x_i2c_init);
++
++static void __exit tps6507x_i2c_exit(void)
++{
++ i2c_del_driver(&tps6507x_i2c_driver);
++}
++module_exit(tps6507x_i2c_exit);
++
++MODULE_DESCRIPTION("TPS6507x chip family multi-function driver")
++MODULE_LICENSE("GPL");
+Index: git/include/linux/mfd/tps6507x.h
+===================================================================
+--- git.orig/include/linux/mfd/tps6507x.h 2010-01-12 08:43:00.797384396 -0600
++++ git/include/linux/mfd/tps6507x.h 2010-01-12 08:53:28.437624848 -0600
+@@ -131,6 +131,8 @@
+ /* VDCDC MASK */
+ #define TPS6507X_DEFDCDCX_DCDC_MASK 0X3F
+
++#define TPS6507X_MAX_REGISTER 0X19
++
+ /**
+ * struct tps6507x_board - packages regulator and touchscreen init data
+ * @tps6507x_regulator_data: regulator initialization values
+@@ -142,4 +144,22 @@
+ struct regulator_init_data *tps6507x_pmic_init_data;
+ };
+
++/**
++ * struct tps6507x_dev - tps6507x sub-driver chip access routines
++ * @read_dev() - I2C register read function
++ * @write_dev() - I2C register write function
++ *
++ * Device data may be used to access the TPS6507x chip
++ */
++
++struct tps6507x_dev {
++ struct device *dev;
++ struct i2c_client *i2c_client;
++ int (*read_dev)(struct tps6507x_dev *tps6507x, char reg, int size,
++ void *dest);
++ int (*write_dev)(struct tps6507x_dev *tps6507x, char reg, int size,
++ void *src);
++ struct mutex adc_mutex;
++};
++
+ #endif /* __LINUX_MFD_TPS6507X_H */