Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 346915
b: refs/heads/master
c: ad5396e
h: refs/heads/master
i:
  346913: 424038f
  346911: 830aa00
v: v3
  • Loading branch information
Tomasz Figa authored and Dmitry Torokhov committed Oct 11, 2012
1 parent af3b329 commit b48fad9
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 3 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: dae6ba4ab797ed411fbde60ef5b5f6fbf13f0090
refs/heads/master: ad5396ee32afbdabb6188ffba67778080ea795b8
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
* MELFAS MMS114 touchscreen controller

Required properties:
- compatible: must be "melfas,mms114"
- reg: I2C address of the chip
- interrupts: interrupt to which the chip is connected
- x-size: horizontal resolution of touchscreen
- y-size: vertical resolution of touchscreen

Optional properties:
- contact-threshold:
- moving-threshold:
- x-invert: invert X axis
- y-invert: invert Y axis

Example:

i2c@00000000 {
/* ... */

touchscreen@48 {
compatible = "melfas,mms114";
reg = <0x48>;
interrupts = <39 0>;
x-size = <720>;
y-size = <1280>;
contact-threshold = <10>;
moving-threshold = <10>;
x-invert;
y-invert;
};

/* ... */
};
62 changes: 60 additions & 2 deletions trunk/drivers/input/touchscreen/mms114.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <linux/module.h>
#include <linux/init.h>
#include <linux/delay.h>
#include <linux/of.h>
#include <linux/i2c.h>
#include <linux/i2c/mms114.h>
#include <linux/input/mt.h>
Expand Down Expand Up @@ -360,14 +361,63 @@ static void mms114_input_close(struct input_dev *dev)
mms114_stop(data);
}

#ifdef CONFIG_OF
static struct mms114_platform_data * __devinit mms114_parse_dt(struct device *dev)
{
struct mms114_platform_data *pdata;
struct device_node *np = dev->of_node;

if (!np)
return NULL;

pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
if (!pdata) {
dev_err(dev, "failed to allocate platform data\n");
return NULL;
}

if (of_property_read_u32(np, "x-size", &pdata->x_size)) {
dev_err(dev, "failed to get x-size property\n");
return NULL;
};

if (of_property_read_u32(np, "y-size", &pdata->y_size)) {
dev_err(dev, "failed to get y-size property\n");
return NULL;
};

of_property_read_u32(np, "contact-threshold",
&pdata->contact_threshold);
of_property_read_u32(np, "moving-threshold",
&pdata->moving_threshold);

if (of_find_property(np, "x-invert", NULL))
pdata->x_invert = true;
if (of_find_property(np, "y-invert", NULL))
pdata->y_invert = true;

return pdata;
}
#else
static inline struct mms114_platform_data *mms114_parse_dt(struct device *dev)
{
return NULL;
}
#endif

static int __devinit mms114_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
const struct mms114_platform_data *pdata;
struct mms114_data *data;
struct input_dev *input_dev;
int error;

if (!client->dev.platform_data) {
pdata = dev_get_platdata(&client->dev);
if (!pdata)
pdata = mms114_parse_dt(&client->dev);

if (!pdata) {
dev_err(&client->dev, "Need platform data\n");
return -EINVAL;
}
Expand All @@ -389,7 +439,7 @@ static int __devinit mms114_probe(struct i2c_client *client,

data->client = client;
data->input_dev = input_dev;
data->pdata = client->dev.platform_data;
data->pdata = pdata;

input_dev->name = "MELPAS MMS114 Touchscreen";
input_dev->id.bustype = BUS_I2C;
Expand Down Expand Up @@ -525,11 +575,19 @@ static const struct i2c_device_id mms114_id[] = {
};
MODULE_DEVICE_TABLE(i2c, mms114_id);

#ifdef CONFIG_OF
static struct of_device_id __devinitdata mms114_dt_match[] = {
{ .compatible = "melfas,mms114" },
{ }
};
#endif

static struct i2c_driver mms114_driver = {
.driver = {
.name = "mms114",
.owner = THIS_MODULE,
.pm = &mms114_pm_ops,
.of_match_table = of_match_ptr(mms114_dt_match),
},
.probe = mms114_probe,
.remove = __devexit_p(mms114_remove),
Expand Down

0 comments on commit b48fad9

Please sign in to comment.