From patchwork Tue Nov 27 13:13:10 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 13238 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 D473D4C1794 for ; Tue, 27 Nov 2012 13:13:24 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id 6E224A19CA4 for ; Tue, 27 Nov 2012 13:13:24 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id c10so6338687ieb.11 for ; Tue, 27 Nov 2012 05:13:24 -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=u2eg4wQw8H73VHgwRp0dSAm9lZka7TTZ+mUoh5RcfvA=; b=izXtpT4biMxDFd8DAm/cXpx/42rp0EEu4ieHLWgkEZDt30o/UeR9jnnbftmK1DdqsR NumlPJFTzuKJcCpHQ7E7Ym22n0ZLp8S5cIM4oRhjs0u766IksaoGVMrr5IIAHB525dTA Fg0RPAN+HuE7+v6VG42nzY/34nrxzN7Bp1SPPaucTyP1+432jbF77kM2C1lNKa31WGom c5xvOkeFRrIN9sWSXAe3ZumTm2oYm+v7FEdi4whCigmNf+1YLVuwqmhSHGGiAORHmiKk rtbd9HTUCeCCOaVgeSGiBmtR7E4VtrDshnRUksYtG2FGWZwn+LLmWeXR3cM10lWWuDXb J4vg== Received: by 10.43.46.2 with SMTP id um2mr13573519icb.18.1354022004187; Tue, 27 Nov 2012 05:13:24 -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 n20csp455321igt; Tue, 27 Nov 2012 05:13:23 -0800 (PST) Received: by 10.216.133.94 with SMTP id p72mr5307721wei.82.1354022002741; Tue, 27 Nov 2012 05:13:22 -0800 (PST) Received: from mail-wi0-f170.google.com (mail-wi0-f170.google.com [209.85.212.170]) by mx.google.com with ESMTPS id ei8si2058693wib.16.2012.11.27.05.13.22 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 27 Nov 2012 05:13:22 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.170 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=209.85.212.170; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.170 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-f170.google.com with SMTP id hq7so3765328wib.3 for ; Tue, 27 Nov 2012 05:13:22 -0800 (PST) Received: by 10.180.102.2 with SMTP id fk2mr23360605wib.10.1354022002220; Tue, 27 Nov 2012 05:13:22 -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 hv4sm2489443wib.0.2012.11.27.05.13.20 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 27 Nov 2012 05:13:21 -0800 (PST) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: arnd@arndb.de, linus.walleij@stericsson.com, Lee Jones , Dmitry Torokhov , linux-input@vger.kernel.org Subject: [PATCH 3/3] Input: bu21013_ts - Add support for Device Tree booting Date: Tue, 27 Nov 2012 13:13:10 +0000 Message-Id: <1354021990-16978-4-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1354021990-16978-1-git-send-email-lee.jones@linaro.org> References: <1354021990-16978-1-git-send-email-lee.jones@linaro.org> X-Gm-Message-State: ALoCoQmWFP7i9W7kjcdTauJLS1q826UsjzicDO5kM41RLL3QJlqkdIKty2+ZgxaIOfVpbtpH/kou 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 | 36 ++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/drivers/input/touchscreen/bu21013_ts.c b/drivers/input/touchscreen/bu21013_ts.c index 8982bea..dbbd1f8 100644 --- a/drivers/input/touchscreen/bu21013_ts.c +++ b/drivers/input/touchscreen/bu21013_ts.c @@ -15,6 +15,8 @@ #include #include #include +#include +#include #define PEN_DOWN_INTR 0 #define MAX_FINGERS 2 @@ -454,13 +456,30 @@ static void bu21013_cs_disable(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; + + pdata->x_flip = of_property_read_bool(np, "rohm,flip-x"); + pdata->y_flip = of_property_read_bool(np, "rohm,flip-y"); + + 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, @@ -470,8 +489,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; + } } if (!gpio_is_valid(pdata->touch_pin)) {