summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoel <joel@jms.id.au>2017-12-23 08:05:28 -0500
committerGuenter Roeck <linux@roeck-us.net>2018-01-02 18:05:34 -0500
commit18c514cc0e0278b7852a6741973a9523ad012700 (patch)
tree734dfcbba032f2149eceddeee6e00f611c661c55
parent8c9e52705740b21c546907711630c389ef09715e (diff)
hwmon: (aspeed-pwm-tacho) Deassert reset in probe
The ASPEED SoC must deassert a reset in order to use the PWM/tach peripheral. Signed-off-by: Joel Stanley <joel@jms.id.au> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
-rw-r--r--drivers/hwmon/aspeed-pwm-tacho.c22
1 files changed, 22 insertions, 0 deletions
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 @@
19#include <linux/of_platform.h> 19#include <linux/of_platform.h>
20#include <linux/platform_device.h> 20#include <linux/platform_device.h>
21#include <linux/regmap.h> 21#include <linux/regmap.h>
22#include <linux/reset.h>
22#include <linux/sysfs.h> 23#include <linux/sysfs.h>
23#include <linux/thermal.h> 24#include <linux/thermal.h>
24 25
@@ -181,6 +182,7 @@ struct aspeed_cooling_device {
181 182
182struct aspeed_pwm_tacho_data { 183struct aspeed_pwm_tacho_data {
183 struct regmap *regmap; 184 struct regmap *regmap;
185 struct reset_control *rst;
184 unsigned long clk_freq; 186 unsigned long clk_freq;
185 bool pwm_present[8]; 187 bool pwm_present[8];
186 bool fan_tach_present[16]; 188 bool fan_tach_present[16];
@@ -905,6 +907,13 @@ static int aspeed_create_fan(struct device *dev,
905 return 0; 907 return 0;
906} 908}
907 909
910static void aspeed_pwm_tacho_remove(void *data)
911{
912 struct aspeed_pwm_tacho_data *priv = data;
913
914 reset_control_assert(priv->rst);
915}
916
908static int aspeed_pwm_tacho_probe(struct platform_device *pdev) 917static int aspeed_pwm_tacho_probe(struct platform_device *pdev)
909{ 918{
910 struct device *dev = &pdev->dev; 919 struct device *dev = &pdev->dev;
@@ -931,6 +940,19 @@ static int aspeed_pwm_tacho_probe(struct platform_device *pdev)
931 &aspeed_pwm_tacho_regmap_config); 940 &aspeed_pwm_tacho_regmap_config);
932 if (IS_ERR(priv->regmap)) 941 if (IS_ERR(priv->regmap))
933 return PTR_ERR(priv->regmap); 942 return PTR_ERR(priv->regmap);
943
944 priv->rst = devm_reset_control_get_exclusive(dev, NULL);
945 if (IS_ERR(priv->rst)) {
946 dev_err(dev,
947 "missing or invalid reset controller device tree entry");
948 return PTR_ERR(priv->rst);
949 }
950 reset_control_deassert(priv->rst);
951
952 ret = devm_add_action_or_reset(dev, aspeed_pwm_tacho_remove, priv);
953 if (ret)
954 return ret;
955
934 regmap_write(priv->regmap, ASPEED_PTCR_TACH_SOURCE, 0); 956 regmap_write(priv->regmap, ASPEED_PTCR_TACH_SOURCE, 0);
935 regmap_write(priv->regmap, ASPEED_PTCR_TACH_SOURCE_EXT, 0); 957 regmap_write(priv->regmap, ASPEED_PTCR_TACH_SOURCE_EXT, 0);
936 958