From patchwork Wed Dec 18 09:21:12 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 302750 Return-Path: X-Original-To: incoming-dt@patchwork.ozlabs.org Delivered-To: patchwork-incoming-dt@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id CEFED2C00A6 for ; Wed, 18 Dec 2013 20:28:30 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752945Ab3LRJ0l (ORCPT ); Wed, 18 Dec 2013 04:26:41 -0500 Received: from devils.ext.ti.com ([198.47.26.153]:34220 "EHLO devils.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752843Ab3LRJWI (ORCPT ); Wed, 18 Dec 2013 04:22:08 -0500 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id rBI9M0qv018123; Wed, 18 Dec 2013 03:22:00 -0600 Received: from DLEE70.ent.ti.com (dlee70.ent.ti.com [157.170.170.113]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id rBI9M00P013298; Wed, 18 Dec 2013 03:22:00 -0600 Received: from dflp32.itg.ti.com (10.64.6.15) by DLEE70.ent.ti.com (157.170.170.113) with Microsoft SMTP Server id 14.2.342.3; Wed, 18 Dec 2013 03:21:59 -0600 Received: from localhost.localdomain (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id rBI9LjTr008288; Wed, 18 Dec 2013 03:21:54 -0600 From: Roger Quadros To: CC: , , , , , Roger Quadros Subject: [PATCH 1/9] Input: pixcir_i2c_ts: Add device tree support Date: Wed, 18 Dec 2013 14:51:12 +0530 Message-ID: <1387358480-8313-2-git-send-email-rogerq@ti.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1387358480-8313-1-git-send-email-rogerq@ti.com> References: <1387358480-8313-1-git-send-email-rogerq@ti.com> MIME-Version: 1.0 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Provide device tree support and binding information. Change platform data parameters from x/y_max to x/y_size.. Signed-off-by: Roger Quadros Acked-by: Mugunthan V N --- .../bindings/input/touchscreen/pixcir_i2c_ts.txt | 26 ++++++++ drivers/input/touchscreen/pixcir_i2c_ts.c | 77 ++++++++++++++++++++-- include/linux/input/pixcir_ts.h | 5 +- 3 files changed, 101 insertions(+), 7 deletions(-) create mode 100644 Documentation/devicetree/bindings/input/touchscreen/pixcir_i2c_ts.txt diff --git a/Documentation/devicetree/bindings/input/touchscreen/pixcir_i2c_ts.txt b/Documentation/devicetree/bindings/input/touchscreen/pixcir_i2c_ts.txt new file mode 100644 index 0000000..c0b0b270 --- /dev/null +++ b/Documentation/devicetree/bindings/input/touchscreen/pixcir_i2c_ts.txt @@ -0,0 +1,26 @@ +* Pixcir I2C touchscreen controllers + +Required properties: +- compatible: must be "pixcir,pixcir_ts" +- reg: I2C address of the chip +- interrupts: interrupt to which the chip is connected +- attb-gpio: GPIO connected to the ATTB line of the chip +- x-size: horizontal resolution of touchscreen +- y-size: vertical resolution of touchscreen + +Example: + + i2c@00000000 { + /* ... */ + + pixcir_ts@5c { + compatible = "pixcir,pixcir_ts"; + reg = <0x5c>; + interrupts = <2 0>; + attb-gpio = <&gpf 2 0 2>; + x-size = <800>; + y-size = <600>; + }; + + /* ... */ + }; diff --git a/drivers/input/touchscreen/pixcir_i2c_ts.c b/drivers/input/touchscreen/pixcir_i2c_ts.c index 6cc6b36..3a447c9 100644 --- a/drivers/input/touchscreen/pixcir_i2c_ts.c +++ b/drivers/input/touchscreen/pixcir_i2c_ts.c @@ -24,6 +24,10 @@ #include #include #include +#include +#include +#include +#include struct pixcir_i2c_ts_data { struct i2c_client *client; @@ -125,15 +129,65 @@ static int pixcir_i2c_ts_resume(struct device *dev) static SIMPLE_DEV_PM_OPS(pixcir_dev_pm_ops, pixcir_i2c_ts_suspend, pixcir_i2c_ts_resume); +#if defined(CONFIG_OF) +static const struct of_device_id pixcir_of_match[]; + +static struct pixcir_ts_platform_data *pixcir_parse_dt(struct device *dev) +{ + struct pixcir_ts_platform_data *pdata; + struct device_node *np = dev->of_node; + const struct of_device_id *match; + + match = of_match_device(of_match_ptr(pixcir_of_match), dev); + if (!match) + return ERR_PTR(-EINVAL); + + pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); + if (!pdata) + return ERR_PTR(-ENOMEM); + + pdata->gpio_attb = of_get_named_gpio(np, "attb-gpio", 0); + if (!gpio_is_valid(pdata->gpio_attb)) + dev_err(dev, "Failed to get ATTB GPIO\n"); + + if (of_property_read_u32(np, "x-size", &pdata->x_size)) { + dev_err(dev, "Failed to get x-size property\n"); + return ERR_PTR(-EINVAL); + } + + if (of_property_read_u32(np, "y-size", &pdata->y_size)) { + dev_err(dev, "Failed to get y-size property\n"); + return ERR_PTR(-EINVAL); + } + + dev_dbg(dev, "%s: x %d, y %d, gpio %d\n", __func__, + pdata->x_size, pdata->y_size, pdata->gpio_attb); + + return pdata; +} +#else +static struct pixcir_ts_platform_data *pixcir_parse_dt(struct device *dev) +{ + return NULL; +} +#endif + static int pixcir_i2c_ts_probe(struct i2c_client *client, const struct i2c_device_id *id) { const struct pixcir_ts_platform_data *pdata = client->dev.platform_data; + struct device *dev = &client->dev; + struct device_node *np = dev->of_node; struct pixcir_i2c_ts_data *tsdata; struct input_dev *input; int error; - if (!pdata) { + if (np) { + pdata = pixcir_parse_dt(dev); + if (IS_ERR(pdata)) + return PTR_ERR(pdata); + + } else if (!pdata) { dev_err(&client->dev, "platform data not defined\n"); return -EINVAL; } @@ -157,10 +211,14 @@ static int pixcir_i2c_ts_probe(struct i2c_client *client, __set_bit(EV_KEY, input->evbit); __set_bit(EV_ABS, input->evbit); __set_bit(BTN_TOUCH, input->keybit); - input_set_abs_params(input, ABS_X, 0, pdata->x_max, 0, 0); - input_set_abs_params(input, ABS_Y, 0, pdata->y_max, 0, 0); - input_set_abs_params(input, ABS_MT_POSITION_X, 0, pdata->x_max, 0, 0); - input_set_abs_params(input, ABS_MT_POSITION_Y, 0, pdata->y_max, 0, 0); + input_set_abs_params(input, ABS_X, + 0, pdata->x_size - 1, 0, 0); + input_set_abs_params(input, ABS_Y, + 0, pdata->y_size - 1, 0, 0); + input_set_abs_params(input, ABS_MT_POSITION_X, + 0, pdata->x_size - 1, 0, 0); + input_set_abs_params(input, ABS_MT_POSITION_Y, + 0, pdata->y_size - 1, 0, 0); input_set_drvdata(input, tsdata); @@ -211,11 +269,20 @@ static const struct i2c_device_id pixcir_i2c_ts_id[] = { }; MODULE_DEVICE_TABLE(i2c, pixcir_i2c_ts_id); +#if defined(CONFIG_OF) +static const struct of_device_id pixcir_of_match[] = { + { .compatible = "pixcir,pixcir_ts", }, + { } +}; +MODULE_DEVICE_TABLE(of, pixcir_of_match); +#endif + static struct i2c_driver pixcir_i2c_ts_driver = { .driver = { .owner = THIS_MODULE, .name = "pixcir_ts", .pm = &pixcir_dev_pm_ops, + .of_match_table = of_match_ptr(pixcir_of_match), }, .probe = pixcir_i2c_ts_probe, .remove = pixcir_i2c_ts_remove, diff --git a/include/linux/input/pixcir_ts.h b/include/linux/input/pixcir_ts.h index 7163d91..b34ff7e 100644 --- a/include/linux/input/pixcir_ts.h +++ b/include/linux/input/pixcir_ts.h @@ -3,8 +3,9 @@ struct pixcir_ts_platform_data { int (*attb_read_val)(void); - int x_max; - int y_max; + unsigned int x_size; /* X axis resolution */ + unsigned int y_size; /* Y axis resolution */ + int gpio_attb; /* GPIO connected to ATTB line */ }; #endif