Commit 16fa935a authored by Kevin Hilman's avatar Kevin Hilman

Merge branch 'davinci-upstream-accepted' into davinci-reset

parents b57f95a3 bb59c752
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/i2c/at24.h> #include <linux/i2c/at24.h>
#include <linux/i2c/pca953x.h> #include <linux/i2c/pca953x.h>
#include <linux/mfd/tps6507x.h>
#include <linux/gpio.h> #include <linux/gpio.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/mtd/mtd.h> #include <linux/mtd/mtd.h>
...@@ -24,6 +25,8 @@ ...@@ -24,6 +25,8 @@
#include <linux/mtd/partitions.h> #include <linux/mtd/partitions.h>
#include <linux/mtd/physmap.h> #include <linux/mtd/physmap.h>
#include <linux/regulator/machine.h> #include <linux/regulator/machine.h>
#include <linux/mfd/tps6507x.h>
#include <linux/input/tps6507x-ts.h>
#include <asm/mach-types.h> #include <asm/mach-types.h>
#include <asm/mach/arch.h> #include <asm/mach/arch.h>
...@@ -533,10 +536,24 @@ struct regulator_init_data tps65070_regulator_data[] = { ...@@ -533,10 +536,24 @@ struct regulator_init_data tps65070_regulator_data[] = {
}, },
}; };
static struct touchscreen_init_data tps6507x_touchscreen_data = {
.poll_period = 30, /* ms between touch samples */
.min_pressure = 0x30, /* minimum pressure to trigger touch */
.vref = 0, /* turn off vref when not using A/D */
.vendor = 0, /* /sys/class/input/input?/id/vendor */
.product = 65070, /* /sys/class/input/input?/id/product */
.version = 0x100, /* /sys/class/input/input?/id/version */
};
static struct tps6507x_board tps_board = {
.tps6507x_pmic_init_data = &tps65070_regulator_data[0],
.tps6507x_ts_init_data = &tps6507x_touchscreen_data,
};
static struct i2c_board_info __initdata da850evm_tps65070_info[] = { static struct i2c_board_info __initdata da850evm_tps65070_info[] = {
{ {
I2C_BOARD_INFO("tps6507x", 0x48), I2C_BOARD_INFO("tps6507x", 0x48),
.platform_data = &tps65070_regulator_data[0], .platform_data = &tps_board,
}, },
}; };
......
...@@ -22,6 +22,9 @@ struct davinci_mmc_config { ...@@ -22,6 +22,9 @@ struct davinci_mmc_config {
/* Version of the MMC/SD controller */ /* Version of the MMC/SD controller */
u8 version; u8 version;
/* Number of sg segments */
u8 nr_sg;
}; };
void davinci_setup_mmc(int module, struct davinci_mmc_config *config); void davinci_setup_mmc(int module, struct davinci_mmc_config *config);
......
...@@ -594,4 +594,17 @@ config TOUCHSCREEN_PCAP ...@@ -594,4 +594,17 @@ config TOUCHSCREEN_PCAP
To compile this driver as a module, choose M here: the To compile this driver as a module, choose M here: the
module will be called pcap_ts. module will be called pcap_ts.
config TOUCHSCREEN_TPS6507X
tristate "TPS6507x based touchscreens"
depends on I2C
help
Say Y here if you have a TPS6507x based touchscreen
controller.
If unsure, say N.
To compile this driver as a module, choose M here: the
module will be called tps6507x_ts.
endif endif
...@@ -46,3 +46,4 @@ obj-$(CONFIG_TOUCHSCREEN_WM97XX_ATMEL) += atmel-wm97xx.o ...@@ -46,3 +46,4 @@ obj-$(CONFIG_TOUCHSCREEN_WM97XX_ATMEL) += atmel-wm97xx.o
obj-$(CONFIG_TOUCHSCREEN_WM97XX_MAINSTONE) += mainstone-wm97xx.o obj-$(CONFIG_TOUCHSCREEN_WM97XX_MAINSTONE) += mainstone-wm97xx.o
obj-$(CONFIG_TOUCHSCREEN_WM97XX_ZYLONITE) += zylonite-wm97xx.o obj-$(CONFIG_TOUCHSCREEN_WM97XX_ZYLONITE) += zylonite-wm97xx.o
obj-$(CONFIG_TOUCHSCREEN_W90X900) += w90p910_ts.o obj-$(CONFIG_TOUCHSCREEN_W90X900) += w90p910_ts.o
obj-$(CONFIG_TOUCHSCREEN_TPS6507X) += tps6507x-ts.o
/*
* drivers/input/touchscreen/tps6507x_ts.c
*
* Touchscreen driver for the tps6507x chip.
*
* Copyright (c) 2009 RidgeRun (todd.fischer@ridgerun.com)
*
* Credits:
*
* Using code from tsc2007, MtekVision Co., Ltd.
*
* For licencing details see kernel-base/COPYING
*
* TPS65070, TPS65073, TPS650731, and TPS650732 support
* 10 bit touch screen interface.
*/
#include <linux/module.h>
#include <linux/workqueue.h>
#include <linux/slab.h>
#include <linux/input.h>
#include <linux/platform_device.h>
#include <linux/mfd/tps6507x.h>
#include <linux/input/tps6507x-ts.h>
#include <linux/delay.h>
#define TSC_DEFAULT_POLL_PERIOD 30 /* ms */
#define TPS_DEFAULT_MIN_PRESSURE 0x30
#define MAX_10BIT ((1 << 10) - 1)
#define TPS6507X_ADCONFIG_CONVERT_TS (TPS6507X_ADCONFIG_AD_ENABLE | \
TPS6507X_ADCONFIG_START_CONVERSION | \
TPS6507X_ADCONFIG_INPUT_REAL_TSC)
#define TPS6507X_ADCONFIG_POWER_DOWN_TS (TPS6507X_ADCONFIG_INPUT_REAL_TSC)
struct ts_event {
u16 x;
u16 y;
u16 pressure;
};
struct tps6507x_ts {
struct input_dev *input_dev;
struct device *dev;
char phys[32];
struct workqueue_struct *wq;
struct delayed_work work;
unsigned polling; /* polling is active */
struct ts_event tc;
struct tps6507x_dev *mfd;
u16 model;
unsigned pendown;
int irq;
void (*clear_penirq)(void);
unsigned long poll_period; /* ms */
u16 min_pressure;
int vref; /* non-zero to leave vref on */
};
static int tps6507x_read_u8(struct tps6507x_ts *tsc, u8 reg, u8 *data)
{
int err;
err = tsc->mfd->read_dev(tsc->mfd, reg, 1, data);
if (err)
return err;
return 0;
}
static int tps6507x_write_u8(struct tps6507x_ts *tsc, u8 reg, u8 data)
{
return tsc->mfd->write_dev(tsc->mfd, reg, 1, &data);
}
static s32 tps6507x_adc_conversion(struct tps6507x_ts *tsc,
u8 tsc_mode, u16 *value)
{
s32 ret;
u8 adc_status;
u8 result;
/* Route input signal to A/D converter */
ret = tps6507x_write_u8(tsc, TPS6507X_REG_TSCMODE, tsc_mode);
if (ret) {
dev_err(tsc->dev, "TSC mode read failed\n");
goto err;
}
/* Start A/D conversion */
ret = tps6507x_write_u8(tsc, TPS6507X_REG_ADCONFIG,
TPS6507X_ADCONFIG_CONVERT_TS);
if (ret) {
dev_err(tsc->dev, "ADC config write failed\n");
return ret;
}
do {
ret = tps6507x_read_u8(tsc, TPS6507X_REG_ADCONFIG,
&adc_status);
if (ret) {
dev_err(tsc->dev, "ADC config read failed\n");
goto err;
}
} while (adc_status & TPS6507X_ADCONFIG_START_CONVERSION);
ret = tps6507x_read_u8(tsc, TPS6507X_REG_ADRESULT_2, &result);
if (ret) {
dev_err(tsc->dev, "ADC result 2 read failed\n");
goto err;
}
*value = (result & TPS6507X_REG_ADRESULT_2_MASK) << 8;
ret = tps6507x_read_u8(tsc, TPS6507X_REG_ADRESULT_1, &result);
if (ret) {
dev_err(tsc->dev, "ADC result 1 read failed\n");
goto err;
}
*value |= result;
dev_dbg(tsc->dev, "TSC channel %d = 0x%X\n", tsc_mode, *value);
err:
return ret;
}
/* Need to call tps6507x_adc_standby() after using A/D converter for the
* touch screen interrupt to work properly.
*/
static s32 tps6507x_adc_standby(struct tps6507x_ts *tsc)
{
s32 ret;
s32 loops = 0;
u8 val;
ret = tps6507x_write_u8(tsc, TPS6507X_REG_ADCONFIG,
TPS6507X_ADCONFIG_INPUT_TSC);
if (ret)
return ret;
ret = tps6507x_write_u8(tsc, TPS6507X_REG_TSCMODE,
TPS6507X_TSCMODE_STANDBY);
if (ret)
return ret;
ret = tps6507x_read_u8(tsc, TPS6507X_REG_INT, &val);
if (ret)
return ret;
while (val & TPS6507X_REG_TSC_INT) {
mdelay(10);
ret = tps6507x_read_u8(tsc, TPS6507X_REG_INT, &val);
if (ret)
return ret;
loops++;
}
return ret;
}
static void tps6507x_ts_handler(struct work_struct *work)
{
struct tps6507x_ts *tsc = container_of(work,
struct tps6507x_ts, work.work);
struct input_dev *input_dev = tsc->input_dev;
int pendown;
int schd;
int poll = 0;
s32 ret;
ret = tps6507x_adc_conversion(tsc, TPS6507X_TSCMODE_PRESSURE,
&tsc->tc.pressure);
if (ret)
goto done;
pendown = tsc->tc.pressure > tsc->min_pressure;
if (unlikely(!pendown && tsc->pendown)) {
dev_dbg(tsc->dev, "UP\n");
input_report_key(input_dev, BTN_TOUCH, 0);
input_report_abs(input_dev, ABS_PRESSURE, 0);
input_sync(input_dev);
tsc->pendown = 0;
}
if (pendown) {
if (!tsc->pendown) {
dev_dbg(tsc->dev, "DOWN\n");
input_report_key(input_dev, BTN_TOUCH, 1);
} else
dev_dbg(tsc->dev, "still down\n");
ret = tps6507x_adc_conversion(tsc, TPS6507X_TSCMODE_X_POSITION,
&tsc->tc.x);
if (ret)
goto done;
ret = tps6507x_adc_conversion(tsc, TPS6507X_TSCMODE_Y_POSITION,
&tsc->tc.y);
if (ret)
goto done;
input_report_abs(input_dev, ABS_X, tsc->tc.x);
input_report_abs(input_dev, ABS_Y, tsc->tc.y);
input_report_abs(input_dev, ABS_PRESSURE, tsc->tc.pressure);
input_sync(input_dev);
tsc->pendown = 1;
poll = 1;
}
done:
/* always poll if not using interrupts */
poll = 1;
if (poll) {
schd = queue_delayed_work(tsc->wq, &tsc->work,
tsc->poll_period * HZ / 1000);
if (schd)
tsc->polling = 1;
else {
tsc->polling = 0;
dev_err(tsc->dev, "re-schedule failed");
}
} else
tsc->polling = 0;
ret = tps6507x_adc_standby(tsc);
}
static int tps6507x_ts_probe(struct platform_device *pdev)
{
int error;
struct tps6507x_ts *tsc;
struct tps6507x_dev *tps6507x_dev = dev_get_drvdata(pdev->dev.parent);
struct touchscreen_init_data *init_data;
struct input_dev *input_dev;
struct tps6507x_board *tps_board;
int schd;
/**
* tps_board points to pmic related constants
* coming from the board-evm file.
*/
tps_board = (struct tps6507x_board *)tps6507x_dev->dev->platform_data;
if (!tps_board) {
dev_err(tps6507x_dev->dev,
"Could not find tps6507x platform data\n");
return -EIO;
}
/**
* init_data points to array of regulator_init structures
* coming from the board-evm file.
*/
init_data = tps_board->tps6507x_ts_init_data;
tsc = kzalloc(sizeof(struct tps6507x_ts), GFP_KERNEL);
if (!tsc) {
dev_err(tps6507x_dev->dev, "failed to allocate driver data\n");
error = -ENOMEM;
goto err0;
}
tps6507x_dev->ts = tsc;
tsc->mfd = tps6507x_dev;
tsc->dev = tps6507x_dev->dev;
input_dev = input_allocate_device();
if (!input_dev) {
dev_err(tsc->dev, "Failed to allocate input device.\n");
error = -ENOMEM;
goto err1;
}
input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
input_set_abs_params(input_dev, ABS_X, 0, MAX_10BIT, 0, 0);
input_set_abs_params(input_dev, ABS_Y, 0, MAX_10BIT, 0, 0);
input_set_abs_params(input_dev, ABS_PRESSURE, 0, MAX_10BIT, 0, 0);
input_dev->name = "TPS6507x Touchscreen";
input_dev->id.bustype = BUS_I2C;
input_dev->dev.parent = tsc->dev;
snprintf(tsc->phys, sizeof(tsc->phys),
"%s/input0", dev_name(tsc->dev));
input_dev->phys = tsc->phys;
dev_dbg(tsc->dev, "device: %s\n", input_dev->phys);
input_set_drvdata(input_dev, tsc);
tsc->input_dev = input_dev;
INIT_DELAYED_WORK(&tsc->work, tps6507x_ts_handler);
tsc->wq = create_workqueue("TPS6507x Touchscreen");
if (init_data) {
tsc->poll_period = init_data->poll_period;
tsc->vref = init_data->vref;
tsc->min_pressure = init_data->min_pressure;
input_dev->id.vendor = init_data->vendor;
input_dev->id.product = init_data->product;
input_dev->id.version = init_data->version;
} else {
tsc->poll_period = TSC_DEFAULT_POLL_PERIOD;
tsc->min_pressure = TPS_DEFAULT_MIN_PRESSURE;
}
error = tps6507x_adc_standby(tsc);
if (error)
goto err2;
error = input_register_device(input_dev);
if (error)
goto err2;
schd = queue_delayed_work(tsc->wq, &tsc->work,
tsc->poll_period * HZ / 1000);
if (schd)
tsc->polling = 1;
else {
tsc->polling = 0;
dev_err(tsc->dev, "schedule failed");
goto err2;
}
return 0;
err2:
cancel_delayed_work(&tsc->work);
flush_workqueue(tsc->wq);
destroy_workqueue(tsc->wq);
tsc->wq = 0;
input_free_device(input_dev);
err1:
kfree(tsc);
tps6507x_dev->ts = NULL;
err0:
return error;
}
static int __devexit tps6507x_ts_remove(struct platform_device *pdev)
{
struct tps6507x_dev *tps6507x_dev = platform_get_drvdata(pdev);
struct tps6507x_ts *tsc = tps6507x_dev->ts;
struct input_dev *input_dev = tsc->input_dev;
if (!tsc)
return 0;
cancel_delayed_work(&tsc->work);
flush_workqueue(tsc->wq);
destroy_workqueue(tsc->wq);
tsc->wq = 0;
input_free_device(input_dev);
tps6507x_dev->ts = NULL;
kfree(tsc);
return 0;
}
static struct platform_driver tps6507x_ts_driver = {
.driver = {
.name = "tps6507x-ts",
.owner = THIS_MODULE,
},
.probe = tps6507x_ts_probe,
.remove = __devexit_p(tps6507x_ts_remove),
};
static int __init tps6507x_ts_init(void)
{
return platform_driver_register(&tps6507x_ts_driver);
}
module_init(tps6507x_ts_init);
static void __exit tps6507x_ts_exit(void)
{
platform_driver_unregister(&tps6507x_ts_driver);
}
module_exit(tps6507x_ts_exit);
MODULE_AUTHOR("Todd Fischer <todd.fischer@ridgerun.com>");
MODULE_DESCRIPTION("TPS6507x - TouchScreen driver");
MODULE_LICENSE("GPL v2");
MODULE_ALIAS("platform:tps6507x-tsc");
...@@ -111,6 +111,18 @@ config TPS65010 ...@@ -111,6 +111,18 @@ config TPS65010
This driver can also be built as a module. If so, the module This driver can also be built as a module. If so, the module
will be called tps65010. will be called tps65010.
config TPS6507X
tristate "TPS6507x Power Management / Touch Screen chips"
select MFD_CORE
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 config MENELAUS
bool "Texas Instruments TWL92330/Menelaus PM chip" bool "Texas Instruments TWL92330/Menelaus PM chip"
depends on I2C=y && ARCH_OMAP2 depends on I2C=y && ARCH_OMAP2
......
...@@ -28,6 +28,7 @@ obj-$(CONFIG_MFD_WM8350_I2C) += wm8350-i2c.o ...@@ -28,6 +28,7 @@ obj-$(CONFIG_MFD_WM8350_I2C) += wm8350-i2c.o
obj-$(CONFIG_MFD_WM8994) += wm8994-core.o obj-$(CONFIG_MFD_WM8994) += wm8994-core.o
obj-$(CONFIG_TPS65010) += tps65010.o obj-$(CONFIG_TPS65010) += tps65010.o
obj-$(CONFIG_TPS6507X) += tps6507x.o
obj-$(CONFIG_MENELAUS) += menelaus.o obj-$(CONFIG_MENELAUS) += menelaus.o
obj-$(CONFIG_TWL4030_CORE) += twl-core.o twl4030-irq.o twl6030-irq.o obj-$(CONFIG_TWL4030_CORE) += twl-core.o twl4030-irq.o twl6030-irq.o
...@@ -62,4 +63,4 @@ obj-$(CONFIG_AB3100_OTP) += ab3100-otp.o ...@@ -62,4 +63,4 @@ obj-$(CONFIG_AB3100_OTP) += ab3100-otp.o
obj-$(CONFIG_AB4500_CORE) += ab4500-core.o obj-$(CONFIG_AB4500_CORE) += ab4500-core.o
obj-$(CONFIG_MFD_TIMBERDALE) += timberdale.o obj-$(CONFIG_MFD_TIMBERDALE) += timberdale.o
obj-$(CONFIG_PMIC_ADP5520) += adp5520.o obj-$(CONFIG_PMIC_ADP5520) += adp5520.o
obj-$(CONFIG_LPC_SCH) += lpc_sch.o obj-$(CONFIG_LPC_SCH) += lpc_sch.o
\ No newline at end of file
/*
* 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 wm831x-*.c, wm8400-core, 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/mfd/core.h>
#include <linux/mfd/tps6507x.h>
static struct mfd_cell tps6507x_devs[] = {
{
.name = "tps6507x-pmic",
},
{
.name = "tps6507x-ts",
},
};
static int tps6507x_i2c_read_device(struct tps6507x_dev *tps6507x, char reg,
int bytes, void *dest)
{
struct i2c_client *i2c = tps6507x->i2c_client;
struct i2c_msg xfer[2];
int ret;
/* Write register */
xfer[0].addr = i2c->addr;
xfer[0].flags = 0;
xfer[0].len = 1;
xfer[0].buf = &reg;
/* Read data */
xfer[1].addr = i2c->addr;
xfer[1].flags = I2C_M_RD;
xfer[1].len = bytes;
xfer[1].buf = dest;
ret = i2c_transfer(i2c->adapter, xfer, 2);
if (ret == 2)
ret = 0;
else if (ret >= 0)
ret = -EIO;
return ret;
}
static int tps6507x_i2c_write_device(struct tps6507x_dev *tps6507x, char reg,
int bytes, void *src)
{
struct i2c_client *i2c = tps6507x->i2c_client;
/* we add 1 byte for device register */
u8 msg[TPS6507X_MAX_REGISTER + 1];
int ret;
if (bytes > (TPS6507X_MAX_REGISTER + 1))
return -EINVAL;
msg[0] = reg;
memcpy(&msg[1], src, bytes);
ret = i2c_master_send(i2c, msg, bytes + 1);
if (ret < 0)
return ret;
if (ret != bytes + 1)
return -EIO;
return 0;
}
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;
ret = mfd_add_devices(tps6507x->dev, -1,
tps6507x_devs, ARRAY_SIZE(tps6507x_devs),
NULL, 0);
if (ret < 0)
goto err;
return ret;
err:
mfd_remove_devices(tps6507x->dev);
kfree(tps6507x);
return ret;
}
static int tps6507x_i2c_remove(struct i2c_client *i2c)
{
struct tps6507x_dev *tps6507x = i2c_get_clientdata(i2c);
mfd_remove_devices(tps6507x->dev);
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");
...@@ -137,15 +137,15 @@ ...@@ -137,15 +137,15 @@
/* /*
* One scatterlist dma "segment" is at most MAX_CCNT rw_threshold units, * One scatterlist dma "segment" is at most MAX_CCNT rw_threshold units,
* and we handle up to NR_SG segments. MMC_BLOCK_BOUNCE kicks in only * and we handle up to MAX_NR_SG segments. MMC_BLOCK_BOUNCE kicks in only
* for drivers with max_hw_segs == 1, making the segments bigger (64KB) * for drivers with max_hw_segs == 1, making the segments bigger (64KB)
* than the page or two that's otherwise typical. NR_SG == 16 gives at * than the page or two that's otherwise typical. nr_sg (passed from
* least the same throughput boost, using EDMA transfer linkage instead * platform data) == 16 gives at least the same throughput boost, using
* of spending CPU time copying pages. * EDMA transfer linkage instead of spending CPU time copying pages.
*/ */
#define MAX_CCNT ((1 << 16) - 1) #define MAX_CCNT ((1 << 16) - 1)
#define NR_SG 16 #define MAX_NR_SG 16
static unsigned rw_threshold = 32; static unsigned rw_threshold = 32;
module_param(rw_threshold, uint, S_IRUGO); module_param(rw_threshold, uint, S_IRUGO);
...@@ -171,6 +171,7 @@ struct mmc_davinci_host { ...@@ -171,6 +171,7 @@ struct mmc_davinci_host {
#define DAVINCI_MMC_DATADIR_READ 1 #define DAVINCI_MMC_DATADIR_READ 1
#define DAVINCI_MMC_DATADIR_WRITE 2 #define DAVINCI_MMC_DATADIR_WRITE 2
unsigned char data_dir; unsigned char data_dir;
unsigned char suspended;
/* buffer is used during PIO of one scatterlist segment, and /* buffer is used during PIO of one scatterlist segment, and
* is updated along with buffer_bytes_left. bytes_left applies * is updated along with buffer_bytes_left. bytes_left applies
...@@ -192,7 +193,7 @@ struct mmc_davinci_host { ...@@ -192,7 +193,7 @@ struct mmc_davinci_host {
struct edmacc_param tx_template; struct edmacc_param tx_template;
struct edmacc_param rx_template; struct edmacc_param rx_template;
unsigned n_link; unsigned n_link;
u32 links[NR_SG - 1]; u32 links[MAX_NR_SG - 1];
/* For PIO we walk scatterlists one segment at a time. */ /* For PIO we walk scatterlists one segment at a time. */
unsigned int sg_len; unsigned int sg_len;
...@@ -202,6 +203,8 @@ struct mmc_davinci_host { ...@@ -202,6 +203,8 @@ struct mmc_davinci_host {
u8 version; u8 version;
/* for ns in one cycle calculation */ /* for ns in one cycle calculation */
unsigned ns_in_one_cycle; unsigned ns_in_one_cycle;
/* Number of sg segments */
u8 nr_sg;
#ifdef CONFIG_CPU_FREQ #ifdef CONFIG_CPU_FREQ
struct notifier_block freq_transition; struct notifier_block freq_transition;
#endif #endif
...@@ -568,6 +571,7 @@ davinci_release_dma_channels(struct mmc_davinci_host *host) ...@@ -568,6 +571,7 @@ davinci_release_dma_channels(struct mmc_davinci_host *host)
static int __init davinci_acquire_dma_channels(struct mmc_davinci_host *host) static int __init davinci_acquire_dma_channels(struct mmc_davinci_host *host)
{ {
u32 link_size;
int r, i; int r, i;
/* Acquire master DMA write channel */ /* Acquire master DMA write channel */
...@@ -593,7 +597,8 @@ static int __init davinci_acquire_dma_channels(struct mmc_davinci_host *host) ...@@ -593,7 +597,8 @@ static int __init davinci_acquire_dma_channels(struct mmc_davinci_host *host)
/* Allocate parameter RAM slots, which will later be bound to a /* Allocate parameter RAM slots, which will later be bound to a
* channel as needed to handle a scatterlist. * channel as needed to handle a scatterlist.
*/ */
for (i = 0; i < ARRAY_SIZE(host->links); i++) { link_size = min_t(unsigned, host->nr_sg, ARRAY_SIZE(host->links));
for (i = 0; i < link_size; i++) {
r = edma_alloc_slot(EDMA_CTLR(host->txdma), EDMA_SLOT_ANY); r = edma_alloc_slot(EDMA_CTLR(host->txdma), EDMA_SLOT_ANY);
if (r < 0) { if (r < 0) {
dev_dbg(mmc_dev(host->mmc), "dma PaRAM alloc --> %d\n", dev_dbg(mmc_dev(host->mmc), "dma PaRAM alloc --> %d\n",
...@@ -905,19 +910,26 @@ static void mmc_davinci_cmd_done(struct mmc_davinci_host *host, ...@@ -905,19 +910,26 @@ static void mmc_davinci_cmd_done(struct mmc_davinci_host *host,
} }
} }
static void static inline void mmc_davinci_reset_ctrl(struct mmc_davinci_host *host,
davinci_abort_data(struct mmc_davinci_host *host, struct mmc_data *data) int val)
{ {
u32 temp; u32 temp;
/* reset command and data state machines */
temp = readl(host->base + DAVINCI_MMCCTL); temp = readl(host->base + DAVINCI_MMCCTL);
writel(temp | MMCCTL_CMDRST | MMCCTL_DATRST, if (val) /* reset */
host->base + DAVINCI_MMCCTL); temp |= MMCCTL_CMDRST | MMCCTL_DATRST;
else /* enable */
temp &= ~(MMCCTL_CMDRST | MMCCTL_DATRST);
temp &= ~(MMCCTL_CMDRST | MMCCTL_DATRST);
udelay(10);
writel(temp, host->base + DAVINCI_MMCCTL); writel(temp, host->base + DAVINCI_MMCCTL);
udelay(10);
}
static void
davinci_abort_data(struct mmc_davinci_host *host, struct mmc_data *data)
{
mmc_davinci_reset_ctrl(host, 1);
mmc_davinci_reset_ctrl(host, 0);
} }
static irqreturn_t mmc_davinci_irq(int irq, void *dev_id) static irqreturn_t mmc_davinci_irq(int irq, void *dev_id)
...@@ -1121,15 +1133,8 @@ static inline void mmc_davinci_cpufreq_deregister(struct mmc_davinci_host *host) ...@@ -1121,15 +1133,8 @@ static inline void mmc_davinci_cpufreq_deregister(struct mmc_davinci_host *host)
#endif #endif
static void __init init_mmcsd_host(struct mmc_davinci_host *host) static void __init init_mmcsd_host(struct mmc_davinci_host *host)
{ {
/* DAT line portion is diabled and in reset state */
writel(readl(host->base + DAVINCI_MMCCTL) | MMCCTL_DATRST,
host->base + DAVINCI_MMCCTL);
/* CMD line portion is diabled and in reset state */
writel(readl(host->base + DAVINCI_MMCCTL) | MMCCTL_CMDRST,
host->base + DAVINCI_MMCCTL);
udelay(10); mmc_davinci_reset_ctrl(host, 1);
writel(0, host->base + DAVINCI_MMCCLK); writel(0, host->base + DAVINCI_MMCCLK);
writel(MMCCLK_CLKEN, host->base + DAVINCI_MMCCLK); writel(MMCCLK_CLKEN, host->base + DAVINCI_MMCCLK);
...@@ -1137,12 +1142,7 @@ static void __init init_mmcsd_host(struct mmc_davinci_host *host) ...@@ -1137,12 +1142,7 @@ static void __init init_mmcsd_host(struct mmc_davinci_host *host)
writel(0x1FFF, host->base + DAVINCI_MMCTOR); writel(0x1FFF, host->base + DAVINCI_MMCTOR);
writel(0xFFFF, host->base + DAVINCI_MMCTOD); writel(0xFFFF, host->base + DAVINCI_MMCTOD);
writel(readl(host->base + DAVINCI_MMCCTL) & ~MMCCTL_DATRST, mmc_davinci_reset_ctrl(host, 0);
host->base + DAVINCI_MMCCTL);
writel(readl(host->base + DAVINCI_MMCCTL) & ~MMCCTL_CMDRST,
host->base + DAVINCI_MMCCTL);
udelay(10);
} }
static int __init davinci_mmcsd_probe(struct platform_device *pdev) static int __init davinci_mmcsd_probe(struct platform_device *pdev)
...@@ -1202,6 +1202,12 @@ static int __init davinci_mmcsd_probe(struct platform_device *pdev) ...@@ -1202,6 +1202,12 @@ static int __init davinci_mmcsd_probe(struct platform_device *pdev)
init_mmcsd_host(host); init_mmcsd_host(host);
if (pdata->nr_sg)
host->nr_sg = pdata->nr_sg - 1;
if (host->nr_sg > MAX_NR_SG || !host->nr_sg)
host->nr_sg = MAX_NR_SG;
host->use_dma = use_dma; host->use_dma = use_dma;
host->irq = irq; host->irq = irq;
...@@ -1327,32 +1333,66 @@ static int __exit davinci_mmcsd_remove(struct platform_device *pdev) ...@@ -1327,32 +1333,66 @@ static int __exit davinci_mmcsd_remove(struct platform_device *pdev)
} }
#ifdef CONFIG_PM #ifdef CONFIG_PM
static int davinci_mmcsd_suspend(struct platform_device *pdev, pm_message_t msg) static int davinci_mmcsd_suspend(struct device *dev)
{ {
struct platform_device *pdev = to_platform_device(dev);
struct mmc_davinci_host *host = platform_get_drvdata(pdev); struct mmc_davinci_host *host = platform_get_drvdata(pdev);
struct pm_message msg = { PM_EVENT_SUSPEND };
int ret;
return mmc_suspend_host(host->mmc, msg); mmc_host_enable(host->mmc);
ret = mmc_suspend_host(host->mmc, msg);
if (!ret) {
writel(0, host->base + DAVINCI_MMCIM);
mmc_davinci_reset_ctrl(host, 1);
mmc_host_disable(host->mmc);
clk_disable(host->clk);
host->suspended = 1;
} else {
host->suspended = 0;
mmc_host_disable(host->mmc);
}
return ret;
} }
static int davinci_mmcsd_resume(struct platform_device *pdev) static int davinci_mmcsd_resume(struct device *dev)
{ {
struct platform_device *pdev = to_platform_device(dev);
struct mmc_davinci_host *host = platform_get_drvdata(pdev); struct mmc_davinci_host *host = platform_get_drvdata(pdev);
int ret;
if (!host->suspended)
return 0;
return mmc_resume_host(host->mmc); clk_enable(host->clk);
mmc_host_enable(host->mmc);
mmc_davinci_reset_ctrl(host, 0);
ret = mmc_resume_host(host->mmc);
if (!ret)
host->suspended = 0;
return ret;
} }
static struct dev_pm_ops davinci_mmcsd_pm = {
.suspend = davinci_mmcsd_suspend,
.resume = davinci_mmcsd_resume,
};
#define davinci_mmcsd_pm_ops (&davinci_mmcsd_pm)
#else #else
#define davinci_mmcsd_suspend NULL #define davinci_mmcsd_pm_ops NULL
#define davinci_mmcsd_resume NULL
#endif #endif
static struct platform_driver davinci_mmcsd_driver = { static struct platform_driver davinci_mmcsd_driver = {
.driver = { .driver = {
.name = "davinci_mmc", .name = "davinci_mmc",
.owner = THIS_MODULE, .owner = THIS_MODULE,
.pm = davinci_mmcsd_pm_ops,
}, },
.remove = __exit_p(davinci_mmcsd_remove), .remove = __exit_p(davinci_mmcsd_remove),
.suspend = davinci_mmcsd_suspend,
.resume = davinci_mmcsd_resume,
}; };
static int __init davinci_mmcsd_init(void) static int __init davinci_mmcsd_init(void)
......
...@@ -22,68 +22,9 @@ ...@@ -22,68 +22,9 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/regulator/driver.h> #include <linux/regulator/driver.h>
#include <linux/regulator/machine.h> #include <linux/regulator/machine.h>
#include <linux/i2c.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/mfd/tps6507x.h>
/* Register definitions */
#define TPS6507X_REG_PPATH1 0X01
#define TPS6507X_REG_INT 0X02
#define TPS6507X_REG_CHGCONFIG0 0X03
#define TPS6507X_REG_CHGCONFIG1 0X04
#define TPS6507X_REG_CHGCONFIG2 0X05
#define TPS6507X_REG_CHGCONFIG3 0X06
#define TPS6507X_REG_REG_ADCONFIG 0X07
#define TPS6507X_REG_TSCMODE 0X08
#define TPS6507X_REG_ADRESULT_1 0X09
#define TPS6507X_REG_ADRESULT_2 0X0A
#define TPS6507X_REG_PGOOD 0X0B
#define TPS6507X_REG_PGOODMASK 0X0C
#define TPS6507X_REG_CON_CTRL1 0X0D
#define TPS6507X_REG_CON_CTRL2 0X0E
#define TPS6507X_REG_CON_CTRL3 0X0F
#define TPS6507X_REG_DEFDCDC1 0X10
#define TPS6507X_REG_DEFDCDC2_LOW 0X11
#define TPS6507X_REG_DEFDCDC2_HIGH 0X12
#define TPS6507X_REG_DEFDCDC3_LOW 0X13
#define TPS6507X_REG_DEFDCDC3_HIGH 0X14
#define TPS6507X_REG_DEFSLEW 0X15
#define TPS6507X_REG_LDO_CTRL1 0X16
#define TPS6507X_REG_DEFLDO2 0X17
#define TPS6507X_REG_WLED_CTRL1 0X18
#define TPS6507X_REG_WLED_CTRL2 0X19
/* CON_CTRL1 bitfields */
#define TPS6507X_CON_CTRL1_DCDC1_ENABLE BIT(4)
#define TPS6507X_CON_CTRL1_DCDC2_ENABLE BIT(3)
#define TPS6507X_CON_CTRL1_DCDC3_ENABLE BIT(2)
#define TPS6507X_CON_CTRL1_LDO1_ENABLE BIT(1)
#define TPS6507X_CON_CTRL1_LDO2_ENABLE BIT(0)
/* DEFDCDC1 bitfields */
#define TPS6507X_DEFDCDC1_DCDC1_EXT_ADJ_EN BIT(7)
#define TPS6507X_DEFDCDC1_DCDC1_MASK 0X3F
/* DEFDCDC2_LOW bitfields */
#define TPS6507X_DEFDCDC2_LOW_DCDC2_MASK 0X3F
/* DEFDCDC2_HIGH bitfields */
#define TPS6507X_DEFDCDC2_HIGH_DCDC2_MASK 0X3F
/* DEFDCDC3_LOW bitfields */
#define TPS6507X_DEFDCDC3_LOW_DCDC3_MASK 0X3F
/* DEFDCDC3_HIGH bitfields */
#define TPS6507X_DEFDCDC3_HIGH_DCDC3_MASK 0X3F
/* TPS6507X_REG_LDO_CTRL1 bitfields */
#define TPS6507X_REG_LDO_CTRL1_LDO1_MASK 0X0F
/* TPS6507X_REG_DEFLDO2 bitfields */
#define TPS6507X_REG_DEFLDO2_LDO2_MASK 0X3F
/* VDCDC MASK */
#define TPS6507X_DEFDCDCX_DCDC_MASK 0X3F
/* DCDC's */ /* DCDC's */
#define TPS6507X_DCDC_1 0 #define TPS6507X_DCDC_1 0
...@@ -162,101 +103,146 @@ struct tps_info { ...@@ -162,101 +103,146 @@ struct tps_info {
const u16 *table; const u16 *table;
}; };
struct tps_pmic { static const struct tps_info tps6507x_pmic_regs[] = {
{
.name = "VDCDC1",
.min_uV = 725000,
.max_uV = 3300000,
.table_len = ARRAY_SIZE(VDCDCx_VSEL_table),
.table = VDCDCx_VSEL_table,
},
{
.name = "VDCDC2",
.min_uV = 725000,
.max_uV = 3300000,
.table_len = ARRAY_SIZE(VDCDCx_VSEL_table),
.table = VDCDCx_VSEL_table,
},
{
.name = "VDCDC3",
.min_uV = 725000,
.max_uV = 3300000,
.table_len = ARRAY_SIZE(VDCDCx_VSEL_table),
.table = VDCDCx_VSEL_table,
},
{
.name = "LDO1",
.min_uV = 1000000,
.max_uV = 3300000,
.table_len = ARRAY_SIZE(LDO1_VSEL_table),
.table = LDO1_VSEL_table,
},
{
.name = "LDO2",
.min_uV = 725000,
.max_uV = 3300000,
.table_len = ARRAY_SIZE(LDO2_VSEL_table),
.table = LDO2_VSEL_table,
},
};
struct tps6507x_pmic {
struct regulator_desc desc[TPS6507X_NUM_REGULATOR]; struct regulator_desc desc[TPS6507X_NUM_REGULATOR];
struct i2c_client *client; struct tps6507x_dev *mfd;
struct regulator_dev *rdev[TPS6507X_NUM_REGULATOR]; struct regulator_dev *rdev[TPS6507X_NUM_REGULATOR];
const struct tps_info *info[TPS6507X_NUM_REGULATOR]; const struct tps_info *info[TPS6507X_NUM_REGULATOR];
struct mutex io_lock; struct mutex io_lock;
}; };
static inline int tps6507x_pmic_read(struct tps6507x_pmic *tps, u8 reg)
static inline int tps_6507x_read(struct tps_pmic *tps, u8 reg)
{ {
return i2c_smbus_read_byte_data(tps->client, reg); u8 val;
int err;
err = tps->mfd->read_dev(tps->mfd, reg, 1, &val);
if (err)
return err;
return val;
} }
static inline int tps_6507x_write(struct tps_pmic *tps, u8 reg, u8 val) static inline int tps6507x_pmic_write(struct tps6507x_pmic *tps, u8 reg, u8 val)
{ {
return i2c_smbus_write_byte_data(tps->client, reg, val); return tps->mfd->write_dev(tps->mfd, reg, 1, &val);
} }
static int tps_6507x_set_bits(struct tps_pmic *tps, u8 reg, u8 mask) static int tps6507x_pmic_set_bits(struct tps6507x_pmic *tps, u8 reg, u8 mask)
{ {
int err, data; int err, data;
mutex_lock(&tps->io_lock); mutex_lock(&tps->io_lock);
data = tps_6507x_read(tps, reg); data = tps6507x_pmic_read(tps, reg);
if (data < 0) { if (data < 0) {
dev_err(&tps->client->dev, "Read from reg 0x%x failed\n", reg); dev_err(tps->mfd->dev, "Read from reg 0x%x failed\n", reg);
err = data; err = data;
goto out; goto out;
} }
data |= mask; data |= mask;
err = tps_6507x_write(tps, reg, data); err = tps6507x_pmic_write(tps, reg, data);
if (err) if (err)
dev_err(&tps->client->dev, "Write for reg 0x%x failed\n", reg); dev_err(tps->mfd->dev, "Write for reg 0x%x failed\n", reg);
out: out:
mutex_unlock(&tps->io_lock); mutex_unlock(&tps->io_lock);
return err; return err;
} }
static int tps_6507x_clear_bits(struct tps_pmic *tps, u8 reg, u8 mask) static int tps6507x_pmic_clear_bits(struct tps6507x_pmic *tps, u8 reg, u8 mask)
{ {
int err, data; int err, data;
mutex_lock(&tps->io_lock); mutex_lock(&tps->io_lock);
data = tps_6507x_read(tps, reg); data = tps6507x_pmic_read(tps, reg);
if (data < 0) { if (data < 0) {
dev_err(&tps->client->dev, "Read from reg 0x%x failed\n", reg); dev_err(tps->mfd->dev, "Read from reg 0x%x failed\n", reg);
err = data; err = data;
goto out; goto out;
} }
data &= ~mask; data &= ~mask;
err = tps_6507x_write(tps, reg, data); err = tps6507x_pmic_write(tps, reg, data);
if (err) if (err)
dev_err(&tps->client->dev, "Write for reg 0x%x failed\n", reg); dev_err(tps->mfd->dev, "Write for reg 0x%x failed\n", reg);
out: out:
mutex_unlock(&tps->io_lock); mutex_unlock(&tps->io_lock);
return err; return err;
} }
static int tps_6507x_reg_read(struct tps_pmic *tps, u8 reg) static int tps6507x_pmic_reg_read(struct tps6507x_pmic *tps, u8 reg)
{ {
int data; int data;
mutex_lock(&tps->io_lock); mutex_lock(&tps->io_lock);
data = tps_6507x_read(tps, reg); data = tps6507x_pmic_read(tps, reg);
if (data < 0) if (data < 0)
dev_err(&tps->client->dev, "Read from reg 0x%x failed\n", reg); dev_err(tps->mfd->dev, "Read from reg 0x%x failed\n", reg);
mutex_unlock(&tps->io_lock); mutex_unlock(&tps->io_lock);
return data; return data;
} }
static int tps_6507x_reg_write(struct tps_pmic *tps, u8 reg, u8 val) static int tps6507x_pmic_reg_write(struct tps6507x_pmic *tps, u8 reg, u8 val)
{ {
int err; int err;
mutex_lock(&tps->io_lock); mutex_lock(&tps->io_lock);
err = tps_6507x_write(tps, reg, val); err = tps6507x_pmic_write(tps, reg, val);
if (err < 0) if (err < 0)
dev_err(&tps->client->dev, "Write for reg 0x%x failed\n", reg); dev_err(tps->mfd->dev, "Write for reg 0x%x failed\n", reg);
mutex_unlock(&tps->io_lock); mutex_unlock(&tps->io_lock);
return err; return err;
} }
static int tps6507x_dcdc_is_enabled(struct regulator_dev *dev) static int tps6507x_pmic_dcdc_is_enabled(struct regulator_dev *dev)
{ {
struct tps_pmic *tps = rdev_get_drvdata(dev); struct tps6507x_pmic *tps = rdev_get_drvdata(dev);
int data, dcdc = rdev_get_id(dev); int data, dcdc = rdev_get_id(dev);
u8 shift; u8 shift;
...@@ -264,7 +250,7 @@ static int tps6507x_dcdc_is_enabled(struct regulator_dev *dev) ...@@ -264,7 +250,7 @@ static int tps6507x_dcdc_is_enabled(struct regulator_dev *dev)
return -EINVAL; return -EINVAL;
shift = TPS6507X_MAX_REG_ID - dcdc; shift = TPS6507X_MAX_REG_ID - dcdc;
data = tps_6507x_reg_read(tps, TPS6507X_REG_CON_CTRL1); data = tps6507x_pmic_reg_read(tps, TPS6507X_REG_CON_CTRL1);
if (data < 0) if (data < 0)
return data; return data;
...@@ -272,9 +258,9 @@ static int tps6507x_dcdc_is_enabled(struct regulator_dev *dev) ...@@ -272,9 +258,9 @@ static int tps6507x_dcdc_is_enabled(struct regulator_dev *dev)
return (data & 1<<shift) ? 1 : 0; return (data & 1<<shift) ? 1 : 0;
} }
static int tps6507x_ldo_is_enabled(struct regulator_dev *dev) static int tps6507x_pmic_ldo_is_enabled(struct regulator_dev *dev)
{ {
struct tps_pmic *tps = rdev_get_drvdata(dev); struct tps6507x_pmic *tps = rdev_get_drvdata(dev);
int data, ldo = rdev_get_id(dev); int data, ldo = rdev_get_id(dev);
u8 shift; u8 shift;
...@@ -282,7 +268,7 @@ static int tps6507x_ldo_is_enabled(struct regulator_dev *dev) ...@@ -282,7 +268,7 @@ static int tps6507x_ldo_is_enabled(struct regulator_dev *dev)
return -EINVAL; return -EINVAL;
shift = TPS6507X_MAX_REG_ID - ldo; shift = TPS6507X_MAX_REG_ID - ldo;
data = tps_6507x_reg_read(tps, TPS6507X_REG_CON_CTRL1); data = tps6507x_pmic_reg_read(tps, TPS6507X_REG_CON_CTRL1);
if (data < 0) if (data < 0)
return data; return data;
...@@ -290,9 +276,9 @@ static int tps6507x_ldo_is_enabled(struct regulator_dev *dev) ...@@ -290,9 +276,9 @@ static int tps6507x_ldo_is_enabled(struct regulator_dev *dev)
return (data & 1<<shift) ? 1 : 0; return (data & 1<<shift) ? 1 : 0;
} }
static int tps6507x_dcdc_enable(struct regulator_dev *dev) static int tps6507x_pmic_dcdc_enable(struct regulator_dev *dev)
{ {
struct tps_pmic *tps = rdev_get_drvdata(dev); struct tps6507x_pmic *tps = rdev_get_drvdata(dev);
int dcdc = rdev_get_id(dev); int dcdc = rdev_get_id(dev);
u8 shift; u8 shift;
...@@ -300,12 +286,12 @@ static int tps6507x_dcdc_enable(struct regulator_dev *dev) ...@@ -300,12 +286,12 @@ static int tps6507x_dcdc_enable(struct regulator_dev *dev)
return -EINVAL; return -EINVAL;
shift = TPS6507X_MAX_REG_ID - dcdc; shift = TPS6507X_MAX_REG_ID - dcdc;
return tps_6507x_set_bits(tps, TPS6507X_REG_CON_CTRL1, 1 << shift); return tps6507x_pmic_set_bits(tps, TPS6507X_REG_CON_CTRL1, 1 << shift);
} }
static int tps6507x_dcdc_disable(struct regulator_dev *dev) static int tps6507x_pmic_dcdc_disable(struct regulator_dev *dev)
{ {
struct tps_pmic *tps = rdev_get_drvdata(dev); struct tps6507x_pmic *tps = rdev_get_drvdata(dev);
int dcdc = rdev_get_id(dev); int dcdc = rdev_get_id(dev);
u8 shift; u8 shift;
...@@ -313,12 +299,13 @@ static int tps6507x_dcdc_disable(struct regulator_dev *dev) ...@@ -313,12 +299,13 @@ static int tps6507x_dcdc_disable(struct regulator_dev *dev)
return -EINVAL; return -EINVAL;
shift = TPS6507X_MAX_REG_ID - dcdc; shift = TPS6507X_MAX_REG_ID - dcdc;
return tps_6507x_clear_bits(tps, TPS6507X_REG_CON_CTRL1, 1 << shift); return tps6507x_pmic_clear_bits(tps, TPS6507X_REG_CON_CTRL1,
1 << shift);
} }
static int tps6507x_ldo_enable(struct regulator_dev *dev) static int tps6507x_pmic_ldo_enable(struct regulator_dev *dev)
{ {
struct tps_pmic *tps = rdev_get_drvdata(dev); struct tps6507x_pmic *tps = rdev_get_drvdata(dev);
int ldo = rdev_get_id(dev); int ldo = rdev_get_id(dev);
u8 shift; u8 shift;
...@@ -326,12 +313,12 @@ static int tps6507x_ldo_enable(struct regulator_dev *dev) ...@@ -326,12 +313,12 @@ static int tps6507x_ldo_enable(struct regulator_dev *dev)
return -EINVAL; return -EINVAL;
shift = TPS6507X_MAX_REG_ID - ldo; shift = TPS6507X_MAX_REG_ID - ldo;
return tps_6507x_set_bits(tps, TPS6507X_REG_CON_CTRL1, 1 << shift); return tps6507x_pmic_set_bits(tps, TPS6507X_REG_CON_CTRL1, 1 << shift);
} }
static int tps6507x_ldo_disable(struct regulator_dev *dev) static int tps6507x_pmic_ldo_disable(struct regulator_dev *dev)
{ {
struct tps_pmic *tps = rdev_get_drvdata(dev); struct tps6507x_pmic *tps = rdev_get_drvdata(dev);
int ldo = rdev_get_id(dev); int ldo = rdev_get_id(dev);
u8 shift; u8 shift;
...@@ -339,12 +326,13 @@ static int tps6507x_ldo_disable(struct regulator_dev *dev) ...@@ -339,12 +326,13 @@ static int tps6507x_ldo_disable(struct regulator_dev *dev)
return -EINVAL; return -EINVAL;
shift = TPS6507X_MAX_REG_ID - ldo; shift = TPS6507X_MAX_REG_ID - ldo;
return tps_6507x_clear_bits(tps, TPS6507X_REG_CON_CTRL1, 1 << shift); return tps6507x_pmic_clear_bits(tps, TPS6507X_REG_CON_CTRL1,
1 << shift);
} }
static int tps6507x_dcdc_get_voltage(struct regulator_dev *dev) static int tps6507x_pmic_dcdc_get_voltage(struct regulator_dev *dev)
{ {
struct tps_pmic *tps = rdev_get_drvdata(dev); struct tps6507x_pmic *tps = rdev_get_drvdata(dev);
int data, dcdc = rdev_get_id(dev); int data, dcdc = rdev_get_id(dev);
u8 reg; u8 reg;
...@@ -362,7 +350,7 @@ static int tps6507x_dcdc_get_voltage(struct regulator_dev *dev) ...@@ -362,7 +350,7 @@ static int tps6507x_dcdc_get_voltage(struct regulator_dev *dev)
return -EINVAL; return -EINVAL;
} }
data = tps_6507x_reg_read(tps, reg); data = tps6507x_pmic_reg_read(tps, reg);
if (data < 0) if (data < 0)
return data; return data;
...@@ -370,10 +358,10 @@ static int tps6507x_dcdc_get_voltage(struct regulator_dev *dev) ...@@ -370,10 +358,10 @@ static int tps6507x_dcdc_get_voltage(struct regulator_dev *dev)
return tps->info[dcdc]->table[data] * 1000; return tps->info[dcdc]->table[data] * 1000;
} }
static int tps6507x_dcdc_set_voltage(struct regulator_dev *dev, static int tps6507x_pmic_dcdc_set_voltage(struct regulator_dev *dev,
int min_uV, int max_uV) int min_uV, int max_uV)
{ {
struct tps_pmic *tps = rdev_get_drvdata(dev); struct tps6507x_pmic *tps = rdev_get_drvdata(dev);
int data, vsel, dcdc = rdev_get_id(dev); int data, vsel, dcdc = rdev_get_id(dev);
u8 reg; u8 reg;
...@@ -411,19 +399,19 @@ static int tps6507x_dcdc_set_voltage(struct regulator_dev *dev, ...@@ -411,19 +399,19 @@ static int tps6507x_dcdc_set_voltage(struct regulator_dev *dev,
if (vsel == tps->info[dcdc]->table_len) if (vsel == tps->info[dcdc]->table_len)
return -EINVAL; return -EINVAL;
data = tps_6507x_reg_read(tps, reg); data = tps6507x_pmic_reg_read(tps, reg);
if (data < 0) if (data < 0)
return data; return data;
data &= ~TPS6507X_DEFDCDCX_DCDC_MASK; data &= ~TPS6507X_DEFDCDCX_DCDC_MASK;
data |= vsel; data |= vsel;
return tps_6507x_reg_write(tps, reg, data); return tps6507x_pmic_reg_write(tps, reg, data);
} }
static int tps6507x_ldo_get_voltage(struct regulator_dev *dev) static int tps6507x_pmic_ldo_get_voltage(struct regulator_dev *dev)
{ {
struct tps_pmic *tps = rdev_get_drvdata(dev); struct tps6507x_pmic *tps = rdev_get_drvdata(dev);
int data, ldo = rdev_get_id(dev); int data, ldo = rdev_get_id(dev);
u8 reg, mask; u8 reg, mask;
...@@ -437,7 +425,7 @@ static int tps6507x_ldo_get_voltage(struct regulator_dev *dev) ...@@ -437,7 +425,7 @@ static int tps6507x_ldo_get_voltage(struct regulator_dev *dev)
TPS6507X_REG_DEFLDO2_LDO2_MASK); TPS6507X_REG_DEFLDO2_LDO2_MASK);
} }
data = tps_6507x_reg_read(tps, reg); data = tps6507x_pmic_reg_read(tps, reg);
if (data < 0) if (data < 0)
return data; return data;
...@@ -445,10 +433,10 @@ static int tps6507x_ldo_get_voltage(struct regulator_dev *dev) ...@@ -445,10 +433,10 @@ static int tps6507x_ldo_get_voltage(struct regulator_dev *dev)
return tps->info[ldo]->table[data] * 1000; return tps->info[ldo]->table[data] * 1000;
} }
static int tps6507x_ldo_set_voltage(struct regulator_dev *dev, static int tps6507x_pmic_ldo_set_voltage(struct regulator_dev *dev,
int min_uV, int max_uV) int min_uV, int max_uV)
{ {
struct tps_pmic *tps = rdev_get_drvdata(dev); struct tps6507x_pmic *tps = rdev_get_drvdata(dev);
int data, vsel, ldo = rdev_get_id(dev); int data, vsel, ldo = rdev_get_id(dev);
u8 reg, mask; u8 reg, mask;
...@@ -479,20 +467,20 @@ static int tps6507x_ldo_set_voltage(struct regulator_dev *dev, ...@@ -479,20 +467,20 @@ static int tps6507x_ldo_set_voltage(struct regulator_dev *dev,
if (vsel == tps->info[ldo]->table_len) if (vsel == tps->info[ldo]->table_len)
return -EINVAL; return -EINVAL;
data = tps_6507x_reg_read(tps, reg); data = tps6507x_pmic_reg_read(tps, reg);
if (data < 0) if (data < 0)
return data; return data;
data &= ~mask; data &= ~mask;
data |= vsel; data |= vsel;
return tps_6507x_reg_write(tps, reg, data); return tps6507x_pmic_reg_write(tps, reg, data);
} }
static int tps6507x_dcdc_list_voltage(struct regulator_dev *dev, static int tps6507x_pmic_dcdc_list_voltage(struct regulator_dev *dev,
unsigned selector) unsigned selector)
{ {
struct tps_pmic *tps = rdev_get_drvdata(dev); struct tps6507x_pmic *tps = rdev_get_drvdata(dev);
int dcdc = rdev_get_id(dev); int dcdc = rdev_get_id(dev);
if (dcdc < TPS6507X_DCDC_1 || dcdc > TPS6507X_DCDC_3) if (dcdc < TPS6507X_DCDC_1 || dcdc > TPS6507X_DCDC_3)
...@@ -504,10 +492,10 @@ static int tps6507x_dcdc_list_voltage(struct regulator_dev *dev, ...@@ -504,10 +492,10 @@ static int tps6507x_dcdc_list_voltage(struct regulator_dev *dev,
return tps->info[dcdc]->table[selector] * 1000; return tps->info[dcdc]->table[selector] * 1000;
} }
static int tps6507x_ldo_list_voltage(struct regulator_dev *dev, static int tps6507x_pmic_ldo_list_voltage(struct regulator_dev *dev,
unsigned selector) unsigned selector)
{ {
struct tps_pmic *tps = rdev_get_drvdata(dev); struct tps6507x_pmic *tps = rdev_get_drvdata(dev);
int ldo = rdev_get_id(dev); int ldo = rdev_get_id(dev);
if (ldo < TPS6507X_LDO_1 || ldo > TPS6507X_LDO_2) if (ldo < TPS6507X_LDO_1 || ldo > TPS6507X_LDO_2)
...@@ -520,47 +508,54 @@ static int tps6507x_ldo_list_voltage(struct regulator_dev *dev, ...@@ -520,47 +508,54 @@ static int tps6507x_ldo_list_voltage(struct regulator_dev *dev,
} }
/* Operations permitted on VDCDCx */ /* Operations permitted on VDCDCx */
static struct regulator_ops tps6507x_dcdc_ops = { static struct regulator_ops tps6507x_pmic_dcdc_ops = {
.is_enabled = tps6507x_dcdc_is_enabled, .is_enabled = tps6507x_pmic_dcdc_is_enabled,
.enable = tps6507x_dcdc_enable, .enable = tps6507x_pmic_dcdc_enable,
.disable = tps6507x_dcdc_disable, .disable = tps6507x_pmic_dcdc_disable,
.get_voltage = tps6507x_dcdc_get_voltage, .get_voltage = tps6507x_pmic_dcdc_get_voltage,
.set_voltage = tps6507x_dcdc_set_voltage, .set_voltage = tps6507x_pmic_dcdc_set_voltage,
.list_voltage = tps6507x_dcdc_list_voltage, .list_voltage = tps6507x_pmic_dcdc_list_voltage,
}; };
/* Operations permitted on LDOx */ /* Operations permitted on LDOx */
static struct regulator_ops tps6507x_ldo_ops = { static struct regulator_ops tps6507x_pmic_ldo_ops = {
.is_enabled = tps6507x_ldo_is_enabled, .is_enabled = tps6507x_pmic_ldo_is_enabled,
.enable = tps6507x_ldo_enable, .enable = tps6507x_pmic_ldo_enable,
.disable = tps6507x_ldo_disable, .disable = tps6507x_pmic_ldo_disable,
.get_voltage = tps6507x_ldo_get_voltage, .get_voltage = tps6507x_pmic_ldo_get_voltage,
.set_voltage = tps6507x_ldo_set_voltage, .set_voltage = tps6507x_pmic_ldo_set_voltage,
.list_voltage = tps6507x_ldo_list_voltage, .list_voltage = tps6507x_pmic_ldo_list_voltage,
}; };
static int __devinit tps_6507x_probe(struct i2c_client *client, static __devinit
const struct i2c_device_id *id) int tps6507x_pmic_probe(struct platform_device *pdev)
{ {
struct tps6507x_dev *tps6507x_dev = dev_get_drvdata(pdev->dev.parent);
static int desc_id; static int desc_id;
const struct tps_info *info = (void *)id->driver_data; const struct tps_info *info = &tps6507x_pmic_regs[0];
struct regulator_init_data *init_data; struct regulator_init_data *init_data;
struct regulator_dev *rdev; struct regulator_dev *rdev;
struct tps_pmic *tps; struct tps6507x_pmic *tps;
struct tps6507x_board *tps_board;
int i; int i;
int error; int error;
if (!i2c_check_functionality(client->adapter, /**
I2C_FUNC_SMBUS_BYTE_DATA)) * tps_board points to pmic related constants
return -EIO; * coming from the board-evm file.
*/
tps_board = dev_get_platdata(tps6507x_dev->dev);
if (!tps_board)
return -EINVAL;
/** /**
* init_data points to array of regulator_init structures * init_data points to array of regulator_init structures
* coming from the board-evm file. * coming from the board-evm file.
*/ */
init_data = client->dev.platform_data; init_data = tps_board->tps6507x_pmic_init_data;
if (!init_data) if (!init_data)
return -EIO; return -EINVAL;
tps = kzalloc(sizeof(*tps), GFP_KERNEL); tps = kzalloc(sizeof(*tps), GFP_KERNEL);
if (!tps) if (!tps)
...@@ -569,7 +564,7 @@ static int __devinit tps_6507x_probe(struct i2c_client *client, ...@@ -569,7 +564,7 @@ static int __devinit tps_6507x_probe(struct i2c_client *client,
mutex_init(&tps->io_lock); mutex_init(&tps->io_lock);
/* common for all regulators */ /* common for all regulators */
tps->client = client; tps->mfd = tps6507x_dev;
for (i = 0; i < TPS6507X_NUM_REGULATOR; i++, info++, init_data++) { for (i = 0; i < TPS6507X_NUM_REGULATOR; i++, info++, init_data++) {
/* Register the regulators */ /* Register the regulators */
...@@ -578,15 +573,16 @@ static int __devinit tps_6507x_probe(struct i2c_client *client, ...@@ -578,15 +573,16 @@ static int __devinit tps_6507x_probe(struct i2c_client *client,
tps->desc[i].id = desc_id++; tps->desc[i].id = desc_id++;
tps->desc[i].n_voltages = num_voltages[i]; tps->desc[i].n_voltages = num_voltages[i];
tps->desc[i].ops = (i > TPS6507X_DCDC_3 ? tps->desc[i].ops = (i > TPS6507X_DCDC_3 ?
&tps6507x_ldo_ops : &tps6507x_dcdc_ops); &tps6507x_pmic_ldo_ops : &tps6507x_pmic_dcdc_ops);
tps->desc[i].type = REGULATOR_VOLTAGE; tps->desc[i].type = REGULATOR_VOLTAGE;
tps->desc[i].owner = THIS_MODULE; tps->desc[i].owner = THIS_MODULE;
rdev = regulator_register(&tps->desc[i], rdev = regulator_register(&tps->desc[i],
&client->dev, init_data, tps); tps6507x_dev->dev, init_data, tps);
if (IS_ERR(rdev)) { if (IS_ERR(rdev)) {
dev_err(&client->dev, "failed to register %s\n", dev_err(tps6507x_dev->dev,
id->name); "failed to register %s regulator\n",
pdev->name);
error = PTR_ERR(rdev); error = PTR_ERR(rdev);
goto fail; goto fail;
} }
...@@ -595,7 +591,7 @@ static int __devinit tps_6507x_probe(struct i2c_client *client, ...@@ -595,7 +591,7 @@ static int __devinit tps_6507x_probe(struct i2c_client *client,
tps->rdev[i] = rdev; tps->rdev[i] = rdev;
} }
i2c_set_clientdata(client, tps); tps6507x_dev->pmic = tps;
return 0; return 0;
...@@ -608,19 +604,17 @@ fail: ...@@ -608,19 +604,17 @@ fail:
} }
/** /**
* tps_6507x_remove - TPS6507x driver i2c remove handler * tps6507x_remove - TPS6507x driver i2c remove handler
* @client: i2c driver client device structure * @client: i2c driver client device structure
* *
* Unregister TPS driver as an i2c client device driver * Unregister TPS driver as an i2c client device driver
*/ */
static int __devexit tps_6507x_remove(struct i2c_client *client) static int __devexit tps6507x_pmic_remove(struct platform_device *pdev)
{ {
struct tps_pmic *tps = i2c_get_clientdata(client); struct tps6507x_dev *tps6507x_dev = platform_get_drvdata(pdev);
struct tps6507x_pmic *tps = tps6507x_dev->pmic;
int i; int i;
/* clear the client data in i2c */
i2c_set_clientdata(client, NULL);
for (i = 0; i < TPS6507X_NUM_REGULATOR; i++) for (i = 0; i < TPS6507X_NUM_REGULATOR; i++)
regulator_unregister(tps->rdev[i]); regulator_unregister(tps->rdev[i]);
...@@ -629,83 +623,38 @@ static int __devexit tps_6507x_remove(struct i2c_client *client) ...@@ -629,83 +623,38 @@ static int __devexit tps_6507x_remove(struct i2c_client *client)
return 0; return 0;
} }
static const struct tps_info tps6507x_regs[] = { static struct platform_driver tps6507x_pmic_driver = {
{
.name = "VDCDC1",
.min_uV = 725000,
.max_uV = 3300000,
.table_len = ARRAY_SIZE(VDCDCx_VSEL_table),
.table = VDCDCx_VSEL_table,
},
{
.name = "VDCDC2",
.min_uV = 725000,
.max_uV = 3300000,
.table_len = ARRAY_SIZE(VDCDCx_VSEL_table),
.table = VDCDCx_VSEL_table,
},
{
.name = "VDCDC3",
.min_uV = 725000,
.max_uV = 3300000,
.table_len = ARRAY_SIZE(VDCDCx_VSEL_table),
.table = VDCDCx_VSEL_table,
},
{
.name = "LDO1",
.min_uV = 1000000,
.max_uV = 3300000,
.table_len = ARRAY_SIZE(LDO1_VSEL_table),
.table = LDO1_VSEL_table,
},
{
.name = "LDO2",
.min_uV = 725000,
.max_uV = 3300000,
.table_len = ARRAY_SIZE(LDO2_VSEL_table),
.table = LDO2_VSEL_table,
},
};
static const struct i2c_device_id tps_6507x_id[] = {
{.name = "tps6507x",
.driver_data = (unsigned long) tps6507x_regs,},
{ },
};
MODULE_DEVICE_TABLE(i2c, tps_6507x_id);
static struct i2c_driver tps_6507x_i2c_driver = {
.driver = { .driver = {
.name = "tps6507x", .name = "tps6507x-pmic",
.owner = THIS_MODULE, .owner = THIS_MODULE,
}, },
.probe = tps_6507x_probe, .probe = tps6507x_pmic_probe,
.remove = __devexit_p(tps_6507x_remove), .remove = __devexit_p(tps6507x_pmic_remove),
.id_table = tps_6507x_id,
}; };
/** /**
* tps_6507x_init * tps6507x_pmic_init
* *
* Module init function * Module init function
*/ */
static int __init tps_6507x_init(void) static int __init tps6507x_pmic_init(void)
{ {
return i2c_add_driver(&tps_6507x_i2c_driver); return platform_driver_register(&tps6507x_pmic_driver);
} }
subsys_initcall(tps_6507x_init); subsys_initcall(tps6507x_pmic_init);
/** /**
* tps_6507x_cleanup * tps6507x_pmic_cleanup
* *
* Module exit function * Module exit function
*/ */
static void __exit tps_6507x_cleanup(void) static void __exit tps6507x_pmic_cleanup(void)
{ {
i2c_del_driver(&tps_6507x_i2c_driver); platform_driver_unregister(&tps6507x_pmic_driver);
} }
module_exit(tps_6507x_cleanup); module_exit(tps6507x_pmic_cleanup);
MODULE_AUTHOR("Texas Instruments"); MODULE_AUTHOR("Texas Instruments");
MODULE_DESCRIPTION("TPS6507x voltage regulator driver"); MODULE_DESCRIPTION("TPS6507x voltage regulator driver");
MODULE_LICENSE("GPL v2"); MODULE_LICENSE("GPL v2");
MODULE_ALIAS("platform:tps6507x-pmic");
/* linux/i2c/tps6507x-ts.h
*
* Functions to access TPS65070 touch screen chip.
*
* Copyright (c) 2009 RidgeRun (todd.fischer@ridgerun.com)
*
*
* For licencing details see kernel-base/COPYING
*/
#ifndef __LINUX_I2C_TPS6507X_TS_H
#define __LINUX_I2C_TPS6507X_TS_H
/* Board specific touch screen initial values */
struct touchscreen_init_data {
int poll_period; /* ms */
int vref; /* non-zero to leave vref on */
__u16 min_pressure; /* min reading to be treated as a touch */
__u16 vendor;
__u16 product;
__u16 version;
};
#endif /* __LINUX_I2C_TPS6507X_TS_H */
/* linux/mfd/tps6507x.h
*
* Functions to access TPS65070 power management chip.
*
* Copyright (c) 2009 RidgeRun (todd.fischer@ridgerun.com)
*
*
* For licencing details see kernel-base/COPYING
*/
#ifndef __LINUX_MFD_TPS6507X_H
#define __LINUX_MFD_TPS6507X_H
/*
* ----------------------------------------------------------------------------
* Registers, all 8 bits
* ----------------------------------------------------------------------------
*/
/* Register definitions */
#define TPS6507X_REG_PPATH1 0X01
#define TPS6507X_CHG_USB BIT(7)
#define TPS6507X_CHG_AC BIT(6)
#define TPS6507X_CHG_USB_PW_ENABLE BIT(5)
#define TPS6507X_CHG_AC_PW_ENABLE BIT(4)
#define TPS6507X_CHG_AC_CURRENT BIT(2)
#define TPS6507X_CHG_USB_CURRENT BIT(0)
#define TPS6507X_REG_INT 0X02
#define TPS6507X_REG_MASK_AC_USB BIT(7)
#define TPS6507X_REG_MASK_TSC BIT(6)
#define TPS6507X_REG_MASK_PB_IN BIT(5)
#define TPS6507X_REG_TSC_INT BIT(3)
#define TPS6507X_REG_PB_IN_INT BIT(2)
#define TPS6507X_REG_AC_USB_APPLIED BIT(1)
#define TPS6507X_REG_AC_USB_REMOVED BIT(0)
#define TPS6507X_REG_CHGCONFIG0 0X03
#define TPS6507X_REG_CHGCONFIG1 0X04
#define TPS6507X_CON_CTRL1_DCDC1_ENABLE BIT(4)
#define TPS6507X_CON_CTRL1_DCDC2_ENABLE BIT(3)
#define TPS6507X_CON_CTRL1_DCDC3_ENABLE BIT(2)
#define TPS6507X_CON_CTRL1_LDO1_ENABLE BIT(1)
#define TPS6507X_CON_CTRL1_LDO2_ENABLE BIT(0)
#define TPS6507X_REG_CHGCONFIG2 0X05
#define TPS6507X_REG_CHGCONFIG3 0X06
#define TPS6507X_REG_ADCONFIG 0X07
#define TPS6507X_ADCONFIG_AD_ENABLE BIT(7)
#define TPS6507X_ADCONFIG_START_CONVERSION BIT(6)
#define TPS6507X_ADCONFIG_CONVERSION_DONE BIT(5)
#define TPS6507X_ADCONFIG_VREF_ENABLE BIT(4)
#define TPS6507X_ADCONFIG_INPUT_AD_IN1 0
#define TPS6507X_ADCONFIG_INPUT_AD_IN2 1
#define TPS6507X_ADCONFIG_INPUT_AD_IN3 2
#define TPS6507X_ADCONFIG_INPUT_AD_IN4 3
#define TPS6507X_ADCONFIG_INPUT_TS_PIN 4
#define TPS6507X_ADCONFIG_INPUT_BAT_CURRENT 5
#define TPS6507X_ADCONFIG_INPUT_AC_VOLTAGE 6
#define TPS6507X_ADCONFIG_INPUT_SYS_VOLTAGE 7
#define TPS6507X_ADCONFIG_INPUT_CHARGER_VOLTAGE 8
#define TPS6507X_ADCONFIG_INPUT_BAT_VOLTAGE 9
#define TPS6507X_ADCONFIG_INPUT_THRESHOLD_VOLTAGE 10
#define TPS6507X_ADCONFIG_INPUT_ISET1_VOLTAGE 11
#define TPS6507X_ADCONFIG_INPUT_ISET2_VOLTAGE 12
#define TPS6507X_ADCONFIG_INPUT_REAL_TSC 14
#define TPS6507X_ADCONFIG_INPUT_TSC 15
#define TPS6507X_REG_TSCMODE 0X08
#define TPS6507X_TSCMODE_X_POSITION 0
#define TPS6507X_TSCMODE_Y_POSITION 1
#define TPS6507X_TSCMODE_PRESSURE 2
#define TPS6507X_TSCMODE_X_PLATE 3
#define TPS6507X_TSCMODE_Y_PLATE 4
#define TPS6507X_TSCMODE_STANDBY 5
#define TPS6507X_TSCMODE_ADC_INPUT 6
#define TPS6507X_TSCMODE_DISABLE 7
#define TPS6507X_REG_ADRESULT_1 0X09
#define TPS6507X_REG_ADRESULT_2 0X0A
#define TPS6507X_REG_ADRESULT_2_MASK (BIT(1) | BIT(0))
#define TPS6507X_REG_PGOOD 0X0B
#define TPS6507X_REG_PGOODMASK 0X0C
#define TPS6507X_REG_CON_CTRL1 0X0D
#define TPS6507X_CON_CTRL1_DCDC1_ENABLE BIT(4)
#define TPS6507X_CON_CTRL1_DCDC2_ENABLE BIT(3)
#define TPS6507X_CON_CTRL1_DCDC3_ENABLE BIT(2)
#define TPS6507X_CON_CTRL1_LDO1_ENABLE BIT(1)
#define TPS6507X_CON_CTRL1_LDO2_ENABLE BIT(0)
#define TPS6507X_REG_CON_CTRL2 0X0E
#define TPS6507X_REG_CON_CTRL3 0X0F
#define TPS6507X_REG_DEFDCDC1 0X10
#define TPS6507X_DEFDCDC1_DCDC1_EXT_ADJ_EN BIT(7)
#define TPS6507X_DEFDCDC1_DCDC1_MASK 0X3F
#define TPS6507X_REG_DEFDCDC2_LOW 0X11
#define TPS6507X_DEFDCDC2_LOW_DCDC2_MASK 0X3F
#define TPS6507X_REG_DEFDCDC2_HIGH 0X12
#define TPS6507X_DEFDCDC2_HIGH_DCDC2_MASK 0X3F
#define TPS6507X_REG_DEFDCDC3_LOW 0X13
#define TPS6507X_DEFDCDC3_LOW_DCDC3_MASK 0X3F
#define TPS6507X_REG_DEFDCDC3_HIGH 0X14
#define TPS6507X_DEFDCDC3_HIGH_DCDC3_MASK 0X3F
#define TPS6507X_REG_DEFSLEW 0X15
#define TPS6507X_REG_LDO_CTRL1 0X16
#define TPS6507X_REG_LDO_CTRL1_LDO1_MASK 0X0F
#define TPS6507X_REG_DEFLDO2 0X17
#define TPS6507X_REG_DEFLDO2_LDO2_MASK 0X3F
#define TPS6507X_REG_WLED_CTRL1 0X18
#define TPS6507X_REG_WLED_CTRL2 0X19
/* 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
*
* Board data may be used to initialize regulator and touchscreen.
*/
struct tps6507x_board {
struct regulator_init_data *tps6507x_pmic_init_data;
struct touchscreen_init_data *tps6507x_ts_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);
/* Client devices */
struct tps6507x_pmic *pmic;
struct tps6507x_ts *ts;
};
#endif /* __LINUX_MFD_TPS6507X_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment