Skip to contentSkip to conversation

iio: adc: rockchip_saradc: reset saradc controller before programming it

PATCH Superseded Caesar Wang 4 participants 13 messages Jul 26, 2016 – Jul 27, 2016

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/4 iio: adc: rockchip_saradc: reset saradc controller before programming it

SARADC controller needs to be reset before programming it, otherwise it will not function properly.

Cc Jonathan Cameron <[email protected]>
Cc Heiko Stuebner <[email protected]>
Cc Rob Herring <[email protected]>
Cc linux-iio at vger.kernel.org
Cc linux-rockchip at lists.infradead.org

---

Changes in v2:
- Make the reset as an optional property, since it should work with old devicetrees as well.

 .../bindings/iio/adc/rockchip-saradc.txt           |  7 +++++
 drivers/iio/adc/Kconfig                            |  1 +
 drivers/iio/adc/rockchip_saradc.c                  | 31 ++++++++++++++++++++++
 3 files changed, 39 insertions(+)
Documentation/devicetree/bindings/iio/adc/rockchip-saradc.txt +7 -0
index bf99e2f..205593f 100644
@@ -16,6 +16,11 @@ Required properties:
 - vref-supply: The regulator supply ADC reference voltage.
 - #io-channel-cells: Should be 1, see ../iio-bindings.txt
 
+Optional properties:
+- resets: Must contain an entry for each entry in reset-names if need support
+	  this option. See ../reset/reset.txt for details.
+- reset-names: Must include the name "saradc-apb".
+
 Example:
 	saradc: saradc at 2006c000 {
 		compatible = "rockchip,saradc";
@@ -23,6 +28,8 @@ Example:
 		interrupts = <GIC_SPI 26 IRQ_TYPE_LEVEL_HIGH>;
 		clocks = <&cru SCLK_SARADC>, <&cru PCLK_SARADC>;
 		clock-names = "saradc", "apb_pclk";
+		resets = <&cru SRST_SARADC>;
+		reset-names = "saradc-apb";
 		#io-channel-cells = <1>;
 		vref-supply = <&vcc18>;
 	};
drivers/iio/adc/Kconfig +1 -0
index 1de31bd..7675772 100644
@@ -389,6 +389,7 @@ config QCOM_SPMI_VADC
 config ROCKCHIP_SARADC
 	tristate "Rockchip SARADC driver"
 	depends on ARCH_ROCKCHIP || (ARM && COMPILE_TEST)
+	depends on RESET_CONTROLLER
 	help
 	  Say yes here to build support for the SARADC found in SoCs from
 	  Rockchip.
drivers/iio/adc/rockchip_saradc.c +31 -0
index f9ad6c2..dc1379f 100644
@@ -21,6 +21,8 @@
 #include <linux/of_device.h>
 #include <linux/clk.h>
 #include <linux/completion.h>
+#include <linux/delay.h>
+#include <linux/reset.h>
 #include <linux/regulator/consumer.h>
 #include <linux/iio/iio.h>
 
@@ -53,6 +55,7 @@ struct rockchip_saradc {
 	struct clk		*clk;
 	struct completion	completion;
 	struct regulator	*vref;
+	struct reset_control	*reset;
 	const struct rockchip_saradc_data *data;
 	u16			last_val;
 };
@@ -190,6 +193,16 @@ static const struct of_device_id rockchip_saradc_match[] = {
 };
 MODULE_DEVICE_TABLE(of, rockchip_saradc_match);
 
+/**
+ * Reset SARADC Controller.
+ */
+static void rockchip_saradc_reset_controller(struct reset_control *reset)
+{
+	reset_control_assert(reset);
+	usleep_range(10, 20);
+	reset_control_deassert(reset);
+}
+
 static int rockchip_saradc_probe(struct platform_device *pdev)
 {
 	struct rockchip_saradc *info = NULL;
@@ -218,6 +231,21 @@ static int rockchip_saradc_probe(struct platform_device *pdev)
 	if (IS_ERR(info->regs))
 		return PTR_ERR(info->regs);
 
+	/*
+	 * The reset should be an optional property, as it should work
+	 * with old devicetrees as well
+	 */
+	info->reset = devm_reset_control_get_optional(&pdev->dev,
+			"saradc-apb");
+	if (IS_ERR(info->reset)) {
+		ret = PTR_ERR(info->reset);
+		if (ret != -ENOENT)
+			return ret;
+
+		dev_dbg(&pdev->dev, "no reset control found\n");
+		info->reset = NULL;
+	}
+
 	init_completion(&info->completion);
 
 	irq = platform_get_irq(pdev, 0);
@@ -252,6 +280,9 @@ static int rockchip_saradc_probe(struct platform_device *pdev)
 		return PTR_ERR(info->vref);
 	}
 
+	if (info->reset)
+		rockchip_saradc_reset_controller(info->reset);
+
 	/*
 	 * Use a default value for the converter clock.
 	 * This may become user-configurable in the future.
Signature · 1 line
1.9.1
#1 lore raw

PATCH v2 2/4 arm64: dts: rockchip: add the saradc for rk3399

This patch adds saradc needed information on rk3399 SoCs.

---

Changes in v2: None

 arch/arm64/boot/dts/rockchip/rk3399.dtsi | 12 ++++++++++++
 1 file changed, 12 insertions(+)
arch/arm64/boot/dts/rockchip/rk3399.dtsi +12 -0
index 4c84229..b81f84b 100644
@@ -299,6 +299,18 @@
 		};
 	};
 
+	saradc: saradc at ff100000 {
+		compatible = "rockchip,rk3399-saradc";
+		reg = <0x0 0xff100000 0x0 0x100>;
+		interrupts = <GIC_SPI 62 IRQ_TYPE_LEVEL_HIGH>;
+		#io-channel-cells = <1>;
+		clocks = <&cru SCLK_SARADC>, <&cru PCLK_SARADC>;
+		clock-names = "saradc", "apb_pclk";
+		resets = <&cru SRST_P_SARADC>;
+		reset-names = "saradc-apb";
+		status = "disabled";
+	};
+
 	i2c1: i2c at ff110000 {
 		compatible = "rockchip,rk3399-i2c";
 		reg = <0x0 0xff110000 0x0 0x1000>;
Signature · 1 line
1.9.1
#3 lore raw

PATCH v2 3/4 arm64: dts: rockchip: add reset saradc node for rk3368 SoCs

In reply to Caesar Wang

SARADC controller needs to be reset before programming it, otherwise it will not function properly.

---

Changes in v2: None

 arch/arm64/boot/dts/rockchip/rk3368.dtsi | 2 ++
 1 file changed, 2 insertions(+)
arch/arm64/boot/dts/rockchip/rk3368.dtsi +2 -0
index d02a9003..4f44d11 100644
@@ -270,6 +270,8 @@
 		#io-channel-cells = <1>;
 		clocks = <&cru SCLK_SARADC>, <&cru PCLK_SARADC>;
 		clock-names = "saradc", "apb_pclk";
+		resets = <&cru SRST_SARADC>;
+		reset-names = "saradc-apb";
 		status = "disabled";
 	};
 
Signature · 1 line
1.9.1
#4 lore raw

PATCH v2 4/4 arm: dts: rockchip: add reset node for the exist saradc SoCs

In reply to Caesar Wang

SARADC controller needs to be reset before programming it, otherwise it will not function properly.

---

Changes in v2: None

 arch/arm/boot/dts/rk3066a.dtsi | 2 ++
 arch/arm/boot/dts/rk3288.dtsi  | 2 ++
 arch/arm/boot/dts/rk3xxx.dtsi  | 2 ++
 3 files changed, 6 insertions(+)
arch/arm/boot/dts/rk3066a.dtsi +2 -0
index c0ba86c..0d0dae3 100644
@@ -197,6 +197,8 @@
 		clock-names = "saradc", "apb_pclk";
 		interrupts = <GIC_SPI 21 IRQ_TYPE_LEVEL_HIGH>;
 		#io-channel-cells = <1>;
+		resets = <&cru SRST_SARADC>;
+		reset-names = "saradc-apb";
 		status = "disabled";
 	};
 
arch/arm/boot/dts/rk3288.dtsi +2 -0
index cd33f01..91c4b3c 100644
@@ -279,6 +279,8 @@
 		#io-channel-cells = <1>;
 		clocks = <&cru SCLK_SARADC>, <&cru PCLK_SARADC>;
 		clock-names = "saradc", "apb_pclk";
+		resets = <&cru SRST_SARADC>;
+		reset-names = "saradc-apb";
 		status = "disabled";
 	};
 
arch/arm/boot/dts/rk3xxx.dtsi +2 -0
index 99bbcc2..e2cd683 100644
@@ -399,6 +399,8 @@
 		#io-channel-cells = <1>;
 		clocks = <&cru SCLK_SARADC>, <&cru PCLK_SARADC>;
 		clock-names = "saradc", "apb_pclk";
+		resets = <&cru SRST_SARADC>;
+		reset-names = "saradc-apb";
 		status = "disabled";
 	};
 
Signature · 1 line
1.9.1
#5 lore raw
In reply to Caesar Wang
Quoted 97 lines · Caesar Wang

SARADC controller needs to be reset before programming it, otherwise it will not function properly.

Cc Jonathan Cameron <[email protected]>
Cc Heiko Stuebner <[email protected]>
Cc Rob Herring <[email protected]>
Cc linux-iio at vger.kernel.org
Cc linux-rockchip at lists.infradead.org

---

Changes in v2:
- Make the reset as an optional property, since it should work with old devicetrees as well.

  .../bindings/iio/adc/rockchip-saradc.txt           |  7 +++++
  drivers/iio/adc/Kconfig                            |  1 +
  drivers/iio/adc/rockchip_saradc.c                  | 31 ++++++++++++++++++++++
  3 files changed, 39 insertions(+)
Documentation/devicetree/bindings/iio/adc/rockchip-saradc.txt +7 -0
index bf99e2f..205593f 100644
@@ -16,6 +16,11 @@ Required properties:
  - vref-supply: The regulator supply ADC reference voltage.
  - #io-channel-cells: Should be 1, see ../iio-bindings.txt
 
+Optional properties:
+- resets: Must contain an entry for each entry in reset-names if need support
+	  this option. See ../reset/reset.txt for details.
+- reset-names: Must include the name "saradc-apb".
+
  Example:
  	saradc: saradc at 2006c000 {
  		compatible = "rockchip,saradc";
@@ -23,6 +28,8 @@ Example:
  		interrupts = <GIC_SPI 26 IRQ_TYPE_LEVEL_HIGH>;
  		clocks = <&cru SCLK_SARADC>, <&cru PCLK_SARADC>;
  		clock-names = "saradc", "apb_pclk";
+		resets = <&cru SRST_SARADC>;
+		reset-names = "saradc-apb";
  		#io-channel-cells = <1>;
  		vref-supply = <&vcc18>;
  	};
drivers/iio/adc/Kconfig +1 -0
index 1de31bd..7675772 100644
@@ -389,6 +389,7 @@ config QCOM_SPMI_VADC
  config ROCKCHIP_SARADC
  	tristate "Rockchip SARADC driver"
  	depends on ARCH_ROCKCHIP || (ARM && COMPILE_TEST)
+	depends on RESET_CONTROLLER
  	help
  	  Say yes here to build support for the SARADC found in SoCs from
  	  Rockchip.
drivers/iio/adc/rockchip_saradc.c +13 -0
index f9ad6c2..dc1379f 100644
@@ -21,6 +21,8 @@
  #include <linux/of_device.h>
  #include <linux/clk.h>
  #include <linux/completion.h>
+#include <linux/delay.h>
+#include <linux/reset.h>
  #include <linux/regulator/consumer.h>
  #include <linux/iio/iio.h>
 
@@ -53,6 +55,7 @@ struct rockchip_saradc {
  	struct clk		*clk;
  	struct completion	completion;
  	struct regulator	*vref;
+	struct reset_control	*reset;
  	const struct rockchip_saradc_data *data;
  	u16			last_val;
  };
@@ -190,6 +193,16 @@ static const struct of_device_id rockchip_saradc_match[] = {
  };
  MODULE_DEVICE_TABLE(of, rockchip_saradc_match);
 
+/**
+ * Reset SARADC Controller.
+ */
+static void rockchip_saradc_reset_controller(struct reset_control *reset)
+{
+	reset_control_assert(reset);
+	usleep_range(10, 20);
+	reset_control_deassert(reset);
+}
+
  static int rockchip_saradc_probe(struct platform_device *pdev)
  {
  	struct rockchip_saradc *info = NULL;

drivers/iio/adc/rockchip_saradc.c static int rockchip_saradc_probe(struct platform_device *pdev) · line 239

Quoted 9 lines
drivers/iio/adc/rockchip_saradc.c +6 -0
@@ -218,6 +231,21 @@ static int rockchip_saradc_probe(struct platform_device *pdev)
  	if (IS_ERR(info->regs))
  		return PTR_ERR(info->regs);
 
+	/*
+	 * The reset should be an optional property, as it should work
+	 * with old devicetrees as well
+	 */
+	info->reset = devm_reset_control_get_optional(&pdev->dev,
+			"saradc-apb");

Does anyone know what the _optional API is for ? It seems to be exactly the same as devm_reset_control_get().

Guenter

Quoted 23 lines
drivers/iio/adc/rockchip_saradc.c +12 -0
+	if (IS_ERR(info->reset)) {
+		ret = PTR_ERR(info->reset);
+		if (ret != -ENOENT)
+			return ret;
+
+		dev_dbg(&pdev->dev, "no reset control found\n");
+		info->reset = NULL;
+	}
+
  	init_completion(&info->completion);
 
  	irq = platform_get_irq(pdev, 0);
@@ -252,6 +280,9 @@ static int rockchip_saradc_probe(struct platform_device *pdev)
  		return PTR_ERR(info->vref);
  	}
 
+	if (info->reset)
+		rockchip_saradc_reset_controller(info->reset);
+
  	/*
  	 * Use a default value for the converter clock.
  	 * This may become user-configurable in the future.
#6 lore raw
Quoted 9 lines · Guenter Roeck
Quoted 9 lines

static int rockchip_saradc_probe(struct platform_device *pdev) {
struct rockchip_saradc *info = NULL;

drivers/iio/adc/rockchip_saradc.c +0 -0
@@ -218,6 +231,21 @@ static int rockchip_saradc_probe(struct 
 platform_device *pdev)
 if (IS_ERR(info->regs))
 return PTR_ERR(info->regs);
 
Quoted 10 lines

drivers/iio/adc/rockchip_saradc.c static int rockchip_saradc_probe(struct platform_device *pdev) · line 239

Quoted 6 lines
drivers/iio/adc/rockchip_saradc.c +6 -0
+ /*
+ * The reset should be an optional property, as it should work
+ * with old devicetrees as well
+ */
+ info->reset = devm_reset_control_get_optional(&pdev->dev,
+ "saradc-apb");

Does anyone know what the _optional API is for ? It seems to be exactly the same
as devm_reset_control_get().

?
As far as I see, the difference is WARN_ON(1)
when CONFIG_RESET_CONTROLLER is not defined.

The _optional functions were introduced by the following commit:

----------------->8-----------------
commit b424080a9e086e683ad5fdc624a7cf3c024e0c0f
Author: Philipp Zabel <p.zabel@xxxxxxxxxxxxxx>
Date: Fri Mar 7 15:18:47 2014 +0100

reset: Add optional resets and stubs

This patch adds device_reset_optional and (devm_)reset_control_get_optional variants that drivers can use to indicate they can function without control over the reset line. For those functions, stubs are added so the drivers can
be compiled with CONFIG_RESET_CONTROLLER disabled.
Also, device_reset is annotated with __must_check. Drivers ignoring the return
value should use device_reset_optional instead.

------------------8<-----------------------------
?

for more information on
http://www.spinics.net/lists/kernel/msg2306677.html :-)

Quoted 33 lines

Guenter

Quoted 22 lines
drivers/iio/adc/rockchip_saradc.c +9 -0
+ if (IS_ERR(info->reset)) {
+ ret = PTR_ERR(info->reset);
+ if (ret != -ENOENT)
+ return ret;
+
+ dev_dbg(&pdev->dev, "no reset control found\n");
+ info->reset = NULL;
+ }
+
 init_completion(&info->completion);
 

irq = platform_get_irq(pdev, 0);

drivers/iio/adc/rockchip_saradc.c +3 -0
@@ -252,6 +280,9 @@ static int rockchip_saradc_probe(struct 
 platform_device *pdev)
 return PTR_ERR(info->vref);
 }
 
+ if (info->reset)
+ rockchip_saradc_reset_controller(info->reset);
+
 /*
 * Use a default value for the converter clock.
Quoted 2 lines

* This may become user-configurable in the future.

_______________________________________________
Linux-rockchip mailing list
Linux-rockchip at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

Signature · 1 line
caesar wang | software engineer | wxt at rock-chip.com
#7 lore raw
Quoted 36 lines · Caesar Wang
Quoted 9 lines · Guenter Roeck
Quoted 9 lines

static int rockchip_saradc_probe(struct platform_device *pdev) {
struct rockchip_saradc *info = NULL;

drivers/iio/adc/rockchip_saradc.c +0 -0
@@ -218,6 +231,21 @@ static int rockchip_saradc_probe(struct
 platform_device *pdev)
 if (IS_ERR(info->regs))
 return PTR_ERR(info->regs);
 
Quoted 10 lines

drivers/iio/adc/rockchip_saradc.c static int rockchip_saradc_probe(struct platform_device *pdev) · line 239

Quoted 6 lines
drivers/iio/adc/rockchip_saradc.c +6 -0
+ /*
+ * The reset should be an optional property, as it should work
+ * with old devicetrees as well
+ */
+ info->reset = devm_reset_control_get_optional(&pdev->dev,
+ "saradc-apb");

Does anyone know what the _optional API is for ? It seems to be exactly the same
as devm_reset_control_get().

?
As far as I see, the difference is WARN_ON(1)
when CONFIG_RESET_CONTROLLER is not defined.

The _optional functions were introduced by the following commit:

----------------->8-----------------
commit b424080a9e086e683ad5fdc624a7cf3c024e0c0f
Author: Philipp Zabel <p.zabel@xxxxxxxxxxxxxx>
Date: Fri Mar 7 15:18:47 2014 +0100

reset: Add optional resets and stubs

Quoted 8 lines

This patch adds device_reset_optional and (devm_)reset_control_get_optional variants that drivers can use to indicate they can function without control over the reset line. For those functions, stubs are added so the drivers can be compiled with CONFIG_RESET_CONTROLLER disabled.
Also, device_reset is annotated with __must_check. Drivers ignoring the return
value should use device_reset_optional instead.

Is that really what we are looking for here ? CONFIG_RESET_CONTROLLER is required for other functions of rk3399, isn't it ?

Guenter

Quoted 46 lines

------------------8<-----------------------------
?

for more information on http://www.spinics.net/lists/kernel/msg2306677.html
:-)

Quoted 33 lines

Guenter

Quoted 22 lines
drivers/iio/adc/rockchip_saradc.c +9 -0
+ if (IS_ERR(info->reset)) {
+ ret = PTR_ERR(info->reset);
+ if (ret != -ENOENT)
+ return ret;
+
+ dev_dbg(&pdev->dev, "no reset control found\n");
+ info->reset = NULL;
+ }
+
 init_completion(&info->completion);
 

irq = platform_get_irq(pdev, 0);

drivers/iio/adc/rockchip_saradc.c +3 -0
@@ -252,6 +280,9 @@ static int rockchip_saradc_probe(struct
 platform_device *pdev)
 return PTR_ERR(info->vref);
 }
 
+ if (info->reset)
+ rockchip_saradc_reset_controller(info->reset);
+
 /*
 * Use a default value for the converter clock.
Quoted 2 lines

* This may become user-configurable in the future.

_______________________________________________
Linux-rockchip mailing list
Linux-rockchip at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

Signature · 1 line
caesar wang | software engineer | wxt at rock-chip.com
Tested-by on v2 1/4
#11 lore raw
In reply to Caesar Wang
Quoted 9 lines · Caesar Wang

SARADC controller needs to be reset before programming it, otherwise it will not function properly.

Cc Jonathan Cameron <[email protected]>
Cc Heiko Stuebner <[email protected]>
Cc Rob Herring <[email protected]>
Cc linux-iio at vger.kernel.org
Cc linux-rockchip at lists.infradead.org
Quoted 122 lines

---

Changes in v2:
- Make the reset as an optional property, since it should work with old devicetrees as well.

 .../bindings/iio/adc/rockchip-saradc.txt           |  7 +++++
 drivers/iio/adc/Kconfig                            |  1 +
 drivers/iio/adc/rockchip_saradc.c                  | 31 ++++++++++++++++++++++
 3 files changed, 39 insertions(+)
Documentation/devicetree/bindings/iio/adc/rockchip-saradc.txt +7 -0
index bf99e2f..205593f 100644
@@ -16,6 +16,11 @@ Required properties:
 - vref-supply: The regulator supply ADC reference voltage.
 - #io-channel-cells: Should be 1, see ../iio-bindings.txt
 
+Optional properties:
+- resets: Must contain an entry for each entry in reset-names if need support
+	  this option. See ../reset/reset.txt for details.
+- reset-names: Must include the name "saradc-apb".
+
 Example:
 	saradc: saradc at 2006c000 {
 		compatible = "rockchip,saradc";
@@ -23,6 +28,8 @@ Example:
 		interrupts = <GIC_SPI 26 IRQ_TYPE_LEVEL_HIGH>;
 		clocks = <&cru SCLK_SARADC>, <&cru PCLK_SARADC>;
 		clock-names = "saradc", "apb_pclk";
+		resets = <&cru SRST_SARADC>;
+		reset-names = "saradc-apb";
 		#io-channel-cells = <1>;
 		vref-supply = <&vcc18>;
 	};
drivers/iio/adc/Kconfig +1 -0
index 1de31bd..7675772 100644
@@ -389,6 +389,7 @@ config QCOM_SPMI_VADC
 config ROCKCHIP_SARADC
 	tristate "Rockchip SARADC driver"
 	depends on ARCH_ROCKCHIP || (ARM && COMPILE_TEST)
+	depends on RESET_CONTROLLER
 	help
 	  Say yes here to build support for the SARADC found in SoCs from
 	  Rockchip.
drivers/iio/adc/rockchip_saradc.c +31 -0
index f9ad6c2..dc1379f 100644
@@ -21,6 +21,8 @@
 #include <linux/of_device.h>
 #include <linux/clk.h>
 #include <linux/completion.h>
+#include <linux/delay.h>
+#include <linux/reset.h>
 #include <linux/regulator/consumer.h>
 #include <linux/iio/iio.h>
 
@@ -53,6 +55,7 @@ struct rockchip_saradc {
 	struct clk		*clk;
 	struct completion	completion;
 	struct regulator	*vref;
+	struct reset_control	*reset;
 	const struct rockchip_saradc_data *data;
 	u16			last_val;
 };
@@ -190,6 +193,16 @@ static const struct of_device_id rockchip_saradc_match[] = {
 };
 MODULE_DEVICE_TABLE(of, rockchip_saradc_match);
 
+/**
+ * Reset SARADC Controller.
+ */
+static void rockchip_saradc_reset_controller(struct reset_control *reset)
+{
+	reset_control_assert(reset);
+	usleep_range(10, 20);
+	reset_control_deassert(reset);
+}
+
 static int rockchip_saradc_probe(struct platform_device *pdev)
 {
 	struct rockchip_saradc *info = NULL;
@@ -218,6 +231,21 @@ static int rockchip_saradc_probe(struct platform_device *pdev)
 	if (IS_ERR(info->regs))
 		return PTR_ERR(info->regs);
 
+	/*
+	 * The reset should be an optional property, as it should work
+	 * with old devicetrees as well
+	 */
+	info->reset = devm_reset_control_get_optional(&pdev->dev,
+			"saradc-apb");
+	if (IS_ERR(info->reset)) {
+		ret = PTR_ERR(info->reset);
+		if (ret != -ENOENT)
+			return ret;
+
+		dev_dbg(&pdev->dev, "no reset control found\n");
+		info->reset = NULL;
+	}
+
 	init_completion(&info->completion);
 
 	irq = platform_get_irq(pdev, 0);
@@ -252,6 +280,9 @@ static int rockchip_saradc_probe(struct platform_device *pdev)
 		return PTR_ERR(info->vref);
 	}
 
+	if (info->reset)
+		rockchip_saradc_reset_controller(info->reset);
+
 	/*
 	 * Use a default value for the converter clock.
 	 * This may become user-configurable in the future.
Signature · 1 line
1.9.1
#8 lore raw
In reply to Guenter Roeck
Quoted 41 lines · Guenter Roeck
Quoted 32 lines · Caesar Wang
Quoted 8 lines · Guenter Roeck
Quoted 8 lines

static int rockchip_saradc_probe(struct platform_device *pdev) {
struct rockchip_saradc *info = NULL;

drivers/iio/adc/rockchip_saradc.c +0 -0
@@ -218,6 +231,21 @@ static int rockchip_saradc_probe(struct
 platform_device *pdev)
 if (IS_ERR(info->regs))
 return PTR_ERR(info->regs);
 
Quoted 9 lines

drivers/iio/adc/rockchip_saradc.c static int rockchip_saradc_probe(struct platform_device *pdev) · line 239

Quoted 6 lines
drivers/iio/adc/rockchip_saradc.c +6 -0
+ /*
+ * The reset should be an optional property, as it should work
+ * with old devicetrees as well
+ */
+ info->reset = devm_reset_control_get_optional(&pdev->dev,
+ "saradc-apb");

Does anyone know what the _optional API is for ? It seems to be exactly the same
as devm_reset_control_get().

?
As far as I see, the difference is WARN_ON(1)
when CONFIG_RESET_CONTROLLER is not defined.

The _optional functions were introduced by the following commit:

----------------->8-----------------
commit b424080a9e086e683ad5fdc624a7cf3c024e0c0f
Author: Philipp Zabel <p.zabel@xxxxxxxxxxxxxx>
Date: Fri Mar 7 15:18:47 2014 +0100

reset: Add optional resets and stubs

Quoted 8 lines

This patch adds device_reset_optional and (devm_)reset_control_get_optional variants that drivers can use to indicate they can function without control over the reset line. For those functions, stubs are added so the drivers can be compiled with CONFIG_RESET_CONTROLLER disabled.
Also, device_reset is annotated with __must_check. Drivers ignoring the return
value should use device_reset_optional instead.

Quoted 2 lines

Is that really what we are looking for here ? CONFIG_RESET_CONTROLLER is required for other functions of rk3399, isn't it ?

Right, as the DRM and thermal are depend on the CONFIG_RESET_CONTROLLER
.....

Quoted 50 lines

Guenter

Quoted 26 lines

------------------8<-----------------------------
?

for more information on http://www.spinics.net/lists/kernel/msg2306677.html
:-)

Quoted 19 lines

Guenter

Quoted 17 lines
drivers/iio/adc/rockchip_saradc.c +9 -0
+ if (IS_ERR(info->reset)) {
+ ret = PTR_ERR(info->reset);
+ if (ret != -ENOENT)
+ return ret;
+
+ dev_dbg(&pdev->dev, "no reset control found\n");
+ info->reset = NULL;
+ }
+
 init_completion(&info->completion);
 

irq = platform_get_irq(pdev, 0);

drivers/iio/adc/rockchip_saradc.c +0 -0
@@ -252,6 +280,9 @@ static int rockchip_saradc_probe(struct
 platform_device *pdev)
 return PTR_ERR(info->vref);
 }
 
Quoted 17 lines
Quoted 12 lines
Quoted 7 lines
drivers/iio/adc/rockchip_saradc.c +3 -0
+ if (info->reset)
+ rockchip_saradc_reset_controller(info->reset);
+
 /*
 * Use a default value for the converter clock.

* This may become user-configurable in the future.

_______________________________________________
Linux-rockchip mailing list
Linux-rockchip at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

Signature · 1 line
caesar wang | software engineer | wxt at rock-chip.com

_______________________________________________
Linux-rockchip mailing list
Linux-rockchip at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

Signature · 1 line
caesar wang | software engineer | wxt at rock-chip.com
#9 lore raw
Quoted 43 lines · Caesar Wang
Quoted 41 lines · Guenter Roeck
Quoted 40 lines · Caesar Wang
Quoted 8 lines · Guenter Roeck
Quoted 8 lines

static int rockchip_saradc_probe(struct platform_device *pdev) {
struct rockchip_saradc *info = NULL;

drivers/iio/adc/rockchip_saradc.c +0 -0
@@ -218,6 +231,21 @@ static int rockchip_saradc_probe(struct
 platform_device *pdev)
 if (IS_ERR(info->regs))
 return PTR_ERR(info->regs);
 
Quoted 9 lines

drivers/iio/adc/rockchip_saradc.c static int rockchip_saradc_probe(struct platform_device *pdev) · line 239

Quoted 6 lines
drivers/iio/adc/rockchip_saradc.c +6 -0
+ /*
+ * The reset should be an optional property, as it should work
+ * with old devicetrees as well
+ */
+ info->reset = devm_reset_control_get_optional(&pdev->dev,
+ "saradc-apb");

Does anyone know what the _optional API is for ? It seems to be exactly the same
as devm_reset_control_get().

?
As far as I see, the difference is WARN_ON(1)
when CONFIG_RESET_CONTROLLER is not defined.

The _optional functions were introduced by the following commit:

----------------->8-----------------
commit b424080a9e086e683ad5fdc624a7cf3c024e0c0f
Author: Philipp Zabel <p.zabel@xxxxxxxxxxxxxx>
Date: Fri Mar 7 15:18:47 2014 +0100

reset: Add optional resets and stubs

This patch adds device_reset_optional and (devm_)reset_control_get_optional variants that drivers can use to indicate they can function without control over the reset line. For those functions, stubs are added so the drivers can be compiled with CONFIG_RESET_CONTROLLER disabled.
Also, device_reset is annotated with __must_check. Drivers ignoring the return
value should use device_reset_optional instead.

Quoted 5 lines
Quoted 2 lines

Is that really what we are looking for here ? CONFIG_RESET_CONTROLLER is required for other functions of rk3399, isn't it ?

Right, as the DRM and thermal are depend on the CONFIG_RESET_CONTROLLER .....

Since "optional" doesn't really mean "the reset property is optional" but "CONFIG_RESET_CONTROLLER is optional", I would suggest to use devm_reset_control_get().

Guenter

#10 lore raw
Quoted 50 lines · Guenter Roeck
Quoted 49 lines · Caesar Wang
Quoted 46 lines · Guenter Roeck
Quoted 33 lines · Caesar Wang
Quoted 8 lines · Guenter Roeck
Quoted 8 lines

static int rockchip_saradc_probe(struct platform_device *pdev) {
struct rockchip_saradc *info = NULL;

drivers/iio/adc/rockchip_saradc.c +0 -0
@@ -218,6 +231,21 @@ static int rockchip_saradc_probe(struct
 platform_device *pdev)
 if (IS_ERR(info->regs))
 return PTR_ERR(info->regs);
 
Quoted 10 lines

drivers/iio/adc/rockchip_saradc.c static int rockchip_saradc_probe(struct platform_device *pdev) · line 239

Quoted 6 lines
drivers/iio/adc/rockchip_saradc.c +6 -0
+ /*
+ * The reset should be an optional property, as it should work
+ * with old devicetrees as well
+ */
+ info->reset = devm_reset_control_get_optional(&pdev->dev,
+ "saradc-apb");

Does anyone know what the _optional API is for ? It seems to be exactly
the same
as devm_reset_control_get().

?
As far as I see, the difference is WARN_ON(1) when is not defined.

The _optional functions were introduced by the following commit:

----------------->8----------------- commit b424080a9e086e683ad5fdc624a7cf3c024e0c0f
Author: Philipp Zabel <p.zabel@xxxxxxxxxxxxxx>
Date: Fri Mar 7 15:18:47 2014 +0100

reset: Add optional resets and stubs

Quoted 10 lines

This patch adds device_reset_optional and
variants that drivers can use to indicate they can function without control
over the reset line. For those functions, stubs are added so the drivers can
be compiled with CONFIG_RESET_CONTROLLER disabled.
Also, device_reset is annotated with __must_check. Drivers ignoring the return
value should use device_reset_optional instead.

Is that really what we are looking for here ? CONFIG_RESET_CONTROLLER is required for other functions of rk3399, isn't it ?

Quoted 7 lines
Quoted 3 lines

Right, as the DRM and thermal are depend on the
CONFIG_RESET_CONTROLLER .....

Since "optional" doesn't really mean "the reset property is optional" but "CONFIG_RESET_CONTROLLER is optional", I would suggest to use devm_reset_control_get().

Agree, free riding.
Maybe the API (_optional) will be changed in later. As someone make a point present an idea on
http://www.spinics.net/lists/kernel/msg2306677.html

Okay, devm_reset_control_get() will be better, anyway the driver has been depend on the CONFIG_RESET_CONTROLLER.
--

I will send a new patch for upstream if nobody object it on today.

Sorry for noisy!

Quoted 8 lines

Guenter

_______________________________________________
Linux-rockchip mailing list
Linux-rockchip at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

Signature · 1 line
caesar wang | software engineer | wxt at rock-chip.com
Reviewed-by on v2 2/4
#2 lore raw

Re: [PATCH v2 2/4] arm64: dts: rockchip: add the saradc for rk3399

In reply to Caesar Wang

Hi,

Quoted 20 lines · Caesar Wang

This patch adds saradc needed information on rk3399 SoCs.

---

Changes in v2: None

 arch/arm64/boot/dts/rockchip/rk3399.dtsi | 12 ++++++++++++
 1 file changed, 12 insertions(+)
arch/arm64/boot/dts/rockchip/rk3399.dtsi +2 -0
index 4c84229..b81f84b 100644
@@ -299,6 +299,18 @@
                };
        };
 
+       saradc: saradc at ff100000 {
+               compatible = "rockchip,rk3399-saradc";

arch/arm64/boot/dts/rockchip/rk3399.dtsi line 313

Quoted 10 lines
arch/arm64/boot/dts/rockchip/rk3399.dtsi +10 -0
+               reg = <0x0 0xff100000 0x0 0x100>;
+               interrupts = <GIC_SPI 62 IRQ_TYPE_LEVEL_HIGH>;
+               #io-channel-cells = <1>;
+               clocks = <&cru SCLK_SARADC>, <&cru PCLK_SARADC>;
+               clock-names = "saradc", "apb_pclk";
+               resets = <&cru SRST_P_SARADC>;
+               reset-names = "saradc-apb";
+               status = "disabled";
+       };
+

Seems reasonable to me. I'll let Heiko comment if he cares about the sort ordering. I can never quite figure out what it should be so I've sorta given up on it... ;)

-Doug

maintainer Acked-by on v2 1/4
#12 lore raw
In reply to Caesar Wang
Quoted 10 lines · Caesar Wang

SARADC controller needs to be reset before programming it, otherwise it will not function properly.

Cc Jonathan Cameron <[email protected]>
Cc Heiko Stuebner <[email protected]>
Cc Rob Herring <[email protected]>
Cc linux-iio at vger.kernel.org
Cc linux-rockchip at lists.infradead.org
Quoted 7 lines

---

Changes in v2:
- Make the reset as an optional property, since it should work with old devicetrees as well.

 .../bindings/iio/adc/rockchip-saradc.txt           |  7 +++++
Quoted 3 lines
 drivers/iio/adc/Kconfig                            |  1 +
 drivers/iio/adc/rockchip_saradc.c                  | 31 ++++++++++++++++++++++
 3 files changed, 39 insertions(+)