Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1103415imm; Fri, 13 Jul 2018 11:31:51 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdjFIrNx6DncMtBDccBydQUtXiykGPUXJJ7+py6q+mCqcQvIyWbVpO772PpdM8KBfClOKlm X-Received: by 2002:a17:902:9f81:: with SMTP id g1-v6mr7382075plq.304.1531506711127; Fri, 13 Jul 2018 11:31:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531506711; cv=none; d=google.com; s=arc-20160816; b=sB+E5zInZ2U1aZ+wJ6/5xqwF6Nqi6p+XXrNdgwIJtTLJVSKkeE8kMa1D4LayCTcDv6 ggCqiYhpep6ahwPcZklj32c2l9cL0dTwfXaRtt1XwL/6jM4jddAZYcIuH/lnCBrNZoxc N2mks/fPMOMBncYbzo6phX1rjoeTcLF9UzZ/tRrGPX3xH/z0BjshdjbtNjSgvP/TvFMK 5YnbQCzjwqlEJU+3/dST+61FjZHLBeDnqLkuke8K++5nbewakJcGkpChqMFHL8QfXbDv rR/iWetGUe3QpGd1cY13WYnOu6DG9RH0lOytd6dxLBW6LR+XdQPk0Gsuua9/2V+PFSrt pOlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=SUEo8oTgOxKKgN9CB/xquVykx3NZ4EIVn8RiU4PVBlk=; b=XbuCumb7iVgNvZHZcu4ZehA6iwbe9Bf9Kl7x6+RbhLq+cAaxmRXwvyM92vJbExvnAk qLVAnJbQeiIIWHhD+uQbOnzthHFD3ncTIH8cZ9qsXgE06F3Qlo+sB9UF8AU5CLcTcCGv 5/hM9R2z+158pCqD5FtQL7FBLzKo0pU/A70MqGfhuu1DnfRFUZm41GRcRG4QKBq3rf5J yVvPc/PZXQItiEO6odL93tI/ak668os9tRc1JC26Ut7uhNZNtFd/1o+rAxLypLqiBhDG yV1nBYk6+Bv8WpcCqRnUpF/aTE4q8Rxf6CzsdMgL8ReUQE1YDA44riOWFMkF/XMNSqJu yvvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=K3BBlF+4; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b5-v6si268540pfa.116.2018.07.13.11.31.36; Fri, 13 Jul 2018 11:31:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=K3BBlF+4; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731555AbeGMSqX (ORCPT + 99 others); Fri, 13 Jul 2018 14:46:23 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:43371 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729982AbeGMSqW (ORCPT ); Fri, 13 Jul 2018 14:46:22 -0400 Received: by mail-lj1-f194.google.com with SMTP id r13-v6so25181443ljg.10; Fri, 13 Jul 2018 11:30:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SUEo8oTgOxKKgN9CB/xquVykx3NZ4EIVn8RiU4PVBlk=; b=K3BBlF+4/LaVztEUuOL5ECGwYC+tIQ4S+NqVdi9opEbgdzjoKLqVM7rhLMIVYTgY37 1bT7Be8Lx82G8OxWYvTG0BYNEtviOFL7NFKZWR6p2JwqRnf1gOM2y/P7ekuF33jM2jYY s6c620+ZUTe1bn3GbHcd1+IM+0WtfOK109xnxuY7z1j8zmNvaqnYRoNwV9C4eZm7ZzaY aa1APhsnkoKtozf8mnQGVBfI6WD3g4IunMUZpB6GYurfWhIcwL/Q+Oj1ZnnNyCHmKnyC wu9Depe5Qcr1JFvwNF2yZR5AasVplZFqDys99IuUxJR3H2QLmtqPcSmXSEM124mEISv8 0x+w== 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:mime-version:content-transfer-encoding; bh=SUEo8oTgOxKKgN9CB/xquVykx3NZ4EIVn8RiU4PVBlk=; b=FSXYnHlvKWxCkO8QE7PgNA0rmdiJTi2Q32HzCtyVWsYpEH5u0fxFYTLw55MoFw1tci F32FVfG/Vn/kdi7tfGZMtK8jO39p5YwNiPcWlkXuLvj6Zkf7UAewWkQsXNujg6B/KdDp 0DrExdKIV7j83G6/hcE6R6+GjDgZ0HEWRr07IyVLJ9sCvNkzeaiZFysHIRkZjcLOpbsL bTzXwb98F9NvNgynDvIEIMmybSzJvgeVp3m16wbTjp8FasP7/mc/Ma1TALIoeAgSaFf3 G+L/lu0nkjvVgus9aLUWROHwEstzshE3lkB3tF/3QxGZ5B1yShXzL2iLkEWJWl38b5Tw Sy6Q== X-Gm-Message-State: AOUpUlEkoUqO3S9JZmnYmjXqRP1+RUwqfo/W+dzCltqVAfyWAU8cJKSd lWyCOZCq7S75fQq3skhc++s= X-Received: by 2002:a2e:9ec9:: with SMTP id h9-v6mr3721490ljk.133.1531506633023; Fri, 13 Jul 2018 11:30:33 -0700 (PDT) Received: from localhost.localdomain (user-94-254-174-73.play-internet.pl. [94.254.174.73]) by smtp.googlemail.com with ESMTPSA id j12-v6sm491268ljh.13.2018.07.13.11.30.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 13 Jul 2018 11:30:31 -0700 (PDT) From: =?UTF-8?q?Pawe=C5=82=20Chmiel?= To: nick@shmanahar.org Cc: dmitry.torokhov@gmail.com, robh+dt@kernel.org, mark.rutland@arm.com, nicolas.ferre@microchip.com, alexandre.belloni@bootlin.com, linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Pawe=C5=82=20Chmiel?= Subject: [PATCH 1/2] Input: atmel_mxt_ts: Add support for optional regulators. Date: Fri, 13 Jul 2018 20:30:07 +0200 Message-Id: <1531506608-24479-2-git-send-email-pawel.mikolaj.chmiel@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1531506608-24479-1-git-send-email-pawel.mikolaj.chmiel@gmail.com> References: <1531506608-24479-1-git-send-email-pawel.mikolaj.chmiel@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch adds optional regulators, which can be used to power up touchscreen. After enabling regulators, we need to wait 150msec. This value is taken from official driver. It was tested on Samsung Galaxy i9000 (based on Samsung S5PV210 SOC). Signed-off-by: Paweł Chmiel --- drivers/input/touchscreen/atmel_mxt_ts.c | 45 ++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index 54fe190fd4bc..a7625ec8fb9f 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -198,6 +199,7 @@ enum t100_type { #define MXT_RESET_INVALID_CHG 100 /* msec */ #define MXT_RESET_TIME 200 /* msec */ #define MXT_RESET_TIMEOUT 3000 /* msec */ +#define MXT_REGULATOR_DELAY 150 /* msec */ #define MXT_CRC_TIMEOUT 1000 /* msec */ #define MXT_FW_RESET_TIME 3000 /* msec */ #define MXT_FW_CHG_TIMEOUT 300 /* msec */ @@ -310,6 +312,8 @@ struct mxt_data { struct t7_config t7_cfg; struct mxt_dbg dbg; struct gpio_desc *reset_gpio; + struct regulator *vdd_reg; + struct regulator *avdd_reg; /* Cached parameters from object table */ u16 T5_address; @@ -3076,6 +3080,40 @@ static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id) return error; } + data->vdd_reg = devm_regulator_get_optional(&client->dev, "vdd"); + if (IS_ERR(data->vdd_reg)) { + error = PTR_ERR(data->vdd_reg); + dev_err(&client->dev, "Failed to get vdd regulator: %d\n", + error); + return error; + } + + if (data->vdd_reg) { + error = regulator_enable(data->vdd_reg); + if (error) { + dev_err(&client->dev, "Failed to enable vdd regulator: %d\n", + error); + return error; + } + } + + data->avdd_reg = devm_regulator_get_optional(&client->dev, "avdd"); + if (IS_ERR(data->avdd_reg)) { + error = PTR_ERR(data->avdd_reg); + dev_err(&client->dev, "Failed to get avdd regulator: %d\n", + error); + return error; + } + + if (data->avdd_reg) { + error = regulator_enable(data->avdd_reg); + if (error) { + dev_err(&client->dev, "Failed to enable avdd regulator: %d\n", + error); + return error; + } + } + error = devm_request_threaded_irq(&client->dev, client->irq, NULL, mxt_interrupt, IRQF_ONESHOT, client->name, data); @@ -3086,6 +3124,9 @@ static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id) disable_irq(client->irq); + if (!IS_ERR(data->vdd_reg) || !IS_ERR(data->avdd_reg)) + msleep(MXT_REGULATOR_DELAY); + if (data->reset_gpio) { msleep(MXT_RESET_GPIO_TIME); gpiod_set_value(data->reset_gpio, 1); @@ -3116,6 +3157,10 @@ static int mxt_remove(struct i2c_client *client) struct mxt_data *data = i2c_get_clientdata(client); disable_irq(data->irq); + if (!IS_ERR(data->avdd_reg)) + regulator_disable(data->avdd_reg); + if (!IS_ERR(data->vdd_reg)) + regulator_disable(data->vdd_reg); sysfs_remove_group(&client->dev.kobj, &mxt_attr_group); mxt_free_input_device(data); mxt_free_object_table(data); -- 2.7.4