Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 368097
b: refs/heads/master
c: e6a9081
h: refs/heads/master
i:
  368095: b27e247
v: v3
  • Loading branch information
Bastian Hecht authored and Dmitry Torokhov committed Apr 15, 2013
1 parent 93c9102 commit b252a78
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 5 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 95b24d22135549ac8352d719a052002838bb9f80
refs/heads/master: e6a90810559cc3755a5b1629d1fd0b914462f98c
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
* Sitronix st1232 touchscreen controller

Required properties:
- compatible: must be "sitronix,st1232"
- reg: I2C address of the chip
- interrupts: interrupt to which the chip is connected

Optional properties:
- gpios: a phandle to the reset GPIO

Example:

i2c@00000000 {
/* ... */

touchscreen@55 {
compatible = "sitronix,st1232";
reg = <0x55>;
interrupts = <2 0>;
gpios = <&gpio1 166 0>;
};

/* ... */
};
47 changes: 43 additions & 4 deletions trunk/drivers/input/touchscreen/st1232.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,16 @@
*/

#include <linux/delay.h>
#include <linux/gpio.h>
#include <linux/i2c.h>
#include <linux/input.h>
#include <linux/interrupt.h>
#include <linux/module.h>
#include <linux/of_gpio.h>
#include <linux/pm_qos.h>
#include <linux/slab.h>
#include <linux/types.h>
#include <linux/platform_data/st1232_pdata.h>

#define ST1232_TS_NAME "st1232-ts"

Expand All @@ -48,6 +51,7 @@ struct st1232_ts_data {
struct input_dev *input_dev;
struct st1232_ts_finger finger[MAX_FINGERS];
struct dev_pm_qos_request low_latency_req;
int reset_gpio;
};

static int st1232_ts_read_data(struct st1232_ts_data *ts)
Expand Down Expand Up @@ -139,10 +143,17 @@ static irqreturn_t st1232_ts_irq_handler(int irq, void *dev_id)
return IRQ_HANDLED;
}

static void st1232_ts_power(struct st1232_ts_data *ts, bool poweron)
{
if (gpio_is_valid(ts->reset_gpio))
gpio_direction_output(ts->reset_gpio, poweron);
}

static int st1232_ts_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct st1232_ts_data *ts;
struct st1232_pdata *pdata = client->dev.platform_data;
struct input_dev *input_dev;
int error;

Expand All @@ -167,6 +178,25 @@ static int st1232_ts_probe(struct i2c_client *client,
ts->client = client;
ts->input_dev = input_dev;

if (pdata)
ts->reset_gpio = pdata->reset_gpio;
else if (client->dev.of_node)
ts->reset_gpio = of_get_gpio(client->dev.of_node, 0);
else
ts->reset_gpio = -ENODEV;

if (gpio_is_valid(ts->reset_gpio)) {
error = devm_gpio_request(&client->dev, ts->reset_gpio, NULL);
if (error) {
dev_err(&client->dev,
"Unable to request GPIO pin %d.\n",
ts->reset_gpio);
return error;
}
}

st1232_ts_power(ts, true);

input_dev->name = "st1232-touchscreen";
input_dev->id.bustype = BUS_I2C;
input_dev->dev.parent = &client->dev;
Expand Down Expand Up @@ -203,7 +233,10 @@ static int st1232_ts_probe(struct i2c_client *client,

static int st1232_ts_remove(struct i2c_client *client)
{
struct st1232_ts_data *ts = i2c_get_clientdata(client);

device_init_wakeup(&client->dev, 0);
st1232_ts_power(ts, false);

return 0;
}
Expand All @@ -212,23 +245,29 @@ static int st1232_ts_remove(struct i2c_client *client)
static int st1232_ts_suspend(struct device *dev)
{
struct i2c_client *client = to_i2c_client(dev);
struct st1232_ts_data *ts = i2c_get_clientdata(client);

if (device_may_wakeup(&client->dev))
if (device_may_wakeup(&client->dev)) {
enable_irq_wake(client->irq);
else
} else {
disable_irq(client->irq);
st1232_ts_power(ts, false);
}

return 0;
}

static int st1232_ts_resume(struct device *dev)
{
struct i2c_client *client = to_i2c_client(dev);
struct st1232_ts_data *ts = i2c_get_clientdata(client);

if (device_may_wakeup(&client->dev))
if (device_may_wakeup(&client->dev)) {
disable_irq_wake(client->irq);
else
} else {
st1232_ts_power(ts, true);
enable_irq(client->irq);
}

return 0;
}
Expand Down
13 changes: 13 additions & 0 deletions trunk/include/linux/platform_data/st1232_pdata.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#ifndef _LINUX_ST1232_PDATA_H
#define _LINUX_ST1232_PDATA_H

/*
* Optional platform data
*
* Use this if you want the driver to drive the reset pin.
*/
struct st1232_pdata {
int reset_gpio;
};

#endif

0 comments on commit b252a78

Please sign in to comment.