From patchwork Wed Nov 14 13:47:15 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 12842 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id B697423E13 for ; Wed, 14 Nov 2012 13:47:55 +0000 (UTC) Received: from mail-ia0-f180.google.com (mail-ia0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id 6EF46A19CBC for ; Wed, 14 Nov 2012 13:47:55 +0000 (UTC) Received: by mail-ia0-f180.google.com with SMTP id f6so263043iag.11 for ; Wed, 14 Nov 2012 05:47:55 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=4DKM4e9R6lRUCBNzIMievfsyGHByB+vDZF9LN6/wo+k=; b=bMKcvo1c+1/iQb1ZXrVB0Is6EB2iFplpl1U9WaiEE2X6YIF1/wYkj6Q1ulV7xpHst6 2jAqphThyQ0oFYL0qZP6veh+tXuSozfdDaUJN0u3rqgqZBGi1L/5D0HHuBGyuYVwNdsJ vhoRg981pEcJuJL7Ml5t5InE+JxREOOOqfQD5Hq67us1YLi7v+zlsb+DBjFTqx74sk+z 5WjMXa2IEwVv9CBJq0hq53vIiyuRJnhVgqWqRAIk9LYbUiFzwjaAthS9RHxTZX1NvCh+ eX5QzJqH7LqoYsRbZwGqXjQqKUTuOeEgvJipXggQqod/SLqKoVCrw+Zcv+YASR0ddrKC jBEQ== Received: by 10.50.152.137 with SMTP id uy9mr1740608igb.62.1352900875211; Wed, 14 Nov 2012 05:47:55 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.67.148 with SMTP id n20csp662907igt; Wed, 14 Nov 2012 05:47:54 -0800 (PST) Received: by 10.216.74.85 with SMTP id w63mr1776162wed.212.1352900873914; Wed, 14 Nov 2012 05:47:53 -0800 (PST) Received: from mail-wi0-f182.google.com (mail-wi0-f182.google.com [209.85.212.182]) by mx.google.com with ESMTPS id j12si1319346wie.1.2012.11.14.05.47.53 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 14 Nov 2012 05:47:53 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.182 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=209.85.212.182; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.182 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) smtp.mail=lee.jones@linaro.org Received: by mail-wi0-f182.google.com with SMTP id cb5so198585wib.5 for ; Wed, 14 Nov 2012 05:47:53 -0800 (PST) Received: by 10.216.74.13 with SMTP id w13mr1804231wed.101.1352900872949; Wed, 14 Nov 2012 05:47:52 -0800 (PST) Received: from localhost.localdomain (cpc1-aztw13-0-0-cust473.18-1.cable.virginmedia.com. [77.102.241.218]) by mx.google.com with ESMTPS id b1sm2516537wix.11.2012.11.14.05.47.51 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 14 Nov 2012 05:47:52 -0800 (PST) From: Lee Jones To: linux-kernel@vger.kernel.org Cc: Lee Jones , Dmitry Torokhov , linux-input@vger.kernel.org Subject: [PATCH 3/5] Input: bu21013_ts - Add support for Device Tree booting Date: Wed, 14 Nov 2012 13:47:15 +0000 Message-Id: <1352900837-20759-4-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1352900837-20759-1-git-send-email-lee.jones@linaro.org> References: <1352900837-20759-1-git-send-email-lee.jones@linaro.org> X-Gm-Message-State: ALoCoQml3Z+P4m2ooecNZZy0aIsKnmC39zsaiMOQ23AqTnSC0biuXJ/uVxZvXFyIc/1XzKciot+A Now we can register the BU21013_ts touch screen when booting with Device Tree enabled. Here we parse all the necessary components previously expected to be passed from platform data. Cc: Dmitry Torokhov Cc: linux-input@vger.kernel.org Acked-by: Arnd Bergmann Acked-by: Linus Walleij Signed-off-by: Lee Jones --- drivers/input/touchscreen/bu21013_ts.c | 39 ++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/drivers/input/touchscreen/bu21013_ts.c b/drivers/input/touchscreen/bu21013_ts.c index 5d8fc75..afef874 100644 --- a/drivers/input/touchscreen/bu21013_ts.c +++ b/drivers/input/touchscreen/bu21013_ts.c @@ -15,6 +15,8 @@ #include #include #include +#include +#include /* Reference tracking for multiple displays. */ static int bu21013_devices = 0; @@ -487,13 +489,33 @@ static void bu21013_free_irq(struct bu21013_ts_data *bu21013_data) * This function used to initializes the i2c-client touchscreen * driver and returns integer. */ +static void __devinit bu21013_of_probe(struct device_node *np, + struct bu21013_platform_device *pdata) +{ + pdata->y_flip = pdata->x_flip = false; + + if (of_get_property(np, "rohm,flip-x", NULL)) + pdata->x_flip = true; + + if (of_get_property(np, "rohm,flip-y", NULL)) + pdata->y_flip = true; + + of_property_read_u32(np, "rohm,touch-max-x", &pdata->touch_x_max); + of_property_read_u32(np, "rohm,touch-max-y", &pdata->touch_y_max); + + pdata->touch_pin = of_get_named_gpio(np, "touch-gpio", 0); + pdata->cs_pin = of_get_named_gpio(np, "reset-gpio", 0); + + pdata->ext_clk = false; +} + static int __devinit bu21013_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct bu21013_ts_data *bu21013_data; struct input_dev *in_dev; - const struct bu21013_platform_device *pdata = - client->dev.platform_data; + struct device_node *np = client->dev.of_node; + struct bu21013_platform_device *pdata = client->dev.platform_data; int error; if (!i2c_check_functionality(client->adapter, @@ -503,8 +525,17 @@ static int __devinit bu21013_probe(struct i2c_client *client, } if (!pdata) { - dev_err(&client->dev, "platform data not defined\n"); - return -EINVAL; + if (np) { + pdata = devm_kzalloc(&client->dev, sizeof(*pdata), + GFP_KERNEL); + if (!pdata) + return -ENOMEM; + + bu21013_of_probe(np, pdata); + } else { + dev_err(&client->dev, "no device tree or platform data\n"); + return -EINVAL; + } } pdata->irq = gpio_to_irq(pdata->touch_pin);