devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Joel Stanley <joel-U3u1mxZcP9KHXe+LvDLADg@public.gmane.org>
To: Guenter Roeck <linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>,
	Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: Philipp Zabel
	<philipp.zabel-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Mykola Kostenok
	<c_mykolak-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>,
	Jaghathiswari Rankappagounder Natarajan
	<jaghu-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>,
	Patrick Venture <venture-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>,
	Andrew Jeffery <andrew-zrmu5oMJ5Fs@public.gmane.org>,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-hwmon-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: [PATCH v2 2/3] hwmon: (aspeed-pwm-tacho) Deassert reset in probe
Date: Thu,  2 Nov 2017 14:53:48 +1100	[thread overview]
Message-ID: <20171102035349.1902-3-joel@jms.id.au> (raw)
In-Reply-To: <20171102035349.1902-1-joel-U3u1mxZcP9KHXe+LvDLADg@public.gmane.org>

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>
---
v2:
 - Correct horrible mistakes
 - Boot tested and hwmon sysfs files checked
---
 drivers/hwmon/aspeed-pwm-tacho.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/drivers/hwmon/aspeed-pwm-tacho.c b/drivers/hwmon/aspeed-pwm-tacho.c
index 63a95e23ca81..77bb7a4bbed4 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];
@@ -931,6 +933,15 @@ 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);
+
 	regmap_write(priv->regmap, ASPEED_PTCR_TACH_SOURCE, 0);
 	regmap_write(priv->regmap, ASPEED_PTCR_TACH_SOURCE_EXT, 0);
 
@@ -960,6 +971,15 @@ static int aspeed_pwm_tacho_probe(struct platform_device *pdev)
 	return PTR_ERR_OR_ZERO(hwmon);
 }
 
+static int aspeed_pwm_tacho_remove(struct platform_device *pdev)
+{
+	struct aspeed_pwm_tacho_data *priv = platform_get_drvdata(pdev);
+
+	reset_control_assert(priv->rst);
+
+	return 0;
+}
+
 static const struct of_device_id of_pwm_tacho_match_table[] = {
 	{ .compatible = "aspeed,ast2400-pwm-tacho", },
 	{ .compatible = "aspeed,ast2500-pwm-tacho", },
@@ -969,6 +989,7 @@ MODULE_DEVICE_TABLE(of, of_pwm_tacho_match_table);
 
 static struct platform_driver aspeed_pwm_tacho_driver = {
 	.probe		= aspeed_pwm_tacho_probe,
+	.remove 	= aspeed_pwm_tacho_remove,
 	.driver		= {
 		.name	= "aspeed_pwm_tacho",
 		.of_match_table = of_pwm_tacho_match_table,
-- 
2.14.1

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

  parent reply	other threads:[~2017-11-02  3:53 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-02  3:53 [PATCH v2 0/3] hwmon: Add reset support to aspeed-pwm-tach Joel Stanley
2017-11-02  3:53 ` [PATCH v2 1/3] hwmon: (aspeed-pwm-tacho) Sort headers Joel Stanley
2017-11-04 18:09   ` [v2,1/3] " Guenter Roeck
     [not found] ` <20171102035349.1902-1-joel-U3u1mxZcP9KHXe+LvDLADg@public.gmane.org>
2017-11-02  3:53   ` Joel Stanley [this message]
2017-11-02 14:54     ` [PATCH v2 2/3] hwmon: (aspeed-pwm-tacho) Deassert reset in probe Guenter Roeck
     [not found]       ` <20171102145406.GA9240-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
2017-11-03  2:32         ` Joel Stanley
     [not found]           ` <CACPK8Xc3Hsj9TD8L2A6e-iCMZp5=HG9aan5m0YsWV-CZHFPo5A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-11-03 10:11             ` Guenter Roeck
     [not found]     ` <20171102035349.1902-3-joel-U3u1mxZcP9KHXe+LvDLADg@public.gmane.org>
2017-12-03 18:58       ` [v2,2/3] " Guenter Roeck
2017-11-02  3:53 ` [PATCH v2 3/3] dt-bindings: hwmon: aspeed-pwm-tacho: Add reset node Joel Stanley
     [not found]   ` <20171102035349.1902-4-joel-U3u1mxZcP9KHXe+LvDLADg@public.gmane.org>
2017-11-06 21:42     ` Rob Herring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171102035349.1902-3-joel@jms.id.au \
    --to=joel-u3u1mxzcp9khxe+lvdladg@public.gmane.org \
    --cc=andrew-zrmu5oMJ5Fs@public.gmane.org \
    --cc=c_mykolak-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=jaghu-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
    --cc=linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org \
    --cc=linux-hwmon-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=philipp.zabel-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=venture-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).