linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] Add devicetree support for ad5933
@ 2018-12-08 18:18 Marcelo Schmitt
  2018-12-08 18:19 ` [PATCH 1/3] staging: iio: ad5933: change regulator binging for vref Marcelo Schmitt
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: Marcelo Schmitt @ 2018-12-08 18:18 UTC (permalink / raw)
  To: lars, Michael.Hennerich, jic23, knaack.h, pmeerw, gregkh,
	stefan.popa, alexandru.Ardelean
  Cc: linux-iio, devel, linux-kernel, kernel-usp

This series of patches change voltage regulator error handling for the
ad5933.
It also add an option to specify external clock reference using a clock
framework and remove the old platform data structure.
Finally it adds binding documentation for devicetree.

Marcelo Schmitt (3):
  staging: iio: ad5933: change regulator binging for vref
  staging: iio: ad5933: use clock framework for clock reference
  staging: iio: ad5933: add binding doc for ad5933

 .../iio/impedance-analyzer/ad5933.txt         | 26 +++++++++
 .../staging/iio/impedance-analyzer/ad5933.c   | 57 +++++++++----------
 2 files changed, 54 insertions(+), 29 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/iio/impedance-analyzer/ad5933.txt

-- 
2.17.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 1/3] staging: iio: ad5933: change regulator binging for vref
  2018-12-08 18:18 [PATCH 0/3] Add devicetree support for ad5933 Marcelo Schmitt
@ 2018-12-08 18:19 ` Marcelo Schmitt
  2018-12-16 12:13   ` Jonathan Cameron
  2018-12-08 18:19 ` [PATCH 2/3] staging: iio: ad5933: use clock framework for clock reference Marcelo Schmitt
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 12+ messages in thread
From: Marcelo Schmitt @ 2018-12-08 18:19 UTC (permalink / raw)
  To: lars, Michael.Hennerich, jic23, knaack.h, pmeerw, gregkh,
	stefan.popa, alexandru.Ardelean
  Cc: linux-iio, devel, linux-kernel, kernel-usp

Set a single voltage regulator for all voltage references.
Remove voltage reference value from default platafrom data struct.

Signed-off-by: Marcelo Schmitt <marcelo.schmitt1@gmail.com>
Signed-off-by: Gabriel Capella <gabriel@capella.pro>
Co-Developed-by: Gabriel Capella <gabriel@capella.pro>
---
 drivers/staging/iio/impedance-analyzer/ad5933.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/iio/impedance-analyzer/ad5933.c b/drivers/staging/iio/impedance-analyzer/ad5933.c
index 9e52384f5370..730bc397a26b 100644
--- a/drivers/staging/iio/impedance-analyzer/ad5933.c
+++ b/drivers/staging/iio/impedance-analyzer/ad5933.c
@@ -91,7 +91,6 @@
 
 struct ad5933_platform_data {
 	unsigned long			ext_clk_hz;
-	unsigned short			vref_mv;
 };
 
 struct ad5933_state {
@@ -113,7 +112,6 @@ struct ad5933_state {
 };
 
 static struct ad5933_platform_data ad5933_default_pdata  = {
-	.vref_mv = 3300,
 };
 
 #define AD5933_CHANNEL(_type, _extend_name, _info_mask_separate, _address, \
@@ -691,7 +689,7 @@ static void ad5933_work(struct work_struct *work)
 static int ad5933_probe(struct i2c_client *client,
 			const struct i2c_device_id *id)
 {
-	int ret, voltage_uv = 0;
+	int ret;
 	struct ad5933_platform_data *pdata = dev_get_platdata(&client->dev);
 	struct ad5933_state *st;
 	struct iio_dev *indio_dev;
@@ -718,12 +716,12 @@ static int ad5933_probe(struct i2c_client *client,
 		dev_err(&client->dev, "Failed to enable specified VDD supply\n");
 		return ret;
 	}
-	voltage_uv = regulator_get_voltage(st->reg);
+	ret = regulator_get_voltage(st->reg);
+
+	if (ret < 0)
+		goto error_disable_reg;
 
-	if (voltage_uv)
-		st->vref_mv = voltage_uv / 1000;
-	else
-		st->vref_mv = pdata->vref_mv;
+	st->vref_mv = ret / 1000;
 
 	if (pdata->ext_clk_hz) {
 		st->mclk_hz = pdata->ext_clk_hz;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 2/3] staging: iio: ad5933: use clock framework for clock reference
  2018-12-08 18:18 [PATCH 0/3] Add devicetree support for ad5933 Marcelo Schmitt
  2018-12-08 18:19 ` [PATCH 1/3] staging: iio: ad5933: change regulator binging for vref Marcelo Schmitt
@ 2018-12-08 18:19 ` Marcelo Schmitt
  2018-12-16 12:14   ` Jonathan Cameron
  2018-12-08 18:19 ` [PATCH 3/3] staging: iio: ad5933: add binding doc for ad5933 Marcelo Schmitt
  2018-12-08 18:56 ` [PATCH 0/3] Add devicetree support " Marcelo Schmitt
  3 siblings, 1 reply; 12+ messages in thread
From: Marcelo Schmitt @ 2018-12-08 18:19 UTC (permalink / raw)
  To: lars, Michael.Hennerich, jic23, knaack.h, pmeerw, gregkh,
	stefan.popa, alexandru.Ardelean
  Cc: linux-iio, devel, linux-kernel, kernel-usp

Add the option to specify the external clock (MCLK) using the clock
framework.
Also remove the old platform data structure.

Signed-off-by: Marcelo Schmitt <marcelo.schmitt1@gmail.com>
Signed-off-by: Gabriel Capella <gabriel@capella.pro>
Co-Developed-by: Gabriel Capella <gabriel@capella.pro>
---
 .../staging/iio/impedance-analyzer/ad5933.c   | 43 ++++++++++---------
 1 file changed, 22 insertions(+), 21 deletions(-)

diff --git a/drivers/staging/iio/impedance-analyzer/ad5933.c b/drivers/staging/iio/impedance-analyzer/ad5933.c
index 730bc397a26b..3134295f014f 100644
--- a/drivers/staging/iio/impedance-analyzer/ad5933.c
+++ b/drivers/staging/iio/impedance-analyzer/ad5933.c
@@ -16,6 +16,7 @@
 #include <linux/err.h>
 #include <linux/delay.h>
 #include <linux/module.h>
+#include <linux/clk.h>
 
 #include <linux/iio/iio.h>
 #include <linux/iio/sysfs.h>
@@ -82,20 +83,10 @@
 #define AD5933_POLL_TIME_ms		10
 #define AD5933_INIT_EXCITATION_TIME_ms	100
 
-/**
- * struct ad5933_platform_data - platform specific data
- * @ext_clk_hz:		the external clock frequency in Hz, if not set
- *			the driver uses the internal clock (16.776 MHz)
- * @vref_mv:		the external reference voltage in millivolt
- */
-
-struct ad5933_platform_data {
-	unsigned long			ext_clk_hz;
-};
-
 struct ad5933_state {
 	struct i2c_client		*client;
 	struct regulator		*reg;
+	struct clk			*mclk;
 	struct delayed_work		work;
 	struct mutex			lock; /* Protect sensor state */
 	unsigned long			mclk_hz;
@@ -111,9 +102,6 @@ struct ad5933_state {
 	unsigned int			poll_time_jiffies;
 };
 
-static struct ad5933_platform_data ad5933_default_pdata  = {
-};
-
 #define AD5933_CHANNEL(_type, _extend_name, _info_mask_separate, _address, \
 		_scan_index, _realbits) { \
 	.type = (_type), \
@@ -690,9 +678,9 @@ static int ad5933_probe(struct i2c_client *client,
 			const struct i2c_device_id *id)
 {
 	int ret;
-	struct ad5933_platform_data *pdata = dev_get_platdata(&client->dev);
 	struct ad5933_state *st;
 	struct iio_dev *indio_dev;
+	unsigned long ext_clk_hz = 0;
 
 	indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*st));
 	if (!indio_dev)
@@ -704,9 +692,6 @@ static int ad5933_probe(struct i2c_client *client,
 
 	mutex_init(&st->lock);
 
-	if (!pdata)
-		pdata = &ad5933_default_pdata;
-
 	st->reg = devm_regulator_get(&client->dev, "vdd");
 	if (IS_ERR(st->reg))
 		return PTR_ERR(st->reg);
@@ -723,8 +708,21 @@ static int ad5933_probe(struct i2c_client *client,
 
 	st->vref_mv = ret / 1000;
 
-	if (pdata->ext_clk_hz) {
-		st->mclk_hz = pdata->ext_clk_hz;
+	st->mclk = devm_clk_get(&client->dev, "mclk");
+	if (IS_ERR(st->mclk) && PTR_ERR(st->mclk) != -ENOENT) {
+		ret = PTR_ERR(st->mclk);
+		goto error_disable_reg;
+	}
+
+	if (!IS_ERR(st->mclk)) {
+		ret = clk_prepare_enable(st->mclk);
+		if (ret < 0)
+			goto error_disable_reg;
+		ext_clk_hz = clk_get_rate(st->mclk);
+	}
+
+	if (ext_clk_hz) {
+		st->mclk_hz = ext_clk_hz;
 		st->ctrl_lb = AD5933_CTRL_EXT_SYSCLK;
 	} else {
 		st->mclk_hz = AD5933_INT_OSC_FREQ_Hz;
@@ -744,7 +742,7 @@ static int ad5933_probe(struct i2c_client *client,
 
 	ret = ad5933_register_ring_funcs_and_init(indio_dev);
 	if (ret)
-		goto error_disable_reg;
+		goto error_disable_mclk;
 
 	ret = ad5933_setup(st);
 	if (ret)
@@ -758,6 +756,8 @@ static int ad5933_probe(struct i2c_client *client,
 
 error_unreg_ring:
 	iio_kfifo_free(indio_dev->buffer);
+error_disable_mclk:
+	clk_disable_unprepare(st->mclk);
 error_disable_reg:
 	regulator_disable(st->reg);
 
@@ -772,6 +772,7 @@ static int ad5933_remove(struct i2c_client *client)
 	iio_device_unregister(indio_dev);
 	iio_kfifo_free(indio_dev->buffer);
 	regulator_disable(st->reg);
+	clk_disable_unprepare(st->mclk);
 
 	return 0;
 }
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 3/3] staging: iio: ad5933: add binding doc for ad5933
  2018-12-08 18:18 [PATCH 0/3] Add devicetree support for ad5933 Marcelo Schmitt
  2018-12-08 18:19 ` [PATCH 1/3] staging: iio: ad5933: change regulator binging for vref Marcelo Schmitt
  2018-12-08 18:19 ` [PATCH 2/3] staging: iio: ad5933: use clock framework for clock reference Marcelo Schmitt
@ 2018-12-08 18:19 ` Marcelo Schmitt
  2018-12-10 21:27   ` Jonathan Cameron
  2018-12-08 18:56 ` [PATCH 0/3] Add devicetree support " Marcelo Schmitt
  3 siblings, 1 reply; 12+ messages in thread
From: Marcelo Schmitt @ 2018-12-08 18:19 UTC (permalink / raw)
  To: lars, Michael.Hennerich, jic23, knaack.h, pmeerw, gregkh,
	stefan.popa, alexandru.Ardelean
  Cc: linux-iio, devel, linux-kernel, kernel-usp

Add a devicetree documentation for the ad5933 and ad5934 impedance
converter, network analyzer.

Signed-off-by: Marcelo Schmitt <marcelo.schmitt1@gmail.com>
Signed-off-by: Gabriel Capella <gabriel@capella.pro>
Co-Developed-by: Gabriel Capella <gabriel@capella.pro>
---
 .../iio/impedance-analyzer/ad5933.txt         | 26 +++++++++++++++++++
 1 file changed, 26 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/impedance-analyzer/ad5933.txt

diff --git a/Documentation/devicetree/bindings/iio/impedance-analyzer/ad5933.txt b/Documentation/devicetree/bindings/iio/impedance-analyzer/ad5933.txt
new file mode 100644
index 000000000000..5ff38728ff91
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/impedance-analyzer/ad5933.txt
@@ -0,0 +1,26 @@
+Analog Devices AD5933/AD5934 Impedance Converter, Network Analyzer
+
+https://www.analog.com/media/en/technical-documentation/data-sheets/AD5933.pdf
+https://www.analog.com/media/en/technical-documentation/data-sheets/AD5934.pdf
+
+Required properties:
+ - compatible : should be one of
+		"adi,ad5933"
+		"adi,ad5934"
+ - reg : the I2C address.
+ - vdd-supply : The regulator supply for DVDD, AVDD1 and AVDD2 when they
+   are connected together.
+
+Optional properties:
+- clocks : external clock reference.
+- clock-names : must be "mclk" if clocks is set.
+
+Example for a I2C device node:
+
+	impedance-analyzer@0d {
+		compatible = "adi,adxl345";
+		reg = <0x0d>;
+		vdd-supply = <&vdd_supply>;
+		clocks = <&ref_clk>;
+		clock-names = "mclk";
+	};
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH 0/3] Add devicetree support for ad5933
  2018-12-08 18:18 [PATCH 0/3] Add devicetree support for ad5933 Marcelo Schmitt
                   ` (2 preceding siblings ...)
  2018-12-08 18:19 ` [PATCH 3/3] staging: iio: ad5933: add binding doc for ad5933 Marcelo Schmitt
@ 2018-12-08 18:56 ` Marcelo Schmitt
  2018-12-08 21:10   ` Greg KH
  3 siblings, 1 reply; 12+ messages in thread
From: Marcelo Schmitt @ 2018-12-08 18:56 UTC (permalink / raw)
  To: lars, Michael.Hennerich, jic23, knaack.h, pmeerw, gregkh,
	stefan.popa, alexandru.Ardelean
  Cc: linux-iio, devel, linux-kernel, kernel-usp

Parts of this work came from contributions of Alexandru Ardelean and
Dragos Bogdan, I and Gabriel would like to thank for the insights
provided by their previous patches. Maybe it would be the case to add
them as co-authors of this patch set.
We also wanted to thank Jhonatan Cameron for giving us the pieces of
advice needed for this work.

Thanks,
Marcelo

Em sáb, 8 de dez de 2018 às 16:18, Marcelo Schmitt
<marcelo.schmitt1@gmail.com> escreveu:
>
> This series of patches change voltage regulator error handling for the
> ad5933.
> It also add an option to specify external clock reference using a clock
> framework and remove the old platform data structure.
> Finally it adds binding documentation for devicetree.
>
> Marcelo Schmitt (3):
>   staging: iio: ad5933: change regulator binging for vref
>   staging: iio: ad5933: use clock framework for clock reference
>   staging: iio: ad5933: add binding doc for ad5933
>
>  .../iio/impedance-analyzer/ad5933.txt         | 26 +++++++++
>  .../staging/iio/impedance-analyzer/ad5933.c   | 57 +++++++++----------
>  2 files changed, 54 insertions(+), 29 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/iio/impedance-analyzer/ad5933.txt
>
> --
> 2.17.1
>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 0/3] Add devicetree support for ad5933
  2018-12-08 18:56 ` [PATCH 0/3] Add devicetree support " Marcelo Schmitt
@ 2018-12-08 21:10   ` Greg KH
  2018-12-10 21:27     ` Jonathan Cameron
  0 siblings, 1 reply; 12+ messages in thread
From: Greg KH @ 2018-12-08 21:10 UTC (permalink / raw)
  To: Marcelo Schmitt
  Cc: lars, Michael.Hennerich, jic23, knaack.h, pmeerw, stefan.popa,
	alexandru.Ardelean, linux-iio, devel, linux-kernel, kernel-usp

On Sat, Dec 08, 2018 at 04:56:45PM -0200, Marcelo Schmitt wrote:
> Parts of this work came from contributions of Alexandru Ardelean and
> Dragos Bogdan, I and Gabriel would like to thank for the insights
> provided by their previous patches. Maybe it would be the case to add
> them as co-authors of this patch set.

That's what the Co-developed-by: tag is for, please use it :)


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 3/3] staging: iio: ad5933: add binding doc for ad5933
  2018-12-08 18:19 ` [PATCH 3/3] staging: iio: ad5933: add binding doc for ad5933 Marcelo Schmitt
@ 2018-12-10 21:27   ` Jonathan Cameron
  2018-12-16 12:16     ` Jonathan Cameron
  0 siblings, 1 reply; 12+ messages in thread
From: Jonathan Cameron @ 2018-12-10 21:27 UTC (permalink / raw)
  To: Marcelo Schmitt
  Cc: lars, Michael.Hennerich, knaack.h, pmeerw, gregkh, stefan.popa,
	alexandru.Ardelean, linux-iio, devel, linux-kernel, kernel-usp,
	Rob Herring, Mark Rutland, devicetree

On Sat, 8 Dec 2018 16:19:59 -0200
Marcelo Schmitt <marcelo.schmitt1@gmail.com> wrote:

> Add a devicetree documentation for the ad5933 and ad5934 impedance
> converter, network analyzer.
> 
> Signed-off-by: Marcelo Schmitt <marcelo.schmitt1@gmail.com>
> Signed-off-by: Gabriel Capella <gabriel@capella.pro>
> Co-Developed-by: Gabriel Capella <gabriel@capella.pro>
Device tree binding patches need to also go to the DT maintainers and list
for review.

This looks fine to me but they are the specialists in these!

+cc Rob, Mark and DT list.

Jonathan
> ---
>  .../iio/impedance-analyzer/ad5933.txt         | 26 +++++++++++++++++++
>  1 file changed, 26 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/iio/impedance-analyzer/ad5933.txt
> 
> diff --git a/Documentation/devicetree/bindings/iio/impedance-analyzer/ad5933.txt b/Documentation/devicetree/bindings/iio/impedance-analyzer/ad5933.txt
> new file mode 100644
> index 000000000000..5ff38728ff91
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/iio/impedance-analyzer/ad5933.txt
> @@ -0,0 +1,26 @@
> +Analog Devices AD5933/AD5934 Impedance Converter, Network Analyzer
> +
> +https://www.analog.com/media/en/technical-documentation/data-sheets/AD5933.pdf
> +https://www.analog.com/media/en/technical-documentation/data-sheets/AD5934.pdf
> +
> +Required properties:
> + - compatible : should be one of
> +		"adi,ad5933"
> +		"adi,ad5934"
> + - reg : the I2C address.
> + - vdd-supply : The regulator supply for DVDD, AVDD1 and AVDD2 when they
> +   are connected together.
> +
> +Optional properties:
> +- clocks : external clock reference.
> +- clock-names : must be "mclk" if clocks is set.
> +
> +Example for a I2C device node:
> +
> +	impedance-analyzer@0d {
> +		compatible = "adi,adxl345";
> +		reg = <0x0d>;
> +		vdd-supply = <&vdd_supply>;
> +		clocks = <&ref_clk>;
> +		clock-names = "mclk";
> +	};


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 0/3] Add devicetree support for ad5933
  2018-12-08 21:10   ` Greg KH
@ 2018-12-10 21:27     ` Jonathan Cameron
  2018-12-11 10:31       ` Ardelean, Alexandru
  0 siblings, 1 reply; 12+ messages in thread
From: Jonathan Cameron @ 2018-12-10 21:27 UTC (permalink / raw)
  To: Greg KH
  Cc: Marcelo Schmitt, lars, Michael.Hennerich, knaack.h, pmeerw,
	stefan.popa, alexandru.Ardelean, linux-iio, devel, linux-kernel,
	kernel-usp, Dragos Bogdan

On Sat, 8 Dec 2018 22:10:43 +0100
Greg KH <gregkh@linuxfoundation.org> wrote:

> On Sat, Dec 08, 2018 at 04:56:45PM -0200, Marcelo Schmitt wrote:
> > Parts of this work came from contributions of Alexandru Ardelean and
> > Dragos Bogdan, I and Gabriel would like to thank for the insights
> > provided by their previous patches. Maybe it would be the case to add
> > them as co-authors of this patch set.  
> 
> That's what the Co-developed-by: tag is for, please use it :)
> 
Alexandru, Dragos.  No idea how involved you were in the actual
patch...

Work amongst amongst the 4 of you what you would like to do and
let us know!

Patches look fine, though we need to let the DT maintainers have a few
days at least to get around to looking if they want to (they don't always
on simple bindings like these).

Jonathan
 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 0/3] Add devicetree support for ad5933
  2018-12-10 21:27     ` Jonathan Cameron
@ 2018-12-11 10:31       ` Ardelean, Alexandru
  0 siblings, 0 replies; 12+ messages in thread
From: Ardelean, Alexandru @ 2018-12-11 10:31 UTC (permalink / raw)
  To: jic23, gregkh
  Cc: kernel-usp, lars, linux-kernel, knaack.h, Popa, Stefan Serban,
	Hennerich, Michael, linux-iio, devel, Bogdan, Dragos, pmeerw,
	marcelo.schmitt1

On Mon, 2018-12-10 at 21:27 +0000, Jonathan Cameron wrote:
> On Sat, 8 Dec 2018 22:10:43 +0100
> Greg KH <gregkh@linuxfoundation.org> wrote:
> 
> > On Sat, Dec 08, 2018 at 04:56:45PM -0200, Marcelo Schmitt wrote:
> > > Parts of this work came from contributions of Alexandru Ardelean and
> > > Dragos Bogdan, I and Gabriel would like to thank for the insights
> > > provided by their previous patches. Maybe it would be the case to add
> > > them as co-authors of this patch set.  
> > 
> > That's what the Co-developed-by: tag is for, please use it :)
> > 
> 
> Alexandru, Dragos.  No idea how involved you were in the actual
> patch...
> 
> Work amongst amongst the 4 of you what you would like to do and
> let us know!
> 

Hey,

To give a bit of context, I sent some patches some time ago that deal with
this, but haven't had time to re-spin them [based on Jonathan's comments].

I've discussed with Dragos.
From our side, any version that is decided with respect to the `Co-
developed-by:` tag is fine. i.e. we don't need to be mentioned in the
commits.

I hope this is a sufficiently good answer [for the whole legal stuff].

> Patches look fine, though we need to let the DT maintainers have a few
> days at least to get around to looking if they want to (they don't always
> on simple bindings like these).
> 

Thanks
Alex

> Jonathan
>  

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/3] staging: iio: ad5933: change regulator binging for vref
  2018-12-08 18:19 ` [PATCH 1/3] staging: iio: ad5933: change regulator binging for vref Marcelo Schmitt
@ 2018-12-16 12:13   ` Jonathan Cameron
  0 siblings, 0 replies; 12+ messages in thread
From: Jonathan Cameron @ 2018-12-16 12:13 UTC (permalink / raw)
  To: Marcelo Schmitt
  Cc: lars, Michael.Hennerich, knaack.h, pmeerw, gregkh, stefan.popa,
	alexandru.Ardelean, linux-iio, devel, linux-kernel, kernel-usp

On Sat, 8 Dec 2018 16:19:08 -0200
Marcelo Schmitt <marcelo.schmitt1@gmail.com> wrote:

> Set a single voltage regulator for all voltage references.
> Remove voltage reference value from default platafrom data struct.
> 
> Signed-off-by: Marcelo Schmitt <marcelo.schmitt1@gmail.com>
> Signed-off-by: Gabriel Capella <gabriel@capella.pro>
> Co-Developed-by: Gabriel Capella <gabriel@capella.pro>
Applied to the togreg branch of iio.git and pushed out as testing
for the autobuilders to play with it.

Thanks,

Jonathan

> ---
>  drivers/staging/iio/impedance-analyzer/ad5933.c | 14 ++++++--------
>  1 file changed, 6 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/staging/iio/impedance-analyzer/ad5933.c b/drivers/staging/iio/impedance-analyzer/ad5933.c
> index 9e52384f5370..730bc397a26b 100644
> --- a/drivers/staging/iio/impedance-analyzer/ad5933.c
> +++ b/drivers/staging/iio/impedance-analyzer/ad5933.c
> @@ -91,7 +91,6 @@
>  
>  struct ad5933_platform_data {
>  	unsigned long			ext_clk_hz;
> -	unsigned short			vref_mv;
>  };
>  
>  struct ad5933_state {
> @@ -113,7 +112,6 @@ struct ad5933_state {
>  };
>  
>  static struct ad5933_platform_data ad5933_default_pdata  = {
> -	.vref_mv = 3300,
>  };
>  
>  #define AD5933_CHANNEL(_type, _extend_name, _info_mask_separate, _address, \
> @@ -691,7 +689,7 @@ static void ad5933_work(struct work_struct *work)
>  static int ad5933_probe(struct i2c_client *client,
>  			const struct i2c_device_id *id)
>  {
> -	int ret, voltage_uv = 0;
> +	int ret;
>  	struct ad5933_platform_data *pdata = dev_get_platdata(&client->dev);
>  	struct ad5933_state *st;
>  	struct iio_dev *indio_dev;
> @@ -718,12 +716,12 @@ static int ad5933_probe(struct i2c_client *client,
>  		dev_err(&client->dev, "Failed to enable specified VDD supply\n");
>  		return ret;
>  	}
> -	voltage_uv = regulator_get_voltage(st->reg);
> +	ret = regulator_get_voltage(st->reg);
> +
> +	if (ret < 0)
> +		goto error_disable_reg;
>  
> -	if (voltage_uv)
> -		st->vref_mv = voltage_uv / 1000;
> -	else
> -		st->vref_mv = pdata->vref_mv;
> +	st->vref_mv = ret / 1000;
>  
>  	if (pdata->ext_clk_hz) {
>  		st->mclk_hz = pdata->ext_clk_hz;


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/3] staging: iio: ad5933: use clock framework for clock reference
  2018-12-08 18:19 ` [PATCH 2/3] staging: iio: ad5933: use clock framework for clock reference Marcelo Schmitt
@ 2018-12-16 12:14   ` Jonathan Cameron
  0 siblings, 0 replies; 12+ messages in thread
From: Jonathan Cameron @ 2018-12-16 12:14 UTC (permalink / raw)
  To: Marcelo Schmitt
  Cc: lars, Michael.Hennerich, knaack.h, pmeerw, gregkh, stefan.popa,
	alexandru.Ardelean, linux-iio, devel, linux-kernel, kernel-usp

On Sat, 8 Dec 2018 16:19:38 -0200
Marcelo Schmitt <marcelo.schmitt1@gmail.com> wrote:

> Add the option to specify the external clock (MCLK) using the clock
> framework.
> Also remove the old platform data structure.
> 
> Signed-off-by: Marcelo Schmitt <marcelo.schmitt1@gmail.com>
> Signed-off-by: Gabriel Capella <gabriel@capella.pro>
> Co-Developed-by: Gabriel Capella <gabriel@capella.pro>
Applied to the togreg branch of iio.git and pushed out as testing for
the autobuilders to play with it.

Thanks,

Jonathan

> ---
>  .../staging/iio/impedance-analyzer/ad5933.c   | 43 ++++++++++---------
>  1 file changed, 22 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/staging/iio/impedance-analyzer/ad5933.c b/drivers/staging/iio/impedance-analyzer/ad5933.c
> index 730bc397a26b..3134295f014f 100644
> --- a/drivers/staging/iio/impedance-analyzer/ad5933.c
> +++ b/drivers/staging/iio/impedance-analyzer/ad5933.c
> @@ -16,6 +16,7 @@
>  #include <linux/err.h>
>  #include <linux/delay.h>
>  #include <linux/module.h>
> +#include <linux/clk.h>
>  
>  #include <linux/iio/iio.h>
>  #include <linux/iio/sysfs.h>
> @@ -82,20 +83,10 @@
>  #define AD5933_POLL_TIME_ms		10
>  #define AD5933_INIT_EXCITATION_TIME_ms	100
>  
> -/**
> - * struct ad5933_platform_data - platform specific data
> - * @ext_clk_hz:		the external clock frequency in Hz, if not set
> - *			the driver uses the internal clock (16.776 MHz)
> - * @vref_mv:		the external reference voltage in millivolt
> - */
> -
> -struct ad5933_platform_data {
> -	unsigned long			ext_clk_hz;
> -};
> -
>  struct ad5933_state {
>  	struct i2c_client		*client;
>  	struct regulator		*reg;
> +	struct clk			*mclk;
>  	struct delayed_work		work;
>  	struct mutex			lock; /* Protect sensor state */
>  	unsigned long			mclk_hz;
> @@ -111,9 +102,6 @@ struct ad5933_state {
>  	unsigned int			poll_time_jiffies;
>  };
>  
> -static struct ad5933_platform_data ad5933_default_pdata  = {
> -};
> -
>  #define AD5933_CHANNEL(_type, _extend_name, _info_mask_separate, _address, \
>  		_scan_index, _realbits) { \
>  	.type = (_type), \
> @@ -690,9 +678,9 @@ static int ad5933_probe(struct i2c_client *client,
>  			const struct i2c_device_id *id)
>  {
>  	int ret;
> -	struct ad5933_platform_data *pdata = dev_get_platdata(&client->dev);
>  	struct ad5933_state *st;
>  	struct iio_dev *indio_dev;
> +	unsigned long ext_clk_hz = 0;
>  
>  	indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*st));
>  	if (!indio_dev)
> @@ -704,9 +692,6 @@ static int ad5933_probe(struct i2c_client *client,
>  
>  	mutex_init(&st->lock);
>  
> -	if (!pdata)
> -		pdata = &ad5933_default_pdata;
> -
>  	st->reg = devm_regulator_get(&client->dev, "vdd");
>  	if (IS_ERR(st->reg))
>  		return PTR_ERR(st->reg);
> @@ -723,8 +708,21 @@ static int ad5933_probe(struct i2c_client *client,
>  
>  	st->vref_mv = ret / 1000;
>  
> -	if (pdata->ext_clk_hz) {
> -		st->mclk_hz = pdata->ext_clk_hz;
> +	st->mclk = devm_clk_get(&client->dev, "mclk");
> +	if (IS_ERR(st->mclk) && PTR_ERR(st->mclk) != -ENOENT) {
> +		ret = PTR_ERR(st->mclk);
> +		goto error_disable_reg;
> +	}
> +
> +	if (!IS_ERR(st->mclk)) {
> +		ret = clk_prepare_enable(st->mclk);
> +		if (ret < 0)
> +			goto error_disable_reg;
> +		ext_clk_hz = clk_get_rate(st->mclk);
> +	}
> +
> +	if (ext_clk_hz) {
> +		st->mclk_hz = ext_clk_hz;
>  		st->ctrl_lb = AD5933_CTRL_EXT_SYSCLK;
>  	} else {
>  		st->mclk_hz = AD5933_INT_OSC_FREQ_Hz;
> @@ -744,7 +742,7 @@ static int ad5933_probe(struct i2c_client *client,
>  
>  	ret = ad5933_register_ring_funcs_and_init(indio_dev);
>  	if (ret)
> -		goto error_disable_reg;
> +		goto error_disable_mclk;
>  
>  	ret = ad5933_setup(st);
>  	if (ret)
> @@ -758,6 +756,8 @@ static int ad5933_probe(struct i2c_client *client,
>  
>  error_unreg_ring:
>  	iio_kfifo_free(indio_dev->buffer);
> +error_disable_mclk:
> +	clk_disable_unprepare(st->mclk);
>  error_disable_reg:
>  	regulator_disable(st->reg);
>  
> @@ -772,6 +772,7 @@ static int ad5933_remove(struct i2c_client *client)
>  	iio_device_unregister(indio_dev);
>  	iio_kfifo_free(indio_dev->buffer);
>  	regulator_disable(st->reg);
> +	clk_disable_unprepare(st->mclk);
>  
>  	return 0;
>  }


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 3/3] staging: iio: ad5933: add binding doc for ad5933
  2018-12-10 21:27   ` Jonathan Cameron
@ 2018-12-16 12:16     ` Jonathan Cameron
  0 siblings, 0 replies; 12+ messages in thread
From: Jonathan Cameron @ 2018-12-16 12:16 UTC (permalink / raw)
  To: Marcelo Schmitt
  Cc: lars, Michael.Hennerich, knaack.h, pmeerw, gregkh, stefan.popa,
	alexandru.Ardelean, linux-iio, devel, linux-kernel, kernel-usp,
	Rob Herring, Mark Rutland, devicetree

On Mon, 10 Dec 2018 21:27:02 +0000
Jonathan Cameron <jic23@kernel.org> wrote:

> On Sat, 8 Dec 2018 16:19:59 -0200
> Marcelo Schmitt <marcelo.schmitt1@gmail.com> wrote:
> 
> > Add a devicetree documentation for the ad5933 and ad5934 impedance
> > converter, network analyzer.
> > 
> > Signed-off-by: Marcelo Schmitt <marcelo.schmitt1@gmail.com>
> > Signed-off-by: Gabriel Capella <gabriel@capella.pro>
> > Co-Developed-by: Gabriel Capella <gabriel@capella.pro>  
> Device tree binding patches need to also go to the DT maintainers and list
> for review.
> 
> This looks fine to me but they are the specialists in these!
> 
> +cc Rob, Mark and DT list.

Long enough I think.  This will be in my tree in a fashion I can rebase for
a week or so anyway so please still feel free to comment.

Applied to the togreg branch of iio.git and pushed out as testing for
the autobuilders to play with it.

Thanks,

Jonathan
> 
> Jonathan
> > ---
> >  .../iio/impedance-analyzer/ad5933.txt         | 26 +++++++++++++++++++
> >  1 file changed, 26 insertions(+)
> >  create mode 100644 Documentation/devicetree/bindings/iio/impedance-analyzer/ad5933.txt
> > 
> > diff --git a/Documentation/devicetree/bindings/iio/impedance-analyzer/ad5933.txt b/Documentation/devicetree/bindings/iio/impedance-analyzer/ad5933.txt
> > new file mode 100644
> > index 000000000000..5ff38728ff91
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/iio/impedance-analyzer/ad5933.txt
> > @@ -0,0 +1,26 @@
> > +Analog Devices AD5933/AD5934 Impedance Converter, Network Analyzer
> > +
> > +https://www.analog.com/media/en/technical-documentation/data-sheets/AD5933.pdf
> > +https://www.analog.com/media/en/technical-documentation/data-sheets/AD5934.pdf
> > +
> > +Required properties:
> > + - compatible : should be one of
> > +		"adi,ad5933"
> > +		"adi,ad5934"
> > + - reg : the I2C address.
> > + - vdd-supply : The regulator supply for DVDD, AVDD1 and AVDD2 when they
> > +   are connected together.
> > +
> > +Optional properties:
> > +- clocks : external clock reference.
> > +- clock-names : must be "mclk" if clocks is set.
> > +
> > +Example for a I2C device node:
> > +
> > +	impedance-analyzer@0d {
> > +		compatible = "adi,adxl345";
> > +		reg = <0x0d>;
> > +		vdd-supply = <&vdd_supply>;
> > +		clocks = <&ref_clk>;
> > +		clock-names = "mclk";
> > +	};  
> 


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2018-12-16 12:16 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-08 18:18 [PATCH 0/3] Add devicetree support for ad5933 Marcelo Schmitt
2018-12-08 18:19 ` [PATCH 1/3] staging: iio: ad5933: change regulator binging for vref Marcelo Schmitt
2018-12-16 12:13   ` Jonathan Cameron
2018-12-08 18:19 ` [PATCH 2/3] staging: iio: ad5933: use clock framework for clock reference Marcelo Schmitt
2018-12-16 12:14   ` Jonathan Cameron
2018-12-08 18:19 ` [PATCH 3/3] staging: iio: ad5933: add binding doc for ad5933 Marcelo Schmitt
2018-12-10 21:27   ` Jonathan Cameron
2018-12-16 12:16     ` Jonathan Cameron
2018-12-08 18:56 ` [PATCH 0/3] Add devicetree support " Marcelo Schmitt
2018-12-08 21:10   ` Greg KH
2018-12-10 21:27     ` Jonathan Cameron
2018-12-11 10:31       ` Ardelean, Alexandru

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).