From patchwork Tue Apr 23 22:33:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aren X-Patchwork-Id: 13640841 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 76C11C19F4F for ; Tue, 23 Apr 2024 22:41:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=mXjAn8bw74acsBJhH6ywhnvTr7/jS76PwBhESVrg1NQ=; b=EpGJ2PqslTJvr6 Lx3lSYkhhIli+1DXjx59HceXAMR3QVwosEvqfL5RZVERh10SjQrd0c5Xw7Eqh4YHUkbdzK3reIiGg aiNKZXfTs2Hnlo1ny/5RtktCp8IfUMAh6gHOsAYXMZ5tz28JTz2p9u1lrBnPPA9TsTt0YqFWFgzLB ouGbgd5nxhUn7LpibNFV/DD4yGmbJwndY8wH/EHHjcigwNPSFT4sdOg2AnSJG/xFVAhfTyjui+kmm +Oirj0ICIEYMwkpnWyONgcf/wIVPcwXsY69JSO4A1WGd/8R3LaC9X/tW7Xs8nduAo9EnN0jSWGVFL stVKZYEp8tCoRLrBh0FA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rzOpB-00000001iD9-3xtH; Tue, 23 Apr 2024 22:41:17 +0000 Received: from a.peacevolution.org ([206.189.193.133]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rzOp7-00000001iA4-34AR for linux-arm-kernel@lists.infradead.org; Tue, 23 Apr 2024 22:41:15 +0000 Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by a.peacevolution.org (Postfix) with ESMTPA id B48B347A59; Tue, 23 Apr 2024 22:41:09 +0000 (UTC) From: Aren Moynihan To: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Liam Girdwood , Mark Brown Cc: Aren Moynihan , Andy Shevchenko , Ondrej Jirman , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , linux-iio@vger.kernel.org, phone-devel@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, Willow Barraco Subject: [PATCH v2 1/6] dt-bindings: iio: light: stk33xx: add vdd and leda regulators Date: Tue, 23 Apr 2024 18:33:04 -0400 Message-ID: <20240423223309.1468198-3-aren@peacevolution.org> In-Reply-To: <20240423223309.1468198-2-aren@peacevolution.org> References: <20240423223309.1468198-2-aren@peacevolution.org> MIME-Version: 1.0 Authentication-Results: auth=pass smtp.auth=aren@peacevolution.org smtp.mailfrom=aren@peacevolution.org X-Spamd-Bar: ++++++ DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=peacevolution.org; s=dkim; t=1713912070; h=from:subject:date:message-id:to:cc:mime-version:content-transfer-encoding:in-reply-to:references; bh=hlnyfPS5DLUVzYwzjrSWJSZ4OjlFWvwqBdiJD2oce78=; b=FDF1nKYmRgxkjKMC7adv/4y67VUjqBxJcmtSVhHQcoS8nTaAWd+tXzFaSIaINcMlmAVOW3 kBJzxKIE5VTxxNMkTgtqfP7igJhw5rrvtQ5hnNZ/U4sw0TntAT9TapNfBBOUnHXMTJfMcg C3MqiYn2+Qn3sfIGGQOUs9YqlOcIU/Y= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240423_154113_945322_706EB2A4 X-CRM114-Status: UNSURE ( 8.11 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org stk3310 and stk3311 are typically connected to power supplies for the chip (vdd) and the infrared LED (leda). Add properties so we can power these up / down appropriately. Signed-off-by: Aren Moynihan Reviewed-by: Krzysztof Kozlowski --- Notes: Changes in v2: - add leda-supply - add supplies to examples Documentation/devicetree/bindings/iio/light/stk33xx.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Documentation/devicetree/bindings/iio/light/stk33xx.yaml b/Documentation/devicetree/bindings/iio/light/stk33xx.yaml index f6e22dc9814a..43ead524cecb 100644 --- a/Documentation/devicetree/bindings/iio/light/stk33xx.yaml +++ b/Documentation/devicetree/bindings/iio/light/stk33xx.yaml @@ -29,6 +29,8 @@ properties: interrupts: maxItems: 1 + vdd-supply: true + leda-supply: true proximity-near-level: true required: @@ -52,6 +54,8 @@ examples: proximity-near-level = <25>; interrupt-parent = <&gpio1>; interrupts = <5 IRQ_TYPE_LEVEL_LOW>; + vdd-supply = <&vdd_regulator>; + leda-supply = <&led_regulator>; }; }; ... From patchwork Tue Apr 23 22:33:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aren X-Patchwork-Id: 13640840 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DE6CFC4345F for ; Tue, 23 Apr 2024 22:41:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=bX0/4Sl6nbFqzPRE7YlOEwghspr5i607XLI/qB9zkSU=; b=axLOmgFtPYrFBZ dr7IaKNW6c5EqaKDmFutXTUjCBt6+T1zSZxi7pXSijZCshk5/qBQaG5hhu6lG2FQtaETZ9KKPAnap huOzlqdvlgYeqCQd5aXhz5XlUptsa7gje2NPsDoAXuwTq14b7sEU5AgSrebDkqP0dBbRbWSq5qEaQ 0nH32A4OIQFgUKK2vzsovWOH68/oLEmqY1tzldXUkliTVZFQlAG47xthqhfy048239RPLYXND9xSJ MjK+WSsf4nNh8vKh/O6Too47OUIBEsoBiIdULi+Jsfc7kzw5PpM0g9f7+YJdqHZ+QNoTwt3V/htNx R85CZd//XPfM7tbgLQPQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rzOpD-00000001iDl-1k8G; Tue, 23 Apr 2024 22:41:19 +0000 Received: from a.peacevolution.org ([206.189.193.133]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rzOp7-00000001iAG-3Sis for linux-arm-kernel@lists.infradead.org; Tue, 23 Apr 2024 22:41:16 +0000 Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by a.peacevolution.org (Postfix) with ESMTPA id 0E5CB47A5A; Tue, 23 Apr 2024 22:41:11 +0000 (UTC) From: Aren Moynihan To: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Liam Girdwood , Mark Brown Cc: Aren Moynihan , Andy Shevchenko , Ondrej Jirman , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , linux-iio@vger.kernel.org, phone-devel@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, Willow Barraco Subject: [PATCH v2 2/6] iio: light: stk3310: Implement vdd supply and power it off during suspend Date: Tue, 23 Apr 2024 18:33:05 -0400 Message-ID: <20240423223309.1468198-4-aren@peacevolution.org> In-Reply-To: <20240423223309.1468198-2-aren@peacevolution.org> References: <20240423223309.1468198-2-aren@peacevolution.org> MIME-Version: 1.0 Authentication-Results: auth=pass smtp.auth=aren@peacevolution.org smtp.mailfrom=aren@peacevolution.org X-Spamd-Bar: ++++ DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=peacevolution.org; s=dkim; t=1713912072; h=from:subject:date:message-id:to:cc:mime-version:content-transfer-encoding:in-reply-to:references; bh=Pocgw671NmVP3upSEXxvVD2OibWy7kumLvOzth5JeTg=; b=l+nUddnXDeq2ogq+5wgM2loG+Zhw9lbTkOdpiEms8CGYX47TIDLx5TnywJYBYr8tJVrN9f 8Pem/UxHV78BEhybQuH9K5YyOFtNDmESnC3g4YfWLylccPCttb6Dl3OhrMQZXMEXaW/0bS ZNCp+zXZmDGGd5WHjWsxyyeXXmk0lQE= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240423_154114_020819_7E73621D X-CRM114-Status: GOOD ( 17.75 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Ondrej Jirman VDD power input can be used to completely power off the chip during system suspend. Do so if available. Signed-off-by: Ondrej Jirman Signed-off-by: Aren Moynihan --- Notes: Changes in v2: - always enable / disable regulators and rely on a dummy regulator if one isn't specified - replace usleep_range with fsleep - reorder includes so iio headers are last - add missing error handling to resume drivers/iio/light/stk3310.c | 49 ++++++++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/drivers/iio/light/stk3310.c b/drivers/iio/light/stk3310.c index 7b71ad71d78d..a0547eeca3e3 100644 --- a/drivers/iio/light/stk3310.c +++ b/drivers/iio/light/stk3310.c @@ -13,6 +13,8 @@ #include #include #include +#include + #include #include #include @@ -117,6 +119,7 @@ struct stk3310_data { struct regmap_field *reg_int_ps; struct regmap_field *reg_flag_psint; struct regmap_field *reg_flag_nf; + struct regulator *vdd_reg; }; static const struct iio_event_spec stk3310_events[] = { @@ -607,6 +610,10 @@ static int stk3310_probe(struct i2c_client *client) mutex_init(&data->lock); + data->vdd_reg = devm_regulator_get(&client->dev, "vdd"); + if (IS_ERR(data->vdd_reg)) + return dev_err_probe(&client->dev, ret, "get regulator vdd failed\n"); + ret = stk3310_regmap_init(data); if (ret < 0) return ret; @@ -617,9 +624,17 @@ static int stk3310_probe(struct i2c_client *client) indio_dev->channels = stk3310_channels; indio_dev->num_channels = ARRAY_SIZE(stk3310_channels); + ret = regulator_enable(data->vdd_reg); + if (ret) + return dev_err_probe(&client->dev, ret, + "regulator vdd enable failed\n"); + + /* we need a short delay to allow the chip time to power on */ + fsleep(1000); + ret = stk3310_init(indio_dev); if (ret < 0) - return ret; + goto err_vdd_disable; if (client->irq > 0) { ret = devm_request_threaded_irq(&client->dev, client->irq, @@ -645,32 +660,60 @@ static int stk3310_probe(struct i2c_client *client) err_standby: stk3310_set_state(data, STK3310_STATE_STANDBY); +err_vdd_disable: + regulator_disable(data->vdd_reg); return ret; } static void stk3310_remove(struct i2c_client *client) { struct iio_dev *indio_dev = i2c_get_clientdata(client); + struct stk3310_data *data = iio_priv(indio_dev); iio_device_unregister(indio_dev); stk3310_set_state(iio_priv(indio_dev), STK3310_STATE_STANDBY); + regulator_disable(data->vdd_reg); } static int stk3310_suspend(struct device *dev) { struct stk3310_data *data; + int ret; data = iio_priv(i2c_get_clientdata(to_i2c_client(dev))); - return stk3310_set_state(data, STK3310_STATE_STANDBY); + ret = stk3310_set_state(data, STK3310_STATE_STANDBY); + if (ret) + return ret; + + regcache_mark_dirty(data->regmap); + regulator_disable(data->vdd_reg); + + return 0; } static int stk3310_resume(struct device *dev) { - u8 state = 0; struct stk3310_data *data; + u8 state = 0; + int ret; data = iio_priv(i2c_get_clientdata(to_i2c_client(dev))); + + ret = regulator_enable(data->vdd_reg); + if (ret) { + dev_err(dev, "Failed to re-enable regulator vdd\n"); + return ret; + } + + fsleep(1000); + + ret = regcache_sync(data->regmap); + if (ret) { + dev_err(dev, "Failed to restore registers: %d\n", ret); + return ret; + } + if (data->ps_enabled) state |= STK3310_STATE_EN_PS; if (data->als_enabled) From patchwork Tue Apr 23 22:33:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aren X-Patchwork-Id: 13640838 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D9921C4345F for ; Tue, 23 Apr 2024 22:41:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=J1uQs2CazMMlU1EkdIUKoFkycR7pJxCt9qUvd1nOprs=; b=Xd6I5TXd+k/eLL ajOEp5lOhBpUAEmzTkSfM2XuFbE23ffZxhkeXTIXDhy6jm9FMvdy22FeMVc7b2Zugtq/4jEbyDasJ ELBEAOy7SYRlJsHDt4Xhr7jXmdZg0aW3UVH12FFn5seehaW3SvQAQQ6yYCCoRzpqQS1h51dfkOSdl 3eHUwSYASjMPbnaZC7KTCczyJeSA/Sm4eggiX6+vGW64UTWEWPSPokhEjUG2oFE5cYXMPX+N2UvAz iNUqDS1Y9QIm7O8bLmFzcqUD4aTW40Ie/UXAUQM1/a8EEqU8m/oQv7GLS2fmvEvdsmRpKHU6JUJTj 0/OQntw9JD/YdvTqwXYw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rzOpE-00000001iDw-14b5; Tue, 23 Apr 2024 22:41:20 +0000 Received: from a.peacevolution.org ([206.189.193.133]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rzOp8-00000001iAX-0xLj for linux-arm-kernel@lists.infradead.org; Tue, 23 Apr 2024 22:41:16 +0000 Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by a.peacevolution.org (Postfix) with ESMTPA id 5C34F47A5C; Tue, 23 Apr 2024 22:41:12 +0000 (UTC) From: Aren Moynihan To: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Liam Girdwood , Mark Brown Cc: Aren Moynihan , Andy Shevchenko , Ondrej Jirman , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , linux-iio@vger.kernel.org, phone-devel@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, Willow Barraco Subject: [PATCH v2 3/6] iio: light: stk3310: Manage LED power supply Date: Tue, 23 Apr 2024 18:33:06 -0400 Message-ID: <20240423223309.1468198-5-aren@peacevolution.org> In-Reply-To: <20240423223309.1468198-2-aren@peacevolution.org> References: <20240423223309.1468198-2-aren@peacevolution.org> MIME-Version: 1.0 Authentication-Results: auth=pass smtp.auth=aren@peacevolution.org smtp.mailfrom=aren@peacevolution.org X-Spamd-Bar: ++ DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=peacevolution.org; s=dkim; t=1713912073; h=from:subject:date:message-id:to:cc:mime-version:content-transfer-encoding:in-reply-to:references; bh=HCCF9rxoV0qyxUrOixYZsFhioeAo5bm11hFlJpbzygM=; b=HSb11MRzuz/XBflQACsKZGFgXiRga8WQaXWlqiASFFQXdY5wHBP78NmzQyhYtY0p//6zPR iZ+ilr2ls1WGPFzTHmMP6dRe520CPj53L+dXo42q1afcEK6c3KxXTeyc1h2qN6lXuN8a+O BuHcQNYCWP6SYgM1y/h3XSmUimNUyJg= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240423_154114_421940_F95183FE X-CRM114-Status: GOOD ( 15.07 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The stk3310 and stk3310 chips have an input for power to the infrared LED. Add support for managing it's state. Signed-off-by: Aren Moynihan --- drivers/iio/light/stk3310.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/drivers/iio/light/stk3310.c b/drivers/iio/light/stk3310.c index a0547eeca3e3..ee1ac95dbc0e 100644 --- a/drivers/iio/light/stk3310.c +++ b/drivers/iio/light/stk3310.c @@ -120,6 +120,7 @@ struct stk3310_data { struct regmap_field *reg_flag_psint; struct regmap_field *reg_flag_nf; struct regulator *vdd_reg; + struct regulator *led_reg; }; static const struct iio_event_spec stk3310_events[] = { @@ -614,6 +615,10 @@ static int stk3310_probe(struct i2c_client *client) if (IS_ERR(data->vdd_reg)) return dev_err_probe(&client->dev, ret, "get regulator vdd failed\n"); + data->led_reg = devm_regulator_get(&client->dev, "leda"); + if (IS_ERR(data->led_reg)) + return dev_err_probe(&client->dev, ret, "get regulator led failed\n"); + ret = stk3310_regmap_init(data); if (ret < 0) return ret; @@ -629,12 +634,18 @@ static int stk3310_probe(struct i2c_client *client) return dev_err_probe(&client->dev, ret, "regulator vdd enable failed\n"); + ret = regulator_enable(data->led_reg); + if (ret) { + dev_err_probe(&client->dev, ret, "regulator led enable failed\n"); + goto err_vdd_disable; + } + /* we need a short delay to allow the chip time to power on */ fsleep(1000); ret = stk3310_init(indio_dev); if (ret < 0) - goto err_vdd_disable; + goto err_led_disable; if (client->irq > 0) { ret = devm_request_threaded_irq(&client->dev, client->irq, @@ -660,6 +671,8 @@ static int stk3310_probe(struct i2c_client *client) err_standby: stk3310_set_state(data, STK3310_STATE_STANDBY); +err_led_disable: + regulator_disable(data->led_reg); err_vdd_disable: regulator_disable(data->vdd_reg); return ret; @@ -672,6 +685,7 @@ static void stk3310_remove(struct i2c_client *client) iio_device_unregister(indio_dev); stk3310_set_state(iio_priv(indio_dev), STK3310_STATE_STANDBY); + regulator_disable(data->led_reg); regulator_disable(data->vdd_reg); } @@ -687,6 +701,7 @@ static int stk3310_suspend(struct device *dev) return ret; regcache_mark_dirty(data->regmap); + regulator_disable(data->led_reg); regulator_disable(data->vdd_reg); return 0; @@ -706,6 +721,12 @@ static int stk3310_resume(struct device *dev) return ret; } + ret = regulator_enable(data->led_reg); + if (ret) { + dev_err(dev, "Failed to re-enable regulator led\n"); + return ret; + } + fsleep(1000); ret = regcache_sync(data->regmap); From patchwork Tue Apr 23 22:33:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aren X-Patchwork-Id: 13640894 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2FA72C10F15 for ; Tue, 23 Apr 2024 23:46:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=8tcOeYFnmNTB1gGYwdIYDqqffF5JUhlssBr0MZBTei4=; b=Vu0z3SJ0R0Bq1f 5q4bxInYqODCw1OPE/Bc/3/2Oj9fKUMtKN5/E4Kp1S2NzzMzkFGB2I5P6uU6fQU4HGDjeyk8uFH/F d2hEwqwX+kQrrUNvIEHKXB1nJzslmWucoiHBjOBTfwV9h764KV0kC9sKpOdEnMrWkgOS1/4z/CXpu 5cOoou+uOCjEBJj3iHbQNjXgXiuBOyVPffj6J6Xk2EEkQCGrgdcxgdC9mh0dXmgbDv3NEmbX7M3qP PhWumDNoPXa831ZS7oXlMWOpMpWqK3kWXU1w3i8HQfynNauiBG2EMUsCndTGhc+2448H2JP7o2AnY 9/iYqLeGmZZ3wxMmOsfQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rzPpo-00000001sX3-10BN; Tue, 23 Apr 2024 23:46:00 +0000 Received: from a.peacevolution.org ([206.189.193.133]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rzOp9-00000001iBo-23jF for linux-arm-kernel@lists.infradead.org; Tue, 23 Apr 2024 22:41:17 +0000 Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by a.peacevolution.org (Postfix) with ESMTPA id A939547A5F; Tue, 23 Apr 2024 22:41:13 +0000 (UTC) From: Aren Moynihan To: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Liam Girdwood , Mark Brown Cc: Aren Moynihan , Andy Shevchenko , Ondrej Jirman , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , linux-iio@vger.kernel.org, phone-devel@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, Willow Barraco Subject: [PATCH v2 4/6] iio: light: stk3310: use dev_err_probe where possible Date: Tue, 23 Apr 2024 18:33:07 -0400 Message-ID: <20240423223309.1468198-6-aren@peacevolution.org> In-Reply-To: <20240423223309.1468198-2-aren@peacevolution.org> References: <20240423223309.1468198-2-aren@peacevolution.org> MIME-Version: 1.0 Authentication-Results: auth=pass smtp.auth=aren@peacevolution.org smtp.mailfrom=aren@peacevolution.org X-Spamd-Bar: +++ DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=peacevolution.org; s=dkim; t=1713912074; h=from:subject:date:message-id:to:cc:mime-version:content-transfer-encoding:in-reply-to:references; bh=H5coa02/iaOjA9iqLxo1Oztbgi2cxOUrNasxJP7xbIE=; b=a4Lk9guU0NEdyN6/998Mxl90hggHJaHblk9XS8qF2T7129mcpApydDwPe+0VXsjTlWJt96 Boedlc8cpdlMESLG7EeHzoycM2whNz/nKnNj9HlhQtaU7gomXRkM6GTCPvWVP8X6ZvXMXo uuxj5Up77P48MW4o7v7RTlNWHasx9uc= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240423_154116_251651_08555B43 X-CRM114-Status: GOOD ( 11.84 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Using dev_err_probe instead of dev_err and return makes the errors easier to understand by including the error name, and saves a little code. Signed-off-by: Aren Moynihan --- Notes: Added in v2 drivers/iio/light/stk3310.c | 44 +++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/drivers/iio/light/stk3310.c b/drivers/iio/light/stk3310.c index ee1ac95dbc0e..c56c6298d292 100644 --- a/drivers/iio/light/stk3310.c +++ b/drivers/iio/light/stk3310.c @@ -60,10 +60,10 @@ data->reg_##name = \ devm_regmap_field_alloc(&client->dev, regmap, \ stk3310_reg_field_##name); \ - if (IS_ERR(data->reg_##name)) { \ - dev_err(&client->dev, "reg field alloc failed.\n"); \ - return PTR_ERR(data->reg_##name); \ - } \ + if (IS_ERR(data->reg_##name)) \ + return dev_err_probe(&client->dev, \ + PTR_ERR(data->reg_##name), \ + "reg field alloc failed.\n"); \ } while (0) static const struct reg_field stk3310_reg_field_state = @@ -480,22 +480,20 @@ static int stk3310_init(struct iio_dev *indio_dev) if (chipid != STK3310_CHIP_ID_VAL && chipid != STK3311_CHIP_ID_VAL && chipid != STK3311X_CHIP_ID_VAL && - chipid != STK3335_CHIP_ID_VAL) { - dev_err(&client->dev, "invalid chip id: 0x%x\n", chipid); - return -ENODEV; - } + chipid != STK3335_CHIP_ID_VAL) + return dev_err_probe(&client->dev, -ENODEV, + "invalid chip id: 0x%x\n", chipid); state = STK3310_STATE_EN_ALS | STK3310_STATE_EN_PS; ret = stk3310_set_state(data, state); - if (ret < 0) { - dev_err(&client->dev, "failed to enable sensor"); - return ret; - } + if (ret < 0) + return dev_err_probe(&client->dev, ret, "failed to enable sensor\n"); /* Enable PS interrupts */ ret = regmap_field_write(data->reg_int_ps, STK3310_PSINT_EN); if (ret < 0) - dev_err(&client->dev, "failed to enable interrupts!\n"); + return dev_err_probe(&client->dev, ret, + "failed to enable interrupts!\n"); return ret; } @@ -530,10 +528,10 @@ static int stk3310_regmap_init(struct stk3310_data *data) client = data->client; regmap = devm_regmap_init_i2c(client, &stk3310_regmap_config); - if (IS_ERR(regmap)) { - dev_err(&client->dev, "regmap initialization failed.\n"); - return PTR_ERR(regmap); - } + if (IS_ERR(regmap)) + return dev_err_probe(&client->dev, PTR_ERR(regmap), + "regmap initialization failed.\n"); + data->regmap = regmap; STK3310_REGFIELD(state); @@ -597,10 +595,8 @@ static int stk3310_probe(struct i2c_client *client) struct stk3310_data *data; indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data)); - if (!indio_dev) { - dev_err(&client->dev, "iio allocation failed!\n"); - return -ENOMEM; - } + if (!indio_dev) + return dev_err_probe(&client->dev, -ENOMEM, "iio allocation failed!\n"); data = iio_priv(indio_dev); data->client = client; @@ -655,15 +651,15 @@ static int stk3310_probe(struct i2c_client *client) IRQF_ONESHOT, STK3310_EVENT, indio_dev); if (ret < 0) { - dev_err(&client->dev, "request irq %d failed\n", - client->irq); + dev_err_probe(&client->dev, ret, "request irq %d failed\n", + client->irq); goto err_standby; } } ret = iio_device_register(indio_dev); if (ret < 0) { - dev_err(&client->dev, "device_register failed\n"); + dev_err_probe(&client->dev, ret, "device_register failed\n"); goto err_standby; } From patchwork Tue Apr 23 22:33:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aren X-Patchwork-Id: 13640893 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id ED7EDC4345F for ; Tue, 23 Apr 2024 23:46:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=6SOQRKdPnuCASQJLVLfaYKIV7SeLs28gLmge3FK2kHs=; b=zOwj0ZLgQ2f70K 3lfAHv4zs2H3yI/DVfHCfyGSykyqrMZvWmLJTAKM6Cyymc6hjlx3cAyaROffmpH+Psa4D5DXzD4HE 2qrYNG4iWxopvMbh+hP4JeEUDiDR9m+/6veagNHR7rJLTRoyD8crVAK5gyazsmycIZlLm21vd8AfB LPnr84bTxq7+vyW/SGyoDDBlvSvvhuLEVhSDlr7Ie0w0m2wjSpPz9MIBzmGEBa/b8drXFnp4oeviU iX6mrmvUPfiI64XMmWbOYp6+yVi4v3bOeY4DbjSh1gOtaiVqAqdjWUm3jZeXmlAVP+OZtdu4FVKth 0xWHEqAeQ2pbtvPks7ZQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rzPpp-00000001sX9-0UB2; Tue, 23 Apr 2024 23:46:01 +0000 Received: from a.peacevolution.org ([206.189.193.133]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rzOpA-00000001iCX-3SH9 for linux-arm-kernel@lists.infradead.org; Tue, 23 Apr 2024 22:41:18 +0000 Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by a.peacevolution.org (Postfix) with ESMTPA id 045F847A5D; Tue, 23 Apr 2024 22:41:14 +0000 (UTC) From: Aren Moynihan To: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Liam Girdwood , Mark Brown Cc: Aren Moynihan , Andy Shevchenko , Ondrej Jirman , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , linux-iio@vger.kernel.org, phone-devel@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, Willow Barraco Subject: [PATCH v2 5/6] iio: light: stk3310: log error if reading the chip id fails Date: Tue, 23 Apr 2024 18:33:08 -0400 Message-ID: <20240423223309.1468198-7-aren@peacevolution.org> In-Reply-To: <20240423223309.1468198-2-aren@peacevolution.org> References: <20240423223309.1468198-2-aren@peacevolution.org> MIME-Version: 1.0 Authentication-Results: auth=pass smtp.auth=aren@peacevolution.org smtp.mailfrom=aren@peacevolution.org X-Spamd-Bar: ++ DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=peacevolution.org; s=dkim; t=1713912076; h=from:subject:date:message-id:to:cc:mime-version:content-transfer-encoding:in-reply-to:references; bh=UWXpr+mFtuZWn0I9z7i9pNE5fb1S4ZmF1FsSOEaCDY8=; b=ABT0QfHCstWYlhb5huxIJr/n4qDSVSFsxksisDcoy3ke6S+gPj0FLQ37n2R9UXskuwaobf y6Nk9MNPJNNQr8PC1RVGVYnxF5Wb1UCfumq6VIxnyBxM2yJ7+VMnjFW0nXYR4ooduh1sVD 6ImTZmNEn0X9UhpNjNfl71M4isz1flk= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240423_154117_000827_7CDCFB4D X-CRM114-Status: GOOD ( 10.55 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org If the chip isn't powered, this call is likely to return an error. Without a log here the driver will silently fail to probe. Common errors are ENXIO (when the chip isn't powered) and ETIMEDOUT (when the i2c bus isn't powered). Signed-off-by: Aren Moynihan --- Notes: Changes in v2: - use dev_err_probe drivers/iio/light/stk3310.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/light/stk3310.c b/drivers/iio/light/stk3310.c index c56c6298d292..6ee6f145a6d5 100644 --- a/drivers/iio/light/stk3310.c +++ b/drivers/iio/light/stk3310.c @@ -475,7 +475,7 @@ static int stk3310_init(struct iio_dev *indio_dev) ret = regmap_read(data->regmap, STK3310_REG_ID, &chipid); if (ret < 0) - return ret; + return dev_err_probe(&client->dev, ret, "failed to read chip id\n"); if (chipid != STK3310_CHIP_ID_VAL && chipid != STK3311_CHIP_ID_VAL && From patchwork Tue Apr 23 22:33:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aren X-Patchwork-Id: 13640895 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 633E9C04FFE for ; Tue, 23 Apr 2024 23:46:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=4weew27/ZmS7C5XcOrg5JISj0PS00Gwj3EoURQ455zc=; b=ghrQKfQ+I0aPFx BBZdru55DWvn5zfWzH1uow+H2LSrVxbAZnO6pouOVS4J00J1Qro+Xn1wyioDlQ7LAf3fHYn7fwdtG ednz3G2+RGarravqVNfpFJ74gld+2wRrdi+ISaHbilHSC0UQ4gXj3vA1uCS0jEyuVF3/5yxkTMnaP TTcEPeyDdUpUtoXZeQ3CFDqK4aEP7PT4qG2Ll+svtyD5J7D1DbCp/JQ1rGtcVoO2YsWt49cGjCmtd Nf6HTx8Z82nw0VI8LctGkJMn245aGne7pl16qC4aPIWGDGBcyiAlddSASlmu0JIdb4f+iBHAdVdie +0jydAq02e/CAnjrTjrQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rzPpp-00000001sXl-3Nhl; Tue, 23 Apr 2024 23:46:01 +0000 Received: from a.peacevolution.org ([206.189.193.133]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rzOpC-00000001iDA-0xha for linux-arm-kernel@lists.infradead.org; Tue, 23 Apr 2024 22:41:19 +0000 Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by a.peacevolution.org (Postfix) with ESMTPA id 55DCF47A61; Tue, 23 Apr 2024 22:41:16 +0000 (UTC) From: Aren Moynihan To: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Liam Girdwood , Mark Brown Cc: Aren Moynihan , Andy Shevchenko , Ondrej Jirman , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , linux-iio@vger.kernel.org, phone-devel@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, Willow Barraco Subject: [PATCH v2 6/6] arm64: dts: allwinner: pinephone: Add power supplies to stk3311 Date: Tue, 23 Apr 2024 18:33:09 -0400 Message-ID: <20240423223309.1468198-8-aren@peacevolution.org> In-Reply-To: <20240423223309.1468198-2-aren@peacevolution.org> References: <20240423223309.1468198-2-aren@peacevolution.org> MIME-Version: 1.0 Authentication-Results: auth=pass smtp.auth=aren@peacevolution.org smtp.mailfrom=aren@peacevolution.org X-Spamd-Bar: ++++ DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=peacevolution.org; s=dkim; t=1713912077; h=from:subject:date:message-id:to:cc:mime-version:content-transfer-encoding:in-reply-to:references; bh=FlEhwg2fHnQSDRwailCy+HoHae1eW6OjDstY8iNJk/g=; b=bI5ZZXB9QPh5La2pxna6jqgxznrqm3ptb7Uv1iUqmd6Zb5pLCVBzRnKlAh9iZn3bszE+/V ACERH365ljdbaPRNR53Sp2P9OY6sDfCF83tL6n7oKHDWwDT4gRJgPl/jM8wd7TRawVhajI 0SqZ7lX8t711Nc2ZtzckwF+JSjOpRU8= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240423_154118_417479_5DBD6529 X-CRM114-Status: UNSURE ( 8.42 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Ondrej Jirman This makes the driver disable the supply during sleep. Signed-off-by: Ondrej Jirman Signed-off-by: Aren Moynihan --- Notes: Changes in v2: - add leda-supply arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi b/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi index b5a232209f2b..51ab1db95f81 100644 --- a/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi +++ b/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi @@ -250,6 +250,8 @@ light-sensor@48 { reg = <0x48>; interrupt-parent = <&pio>; interrupts = <1 0 IRQ_TYPE_EDGE_FALLING>; /* PB0 */ + vdd-supply = <®_ldo_io0>; + leda-supply = <®_dldo1>; }; /* Accelerometer/gyroscope */