From patchwork Sat Jun 11 05:25:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 9170969 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 3F0356048C for ; Sat, 11 Jun 2016 05:25:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 326FA27C0C for ; Sat, 11 Jun 2016 05:25:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2731F28325; Sat, 11 Jun 2016 05:25:29 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,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 8391C27C0C for ; Sat, 11 Jun 2016 05:25:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751760AbcFKFZ0 (ORCPT ); Sat, 11 Jun 2016 01:25:26 -0400 Received: from mail-pa0-f45.google.com ([209.85.220.45]:32830 "EHLO mail-pa0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751651AbcFKFZZ (ORCPT ); Sat, 11 Jun 2016 01:25:25 -0400 Received: by mail-pa0-f45.google.com with SMTP id b13so7208076pat.0 for ; Fri, 10 Jun 2016 22:25:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=st9AbnvYP2yhr10R/o/XlUUXAxkAXjMY2YKE5DhjJI4=; b=W6tE6jTo6q3Th13dPDwhfCC2fin1nhAEsCrv4Nlo8fDhCWOiqO/aZbcS6k1LvZDevD Z6d+2/ZD8qbCNUjYLg6jaT9Eq2bZ5wV/NtqN57kHpXJQapwpP0bYS1TXS6G1cCO3ef2g tVqNM4a9HsAqlZhSaxipQjvwbozv64g3fiMbw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=st9AbnvYP2yhr10R/o/XlUUXAxkAXjMY2YKE5DhjJI4=; b=RdTbQvPaV+m8zmUjbKBP68hVexEnOEiavjAbGQAXVkYVyHMXCx9VjkXfHefc/DhLa4 3eVilrVxyNo4BOGU4KKyWWAeUpbuVo96aYGnCOE+zO0/X+9I1JpOsMVR/itQlUkP4wWG i4ENGgczZ2Hscu8vMZUtcAl9pWdJGhZdg0TNMAMo1kvlWd2oz1N1YPDodvT6joq1seV4 GdjtG/2wbIK1bTCnJIC9QCce4FLvDb5UJc0PTavmLDZY94Tszg+x0YKOKMkITUHna/0F t0LvP4fqQAGvRnIhUKkbMjfbDGQSyk5jFW0kkZtreareAaK9BcKSdvASZNXrWDlfFZob ag8w== X-Gm-Message-State: ALyK8tIt5AE/kikv89ZeU+eMLUcNTw5/yM7o7mSh9PcuDjMFh5iZWX3gNK++MWkzZGTjYY10 X-Received: by 10.66.52.11 with SMTP id p11mr6484290pao.155.1465622724460; Fri, 10 Jun 2016 22:25:24 -0700 (PDT) Received: from localhost.localdomain (ip68-111-223-48.sd.sd.cox.net. [68.111.223.48]) by smtp.gmail.com with ESMTPSA id h5sm14998026pfb.81.2016.06.10.22.25.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 10 Jun 2016 22:25:23 -0700 (PDT) From: Bjorn Andersson To: Dmitry Torokhov , Rob Herring , Andrew Duggan , Christopher Heiny Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Bjorn Andersson Subject: [PATCH v3] Input: synaptics-rmi4: Support regulator supplies Date: Fri, 10 Jun 2016 22:25:22 -0700 Message-Id: <1465622722-31714-1-git-send-email-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.5.0 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: Bjorn Andersson Support the two supplies - vdd and vio - to make it possible to control power to the Synaptics chip. Signed-off-by: Bjorn Andersson Signed-off-by: Bjorn Andersson Acked-by: Rob Herring Reviewed-by: Andrew Duggan --- .../devicetree/bindings/input/rmi4/rmi_i2c.txt | 9 +++++ drivers/input/rmi4/rmi_i2c.c | 41 ++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/Documentation/devicetree/bindings/input/rmi4/rmi_i2c.txt b/Documentation/devicetree/bindings/input/rmi4/rmi_i2c.txt index 95fa715c6046..ec908b91fd90 100644 --- a/Documentation/devicetree/bindings/input/rmi4/rmi_i2c.txt +++ b/Documentation/devicetree/bindings/input/rmi4/rmi_i2c.txt @@ -22,6 +22,15 @@ See Documentation/devicetree/bindings/interrupt-controller/interrupts.txt - syna,reset-delay-ms: The number of milliseconds to wait after resetting the device. +- syna,startup-delay-ms: The number of milliseconds to wait after powering on + the device. + +- vdd-supply: VDD power supply. +See ../regulator/regulator.txt + +- vio-supply: VIO power supply +See ../regulator/regulator.txt + Function Parameters: Parameters specific to RMI functions are contained in child nodes of the rmi device node. Documentation for the parameters of each function can be found in: diff --git a/drivers/input/rmi4/rmi_i2c.c b/drivers/input/rmi4/rmi_i2c.c index a96a326b53bd..71dc6cdde8ac 100644 --- a/drivers/input/rmi4/rmi_i2c.c +++ b/drivers/input/rmi4/rmi_i2c.c @@ -11,6 +11,8 @@ #include #include #include +#include +#include #include "rmi_driver.h" #define BUFFER_SIZE_INCREMENT 32 @@ -37,6 +39,9 @@ struct rmi_i2c_xport { u8 *tx_buf; size_t tx_buf_size; + + struct regulator_bulk_data supplies[2]; + u32 startup_delay; }; #define RMI_PAGE_SELECT_REGISTER 0xff @@ -246,6 +251,24 @@ static int rmi_i2c_probe(struct i2c_client *client, return -ENODEV; } + rmi_i2c->supplies[0].supply = "vdd"; + rmi_i2c->supplies[1].supply = "vio"; + retval = devm_regulator_bulk_get(&client->dev, + ARRAY_SIZE(rmi_i2c->supplies), + rmi_i2c->supplies); + if (retval < 0) + return retval; + + retval = regulator_bulk_enable(ARRAY_SIZE(rmi_i2c->supplies), + rmi_i2c->supplies); + if (retval < 0) + return retval; + + of_property_read_u32(client->dev.of_node, "syna,startup-delay-ms", + &rmi_i2c->startup_delay); + + msleep(rmi_i2c->startup_delay); + rmi_i2c->client = client; mutex_init(&rmi_i2c->page_mutex); @@ -286,6 +309,7 @@ static int rmi_i2c_remove(struct i2c_client *client) struct rmi_i2c_xport *rmi_i2c = i2c_get_clientdata(client); rmi_unregister_transport_device(&rmi_i2c->xport); + regulator_bulk_disable(ARRAY_SIZE(rmi_i2c->supplies), rmi_i2c->supplies); return 0; } @@ -308,6 +332,9 @@ static int rmi_i2c_suspend(struct device *dev) dev_warn(dev, "Failed to enable irq for wake: %d\n", ret); } + + regulator_bulk_disable(ARRAY_SIZE(rmi_i2c->supplies), rmi_i2c->supplies); + return ret; } @@ -317,6 +344,12 @@ static int rmi_i2c_resume(struct device *dev) struct rmi_i2c_xport *rmi_i2c = i2c_get_clientdata(client); int ret; + ret = regulator_bulk_enable(ARRAY_SIZE(rmi_i2c->supplies), rmi_i2c->supplies); + if (ret) + return ret; + + msleep(rmi_i2c->startup_delay); + enable_irq(rmi_i2c->irq); if (device_may_wakeup(&client->dev)) { ret = disable_irq_wake(rmi_i2c->irq); @@ -346,6 +379,8 @@ static int rmi_i2c_runtime_suspend(struct device *dev) disable_irq(rmi_i2c->irq); + regulator_bulk_disable(ARRAY_SIZE(rmi_i2c->supplies), rmi_i2c->supplies); + return 0; } @@ -355,6 +390,12 @@ static int rmi_i2c_runtime_resume(struct device *dev) struct rmi_i2c_xport *rmi_i2c = i2c_get_clientdata(client); int ret; + ret = regulator_bulk_enable(ARRAY_SIZE(rmi_i2c->supplies), rmi_i2c->supplies); + if (ret) + return ret; + + msleep(rmi_i2c->startup_delay); + enable_irq(rmi_i2c->irq); ret = rmi_driver_resume(rmi_i2c->xport.rmi_dev);