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: 13640816 Received: from a.peacevolution.org (a.peacevolution.org [206.189.193.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EFD172D045; Tue, 23 Apr 2024 22:41:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=206.189.193.133 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713912079; cv=none; b=S0nMFleCM87+bd+letSG32IfNzFK2dwKodapfD1U9P1OM9Y8vLWmrKHdVJWUDKSpSVB4NcDq5YI9Z92V6NV0xr+6iuSe8s3A0QFLzo+FziO5TRDciq2Bt2ZdrzAb/Hw7rVLjc+oXdANA8YRxddeNGvkHTdn02A/4slVIrzFSrXg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713912079; c=relaxed/simple; bh=sPdQp0y78+aQ4Fsgv16GP6aktf1T+o0Ad2IvNQ7mtBI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=r/sgSVg2bbRJWdlyGpp9rhRsheNmsdtOLpxf1uqMTtDbmntWeMEFbvEuiXSpPKwTPwRIcGv+fbq46otjcY0N/ii4xgsZI/stdL4Ruen2hOCeGoPYWT1c7iU0dLlk0XvRzcC7wH+nAp4KHFrjxjnvbKAkq6CvqWVYSC0OnLuUlY4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=peacevolution.org; spf=pass smtp.mailfrom=peacevolution.org; dkim=pass (1024-bit key) header.d=peacevolution.org header.i=@peacevolution.org header.b=FDF1nKYm; arc=none smtp.client-ip=206.189.193.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=peacevolution.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=peacevolution.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=peacevolution.org header.i=@peacevolution.org header.b="FDF1nKYm" 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> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Authentication-Results: auth=pass smtp.auth=aren@peacevolution.org smtp.mailfrom=aren@peacevolution.org X-Spam-Level: ****** 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= 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: 13640819 Received: from a.peacevolution.org (a.peacevolution.org [206.189.193.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8C48818EA8; Tue, 23 Apr 2024 22:41:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=206.189.193.133 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713912080; cv=none; b=C7oIvdDgG5IBFXalcbHyO9rkYT0JfH1Wa9CxfxIsn7Mi6GCPFr2OlI34lSAXMduob4MjnUeP8T+XuDZSgEl9nqrFna5BtUBfElcKg+vcRHbd/aEllR0sIt/LU4m413IgFEsT4v1tKoszUVHnz7KhhEnsU9ieaObjp/r22ix9WVk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713912080; c=relaxed/simple; bh=9WFlEslTo17+AMX3ugsxbIxUCsN22DM+tnAYsHJ1wgk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aOMo5JyhR/ZbbwtT53WLDQmUo8YmADB6zBl7lJLjlIEcI6+RAq1XcLnZcR8zZv9Y+xfveUoTe1vo4/uBDqXUeXzrvjLa8/fM5tLgACbwb/zd+pu6gidN0ghHzbKl4RjudXqqG9yVSLlejpFTpB1F6MGlYuZbbzkko8vqH4WCQUw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=peacevolution.org; spf=pass smtp.mailfrom=peacevolution.org; dkim=pass (1024-bit key) header.d=peacevolution.org header.i=@peacevolution.org header.b=l+nUddnX; arc=none smtp.client-ip=206.189.193.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=peacevolution.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=peacevolution.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=peacevolution.org header.i=@peacevolution.org header.b="l+nUddnX" 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> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Authentication-Results: auth=pass smtp.auth=aren@peacevolution.org smtp.mailfrom=aren@peacevolution.org X-Spam-Level: **** 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= 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: 13640820 Received: from a.peacevolution.org (a.peacevolution.org [206.189.193.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BEC843E479; Tue, 23 Apr 2024 22:41:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=206.189.193.133 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713912081; cv=none; b=aLxc5CQUSMPhP4ZZdy9GSTFkYItj0i7mHDikoVkPvLnICcVKb3QyOU48VvGPdzXY8ruPlMuiS4MJEzae77fTGbdM3JvpdJCfRYAEZlXrUev51G0xi1HgsEX/6gm7GxpkrXFG2eG9N006KG6huL0fqyTwl+hZ5VaGoRAxG+THy2Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713912081; c=relaxed/simple; bh=W0pdx8BuK+xLmOs54GoilrUFme6kM+0J0JTKC9zdz18=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Fh3gvFe85MpeK84ow9nBPrFrHEsHQZRIQDB9Efm/NQ7AAz4opzxQX65Bg1zogbYMrj/CLR3j7WJ9/BW4GGue6bAHmyG+BIyKzs39ezhqEs3T3ghlKJKYfl5t5wqUDA3LqlA3A2uHkZIe9eUYHMvfU8fCADRYIRajVhZSv5AkThU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=peacevolution.org; spf=pass smtp.mailfrom=peacevolution.org; dkim=pass (1024-bit key) header.d=peacevolution.org header.i=@peacevolution.org header.b=HSb11MRz; arc=none smtp.client-ip=206.189.193.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=peacevolution.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=peacevolution.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=peacevolution.org header.i=@peacevolution.org header.b="HSb11MRz" 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> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Authentication-Results: auth=pass smtp.auth=aren@peacevolution.org smtp.mailfrom=aren@peacevolution.org X-Spam-Level: ** 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= 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: 13640814 Received: from a.peacevolution.org (a.peacevolution.org [206.189.193.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DD04518B04; Tue, 23 Apr 2024 22:41:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=206.189.193.133 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713912077; cv=none; b=UwZ1b+WNurT5gKanqZLQljUs3qEplGG0zZXCRaSPfNqLiqgdbVlbyyv0Y5JDDaBmVh7BC0LIw8EuZDF+zET9DSRZzSLFauu7AOUdj9LhV5DggaaURID8Jfkhbd82VnS4Q9nshbUGoYaZFxxcGba9Fneyd4Uv9Ph7GKU0PqVZH4U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713912077; c=relaxed/simple; bh=P1hW2nR8B6iOhbYwXhr0Keb/5gFXWkQwEOZrik5q2G8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Nf/zTjl1yptjtbXOGW0YOTFTeMCYwMnvwJ018tCFHZk3G/6OAJNo543ftM2OJIAOAMCA6yCTgWk+U0kwUeTE2zvtGkG+MRlgSJTzgU7RNEoyx5PXzq7NVq01776NbCo0vwugTNOCx3i7j6P33murF8kHyNg8zVHI8HBvESj2EIU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=peacevolution.org; spf=pass smtp.mailfrom=peacevolution.org; dkim=pass (1024-bit key) header.d=peacevolution.org header.i=@peacevolution.org header.b=a4Lk9guU; arc=none smtp.client-ip=206.189.193.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=peacevolution.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=peacevolution.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=peacevolution.org header.i=@peacevolution.org header.b="a4Lk9guU" 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> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Authentication-Results: auth=pass smtp.auth=aren@peacevolution.org smtp.mailfrom=aren@peacevolution.org X-Spam-Level: *** 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= 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: 13640817 Received: from a.peacevolution.org (a.peacevolution.org [206.189.193.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A994D2E859; Tue, 23 Apr 2024 22:41:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=206.189.193.133 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713912080; cv=none; b=iP1wR/XMEhUSjo56ZQCFKZGc+ADDh7Eg/mg9i+IbVMHpFp2XPrvPiMWARYeE3EtrlXsaUAOYWvM8ccO/00cHXJnjp0g67RMV5NkeRuVWE4t6Lyrc56Dnjgts3Menvr4QZUPuSKFf9nWgelLdqmhgTyfGQ78dJIUS/Bdp9O2eiqY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713912080; c=relaxed/simple; bh=9N73cNhfVQaoSJ0DN5ep872w+52N5ZGu7OsFMCg9whc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=I9q6sfe41cKqAzRC/tgObFGoMiDAMv2gOa6GaLcNhaqLu1HK8HK0Edp1uTAs8sp6hPNFUgwy1kr0v+WVfxhfPr2WCc8rSX+O21yOzG65oGk7UMHnIxJks3lFbx7WEVmvmv+6JVeaYy95Mnz3yXjzfxauMHQfoCyfYtBV0DVcfyI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=peacevolution.org; spf=pass smtp.mailfrom=peacevolution.org; dkim=pass (1024-bit key) header.d=peacevolution.org header.i=@peacevolution.org header.b=ABT0QfHC; arc=none smtp.client-ip=206.189.193.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=peacevolution.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=peacevolution.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=peacevolution.org header.i=@peacevolution.org header.b="ABT0QfHC" 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> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Authentication-Results: auth=pass smtp.auth=aren@peacevolution.org smtp.mailfrom=aren@peacevolution.org X-Spam-Level: ** 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= 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: 13640818 Received: from a.peacevolution.org (a.peacevolution.org [206.189.193.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A82EB2E65B; Tue, 23 Apr 2024 22:41:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=206.189.193.133 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713912080; cv=none; b=R7oQ76DOflgHBzBZUtA4q4OsQd7LD97mE03+1tsORkgvPzLPWTFFT5SvSgoUuKa3HyGd3h/xLhYpiX3MxAemxXyr+rvBnDHt84IktjxOQxIWcXaUEfMPX3VLJQ5lVoerK2M3LAaIfqG3yBFhMHlb2hmKY/5LQJ4yYPJMTjENBz8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713912080; c=relaxed/simple; bh=MfSd1egszYJN6TT1Fc9meDkLwyCYgqTRaV8UU9a38nA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UqBonOcfFOk3JFXk1OZXqQvIebnMe1Ipm1rL5n8PrmgS9hQIentiOr/OgeJmu76+wcuDJ0ZLdp5YPJEL9UXa3GBWwT7n+cA+0XSIuG6M73ctuzbHQVfO3JglsZPtu3FqAQlKTHTuyofQS4gnhIheSqjfoZri60aQPOBdinFDyiE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=peacevolution.org; spf=pass smtp.mailfrom=peacevolution.org; dkim=pass (1024-bit key) header.d=peacevolution.org header.i=@peacevolution.org header.b=bI5ZZXB9; arc=none smtp.client-ip=206.189.193.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=peacevolution.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=peacevolution.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=peacevolution.org header.i=@peacevolution.org header.b="bI5ZZXB9" 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> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Authentication-Results: auth=pass smtp.auth=aren@peacevolution.org smtp.mailfrom=aren@peacevolution.org X-Spam-Level: **** 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= 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 */