* [PATCH 1/2] dt-bindings: iio: accel: kxcjk1013: Document regulator supplies
@ 2020-12-13 17:24 devajithvs
2020-12-13 17:24 ` [PATCH 2/2] iio: accel: kxcjk1013: Add rudimentary regulator support devajithvs
2020-12-15 17:03 ` [PATCH 1/2] dt-bindings: iio: accel: kxcjk1013: Document regulator supplies Rob Herring
0 siblings, 2 replies; 4+ messages in thread
From: devajithvs @ 2020-12-13 17:24 UTC (permalink / raw)
Cc: Devajith V S, Jonathan Cameron, Lars-Peter Clausen,
Peter Meerwald-Stadler, Rob Herring, Stephen Rothwell,
Robert Yang, linux-iio, devicetree, linux-kernel
From: Devajith V S <devajithvs@gmail.com>
kxcjk1013 devices have VDD and VDDIO power lines. Need
to make sure the regulators are enabled before any
communication with kxcjk1013. Document support for
vdd/vddio-supply to implement this.
Signed-off-by: Devajith V S <devajithvs@gmail.com>
---
.../devicetree/bindings/iio/accel/kionix,kxcjk1013.yaml | 3 +++
1 file changed, 3 insertions(+)
diff --git a/Documentation/devicetree/bindings/iio/accel/kionix,kxcjk1013.yaml b/Documentation/devicetree/bindings/iio/accel/kionix,kxcjk1013.yaml
index 5667d09df..fbb714431 100644
--- a/Documentation/devicetree/bindings/iio/accel/kionix,kxcjk1013.yaml
+++ b/Documentation/devicetree/bindings/iio/accel/kionix,kxcjk1013.yaml
@@ -20,6 +20,9 @@ properties:
reg:
maxItems: 1
+ vdd-supply: true
+ vddio-supply: true
+
mount-matrix:
description: an optional 3x3 mounting rotation matrix.
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] iio: accel: kxcjk1013: Add rudimentary regulator support
2020-12-13 17:24 [PATCH 1/2] dt-bindings: iio: accel: kxcjk1013: Document regulator supplies devajithvs
@ 2020-12-13 17:24 ` devajithvs
2020-12-13 18:04 ` Jonathan Cameron
2020-12-15 17:03 ` [PATCH 1/2] dt-bindings: iio: accel: kxcjk1013: Document regulator supplies Rob Herring
1 sibling, 1 reply; 4+ messages in thread
From: devajithvs @ 2020-12-13 17:24 UTC (permalink / raw)
Cc: Devajith V S, Jonathan Cameron, Lars-Peter Clausen,
Peter Meerwald-Stadler, Rob Herring, Stephen Rothwell,
Robert Yang, linux-iio, devicetree, linux-kernel
From: Devajith V S <devajithvs@gmail.com>
kxcjk1013 devices have VDD and VDDIO power lines. Need
to make sure the regulators are enabled before any
communication with kxcjk1013. This patch introduces
vdd/vddio regulators for kxcjk1013.
Signed-off-by: Devajith V S <devajithvs@gmail.com>
---
drivers/iio/accel/kxcjk-1013.c | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/drivers/iio/accel/kxcjk-1013.c b/drivers/iio/accel/kxcjk-1013.c
index e92c7e676..67d3d8270 100644
--- a/drivers/iio/accel/kxcjk-1013.c
+++ b/drivers/iio/accel/kxcjk-1013.c
@@ -14,6 +14,7 @@
#include <linux/acpi.h>
#include <linux/pm.h>
#include <linux/pm_runtime.h>
+#include <linux/regulator/consumer.h>
#include <linux/iio/iio.h>
#include <linux/iio/sysfs.h>
#include <linux/iio/buffer.h>
@@ -133,6 +134,7 @@ enum kx_acpi_type {
};
struct kxcjk1013_data {
+ struct regulator_bulk_data regulators[2];
struct i2c_client *client;
struct iio_trigger *dready_trig;
struct iio_trigger *motion_trig;
@@ -1300,6 +1302,13 @@ static const char *kxcjk1013_match_acpi_device(struct device *dev,
return dev_name(dev);
}
+static void kxcjk1013_disable_regulators(void *d)
+{
+ struct kxcjk1013_data *data = d;
+
+ regulator_bulk_disable(ARRAY_SIZE(data->regulators), data->regulators);
+}
+
static int kxcjk1013_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
@@ -1330,6 +1339,28 @@ static int kxcjk1013_probe(struct i2c_client *client,
return ret;
}
+ data->regulators[0].supply = "vdd";
+ data->regulators[1].supply = "vddio";
+ ret = devm_regulator_bulk_get(&client->dev, ARRAY_SIZE(data->regulators),
+ data->regulators);
+ if (ret)
+ return dev_err_probe(&client->dev, ret, "Failed to get regulators\n");
+
+ ret = regulator_bulk_enable(ARRAY_SIZE(data->regulators),
+ data->regulators);
+ if (ret)
+ return ret;
+
+ ret = devm_add_action_or_reset(&client->dev, kxcjk1013_disable_regulators, data);
+ if (ret)
+ return ret;
+
+ /*
+ * A typical delay of 10ms is required for powering up
+ * according to the data sheets of supported chips.
+ */
+ msleep(20);
+
if (id) {
data->chipset = (enum kx_chipset)(id->driver_data);
name = id->name;
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] iio: accel: kxcjk1013: Add rudimentary regulator support
2020-12-13 17:24 ` [PATCH 2/2] iio: accel: kxcjk1013: Add rudimentary regulator support devajithvs
@ 2020-12-13 18:04 ` Jonathan Cameron
0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2020-12-13 18:04 UTC (permalink / raw)
To: devajithvs
Cc: Lars-Peter Clausen, Peter Meerwald-Stadler, Rob Herring,
Stephen Rothwell, Robert Yang, linux-iio, devicetree,
linux-kernel
On Sun, 13 Dec 2020 22:54:36 +0530
devajithvs <devajithvs@gmail.com> wrote:
> From: Devajith V S <devajithvs@gmail.com>
>
> kxcjk1013 devices have VDD and VDDIO power lines. Need
> to make sure the regulators are enabled before any
> communication with kxcjk1013. This patch introduces
> vdd/vddio regulators for kxcjk1013.
>
> Signed-off-by: Devajith V S <devajithvs@gmail.com>
Looks good to me. Trivial comment on the comment inline that I can fix
whilst applying.
I'll let this sit on the list for a little while though in case
anyone else spots something I have missed.
Thanks,
Jonathan
> ---
> drivers/iio/accel/kxcjk-1013.c | 31 +++++++++++++++++++++++++++++++
> 1 file changed, 31 insertions(+)
>
> diff --git a/drivers/iio/accel/kxcjk-1013.c b/drivers/iio/accel/kxcjk-1013.c
> index e92c7e676..67d3d8270 100644
> --- a/drivers/iio/accel/kxcjk-1013.c
> +++ b/drivers/iio/accel/kxcjk-1013.c
> @@ -14,6 +14,7 @@
> #include <linux/acpi.h>
> #include <linux/pm.h>
> #include <linux/pm_runtime.h>
> +#include <linux/regulator/consumer.h>
> #include <linux/iio/iio.h>
> #include <linux/iio/sysfs.h>
> #include <linux/iio/buffer.h>
> @@ -133,6 +134,7 @@ enum kx_acpi_type {
> };
>
> struct kxcjk1013_data {
> + struct regulator_bulk_data regulators[2];
> struct i2c_client *client;
> struct iio_trigger *dready_trig;
> struct iio_trigger *motion_trig;
> @@ -1300,6 +1302,13 @@ static const char *kxcjk1013_match_acpi_device(struct device *dev,
> return dev_name(dev);
> }
>
> +static void kxcjk1013_disable_regulators(void *d)
> +{
> + struct kxcjk1013_data *data = d;
> +
> + regulator_bulk_disable(ARRAY_SIZE(data->regulators), data->regulators);
> +}
> +
> static int kxcjk1013_probe(struct i2c_client *client,
> const struct i2c_device_id *id)
> {
> @@ -1330,6 +1339,28 @@ static int kxcjk1013_probe(struct i2c_client *client,
> return ret;
> }
>
> + data->regulators[0].supply = "vdd";
> + data->regulators[1].supply = "vddio";
> + ret = devm_regulator_bulk_get(&client->dev, ARRAY_SIZE(data->regulators),
> + data->regulators);
> + if (ret)
> + return dev_err_probe(&client->dev, ret, "Failed to get regulators\n");
> +
> + ret = regulator_bulk_enable(ARRAY_SIZE(data->regulators),
> + data->regulators);
> + if (ret)
> + return ret;
> +
> + ret = devm_add_action_or_reset(&client->dev, kxcjk1013_disable_regulators, data);
> + if (ret)
> + return ret;
> +
> + /*
> + * A typical delay of 10ms is required for powering up
> + * according to the data sheets of supported chips.
Probably want to add something like "so double it to play safe."
> + */
> + msleep(20);
> +
> if (id) {
> data->chipset = (enum kx_chipset)(id->driver_data);
> name = id->name;
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] dt-bindings: iio: accel: kxcjk1013: Document regulator supplies
2020-12-13 17:24 [PATCH 1/2] dt-bindings: iio: accel: kxcjk1013: Document regulator supplies devajithvs
2020-12-13 17:24 ` [PATCH 2/2] iio: accel: kxcjk1013: Add rudimentary regulator support devajithvs
@ 2020-12-15 17:03 ` Rob Herring
1 sibling, 0 replies; 4+ messages in thread
From: Rob Herring @ 2020-12-15 17:03 UTC (permalink / raw)
To: devajithvs
Cc: linux-kernel, linux-iio, Stephen Rothwell, Jonathan Cameron,
Lars-Peter Clausen, Robert Yang, devicetree,
Peter Meerwald-Stadler, Rob Herring
On Sun, 13 Dec 2020 22:54:35 +0530, devajithvs wrote:
> From: Devajith V S <devajithvs@gmail.com>
>
> kxcjk1013 devices have VDD and VDDIO power lines. Need
> to make sure the regulators are enabled before any
> communication with kxcjk1013. Document support for
> vdd/vddio-supply to implement this.
>
> Signed-off-by: Devajith V S <devajithvs@gmail.com>
> ---
> .../devicetree/bindings/iio/accel/kionix,kxcjk1013.yaml | 3 +++
> 1 file changed, 3 insertions(+)
>
Reviewed-by: Rob Herring <robh@kernel.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-12-15 17:04 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-12-13 17:24 [PATCH 1/2] dt-bindings: iio: accel: kxcjk1013: Document regulator supplies devajithvs
2020-12-13 17:24 ` [PATCH 2/2] iio: accel: kxcjk1013: Add rudimentary regulator support devajithvs
2020-12-13 18:04 ` Jonathan Cameron
2020-12-15 17:03 ` [PATCH 1/2] dt-bindings: iio: accel: kxcjk1013: Document regulator supplies Rob Herring
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.