From patchwork Sun Mar 15 10:04:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Cercueil X-Patchwork-Id: 203302 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,UNWANTED_LANGUAGE_BODY,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9752AC2BB1D for ; Sun, 15 Mar 2020 10:04:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7024C206B1 for ; Sun, 15 Mar 2020 10:04:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=crapouillou.net header.i=@crapouillou.net header.b="XXxWrlPv" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728239AbgCOKEc (ORCPT ); Sun, 15 Mar 2020 06:04:32 -0400 Received: from outils.crapouillou.net ([89.234.176.41]:50322 "EHLO crapouillou.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728197AbgCOKEb (ORCPT ); Sun, 15 Mar 2020 06:04:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1584266662; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8K4at98VmVZ/sFGzndyiaIeGeVtmYp4j33U5NwycmlE=; b=XXxWrlPvXOPw8dW7Zjt0Mj2VJjdLgy7L/rL79sPujQA4p3Kw5LOsk6GmefWjmi6Y/W7EaQ AS4rdhpXZo6VXsaaiDQKlpFNrWS44lsEacQ6DjKK1nY6W73CA4tzAKm7iu1ckJl2MU6vNF 5KrkOENWf1EGUI4ieLRvp5VxTfQtlvU= From: Paul Cercueil To: Nick Dyer , Dmitry Torokhov , Rob Herring , Mark Rutland Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Paul Cercueil Subject: [PATCH 2/2] input: atmel_mxt_ts: Add support for optional regulator Date: Sun, 15 Mar 2020 11:04:16 +0100 Message-Id: <20200315100416.14151-2-paul@crapouillou.net> In-Reply-To: <20200315100416.14151-1-paul@crapouillou.net> References: <20200315100416.14151-1-paul@crapouillou.net> MIME-Version: 1.0 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Add support for an optional "vdd" regulator, as some platforms require a regulator to be enabled for the touchscreen to be enabled. Signed-off-by: Paul Cercueil --- drivers/input/touchscreen/atmel_mxt_ts.c | 25 +++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index ae60442efda0..b3511dad475a 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -308,6 +309,7 @@ struct mxt_data { struct t7_config t7_cfg; struct mxt_dbg dbg; struct gpio_desc *reset_gpio; + struct regulator *vdd; /* Cached parameters from object table */ u16 T5_address; @@ -3103,6 +3105,22 @@ static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id) disable_irq(client->irq); + data->vdd = devm_regulator_get_optional(&client->dev, "vdd"); + if (IS_ERR(data->vdd)) { + error = PTR_ERR(data->vdd); + dev_err(&client->dev, "Failed to get regulator: %d\n", error); + return error; + } + + if (data->vdd) { + error = regulator_enable(data->vdd); + if (error) { + dev_err(&client->dev, + "Failed to enable regulator: %d\n", error); + return error; + } + } + if (data->reset_gpio) { msleep(MXT_RESET_GPIO_TIME); gpiod_set_value(data->reset_gpio, 1); @@ -3111,7 +3129,7 @@ static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id) error = mxt_initialize(data); if (error) - return error; + goto err_disable_regulator; error = sysfs_create_group(&client->dev.kobj, &mxt_attr_group); if (error) { @@ -3125,6 +3143,9 @@ static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id) err_free_object: mxt_free_input_device(data); mxt_free_object_table(data); +err_disable_regulator: + if (data->vdd) + regulator_disable(data->vdd); return error; } @@ -3136,6 +3157,8 @@ static int mxt_remove(struct i2c_client *client) sysfs_remove_group(&client->dev.kobj, &mxt_attr_group); mxt_free_input_device(data); mxt_free_object_table(data); + if (data->vdd) + regulator_disable(data->vdd); return 0; }