From patchwork Fri Feb 24 15:42:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yegor Yefremov X-Patchwork-Id: 9590635 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E180E6020A for ; Fri, 24 Feb 2017 15:49:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D646922BF1 for ; Fri, 24 Feb 2017 15:49:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CAC3E286CC; Fri, 24 Feb 2017 15:49:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B645522BF1 for ; Fri, 24 Feb 2017 15:49:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751282AbdBXPoH (ORCPT ); Fri, 24 Feb 2017 10:44:07 -0500 Received: from mail-wr0-f196.google.com ([209.85.128.196]:36398 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751299AbdBXPmx (ORCPT ); Fri, 24 Feb 2017 10:42:53 -0500 Received: by mail-wr0-f196.google.com with SMTP id o22so1829137wro.3 for ; Fri, 24 Feb 2017 07:42:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=PtPCgemxdqEqNr7dAOnPI35lyMC7hGVy1UeRAo9U2aU=; b=Ox/OhdY0boGN4wRlX2R7INDhQK3CfQg/XKZTp9ju/9RgRul1Dxa46VpnOEHg9GEJ9e e3bvj8c8nAY4Ed0XJENi8ijhxp6NJGsfDGCPT5Af/gKZ32EL5KmiMQwKEOKU+Tndw9rA bC3/8ehQgF1WOhx0/dC/qH5nFkLmaw9BTS9C2WM3LV/C2pR80RQ7BZxfET4Qye46cRag y08jFwd+gb1bjYIxeeolZcOG0LDS56O78f6F2GOcR+IG9gSUtaZzNYD8s6YswjLbCG6b fOzfBIhbkz0Tb/KbprVXleT92W7fAKsiMuS6m9R1sihA02Qnd07uTxgJJPun0DD5qCZe 76QA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=PtPCgemxdqEqNr7dAOnPI35lyMC7hGVy1UeRAo9U2aU=; b=VtNiSAVo1feKLG9+pujxcLAOXfxWApoLcbbUYp2Qr23H5M9QEw/+aElJrFqui9Edir JgEgUPQ0LJ2qK8Hbi4mTJ8OIqxj4rs3Y+Vu8hy7TVVcyj/6P7NuHBDXKyGDEYbatYNbm QwJy9W7FGmN86cENN/aPfose/JjEz/MMJbCfbN7wbgShdWUygGIAMucH5aHGYEzLz+hM 6rUZcHD4ZD+LOZAbqPpr/AzMC6+cyQFRkbB07YPAz3RFL4e23T79F8adHkVIobmqp/vY UTExufeHWKOQGJ0FJWvsZ6XXA2Q2fKWnNPG+EBETa1WlyhCncEuqmOMXBcYyM2FJ9YQW RCpA== X-Gm-Message-State: AMke39mZb7AV7n9AuAsi1Zo05k47kdVtxX3hwnbaUDk7vcLllqwH3eHRhRr5kAJJI5wScA== X-Received: by 10.223.170.157 with SMTP id h29mr3011450wrc.63.1487950971942; Fri, 24 Feb 2017 07:42:51 -0800 (PST) Received: from development1.visionsystems.de (mail.visionsystems.de. [213.209.99.202]) by smtp.gmail.com with ESMTPSA id w51sm10757350wrc.12.2017.02.24.07.42.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 24 Feb 2017 07:42:51 -0800 (PST) From: yegorslists@googlemail.com To: linux-input@vger.kernel.org Cc: dmitry.torokhov@gmail.com, lee.jones@linaro.org, robh+dt@kernel.org, mark.rutland@arm.com, andrej.skvortzov@gmail.com, Yegor Yefremov Subject: [PATCH 2/3] tps6507x-ts: add DT support Date: Fri, 24 Feb 2017 16:42:25 +0100 Message-Id: <1487950946-18590-3-git-send-email-yegorslists@googlemail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1487950946-18590-1-git-send-email-yegorslists@googlemail.com> References: <1487950946-18590-1-git-send-email-yegorslists@googlemail.com> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Yegor Yefremov This patch adds support for DT to tps6507x-ts driver. Signed-off-by: Yegor Yefremov --- drivers/input/touchscreen/tps6507x-ts.c | 70 ++++++++++++++++++++------------- 1 file changed, 42 insertions(+), 28 deletions(-) diff --git a/drivers/input/touchscreen/tps6507x-ts.c b/drivers/input/touchscreen/tps6507x-ts.c index 5bf1ec6..2d61220 100644 --- a/drivers/input/touchscreen/tps6507x-ts.c +++ b/drivers/input/touchscreen/tps6507x-ts.c @@ -22,6 +22,8 @@ #include #include #include +#include +#include #define TSC_DEFAULT_POLL_PERIOD 30 /* ms */ #define TPS_DEFAULT_MIN_PRESSURE 0x30 @@ -199,33 +201,52 @@ static void tps6507x_ts_poll(struct input_polled_dev *poll_dev) tps6507x_adc_standby(tsc); } +static void tsc_init_data(struct tps6507x_ts *tsc, + struct input_dev *input_dev) +{ + struct device_node *node = tsc->dev->of_node; + const struct tps6507x_board *tps_board = + dev_get_platdata(tsc->dev); + const struct touchscreen_init_data *init_data = NULL; + + if (tps_board) + /* + * init_data points to array of touchscreen_init structure + * coming from the board-evm file. + */ + init_data = tps_board->tps6507x_ts_init_data; + + if (node == NULL && init_data == NULL) { + tsc->poll_dev->poll_interval = TSC_DEFAULT_POLL_PERIOD; + tsc->min_pressure = TPS_DEFAULT_MIN_PRESSURE; + } else if (init_data) { + tsc->poll_dev->poll_interval = init_data->poll_period; + tsc->min_pressure = init_data->min_pressure; + input_dev->id.vendor = init_data->vendor; + input_dev->id.product = init_data->product; + input_dev->id.version = init_data->version; + } else if (node) { + of_property_read_u32(node, "ti,poll-period", + &tsc->poll_dev->poll_interval); + of_property_read_u16(node, "ti,min-pressure", + &tsc->min_pressure); + of_property_read_u16(node, "ti,vendor", + &input_dev->id.vendor); + of_property_read_u16(node, "ti,product", + &input_dev->id.product); + of_property_read_u16(node, "ti,version", + &input_dev->id.version); + } +} + static int tps6507x_ts_probe(struct platform_device *pdev) { struct tps6507x_dev *tps6507x_dev = dev_get_drvdata(pdev->dev.parent); - const struct tps6507x_board *tps_board; - const struct touchscreen_init_data *init_data; struct tps6507x_ts *tsc; struct input_polled_dev *poll_dev; struct input_dev *input_dev; int error; - /* - * tps_board points to pmic related constants - * coming from the board-evm file. - */ - tps_board = dev_get_platdata(tps6507x_dev->dev); - if (!tps_board) { - dev_err(tps6507x_dev->dev, - "Could not find tps6507x platform data\n"); - return -ENODEV; - } - - /* - * init_data points to array of regulator_init structures - * coming from the board-evm file. - */ - init_data = tps_board->tps6507x_ts_init_data; - tsc = devm_kzalloc(&pdev->dev, sizeof(struct tps6507x_ts), GFP_KERNEL); if (!tsc) { dev_err(tps6507x_dev->dev, "failed to allocate driver data\n"); @@ -234,8 +255,6 @@ static int tps6507x_ts_probe(struct platform_device *pdev) tsc->mfd = tps6507x_dev; tsc->dev = tps6507x_dev->dev; - tsc->min_pressure = init_data ? - init_data->min_pressure : TPS_DEFAULT_MIN_PRESSURE; snprintf(tsc->phys, sizeof(tsc->phys), "%s/input0", dev_name(tsc->dev)); @@ -251,8 +270,6 @@ static int tps6507x_ts_probe(struct platform_device *pdev) poll_dev->private = tsc; poll_dev->poll = tps6507x_ts_poll; - poll_dev->poll_interval = init_data ? - init_data->poll_period : TSC_DEFAULT_POLL_PERIOD; input_dev = poll_dev->input; input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); @@ -266,11 +283,8 @@ static int tps6507x_ts_probe(struct platform_device *pdev) input_dev->phys = tsc->phys; input_dev->dev.parent = tsc->dev; input_dev->id.bustype = BUS_I2C; - if (init_data) { - input_dev->id.vendor = init_data->vendor; - input_dev->id.product = init_data->product; - input_dev->id.version = init_data->version; - } + + tsc_init_data(tsc, input_dev); error = tps6507x_adc_standby(tsc); if (error)