From patchwork Wed Mar 30 16:57:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 8701311 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4500AC0553 for ; Wed, 30 Mar 2016 16:57:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4FE5F2038A for ; Wed, 30 Mar 2016 16:57:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 458C22035E for ; Wed, 30 Mar 2016 16:57:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932932AbcC3Q5J (ORCPT ); Wed, 30 Mar 2016 12:57:09 -0400 Received: from mail-pa0-f54.google.com ([209.85.220.54]:36344 "EHLO mail-pa0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755091AbcC3Q5H (ORCPT ); Wed, 30 Mar 2016 12:57:07 -0400 Received: by mail-pa0-f54.google.com with SMTP id tt10so45179614pab.3 for ; Wed, 30 Mar 2016 09:57:06 -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=Iyp8JEaNOJvQlC8/riQYh2pe1reyX4o5vZF7wMaOtl0=; b=JEs1zhfyKIMmjGm8Ae5feGg9qv1BJUhf+58IO/B6dpPYpiVZO4JEK9TY2JzBrqDWVW yoL2m2I15XamnxaoyCpVwsW8zmbewhrN3VqPKE7TGyX4E7DqAT79/TEVq73o2IRS+KnE HlzUstJmNcDNp4Cftv9bYkJu10StYxF3T/0W8= 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=Iyp8JEaNOJvQlC8/riQYh2pe1reyX4o5vZF7wMaOtl0=; b=S6Y79lAJk59US/0EQcLOpTsNl0N/cHoWw5iG+krZAbcQ24z5DQWCu5ElZYQFtEnxyD YRm4E30W5Sq2oy6BVxqzV4ALT8w/8fodESrO2GyOOn58pBd+JvTEC9ir/laEqdqEkBxR pJ5ReJc/WVIEjySmUqrCkP8VW7m5LLM6ajGsjmu/N2L9j8vbVJCGxbjEFarjNaiHPKqM SDk925R5eEnjlw18obJtKdiEbjm75HrkWDozggGwe2Aa8Q6tLRFfb3w8Ck24WtiKsyOq 3+E83e0mzbB2u7M3scHxZDpaaTYwAtbePJ7deT9Fb2GeynzJBoiZ3YPrCPH/P/LgRrH1 AVNQ== X-Gm-Message-State: AD7BkJJZq2rsjXnOqzQeM1fr2RB6H2h3zfZh8dpJykv/+OnAEFJoiHrNbR5INBw9mechcNTc X-Received: by 10.67.30.163 with SMTP id kf3mr14833218pad.45.1459357026163; Wed, 30 Mar 2016 09:57:06 -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 e12sm7237263pat.19.2016.03.30.09.57.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 30 Mar 2016 09:57:05 -0700 (PDT) From: Bjorn Andersson To: Dmitry Torokhov , Rob Herring , Pawel Moll , Mark Rutland , Ian Campbell , Andrew Duggan , Christopher Heiny Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Bjorn Andersson Subject: [PATCH] Input: synaptics-rmi4: Support regulator supplies Date: Wed, 30 Mar 2016 09:57:03 -0700 Message-Id: <1459357023-5560-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-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.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 --- .../devicetree/bindings/input/rmi4/rmi_i2c.txt | 7 ++++ drivers/input/rmi4/rmi_i2c.c | 45 ++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/Documentation/devicetree/bindings/input/rmi4/rmi_i2c.txt b/Documentation/devicetree/bindings/input/rmi4/rmi_i2c.txt index 95fa715c6046..a8c31f40f816 100644 --- a/Documentation/devicetree/bindings/input/rmi4/rmi_i2c.txt +++ b/Documentation/devicetree/bindings/input/rmi4/rmi_i2c.txt @@ -22,6 +22,13 @@ See Documentation/devicetree/bindings/interrupt-controller/interrupts.txt - syna,reset-delay-ms: The number of milliseconds to wait after resetting the device. +- vdd-supply: VDD power supply. +See Documentation/devicetree/bindings/regulator/regulator.txt + +- vio-supply: VIO power supply +See Documentation/devicetree/bindings/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..a8c794daba04 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,8 @@ struct rmi_i2c_xport { u8 *tx_buf; size_t tx_buf_size; + + struct regulator_bulk_data supplies[2]; }; #define RMI_PAGE_SELECT_REGISTER 0xff @@ -246,6 +250,22 @@ 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; + + /* Allow the firmware to get ready */ + msleep(10); + rmi_i2c->client = client; mutex_init(&rmi_i2c->page_mutex); @@ -286,6 +306,8 @@ 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 +330,10 @@ 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 +343,14 @@ 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; + + /* Allow the firmware to get ready */ + msleep(10); + enable_irq(rmi_i2c->irq); if (device_may_wakeup(&client->dev)) { ret = disable_irq_wake(rmi_i2c->irq); @@ -346,6 +380,9 @@ 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 +392,14 @@ 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; + + /* Allow the firmware to get ready */ + msleep(10); + enable_irq(rmi_i2c->irq); ret = rmi_driver_resume(rmi_i2c->xport.rmi_dev);