From patchwork Tue Jul 17 18:16:25 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: 10530335 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 42AAA6020A for ; Tue, 17 Jul 2018 18:17:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 33FC729607 for ; Tue, 17 Jul 2018 18:17:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2822B29614; Tue, 17 Jul 2018 18:17:17 +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 AAA8929607 for ; Tue, 17 Jul 2018 18:17:16 +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=9g+sy3IkMqBtLhXw11YQ/8aRJC4MnRCaO+utS/KAzSw=; b=IEk7U2Cq4GkvqV J/mDozAUpcj7cp+h5nXJEMiyRJ1R5nhIj9+Os4RMXNmPdEW2tJsNzmXxEplzujXh6y1DGXj3U1Iwl 83co7be0nmQ/71saU6N9obx/dWNAt9x53hkONNc9ivX35ZP9pfEJh4nG2OaSJViXTPT+KpBSLbvZJ cElcgGehot4tcQfmzsUB2ZVDczt9uQrK4fOTZW2y94oQa5Iw6Ie7ll4UzgRaD7I2oL7GhqYBO+KQG +IqtoNlGk8q6P8xWBYxfOsTrokkeJpi69XEQ3rZ1XyzUtqJdJFsl24EfPYbVb3WcQVvTmU4hkaJ9L ZwSBrQJoHheCli4sHdQg==; 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 1ffUX9-00071g-CX; Tue, 17 Jul 2018 18:17:11 +0000 Received: from mail-lf0-x241.google.com ([2a00:1450:4010:c07::241]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1ffUWl-0006Z5-VH for linux-arm-kernel@lists.infradead.org; Tue, 17 Jul 2018 18:16:49 +0000 Received: by mail-lf0-x241.google.com with SMTP id v22-v6so1527521lfe.8 for ; Tue, 17 Jul 2018 11:16:37 -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=QaJ7ttVA72aV94Rh03/JiLjYYA6jS/C/gXFMPtN/Hag=; b=tXRYZoQ450Ol5Bx2/DlrhzrjVtiwLyE+bQKNflohRzqRCSsSyR30VFFrohYgUaxquN zV1HWak8Raeye5gp4jlxrdk6EIXGjgGKkpj6Q8u1o8ZJjJs6hNTMGeKUTJx2B7IDgpU1 QigWm1a6RMGcFxUzitHrPOmhn3u5DH0KhftreAR5OVAFNVh4suDo3RUJrQmzNZD1zVeq pC5sqfAXgJDkAv/d3petvjzH1hzMDyW16SiHpYt/6LlEv6ZOl12V1ryjdaBz51oxFPkD LIwc7TCtDXbZMSgyfqwY9pEXCPl6T39/WEbW07+qi9My3Tg6z2/hmyLz34pzgnYxUf/q QZ7w== 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=QaJ7ttVA72aV94Rh03/JiLjYYA6jS/C/gXFMPtN/Hag=; b=WBXH4CBhkPu6z4ZgOyOvwuWpjJysng6zRvVMBCem60mMI2DJsyk7Jb8WBchNzBSdUP eQwenWz7gbhL8cbn+Kd3rZfod7x93BebYhowbqRTPwmlqDmDRKEJFwkgrZKc58/GhqIE lBmYf9O6Ke+nA//biDuvXmWxLQA7UDrXoJLJN5hnRE0BdZwe5lkmyfZ+wUeNfxlyvaJ+ rwpSR775l/fY+MA72GThwx1F7gX1Qv4actS/5gLa5Wg5XslxLW+glOaWxtk5X38prG5b 8n1n1XvIZ8Cdr7gXichqUnzbwI56+xfhH35l0SH+FONkZVLaUt6zFrkynHurVXTcgkqs LsQw== X-Gm-Message-State: AOUpUlEOXqAL4FfwWsEBgV6B4xKyLFlt2dVwLS7o/kDe9Q/W+dR1nBUg 4QvzeOByp1ZGWPhvD6vIboU= X-Google-Smtp-Source: AAOMgpfBW7XSd6On2v42uJ06Tkr8C+4E3oFWd+d2cWy0ecYpi7D+t0G3t737KUPkEv5goPGDNciCcA== X-Received: by 2002:a19:de4e:: with SMTP id v75-v6mr1870982lfg.14.1531851396196; Tue, 17 Jul 2018 11:16:36 -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 u19-v6sm260911lje.51.2018.07.17.11.16.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 17 Jul 2018 11:16:35 -0700 (PDT) From: =?UTF-8?q?Pawe=C5=82=20Chmiel?= To: nick@shmanahar.org Subject: [PATCH v2 1/2] Input: atmel_mxt_ts: Add support for optional regulators. Date: Tue, 17 Jul 2018 20:16:25 +0200 Message-Id: <1531851386-17840-2-git-send-email-pawel.mikolaj.chmiel@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1531851386-17840-1-git-send-email-pawel.mikolaj.chmiel@gmail.com> References: <1531851386-17840-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-20180717_111648_006186_BD02B4AB X-CRM114-Status: GOOD ( 19.71 ) 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 --- Changes from v1: - Enable regulators only if reset_gpio is present. - Switch from devm_regulator_get_optional to devm_regulator_get --- drivers/input/touchscreen/atmel_mxt_ts.c | 46 ++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index 54fe190fd4bc..005f0fee9fc8 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 @@ -194,10 +195,10 @@ enum t100_type { /* Delay times */ #define MXT_BACKUP_TIME 50 /* msec */ -#define MXT_RESET_GPIO_TIME 20 /* msec */ #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 +311,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 +3079,22 @@ static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id) return error; } + data->vdd_reg = devm_regulator_get(&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; + } + + data->avdd_reg = devm_regulator_get(&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; + } + error = devm_request_threaded_irq(&client->dev, client->irq, NULL, mxt_interrupt, IRQF_ONESHOT, client->name, data); @@ -3087,7 +3106,26 @@ static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id) disable_irq(client->irq); if (data->reset_gpio) { - msleep(MXT_RESET_GPIO_TIME); + error = regulator_enable(data->vdd_reg); + if (error) { + dev_err(&client->dev, "Failed to enable vdd regulator: %d\n", + error); + return error; + } + + error = regulator_enable(data->avdd_reg); + if (error) { + dev_err(&client->dev, "Failed to enable avdd regulator: %d\n", + error); + return error; + } + + /* + * According to maXTouch power sequencing specification, RESET line + * must be kept low until some time after regulators come up to + * voltage + */ + msleep(MXT_REGULATOR_DELAY); gpiod_set_value(data->reset_gpio, 1); msleep(MXT_RESET_INVALID_CHG); } @@ -3116,6 +3154,10 @@ static int mxt_remove(struct i2c_client *client) struct mxt_data *data = i2c_get_clientdata(client); disable_irq(data->irq); + if (data->reset_gpio) { + regulator_disable(data->avdd_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);