Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1560726rbb; Mon, 26 Feb 2024 13:26:59 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWQD2HCDo12bNktD+8pdrUHydKsEpir+wRHRISqFr037HiW7/3fMYmZERIsFSzejfCDZRKEiVttnvruGft7IJMimgHh8DWIQjzCKV7Ryw== X-Google-Smtp-Source: AGHT+IHq1bMNNj/3QVdji/5CZy3KUzZdUL1gauBVhOHQAR0DY1HozUMLiR3aIN1QEtIFiHvw3IfL X-Received: by 2002:a0c:e1ca:0:b0:68f:e821:ed43 with SMTP id v10-20020a0ce1ca000000b0068fe821ed43mr321943qvl.42.1708982819501; Mon, 26 Feb 2024 13:26:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708982819; cv=pass; d=google.com; s=arc-20160816; b=sVb/YxPrTc6oFaLYDvAqPvq00lNIto5XOwWC21/oxhmrvTq7QB2M/UWoHfVwTav3QE u/V+zKyrX8GWoY3WOi3754N66XU4eiMw+FG5bT9xJGld72Bhn/Rd4KGyEoUYm9Oa2JMG tkvalPFoLkjafc372Dp3q6YZDvr7JgJeMKR2gW+57XNWE2rP40AGDz8tHI1wmg2uZNrp YGwG190HoQGFii6CkgiUZ3JceiKv2jAMxCRLRwBY0o2KFw3kfKXcDJMIFzS14appStNl Ayq+2Cv8mcukYZ4XsR8ZQdXQtVyQLrz/SUDlGFQ6+MeyHq1Fom/byQjwsXDdmhEhT57J WGYQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=144mFCoAmLnYhpxBxU841lMdT4yO+1U9AQuLuH2HZyw=; fh=EsGs0VpT6oMjE94YEtbmQSRUfAUwPm4R9qm0NhCntyE=; b=qO41qOp36hWMw0jT9+4v8PnhqZWz9lF3vkxUI0o/Mqhb1vgfD+IjZFNLIpVVW2rdZm p/ioom1Nkis93y1EXxycRYSCCkk3wJJTIuwIbr41cyAxRgsFDjGBSkQD1YOdKcgnVNxj xs+eYXnqs0yBEEG9GGPYQcLmWTY4SH6itbaBMrlMJgtLr6kPl3Bq+PqOV6hjZgsgm0Ry vcgh6VGYC/27gVmjAIXSAirjOrhoIe6GIh6hGtKqdjPzb2ZvjquuboiUjXxo5qQ91s4X 8TMCs+SbqaqN86liSbrVRo2w7m2X9Gc4Vb98oZpbllzdJiLP9suNLmSx9DjKTfYyLWuV SqYQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="go/dzltW"; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-82337-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82337-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id hf4-20020a0562140e8400b0068c71d0cf61si5866383qvb.446.2024.02.26.13.26.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 13:26:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-82337-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="go/dzltW"; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-82337-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82337-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 36BE81C256FB for ; Mon, 26 Feb 2024 21:26:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8A270132C0B; Mon, 26 Feb 2024 21:26:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="go/dzltW" Received: from mail-lf1-f48.google.com (mail-lf1-f48.google.com [209.85.167.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CFB71132467; Mon, 26 Feb 2024 21:26:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708982766; cv=none; b=VyKpYHJj0TxFbrzpBWYuCPTzq7dtQSJFdkgPd2Ini6GRcH4vxdlzEb6nCcnphocf4zexWy1axY7nLEuxcPMGi2I7BhAcA21yHorrEkRtH81BALVy0VzEtAksZkbr+yy7ic02NgLHucQIMeKI23hz1RJrEqCrBT/3wFtsCCd9dAo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708982766; c=relaxed/simple; bh=+aZznYEEJnxpn3Hfp1CaaYgaYW/C+miPXfNVer03ZgQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=sznuEA5EDp/NsBYL1M+rA7hheHCfRdNXUufBQd5tM+Yfxl2X08Dv/AOMY63DMi5MEsbTcKcBNDXPX8CJe880emPwIztkNHiP2V7HiiK1ufxEWB9znypMwu3tvG9KArByKUqp29p+wufsPLLsRN8ty/2mI4SVWTqeOvRO5jk5cy4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=go/dzltW; arc=none smtp.client-ip=209.85.167.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lf1-f48.google.com with SMTP id 2adb3069b0e04-512f6f263a6so1609308e87.2; Mon, 26 Feb 2024 13:26:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708982762; x=1709587562; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=144mFCoAmLnYhpxBxU841lMdT4yO+1U9AQuLuH2HZyw=; b=go/dzltWJvq453cg6xIphjT9bHHy1Tm4rfMV5KKuNt+xkMir0bfn7NirrZ0tWqRO9B Prt4wPjurTd7oA1r0tBGifpmnA8w9hKiydBOtTPeHZvDJKoy0fohSIH2jjquZfTCD6vT 1EVqQWLf35J4lcs/SRiDRP2njOXnwHHubxKn+5SHrOzJHTP7jUze06HbGLbyPPNBiaDn /NWUVaPZoZWMIQhiTj5nUu/pPWFvkTJdxUwUz1LfSTACWTCBzgA9m2cUc/4y01c2ceC4 APkvW0qZ/HEvUTpcNzxB74b650B9cj+pofZ/qTtAbbEqS/1/KvzjaATKmBWRBqzzSN0M UsEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708982762; x=1709587562; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=144mFCoAmLnYhpxBxU841lMdT4yO+1U9AQuLuH2HZyw=; b=Zg8s+hfaC6fNXHjh4jvzcTWkpYTUAHJxuOiaHYavATpZrN+ZD0chEoH3kAEoaTy2Qb 1Sq+EvLegXZq8ZLRbvpsLJYcGdMrQ7qO09+c8lkXvsQaKztEvgPm7L6cX1AgaHD82+zK YuN1jqEztXPSvEVGuA+Uq+v01Fnag9JHdwNuvwnmQuz0s+9qittNb7WOZ69LDUJ4PGgD wWI813t0W2Z1d/jgqW0CzJFlIr1B6eM3HMGxtYUns3YTedcjdwZXjiaiJi5jnL9PtUo/ LcaO9m7OafEzgY20U9SGgLpk385zg8AUShogEQaqCmKww0A92RUBOY4SzpgHuzsBYohf +9zw== X-Forwarded-Encrypted: i=1; AJvYcCUpz8TWxSC/0CvZ6R61PIAf1Id7TepTNJy1C4aGPQCBpNeSkm5+zSnWbinQGMBs86DSdDNJ1HfyLJZsye3PaB6QZbK4O56pvy5uPHv7VXvF4wAEsOXcVByM8cOsioorpL03GNGjIlJsyfgqvf9+bdiZITXWyfM/204gwvCKcWJk99cGJQ== X-Gm-Message-State: AOJu0Yy/izbCtsc7pJ+n9PD1IJ57cdrw9oi9q8GANjnYDMDSW05KgpqR xhUu60lVVuC017QV9HWkhvgcv+1yFlU2qMRFgV4nWRzbXNQhFgzbg8+phF1tQWw= X-Received: by 2002:ac2:4ecf:0:b0:512:d4fb:14da with SMTP id p15-20020ac24ecf000000b00512d4fb14damr4799760lfr.44.1708982762327; Mon, 26 Feb 2024 13:26:02 -0800 (PST) Received: from [127.0.1.1] (2a02-8389-41cf-e200-06e1-5ae1-dc32-d149.cable.dynamic.v6.surfer.at. [2a02:8389:41cf:e200:6e1:5ae1:dc32:d149]) by smtp.gmail.com with ESMTPSA id uz28-20020a170907119c00b00a3df13a4fe0sm122386ejb.15.2024.02.26.13.26.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 13:26:01 -0800 (PST) From: Javier Carrasco Date: Mon, 26 Feb 2024 22:25:57 +0100 Subject: [PATCH v2 3/3] iio: humidity: hdc3020: add reset management Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240226-hdc3020-pm-v2-3-cec6766086e8@gmail.com> References: <20240226-hdc3020-pm-v2-0-cec6766086e8@gmail.com> In-Reply-To: <20240226-hdc3020-pm-v2-0-cec6766086e8@gmail.com> To: Jonathan Cameron , Lars-Peter Clausen , Li peiyu <579lpy@gmail.com>, Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: Jonathan Cameron , linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, Javier Carrasco X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1708982756; l=2300; i=javier.carrasco.cruz@gmail.com; s=20230509; h=from:subject:message-id; bh=+aZznYEEJnxpn3Hfp1CaaYgaYW/C+miPXfNVer03ZgQ=; b=CZMSC7gN5LcIOZou5QfuhlYuJ+aLxLzWNTgKdYnWvtbl6n34l0Vn2Iy1YDlOp497+AzeeU5Wa ppLyaUJsXAsDcbgbfAKxlBH9dEMdJQZAFrJ8mvyxhIC60dUF52FpUgX X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=tIGJV7M+tCizagNijF0eGMBGcOsPD+0cWGfKjl4h6K8= The HDC3020 provides an active low reset signal that must be handled if connected. Asserting this signal turns the device into Trigger-on Demand measurement mode, reducing its power consumption when no measurements are required like in low-power modes. According to the datasheet, the longest "Reset Ready" is 3 ms, which is only taken into account if the reset signal is defined. Signed-off-by: Javier Carrasco --- drivers/iio/humidity/hdc3020.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/iio/humidity/hdc3020.c b/drivers/iio/humidity/hdc3020.c index 6848be41e1c8..aa477b5e583e 100644 --- a/drivers/iio/humidity/hdc3020.c +++ b/drivers/iio/humidity/hdc3020.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -70,6 +71,7 @@ struct hdc3020_data { struct i2c_client *client; + struct gpio_desc *reset_gpio; struct regulator *vdd_supply; /* * Ensure that the sensor configuration (currently only heater is @@ -558,6 +560,9 @@ static int hdc3020_power_off(struct hdc3020_data *data) { hdc3020_exec_cmd(data, HDC3020_EXIT_AUTO); + if (data->reset_gpio) + gpiod_set_value_cansleep(data->reset_gpio, 1); + return regulator_disable(data->vdd_supply); } @@ -571,6 +576,11 @@ static int hdc3020_power_on(struct hdc3020_data *data) fsleep(5000); + if (data->reset_gpio) { + gpiod_set_value_cansleep(data->reset_gpio, 0); + fsleep(3000); + } + if (data->client->irq) { /* * The alert output is activated by default upon power up, @@ -627,6 +637,12 @@ static int hdc3020_probe(struct i2c_client *client) return dev_err_probe(&client->dev, PTR_ERR(data->vdd_supply), "Unable to get VDD regulator\n"); + data->reset_gpio = devm_gpiod_get_optional(&client->dev, "reset", + GPIOD_OUT_HIGH); + if (IS_ERR(data->reset_gpio)) + return dev_err_probe(&client->dev, PTR_ERR(data->reset_gpio), + "Cannot get reset GPIO\n"); + ret = hdc3020_power_on(data); if (ret) return dev_err_probe(&client->dev, ret, "Power on failed\n"); -- 2.40.1