From patchwork Wed Oct 28 10:17:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 319286 Delivered-To: patch@linaro.org Received: by 2002:a92:7b12:0:0:0:0:0 with SMTP id w18csp1014695ilc; Wed, 28 Oct 2020 15:55:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxrSUL2Y8Hy8jz8syEBs+mzK1YEkFroXA9zMwgtG28YjyFDZYX3gZZrFo184twLxXlgVdgq X-Received: by 2002:a17:907:40c2:: with SMTP id nv2mr1249254ejb.337.1603925717198; Wed, 28 Oct 2020 15:55:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603925717; cv=none; d=google.com; s=arc-20160816; b=SU6qK2htGryoba34V2S6u2aMYb517qyusNXR8cuvut/PWtJpZ6aTlqXAYsTYnOCQ8a EF5AbapB8q9fLerlv3DYeoV3Zi/8EUTbgp2lFpQe3bjv9zV9WTBfNTDnTbxtvY3jt+zu yesYvKEgqvNldEOpqWM57w791jmwvaGjXSUgSffpIpD8AtdkIjpWFq+nTpSXVxlhDUE3 lRStNg8+vubvanOZ3w6kgFvP36tboBMiEtFsByRHQZZMNWn3ptzch48PozAHRvGunitf 7HQfhQykE4nnyLH6V9f3SsaGZ6yvbTim5eST1ND4iWVi6rB95wPTKBieZK+r4DrnBeEY NYzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=J41W71IQ8WSj0cCZqufjh6ZHmQkGRw/0YT8/352UCGg=; b=cpHFZc4xt5PnXKgRtfJ097AIO8XS04EpjkNPKLnE7yNO/8H/K3NVd+YHMPJKeWPAbK 2euFIxImW7IPchzLhYKqqEomMH8+C8x1AYyHfbelk9beWtUpqNLNv2OTh6HFh5FFUC/1 kac0yWqdmgiZAxZM03xG7JTzXY5M/dbXX+33r43wTbjzNcwhvbfqIecQNPG8xOefYOmY cA4jVmszwR9FfFVmNXb9bp4o9hpDIDfXvbMO1eadFluClfcVphO6b85Z/lfh0PXI9TOq V9p4BgN+Wk7t1gWk07djefudtGxkF6zRRCcswNjGM9NpON+E4qPHhKJHlf+VEm267uhs 1xcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=a2fMGqvD; spf=pass (google.com: domain of linux-input-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-input-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a2si726440edq.154.2020.10.28.15.55.17; Wed, 28 Oct 2020 15:55:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-input-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=a2fMGqvD; spf=pass (google.com: domain of linux-input-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-input-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389712AbgJ1Wyv (ORCPT + 1 other); Wed, 28 Oct 2020 18:54:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731882AbgJ1WyR (ORCPT ); Wed, 28 Oct 2020 18:54:17 -0400 Received: from mail-ej1-x641.google.com (mail-ej1-x641.google.com [IPv6:2a00:1450:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ABB44C0613CF for ; Wed, 28 Oct 2020 15:54:14 -0700 (PDT) Received: by mail-ej1-x641.google.com with SMTP id s15so1200364ejf.8 for ; Wed, 28 Oct 2020 15:54:14 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=J41W71IQ8WSj0cCZqufjh6ZHmQkGRw/0YT8/352UCGg=; b=a2fMGqvD/R5ExXo7ON4SNTQow6QSUXZJ0oEN74ayDLbg5utNqTPolAjE7pddYpbZSP f7NczRPuiC6UdRNZovCzI0x684EeBMw6LseeFtivV1OW1Z2fJlokPJdPN8gZOZ489ST5 kEyPJOMFl4Sv47u2iFs7+oGLCuDRTR78hXZnqKlRMj2NOHwtvD0zrTfhBD9uEjRSRi/b wJr1k/Os2Sw/gb+3dwHuTERC3IJ/LeMimPscbDaC/6+0aDDOcZO9+Id2O9dkjkdzN6+d eHMonCC8G1hTf+c6rerzru+xIDq2+z9lliI8HoeStLY3ZXX58AQ3Lyk4RUsoSbwQVwGJ poEg== 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=J41W71IQ8WSj0cCZqufjh6ZHmQkGRw/0YT8/352UCGg=; b=dX0hNM/ruLIBb7eMQ3bVS4ghRjRagl17I6cIEP+dWnLxCji24CbfTCC2NNB/a3fQgK vggZGastCnZPSq4tMvKJmDsd/Z1cD1HRv0zNCi2oclLE7Smd7lN6T6FXV6v2oQPhw83v 8qWFLfrRRuN6mewNy5dVGxBRK0jPUGyXz63ok5C+AxjBgtd6iNwl2NRm0Om8zBOSCpb7 diLxlrx7aeI5TkuyPcTy23xKdfD85ISHQZDuKZHj+LDPeX2V+jtnHBaSktf//lKmFpOL 5w22Fahj1I33VjICU12G5zfiO14dB8jc9ostCZbro1znDu3/CH0iitV2ZU3lQPq88PU4 3Krg== X-Gm-Message-State: AOAM530Grtz7SU3oQ+3Bf3BM2HVfkcBKMet3v9cKCboeidnCVyWuXDl5 KhaO35UDEtu79Mpgvq1e5tewl9qVqQx4os0w X-Received: by 2002:a19:b14:: with SMTP id 20mr2693296lfl.308.1603880239749; Wed, 28 Oct 2020 03:17:19 -0700 (PDT) Received: from localhost.bredbandsbolaget (c-92d7225c.014-348-6c756e10.bbcust.telenor.se. [92.34.215.146]) by smtp.gmail.com with ESMTPSA id b12sm478741lfo.177.2020.10.28.03.17.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Oct 2020 03:17:19 -0700 (PDT) From: Linus Walleij To: Dmitry Torokhov , linux-input@vger.kernel.org Cc: Linus Walleij , Nick Dyer , Stephan Gerhold Subject: [PATCH 2/2] Input: atmel_mxt_ts: Support regulator supplies Date: Wed, 28 Oct 2020 11:17:11 +0100 Message-Id: <20201028101711.696423-2-linus.walleij@linaro.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201028101711.696423-1-linus.walleij@linaro.org> References: <20201028101711.696423-1-linus.walleij@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org This adds the code for the Atmel touchscreens such as mXT224 to obtain power regulators for the supply voltages AVDD and VDD. On mobile phones such as Samsung GT-I8190 (Golden) this is needed to explicitly bring power online. We just enable the regulators at probe() and disable them at remove() or in the errorpath for now. As regulators are naturally stubbed if not available, this should have no impact on existing systems. Cc: Nick Dyer Cc: Stephan Gerhold Signed-off-by: Linus Walleij --- drivers/input/touchscreen/atmel_mxt_ts.c | 37 +++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) -- 2.26.2 diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index 98f17fa3a892..701269f9744f 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -309,6 +310,7 @@ struct mxt_data { u8 multitouch; struct t7_config t7_cfg; struct mxt_dbg dbg; + struct regulator_bulk_data regulators[2]; struct gpio_desc *reset_gpio; bool use_retrigen_workaround; @@ -3134,6 +3136,21 @@ static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id) if (error) return error; + /* + * VDDA is the analog voltage supply 2.57..3.47 V + * VDD is the digital voltage supply 1.71..3.47 V + */ + data->regulators[0].supply = "vdda"; + data->regulators[1].supply = "vdd"; + error = devm_regulator_bulk_get(&client->dev, ARRAY_SIZE(data->regulators), + data->regulators); + if (error) { + if (error != -EPROBE_DEFER) + dev_err(&client->dev, "Failed to get regulators %d\n", + error); + return error; + } + data->reset_gpio = devm_gpiod_get_optional(&client->dev, "reset", GPIOD_OUT_LOW); if (IS_ERR(data->reset_gpio)) { @@ -3152,6 +3169,19 @@ static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id) disable_irq(client->irq); + error = regulator_bulk_enable(ARRAY_SIZE(data->regulators), + data->regulators); + if (error) { + dev_err(&client->dev, "failed to enable regulators: %d\n", + error); + return error; + } + /* + * The device takes 40ms to come up after power-on according + * to the mXT224 datasheet, page 13. + */ + msleep(MXT_BACKUP_TIME); + if (data->reset_gpio) { msleep(MXT_RESET_GPIO_TIME); gpiod_set_value(data->reset_gpio, 1); @@ -3160,7 +3190,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_regulators; error = sysfs_create_group(&client->dev.kobj, &mxt_attr_group); if (error) { @@ -3174,6 +3204,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_regulators: + regulator_bulk_disable(ARRAY_SIZE(data->regulators), + data->regulators); return error; } @@ -3185,6 +3218,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); + regulator_bulk_disable(ARRAY_SIZE(data->regulators), + data->regulators); return 0; }