From patchwork Fri Jul 13 18:30:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pawe=C5=82_Chmiel?= X-Patchwork-Id: 10524009 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 5F3446028E for ; Fri, 13 Jul 2018 18:31:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 526D129F96 for ; Fri, 13 Jul 2018 18:31:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3CEAA29FA8; Fri, 13 Jul 2018 18:31:04 +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=-2.9 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BF41C29FA7 for ; Fri, 13 Jul 2018 18:31:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=PKVR+mElFNwcEvw3UzK9S1q5fbg3kxkM7o6iQCqslr0=; b=tqruT0mFZC0veX HxaVaHHoBA4i3oLRMStpNn9XL3rZODKbNXqbReAcKF/rFFCGLSQHzEgMHgJaHbFzM1oOGaq4VVFDg S4MZz+1b3WWwNnDim9SmsWMEnLB6PIPGltvCXTEQ5v+XLTc4qIEqGck+q7LgtTf57PXifrZN1RYWo fVGv3TMIHbv6rz/2RiH4DbkW7yBFVhzVUp53k7+ytd9T9Ee4KwQXDo38GHKZxtDS64oeQMxkF7yWx EOqm6HlrfTqrPufsj9x+O/LzmIoX0RaiQLtIfgg08qNeodzwzFREYnaBskrr7O8GaGCthNlKJfqlL B2AOlGVdgC22LQEf1mog==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fe2qI-00027S-Cz; Fri, 13 Jul 2018 18:30:58 +0000 Received: from mail-lj1-x243.google.com ([2a00:1450:4864:20::243]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fe2q5-0001qM-2D for linux-arm-kernel@lists.infradead.org; Fri, 13 Jul 2018 18:30:46 +0000 Received: by mail-lj1-x243.google.com with SMTP id l15-v6so5074685lji.6 for ; 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=c7xnvuy12BVtmE9mESOtsQHjwj9Hg+6NrRCfz1cQidtA/aPHKJLIdcuFy8K25ZeWHi aaBqj213geRDWlhSWEzUmd5pEk7BWPrJk7FNBdHVsWHC0I457UjoLg1+BMge2+FopWZu 5AFG4uv1m7WkEz4dmp+Kg1Qr+pF/emWPVmdWKGAfxL8Zeog2YK2pkxztMot1CkBtlY1C D1wZyGuOmIUIBtJHHUnVS9xLIiFfNSLHD2TccgaJhG03X6KIoM57yONUbYNznNym3h4W y+nHuvMf8BCTSQSIBzXEkmXFpozymxeNs33LRLOJKrmMdgHO/afgkfJKdpUv/20IqfSc 1kJA== X-Gm-Message-State: AOUpUlHkj/87lqY52N9UxVl77szSixXQv/DkKVVBswT5cbHL0OUCFQ7/ J0WNpcDGOH5AjpZsmDujeDE= X-Google-Smtp-Source: AAOMgpdaOXp6bCOxeZN+/axCSmpFs/oTQa+t8huYUb0Xe8Osgb4gUmQnudnCk8/X1ApbDiJsN5J3hQ== 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180713_113045_103831_E256AA35 X-CRM114-Status: GOOD ( 15.62 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, devicetree@vger.kernel.org, alexandre.belloni@bootlin.com, dmitry.torokhov@gmail.com, linux-kernel@vger.kernel.org, robh+dt@kernel.org, linux-input@vger.kernel.org, linux-arm-kernel@lists.infradead.org, =?UTF-8?q?Pawe=C5=82=20Chmiel?= Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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);