devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/2] hwmon: Add reset support to aspeed-pwm-tach
@ 2017-12-23 13:05 Joel Stanley
  2017-12-23 13:05 ` [PATCH v3 1/2] dt-bindings: hwmon: aspeed-pwm-tacho: Add reset node Joel Stanley
  2017-12-23 13:05 ` [PATCH v3 2/2] hwmon: (aspeed-pwm-tacho) Deassert reset in probe Joel Stanley
  0 siblings, 2 replies; 5+ messages in thread
From: Joel Stanley @ 2017-12-23 13:05 UTC (permalink / raw)
  To: Guenter Roeck, Rob Herring
  Cc: Philipp Zabel, Mykola Kostenok,
	Jaghathiswari Rankappagounder Natarajan, Patrick Venture,
	Andrew Jeffery, devicetree, linux-hwmon, linux-kernel

This series adds reset support so the ASPEED SoC can operate the
PWM/Tach unit without out of tree workarounds.

v3 drops the header sorting patch which is already applied, and adds
Rob's ack to the bindings change.

Joel Stanley (2):
  dt-bindings: hwmon: aspeed-pwm-tacho: Add reset node
  hwmon: (aspeed-pwm-tacho) Deassert reset in probe

 .../devicetree/bindings/hwmon/aspeed-pwm-tacho.txt | 14 +++++---------
 drivers/hwmon/aspeed-pwm-tacho.c                   | 22 ++++++++++++++++++++++
 2 files changed, 27 insertions(+), 9 deletions(-)

-- 
2.15.1


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

* [PATCH v3 1/2] dt-bindings: hwmon: aspeed-pwm-tacho: Add reset node
  2017-12-23 13:05 [PATCH v3 0/2] hwmon: Add reset support to aspeed-pwm-tach Joel Stanley
@ 2017-12-23 13:05 ` Joel Stanley
       [not found]   ` <20171223130528.5346-2-joel-U3u1mxZcP9KHXe+LvDLADg@public.gmane.org>
  2017-12-23 13:05 ` [PATCH v3 2/2] hwmon: (aspeed-pwm-tacho) Deassert reset in probe Joel Stanley
  1 sibling, 1 reply; 5+ messages in thread
From: Joel Stanley @ 2017-12-23 13:05 UTC (permalink / raw)
  To: Guenter Roeck, Rob Herring
  Cc: Philipp Zabel, Mykola Kostenok,
	Jaghathiswari Rankappagounder Natarajan, Patrick Venture,
	Andrew Jeffery, devicetree, linux-hwmon, linux-kernel

The device tree bindings are updated to document the resets phandle, and
the example is updated to match what is expected for both the reset and
clock phandle.

Note that the bindings should have always had the reset controller, as
the hardware is unusable without it.

Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Joel Stanley <joel@jms.id.au>
---
 .../devicetree/bindings/hwmon/aspeed-pwm-tacho.txt         | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/Documentation/devicetree/bindings/hwmon/aspeed-pwm-tacho.txt b/Documentation/devicetree/bindings/hwmon/aspeed-pwm-tacho.txt
index 367c8203213b..3ac02988a1a5 100644
--- a/Documentation/devicetree/bindings/hwmon/aspeed-pwm-tacho.txt
+++ b/Documentation/devicetree/bindings/hwmon/aspeed-pwm-tacho.txt
@@ -22,8 +22,9 @@ Required properties for pwm-tacho node:
 - compatible : should be "aspeed,ast2400-pwm-tacho" for AST2400 and
 	       "aspeed,ast2500-pwm-tacho" for AST2500.
 
-- clocks : a fixed clock providing input clock frequency(PWM
-	   and Fan Tach clock)
+- clocks : phandle to clock provider with the clock number in the second cell
+
+- resets : phandle to reset controller with the reset number in the second cell
 
 fan subnode format:
 ===================
@@ -48,19 +49,14 @@ Required properties for each child node:
 
 Examples:
 
-pwm_tacho_fixed_clk: fixedclk {
-	compatible = "fixed-clock";
-	#clock-cells = <0>;
-	clock-frequency = <24000000>;
-};
-
 pwm_tacho: pwmtachocontroller@1e786000 {
 	#address-cells = <1>;
 	#size-cells = <1>;
 	#cooling-cells = <2>;
 	reg = <0x1E786000 0x1000>;
 	compatible = "aspeed,ast2500-pwm-tacho";
-	clocks = <&pwm_tacho_fixed_clk>;
+	clocks = <&syscon ASPEED_CLK_APB>;
+	resets = <&syscon ASPEED_RESET_PWM>;
 	pinctrl-names = "default";
 	pinctrl-0 = <&pinctrl_pwm0_default &pinctrl_pwm1_default>;
 
-- 
2.15.1

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

* [PATCH v3 2/2] hwmon: (aspeed-pwm-tacho) Deassert reset in probe
  2017-12-23 13:05 [PATCH v3 0/2] hwmon: Add reset support to aspeed-pwm-tach Joel Stanley
  2017-12-23 13:05 ` [PATCH v3 1/2] dt-bindings: hwmon: aspeed-pwm-tacho: Add reset node Joel Stanley
@ 2017-12-23 13:05 ` Joel Stanley
       [not found]   ` <20171223130528.5346-3-joel-U3u1mxZcP9KHXe+LvDLADg@public.gmane.org>
  1 sibling, 1 reply; 5+ messages in thread
From: Joel Stanley @ 2017-12-23 13:05 UTC (permalink / raw)
  To: Guenter Roeck, Rob Herring
  Cc: Philipp Zabel, Mykola Kostenok,
	Jaghathiswari Rankappagounder Natarajan, Patrick Venture,
	Andrew Jeffery, devicetree, linux-hwmon, linux-kernel

The ASPEED SoC must deassert a reset in order to use the PWM/tach
peripheral.

Signed-off-by: Joel Stanley <joel@jms.id.au>
---
 drivers/hwmon/aspeed-pwm-tacho.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/drivers/hwmon/aspeed-pwm-tacho.c b/drivers/hwmon/aspeed-pwm-tacho.c
index 63a95e23ca81..693a3d53cab5 100644
--- a/drivers/hwmon/aspeed-pwm-tacho.c
+++ b/drivers/hwmon/aspeed-pwm-tacho.c
@@ -19,6 +19,7 @@
 #include <linux/of_platform.h>
 #include <linux/platform_device.h>
 #include <linux/regmap.h>
+#include <linux/reset.h>
 #include <linux/sysfs.h>
 #include <linux/thermal.h>
 
@@ -181,6 +182,7 @@ struct aspeed_cooling_device {
 
 struct aspeed_pwm_tacho_data {
 	struct regmap *regmap;
+	struct reset_control *rst;
 	unsigned long clk_freq;
 	bool pwm_present[8];
 	bool fan_tach_present[16];
@@ -905,6 +907,13 @@ static int aspeed_create_fan(struct device *dev,
 	return 0;
 }
 
+static void aspeed_pwm_tacho_remove(void *data)
+{
+	struct aspeed_pwm_tacho_data *priv = data;
+
+	reset_control_assert(priv->rst);
+}
+
 static int aspeed_pwm_tacho_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -931,6 +940,19 @@ static int aspeed_pwm_tacho_probe(struct platform_device *pdev)
 			&aspeed_pwm_tacho_regmap_config);
 	if (IS_ERR(priv->regmap))
 		return PTR_ERR(priv->regmap);
+
+	priv->rst = devm_reset_control_get_exclusive(dev, NULL);
+	if (IS_ERR(priv->rst)) {
+		dev_err(dev,
+			"missing or invalid reset controller device tree entry");
+		return PTR_ERR(priv->rst);
+	}
+	reset_control_deassert(priv->rst);
+
+	ret = devm_add_action_or_reset(dev, aspeed_pwm_tacho_remove, priv);
+	if (ret)
+		return ret;
+
 	regmap_write(priv->regmap, ASPEED_PTCR_TACH_SOURCE, 0);
 	regmap_write(priv->regmap, ASPEED_PTCR_TACH_SOURCE_EXT, 0);
 
-- 
2.15.1


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

* Re: [v3,1/2] dt-bindings: hwmon: aspeed-pwm-tacho: Add reset node
       [not found]   ` <20171223130528.5346-2-joel-U3u1mxZcP9KHXe+LvDLADg@public.gmane.org>
@ 2017-12-26 17:24     ` Guenter Roeck
  0 siblings, 0 replies; 5+ messages in thread
From: Guenter Roeck @ 2017-12-26 17:24 UTC (permalink / raw)
  To: Joel
  Cc: Rob Herring, Philipp Zabel, Mykola Kostenok,
	Jaghathiswari Rankappagounder Natarajan, Patrick Venture,
	Andrew Jeffery, devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-hwmon-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

On Sat, Dec 23, 2017 at 11:35:27PM +1030, Joel wrote:
> The device tree bindings are updated to document the resets phandle, and
> the example is updated to match what is expected for both the reset and
> clock phandle.
> 
> Note that the bindings should have always had the reset controller, as
> the hardware is unusable without it.
> 
> Acked-by: Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
> Signed-off-by: Joel Stanley <joel-U3u1mxZcP9KHXe+LvDLADg@public.gmane.org>

Applied to hwmon-next.

Thanks,
Guenter

> ---
>  .../devicetree/bindings/hwmon/aspeed-pwm-tacho.txt         | 14 +++++---------
>  1 file changed, 5 insertions(+), 9 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/hwmon/aspeed-pwm-tacho.txt b/Documentation/devicetree/bindings/hwmon/aspeed-pwm-tacho.txt
> index 367c8203213b..3ac02988a1a5 100644
> --- a/Documentation/devicetree/bindings/hwmon/aspeed-pwm-tacho.txt
> +++ b/Documentation/devicetree/bindings/hwmon/aspeed-pwm-tacho.txt
> @@ -22,8 +22,9 @@ Required properties for pwm-tacho node:
>  - compatible : should be "aspeed,ast2400-pwm-tacho" for AST2400 and
>  	       "aspeed,ast2500-pwm-tacho" for AST2500.
>  
> -- clocks : a fixed clock providing input clock frequency(PWM
> -	   and Fan Tach clock)
> +- clocks : phandle to clock provider with the clock number in the second cell
> +
> +- resets : phandle to reset controller with the reset number in the second cell
>  
>  fan subnode format:
>  ===================
> @@ -48,19 +49,14 @@ Required properties for each child node:
>  
>  Examples:
>  
> -pwm_tacho_fixed_clk: fixedclk {
> -	compatible = "fixed-clock";
> -	#clock-cells = <0>;
> -	clock-frequency = <24000000>;
> -};
> -
>  pwm_tacho: pwmtachocontroller@1e786000 {
>  	#address-cells = <1>;
>  	#size-cells = <1>;
>  	#cooling-cells = <2>;
>  	reg = <0x1E786000 0x1000>;
>  	compatible = "aspeed,ast2500-pwm-tacho";
> -	clocks = <&pwm_tacho_fixed_clk>;
> +	clocks = <&syscon ASPEED_CLK_APB>;
> +	resets = <&syscon ASPEED_RESET_PWM>;
>  	pinctrl-names = "default";
>  	pinctrl-0 = <&pinctrl_pwm0_default &pinctrl_pwm1_default>;
>  
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [v3,2/2] hwmon: (aspeed-pwm-tacho) Deassert reset in probe
       [not found]   ` <20171223130528.5346-3-joel-U3u1mxZcP9KHXe+LvDLADg@public.gmane.org>
@ 2017-12-26 17:24     ` Guenter Roeck
  0 siblings, 0 replies; 5+ messages in thread
From: Guenter Roeck @ 2017-12-26 17:24 UTC (permalink / raw)
  To: Joel
  Cc: Rob Herring, Philipp Zabel, Mykola Kostenok,
	Jaghathiswari Rankappagounder Natarajan, Patrick Venture,
	Andrew Jeffery, devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-hwmon-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

On Sat, Dec 23, 2017 at 11:35:28PM +1030, Joel wrote:
> The ASPEED SoC must deassert a reset in order to use the PWM/tach
> peripheral.
> 
> Signed-off-by: Joel Stanley <joel-U3u1mxZcP9KHXe+LvDLADg@public.gmane.org>

Applied to hwmon-next.

Thanks,
Guenter

> ---
>  drivers/hwmon/aspeed-pwm-tacho.c | 22 ++++++++++++++++++++++
>  1 file changed, 22 insertions(+)
> 
> diff --git a/drivers/hwmon/aspeed-pwm-tacho.c b/drivers/hwmon/aspeed-pwm-tacho.c
> index 63a95e23ca81..693a3d53cab5 100644
> --- a/drivers/hwmon/aspeed-pwm-tacho.c
> +++ b/drivers/hwmon/aspeed-pwm-tacho.c
> @@ -19,6 +19,7 @@
>  #include <linux/of_platform.h>
>  #include <linux/platform_device.h>
>  #include <linux/regmap.h>
> +#include <linux/reset.h>
>  #include <linux/sysfs.h>
>  #include <linux/thermal.h>
>  
> @@ -181,6 +182,7 @@ struct aspeed_cooling_device {
>  
>  struct aspeed_pwm_tacho_data {
>  	struct regmap *regmap;
> +	struct reset_control *rst;
>  	unsigned long clk_freq;
>  	bool pwm_present[8];
>  	bool fan_tach_present[16];
> @@ -905,6 +907,13 @@ static int aspeed_create_fan(struct device *dev,
>  	return 0;
>  }
>  
> +static void aspeed_pwm_tacho_remove(void *data)
> +{
> +	struct aspeed_pwm_tacho_data *priv = data;
> +
> +	reset_control_assert(priv->rst);
> +}
> +
>  static int aspeed_pwm_tacho_probe(struct platform_device *pdev)
>  {
>  	struct device *dev = &pdev->dev;
> @@ -931,6 +940,19 @@ static int aspeed_pwm_tacho_probe(struct platform_device *pdev)
>  			&aspeed_pwm_tacho_regmap_config);
>  	if (IS_ERR(priv->regmap))
>  		return PTR_ERR(priv->regmap);
> +
> +	priv->rst = devm_reset_control_get_exclusive(dev, NULL);
> +	if (IS_ERR(priv->rst)) {
> +		dev_err(dev,
> +			"missing or invalid reset controller device tree entry");
> +		return PTR_ERR(priv->rst);
> +	}
> +	reset_control_deassert(priv->rst);
> +
> +	ret = devm_add_action_or_reset(dev, aspeed_pwm_tacho_remove, priv);
> +	if (ret)
> +		return ret;
> +
>  	regmap_write(priv->regmap, ASPEED_PTCR_TACH_SOURCE, 0);
>  	regmap_write(priv->regmap, ASPEED_PTCR_TACH_SOURCE_EXT, 0);
>  
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

end of thread, other threads:[~2017-12-26 17:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-23 13:05 [PATCH v3 0/2] hwmon: Add reset support to aspeed-pwm-tach Joel Stanley
2017-12-23 13:05 ` [PATCH v3 1/2] dt-bindings: hwmon: aspeed-pwm-tacho: Add reset node Joel Stanley
     [not found]   ` <20171223130528.5346-2-joel-U3u1mxZcP9KHXe+LvDLADg@public.gmane.org>
2017-12-26 17:24     ` [v3,1/2] " Guenter Roeck
2017-12-23 13:05 ` [PATCH v3 2/2] hwmon: (aspeed-pwm-tacho) Deassert reset in probe Joel Stanley
     [not found]   ` <20171223130528.5346-3-joel-U3u1mxZcP9KHXe+LvDLADg@public.gmane.org>
2017-12-26 17:24     ` [v3,2/2] " Guenter Roeck

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).