Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V3.14 s5p6442 #1

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
[PATCH 1/2] input: touchscreen: atmel_mxt_ts: Add support for voltage…
… regulator

This patch removes the voltage field from platform data of the atmel_mxt_ts driver and replaces it with regulator support.
  • Loading branch information
moikop committed Jan 8, 2014
commit 370a9de12c1213a08d638304bdcab3ede6d9974e
28 changes: 27 additions & 1 deletion arch/arm/mach-s5pv210/mach-goni.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,14 +238,39 @@ static void __init goni_radio_init(void)
}

/* TSP */
static struct regulator_consumer_supply tsp_fixed_consumer =
REGULATOR_SUPPLY("vdd", "2-004a");

static struct regulator_init_data tsp_fixed_voltage_init_data = {
.constraints = {
.name = "TSP_2.8V",
},
.num_consumer_supplies = 1,
.consumer_supplies = &tsp_fixed_consumer,
};

static struct fixed_voltage_config tsp_fixed_voltage_config = {
.supply_name = "TSP_VDD",
.microvolts = 2800000,
.gpio = -EINVAL,
.init_data = &tsp_fixed_voltage_init_data,
};

static struct platform_device tsp_fixed_voltage = {
.name = "reg-fixed-voltage",
.id = 3,
.dev = {
.platform_data = &tsp_fixed_voltage_config,
},
};

static struct mxt_platform_data qt602240_platform_data = {
.x_line = 17,
.y_line = 11,
.x_size = 800,
.y_size = 480,
.blen = 0x21,
.threshold = 0x28,
.voltage = 2800000, /* 2.8V */
.orient = MXT_DIAGONAL,
.irqflags = IRQF_TRIGGER_FALLING,
};
Expand Down Expand Up @@ -885,6 +910,7 @@ static struct platform_device *goni_devices[] __initdata = {
&s3c_device_usb_hsotg,
&samsung_device_keypad,
&s3c_device_i2c1,
&tsp_fixed_voltage,
&s3c_device_i2c2,
&wm8994_fixed_voltage0,
&wm8994_fixed_voltage1,
Expand Down
25 changes: 20 additions & 5 deletions drivers/input/touchscreen/atmel_mxt_ts.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <linux/i2c/atmel_mxt_ts.h>
#include <linux/input/mt.h>
#include <linux/interrupt.h>
#include <linux/regulator/consumer.h>
#include <linux/slab.h>

/* Version */
Expand Down Expand Up @@ -247,6 +248,7 @@ struct mxt_message {
struct mxt_data {
struct i2c_client *client;
struct input_dev *input_dev;
struct regulator *regulator;
char phys[64]; /* device physical location */
const struct mxt_platform_data *pdata;
struct mxt_object *object_table;
Expand Down Expand Up @@ -720,13 +722,14 @@ static void mxt_handle_pdata(struct mxt_data *data)
MXT_TOUCH_YRANGE_MSB, (pdata->y_size - 1) >> 8);

/* Set touchscreen voltage */
if (pdata->voltage) {
if (pdata->voltage < MXT_VOLTAGE_DEFAULT) {
voltage = (MXT_VOLTAGE_DEFAULT - pdata->voltage) /
if (!IS_ERR(data->regulator)) {
int reg_voltage = regulator_get_voltage(data->regulator);
if (reg_voltage < MXT_VOLTAGE_DEFAULT) {
voltage = (MXT_VOLTAGE_DEFAULT - reg_voltage) /
MXT_VOLTAGE_STEP;
voltage = 0xff - voltage + 1;
} else
voltage = (pdata->voltage - MXT_VOLTAGE_DEFAULT) /
voltage = (reg_voltage - MXT_VOLTAGE_DEFAULT) /
MXT_VOLTAGE_STEP;

mxt_write_object(data, MXT_SPT_CTECONFIG_T28,
Expand Down Expand Up @@ -1151,6 +1154,13 @@ static int mxt_probe(struct i2c_client *client,

input_dev->name = (data->is_tp) ? "Atmel maXTouch Touchpad" :
"Atmel maXTouch Touchscreen";

data->regulator = devm_regulator_get(&client->dev, "vdd");
if (!IS_ERR(data->regulator)) {
regulator_enable(data->regulator);
msleep(100);
}

snprintf(data->phys, sizeof(data->phys), "i2c-%u-%04x/input0",
client->adapter->nr, client->addr);

Expand All @@ -1170,7 +1180,7 @@ static int mxt_probe(struct i2c_client *client,

error = mxt_initialize(data);
if (error)
goto err_free_mem;
goto err_disable_regulator;

__set_bit(EV_ABS, input_dev->evbit);
__set_bit(EV_KEY, input_dev->evbit);
Expand Down Expand Up @@ -1253,6 +1263,9 @@ static int mxt_probe(struct i2c_client *client,
free_irq(client->irq, data);
err_free_object:
kfree(data->object_table);
err_disable_regulator:
if (!IS_ERR(data->regulator))
regulator_disable(data->regulator);
err_free_mem:
input_free_device(input_dev);
kfree(data);
Expand All @@ -1267,6 +1280,8 @@ static int mxt_remove(struct i2c_client *client)
free_irq(data->irq, data);
input_unregister_device(data->input_dev);
kfree(data->object_table);
if (!IS_ERR(data->regulator))
regulator_disable(data->regulator);
kfree(data);

return 0;
Expand Down
1 change: 0 additions & 1 deletion include/linux/i2c/atmel_mxt_ts.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ struct mxt_platform_data {
unsigned int y_size;
unsigned int blen;
unsigned int threshold;
unsigned int voltage;
unsigned char orient;
unsigned long irqflags;
bool is_tp;
Expand Down